-
Notifications
You must be signed in to change notification settings - Fork 468
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
Global Quantity, Unit, and Measurement #880
Conversation
…upcast to Quantity on pickling
@hgrecco ready for review and merge |
@hgrecco ping |
I would like to test how this feels for a while. |
@hgrecco ETA to either merge or tweak requests? |
@hgrecco poke |
@hgrecco if you don't have time to go through this yourself, could you please nominate deputies? It's been 23 days now... |
@hgrecco Any updates on the status of this PR? It would be great to see this make it in soon. |
I have been playing with this for a while:
but, it seems to me that a changed is needed in the method/property If that is the case, I would suggest that after calling |
@hgrecco good points. My latest commits address them. |
bors r+ |
880: Global Quantity, Unit, and Measurement r=hgrecco a=crusaderky This PR addresses several issues I found myself facing when using pint in my own projects. - I found myself systematically needing to reference UnitRegistry, Quantity, and Unit in sphinx docstrings and typing annotations. - When prototyping and writing snippet code, I got frequently annoyed by having to typing ``ureg = pint.UnitRegistry()`` every time, even when I was perfectly content with defaults_en.txt (as most novice users will). - I found myself needing to access pint._APP_REGISTRY when creating a Quantity in a dask.distributed function. Changes: - Define global objects ``pint.Quantity``, ``pint.Unit``, and ``pint.Measurement``. They can be used directly, e.g. ``pint.Quantity(1, "kg")``. They use the global application registry. - Fix bug where Measurement objects would be accidentally upcast to Quantity upon pickling - All Exception classes are now accessible from the top-level module (also in intersphinx) - New function ``pint.get_application_registry`` - Documentation for using ``pint.set_application_registry`` in one's application - intersphinx users can now reference ``:class:`pint.UnitRegistry` `` instead of the internal implementation module ``:class:`pint.registry.UnitRegistry` `` - Fixed a wealth of sphinx errors (not all) - Unit tests for pickling/unpickling custom units through the global registry Co-authored-by: Guido Imperiale <guido.imperiale@amphorainc.com> Co-authored-by: Guido Imperiale <crusaderky@gmail.com> Co-authored-by: Unknown <crusaderky@gmail.com>
Thanks @crusaderky for all the work and congratulations! |
Build succeeded |
This PR addresses several issues I found myself facing when using pint in my own projects.
ureg = pint.UnitRegistry()
every time, even when I was perfectly content with defaults_en.txt (as most novice users will).Changes:
pint.Quantity
,pint.Unit
, andpint.Measurement
. They can be used directly, e.g.pint.Quantity(1, "kg")
. They use the global application registry.pint.get_application_registry
pint.set_application_registry
in one's application:class:`pint.UnitRegistry`
instead of the internal implementation module:class:`pint.registry.UnitRegistry`