Skip to content

Fix isapprox for dimensionless Quantity vs Number with atol#838

Merged
sostock merged 1 commit intoJuliaPhysics:masterfrom
aplavin:fix-isapprox-dimensionless-atol
Mar 28, 2026
Merged

Fix isapprox for dimensionless Quantity vs Number with atol#838
sostock merged 1 commit intoJuliaPhysics:masterfrom
aplavin:fix-isapprox-dimensionless-atol

Conversation

@aplavin
Copy link
Copy Markdown
Contributor

@aplavin aplavin commented Mar 1, 2026

Summary

  • 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 requires atol::Real
  • Fix scalar method by promoting atol together with the arguments, so it gets the same unit-stripping treatment
  • Fix array method by stripping atol units via ustrip(NoUnits, atol) when converting Quantity arrays to plain numbers

Test plan

  • Added tests for dimensionless Quantity vs Number with Quantity atol, reversed argument order, plain Number atol, rtol, and the array case
  • Full test suite passes

🤖 Generated with Claude Code

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
Copy link
Copy Markdown

codecov Bot commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@51f55a1). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aplavin
Copy link
Copy Markdown
Contributor Author

aplavin commented Mar 15, 2026

gentle bump

@aplavin
Copy link
Copy Markdown
Contributor Author

aplavin commented Mar 25, 2026

another bump...

@sostock
Copy link
Copy Markdown
Collaborator

sostock commented Mar 25, 2026

I will review it this weekend (or earlier if I have time).

@sostock sostock merged commit f60d1cd into JuliaPhysics:master Mar 28, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants