operations between jagged arrays and scalars#3607
Conversation
|
Nice! This actually simplifies the code since you can "just" use the map function. What are the next steps? Add some unit tests for jagged inputs, update docs, and see what the performance impact is? |
|
Yes exactly, I will proceed with the next steps in the following weeks. Maybe later I will come back to broadcasting jagged arrays. |
gwhitney
left a comment
There was a problem hiding this comment.
Excellent, this is shaping up. A few more things to consider.
|
Hi, all comments are addressed either in code or as a reply. This is ready for review again. |
|
Now we come to the difficulty that at this point, PRs are supposed to have per-function HISTORY for the functions they touch. I had hoped to get one of my PRs that touches a lot of functions to the point of going in to alleviate this big task before anyone else, but with the rate that Jos can review things and by other coincidences it seems as though you are getting there first. How would you like to handle this? Might we split up the chore of inserting such histories for the functions touched in this PR? Let me know your thoughts. |
|
Most of the functions touched in this PR were due to the removal of I've been reviewing the history and this is mostly my fault as I did include them at #2895 because it was needed but then it should have been removed at #3220. Please help me with an example of the history and I can gladly replicate it in the functions where We could split the rest. |
A good current example is src/expressions/parse.js. Note that I do try to make the histories be from inception. The command
Yes, that would be absolutely fine. Please just let me know which functions are "assigned" to me and when is a good time for me to work on them that I can push a commit to this PR without interfering with your work. Thanks! |
|
Wow, thanks for all of the updated history files. Let me know if there are others on my list to supply History for. I also see failed tests, but didn't look at the details. Are these something you'll be taking care of? Thanks again. |
|
I think the history files are done. Just please validate the changes made. The error was due to formatting, so it should be ok now. Just a clarification, some of the reference history files are sorted from newest to oldest and some are from oldest to newest. I also didn't apply them consistently. So please let me know which way to go. As a reference in python documentation they are from oldest to newest.
|
Since these are now the bulk of the HISTORY entries in the whole system, and most of them were newest to oldest, I just changed them all (and changed the archetype src/expressions/parse.js also to have this order). There are probably still some lurking oldest to newest, but we can fix those when the files are touched. Doing final review, then will merge. |
|
Oh, actually in the final review, I checked out the reference to #3537, and noticed this comment. So I added a test that I think corresponds to the expected/desired behavior for those cases. But it fails, and doesn't just produce a different value, it throws an error, and it's not even an error about not supporting that sort of ragged array. So I think it's a bug that should be addressed in this PR. @dvd101x do you want to take a look, or should I? And in either case, should mathjs support |
|
Thanks @gwhitney, I'll take a look and fix the failing test. It seems to be an issue in optimize callback with typed functions because |
|
Right, #3567 noted this behavior but did not address it, because at the time jagged arrays were not "officially allowed" by mathjs. Since this PR for the first time explicitly supports such operations, it is a good opportunity to settle what this behavior should be and implement it. Note that the decision could be to throw an error in this case, but if so, it should be a "better" error than "Too many arguments in square," which seems to come out of nowhere. Thanks! |
|
Hi. It must be ok now. Made a new function to find the first value and added some tests for optimizeCallback. |

Hi, this is the proof of concept discussed at #3537
It's more inline with what Jos and Glen suggested as my initial idea was flawed. This PR only shows two main changes.
My expectation is that all operations between Matrix|Array and scalar should be faster.
The new functionality is that it's possible to do stuff like