-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix: use utility isNaN for consistent max and min results #3389
base: develop
Are you sure you want to change the base?
Conversation
Thanks very much for the PR! Generally, it looks solid. Just two items from review:
Such injections of Personally, I see three possible ways the conflict could be eliminated: (A) have the internal factory be called something like If @josdejong does want to steer away from using injected |
Thanks for the review! I will add more tests and update the documentation appropriately. Regarding your second point, I agree it can be confusing, and I will leave it to Jos to decide how he wants to proceed. For now, I will use option C as a placeholder in this particular implementation, as I don't see it causing any side effects. |
Excellent, thank you! Just awaiting @josdejong's decision on how mathjs should handle isNaN shadowing internally before final review. |
Addresses: #3387
Description:
larger
andsmaller
functions will return false when comparing any value that isNaN, so that the result will not be changedAdditional Notes:
I don't think this is necessarily a big issue because you would have to be comparing a Unit/BigNumber that has a value that is NaN. I think having undefined behaviour for that might be okay or throwing an error (so let me know if you decide not to address the issue).
AI Summary:
This pull request includes changes to the
max
andmin
functions to improve their handling ofNaN
values and adds corresponding unit tests. The key changes involve updating dependencies, modifying the logic for handlingNaN
values, and enhancing test coverage.Enhancements to
max
andmin
functions:src/expression/transform/max.transform.js
: AddedisNaN
to the dependencies ofcreateMaxTransform
.src/expression/transform/min.transform.js
: AddedisNaN
to the dependencies ofcreateMinTransform
.src/function/statistics/max.js
: AddedisNaN
to the dependencies ofcreateMax
and modified the logic to handleNaN
values correctly. [1] [2]src/function/statistics/min.js
: AddedisNaN
to the dependencies ofcreateMin
and modified the logic to handleNaN
values correctly. [1] [2]Unit tests:
test/unit-tests/function/statistics/max.test.js
: Added tests to verify the handling ofNaN
values in themax
function. [1] [2] [3]test/unit-tests/function/statistics/min.test.js
: Added tests to verify the handling ofNaN
values in themin
function. [1] [2] [3]