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

expose some of the internal test functions in pint.testing #1421

Merged
merged 12 commits into from
Feb 23, 2022

Conversation

keewis
Copy link
Contributor

@keewis keewis commented Nov 21, 2021

just as a side note, it might be good to change the autodoc-based documentation to something else, like autosummary

@keewis
Copy link
Contributor Author

keewis commented Nov 21, 2021

okay, I cheated my way around a bug in is_compatible_with when it is used with contexts (it ignores already active contexts), but I don't know enough about contexts to fix that in a general way. Do you have any ideas, @hgrecco, @jules-ch?

@jules-ch
Copy link
Collaborator

Hi @keewis do you have a minimal example for your issue with is_compatible_with ?

@keewis
Copy link
Contributor Author

keewis commented Nov 24, 2021

it would be something like this (taken from test_contexts.py::TestDefinedContexts::test_spectroscopy)

In [6]: ureg = pint.UnitRegistry()
   ...: 
   ...: a = 532.0 * ureg.nm
   ...: b = 563.5 * ureg.terahertz
   ...: 
   ...: with ureg.context("sp"):
   ...:     print(a.to(ureg.terahertz))
   ...:     assert a.is_compatible_with(b), "not compatible"
   ...: 
563.5196578947367 terahertz
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-6-8eaa63cfa960> in <module>
      6 with ureg.context("sp"):
      7     print(a.to(ureg.terahertz))
----> 8     assert a.is_compatible_with(b), "not compatible"
      9 

AssertionError: not compatible

ureg.is_compatible_with behaves the same way (so at least it's consistent)

@jules-ch
Copy link
Collaborator

Can you file an issue regarding this, I'll quickly fix that.

@keewis
Copy link
Contributor Author

keewis commented Nov 24, 2021

sure

@keewis keewis mentioned this pull request Jan 16, 2022
21 tasks
@jules-ch
Copy link
Collaborator

Gonna merge this after CI completes

@jules-ch jules-ch merged commit 43287b3 into hgrecco:master Feb 23, 2022
@keewis keewis deleted the testing branch February 23, 2022 22:10
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.

Where is pint.testing API reference? np.testing.assert_equal does not work with quantity lists
2 participants