-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- api is now split into 3 parts - files are reorganized in folders Additionally, some class members (Quantity, Unit, Measurement, Group, Context, System) are excluded from the docs as they confuse sphinx.
- Loading branch information
Showing
30 changed files
with
446 additions
and
198 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Advanced Guides | ||
=============== | ||
|
||
Pint contains some useful and fun feature. You will find them here. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:hidden: | ||
|
||
performance | ||
serialization | ||
defining | ||
wrapping | ||
measurement | ||
pitheorem | ||
currencies | ||
custom-registry-class |
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions
2
docs/user/serialization.rst → docs/advanced/serialization.rst
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
.. _serialization: | ||
|
||
|
||
Serialization | ||
============= | ||
|
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
Base API | ||
======== | ||
|
||
.. currentmodule:: pint | ||
|
||
|
||
Most important classes | ||
---------------------- | ||
|
||
.. autoclass:: UnitRegistry | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. autoclass:: Quantity | ||
:members: | ||
|
||
.. autoclass:: Unit | ||
:members: | ||
|
||
.. autoclass:: Measurement | ||
:members: | ||
|
||
|
||
Exceptions and warnings | ||
----------------------- | ||
|
||
.. autoexception:: PintError | ||
:members: | ||
|
||
.. autoexception:: DefinitionSyntaxError | ||
:members: | ||
|
||
.. autoexception:: LogarithmicUnitCalculusError | ||
:members: | ||
|
||
.. autoexception:: DimensionalityError | ||
:members: | ||
|
||
.. autoexception:: OffsetUnitCalculusError | ||
:members: | ||
|
||
.. autoexception:: RedefinitionError | ||
:members: | ||
|
||
.. autoexception:: UndefinedUnitError | ||
:members: | ||
|
||
.. autoexception:: UnitStrippedWarning | ||
:members: | ||
|
||
|
||
Sharing registry among packages | ||
------------------------------- | ||
, | ||
.. autofunction:: get_application_registry | ||
.. autofunction:: set_application_registry | ||
|
||
Other functions | ||
--------------- | ||
|
||
.. autofunction:: formatter | ||
.. autofunction:: register_unit_format | ||
.. autofunction:: pi_theorem | ||
.. autoclass:: Context |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Common API | ||
========== | ||
|
||
.. automodule:: pint.babel_names | ||
:members: | ||
|
||
.. automodule:: pint.compat | ||
:members: | ||
|
||
.. automodule:: pint.converters | ||
:members: | ||
|
||
.. automodule:: pint.definitions | ||
:members: | ||
|
||
.. automodule:: pint.errors | ||
:members: | ||
|
||
.. automodule:: pint.formatting | ||
:members: | ||
|
||
.. automodule:: pint.matplotlib | ||
:members: | ||
|
||
.. automodule:: pint.pint_eval | ||
:members: | ||
|
||
.. automodule:: pint.registry | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System, UnitRegistry | ||
|
||
.. automodule:: pint.registry_helpers | ||
:members: | ||
|
||
.. automodule:: pint.testing | ||
:members: | ||
|
||
.. automodule:: pint.util | ||
:members: | ||
:exclude-members: Unit |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
API facets reference | ||
==================== | ||
|
||
|
||
.. automodule:: pint.facets.plain | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.nonmultiplicative | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.formatting | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.numpy | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.dask | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.measurement | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.group | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.system | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System | ||
|
||
.. automodule:: pint.facets.context | ||
:members: | ||
:exclude-members: Quantity, Unit, Measurement, Group, Context, System |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
API reference | ||
============== | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:hidden: | ||
|
||
base | ||
common | ||
facets |
This file contains 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
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
.. _pint_in_your_projects: | ||
|
||
Using Pint in your projects | ||
=========================== | ||
|
||
Having a shared registry | ||
------------------------ | ||
|
||
If you use Pint in multiple modules within your Python package, you normally | ||
want to avoid creating multiple instances of the unit registry. | ||
The best way to do this is by instantiating the registry in a single place. For | ||
example, you can add the following code to your package ``__init__.py`` | ||
|
||
.. doctest:: | ||
|
||
>>> from pint import UnitRegistry | ||
>>> ureg = UnitRegistry() | ||
>>> Q_ = ureg.Quantity | ||
|
||
|
||
Then in ``yourmodule.py`` the code would be | ||
|
||
.. code-block:: python | ||
from . import ureg, Q_ | ||
length = 10 * ureg.meter | ||
my_speed = Q_(20, 'm/s') | ||
If you are pickling and unpickling Quantities within your project, you should | ||
also define the registry as the application registry | ||
|
||
.. code-block:: python | ||
from pint import UnitRegistry, set_application_registry | ||
ureg = UnitRegistry() | ||
set_application_registry(ureg) | ||
.. warning:: There are no global units in Pint. All units belong to a registry and | ||
you can have multiple registries instantiated at the same time. However, you | ||
are not supposed to operate between quantities that belong to different registries. | ||
Never do things like this: | ||
|
||
.. doctest:: | ||
|
||
>>> q1 = 10 * UnitRegistry().meter | ||
>>> q2 = 10 * UnitRegistry().meter | ||
>>> q1 + q2 | ||
Traceback (most recent call last): | ||
... | ||
ValueError: Cannot operate with Quantity and Quantity of different registries. | ||
>>> id(q1._REGISTRY) == id(q2._REGISTRY) | ||
False | ||
|
||
|
||
Keeping up to date with Pint development | ||
---------------------------------------- | ||
|
||
While we work hard to avoid breaking code using Pint, sometimes it | ||
happens. To help you track how Pint is evolving it is recommended | ||
that you run a daily or weekly job against pint master branch. | ||
|
||
For example, this is how xarray_ is doing it: | ||
|
||
If a new version of Pint breaks your code, please open an issue_ to | ||
let us know. | ||
|
||
.. _xarray: https://github.com/pydata/xarray/blob/main/.github/workflows/upstream-dev-ci.yaml | ||
.. _issue: https://github.com/hgrecco/pint/issues |
Oops, something went wrong.