Skip to content
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

Assertion error messages aren't very useful #563

Open
db434 opened this issue Mar 5, 2025 · 1 comment
Open

Assertion error messages aren't very useful #563

db434 opened this issue Mar 5, 2025 · 1 comment

Comments

@db434
Copy link
Contributor

db434 commented Mar 5, 2025

Compare numpy's error messages:

>>> numpy.testing.assert_allclose([1, 2], [1, 3])
AssertionError:
Not equal to tolerance rtol=1e-07, atol=0

Mismatched elements: 1 / 2 (50%)
Max absolute difference: 1
Max relative difference: 0.33333333
 x: array([1, 2])
 y: array([1, 3])

With unyt's:

>>> unyt.testing.assert_allclose_units([1, 2] * unyt.m, [1, 3] * unyt.m)
AssertionError

Is there any appetite for aligning these better, to expose more information when something goes wrong? I'm happy to contribute here - we have something like this internally already.

@neutrinoceros
Copy link
Member

Yes. Definitely. There have been improvements in how numpy.testing functions integrate with unyt, but no effort was spent on improving our own. I would love to see this sort of contribution. Thank you for offering !

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

No branches or pull requests

2 participants