Fix isapprox for dimensionless Quantity vs Number with atol#838
Merged
sostock merged 1 commit intoJuliaPhysics:masterfrom Mar 28, 2026
Merged
Conversation
isapprox(1u"rad", 1.1; atol=0.5u"rad") threw TypeError because promote strips units from dimensionless quantities but atol was passed through unchanged to Base.isapprox which expects atol::Real. Fix by promoting atol together with the arguments, and similarly strip atol units in the array method.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #838 +/- ##
=========================================
Coverage ? 90.05%
=========================================
Files ? 22
Lines ? 1709
Branches ? 0
=========================================
Hits ? 1539
Misses ? 170
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
gentle bump |
Contributor
Author
|
another bump... |
Collaborator
|
I will review it this weekend (or earlier if I have time). |
sostock
approved these changes
Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
isapprox(1u"rad", 1.1; atol=0.5u"rad")threwTypeErrorbecausepromotestrips units from dimensionless quantities butatolwas passed through unchanged toBase.isapproxwhich requiresatol::Realatoltogether with the arguments, so it gets the same unit-stripping treatmentatolunits viaustrip(NoUnits, atol)when converting Quantity arrays to plain numbersTest plan
atol, reversed argument order, plain Numberatol,rtol, and the array case🤖 Generated with Claude Code