New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diff function #1812
Diff function #1812
Conversation
That included a some old commits sorry |
#1634 and I forgot to link it |
Nice, thanks for your work @Veeloxfire . I see the function
What would you like to do? Round it up or go for the next step right away? |
Ill start trying to get it to work for multi-dimensional so it more mirrors the numpy version as that was the original suggestion |
Sounds good 👍 . It will also be consistent with mathjs functions like |
Finally got around to doing this. The only thing its doesnt have that the numpy version does is the ability to say how many times to find the difference. But python has the ability to select parameters with the |
Cool! I'll do some testing this weekend. |
], | ||
examples: [ | ||
'diff([1, 2, 4, 7, 0])', | ||
'diff([1, 2, 4, 7, 0], 0)', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this example should be a 2d array so you can actually see what the dimension does, like
'diff([[1, 2], [3, 6]], 0)',
'diff([[1, 2], [3, 6]], 1)',
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I think I did this because it was just a copy and paste but yes should definitely have more comprehensive examples
* | ||
* const arr = [[1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [9, 8, 7, 6, 4]] | ||
* math.diff(arr) // returns [[0, 0, 0, 0, 0], [8, 6, 4, 2, -1]] | ||
* math.diff(arr) // returns [[1, 1, 1, 1], [1, 1, 1, 1], [-1, -1, -1, -2]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here the dimension should be specified, like math.diff(arr, 1)
?
Looks very good @Veeloxfire 👍 I made two small remarks in the code, and here three more remarks:
|
@Veeloxfire would be great if you can have a look at my feedback |
Sorry I didnt see this! Yep Ill look in to it |
I will have to make another pull request to update this because I decided to reclone the repository to refresh my offline one but I stupidly deleted the old one Ill make sure to reference this one when I do |
👍 thanks |
I'll close this pull request now as its moved to #1920 |
👍 I'll look into your new PR soon |
Add function that returns difference between adjacent members of an array or matrix
Currently no way to decide which axis for multi-dimensional arrays but I could work on that