Skip to content

Commit

Permalink
Remove deprecated usage in docs and fix introduced bug during refacto…
Browse files Browse the repository at this point in the history
…ring.
  • Loading branch information
hgrecco committed May 5, 2023
1 parent 578e212 commit 10ac784
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions docs/getting/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Pint's physical quantities can be easily printed:

.. doctest::

>>> accel = 1.3 * ureg['meter/second**2']
>>> accel = 1.3 * ureg.parse_units('meter/second**2')
>>> # The standard string formatting code
>>> print('The str is {!s}'.format(accel))
The str is 1.3 meter / second ** 2
Expand All @@ -297,7 +297,7 @@ Pint supports float formatting for numpy arrays as well:
.. doctest::

>>> import numpy as np
>>> accel = np.array([-1.1, 1e-6, 1.2505, 1.3]) * ureg['meter/second**2']
>>> accel = np.array([-1.1, 1e-6, 1.2505, 1.3]) * ureg.parse_units('meter/second**2')
>>> # float formatting numpy arrays
>>> print('The array is {:.2f}'.format(accel))
The array is [-1.10 0.00 1.25 1.30] meter / second ** 2
Expand All @@ -309,7 +309,7 @@ Pint also supports `f-strings`_ from python>=3.6 :

.. doctest::

>>> accel = 1.3 * ureg['meter/second**2']
>>> accel = 1.3 * ureg.parse_units('meter/second**2')
>>> print(f'The str is {accel}')
The str is 1.3 meter / second ** 2
>>> print(f'The str is {accel:.3e}')
Expand Down Expand Up @@ -368,7 +368,7 @@ Pint also supports the LaTeX `siunitx` package:
.. doctest::
:skipif: not_installed['uncertainties']

>>> accel = 1.3 * ureg['meter/second**2']
>>> accel = 1.3 * ureg.parse_units('meter/second**2')
>>> # siunitx Latex print
>>> print('The siunitx representation is {:Lx}'.format(accel))
The siunitx representation is \SI[]{1.3}{\meter\per\second\squared}
Expand All @@ -380,7 +380,7 @@ Additionally, you can specify a default format specification:

.. doctest::

>>> accel = 1.3 * ureg['meter/second**2']
>>> accel = 1.3 * ureg.parse_units('meter/second**2')
>>> 'The acceleration is {}'.format(accel)
'The acceleration is 1.3 meter / second ** 2'
>>> ureg.default_format = 'P'
Expand Down Expand Up @@ -414,7 +414,7 @@ and by doing that, string formatting is now localized:

.. doctest::

>>> accel = 1.3 * ureg['meter/second**2']
>>> accel = 1.3 * ureg.parse_units('meter/second**2')
>>> str(accel)
'1.3 mètre par seconde²'
>>> "%s" % accel
Expand Down
3 changes: 1 addition & 2 deletions pint/facets/plain/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ def __getitem__(self, item: str) -> UnitT:
"Calling the getitem method from a UnitRegistry is deprecated. "
"use `parse_expression` method or use the registry as a callable."
)
return self.Quantity()
# return self.parse_expression(item)
return self.parse_expression(item)

def __contains__(self, item: str) -> bool:
"""Support checking prefixed units with the `in` operator"""
Expand Down

0 comments on commit 10ac784

Please sign in to comment.