summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHernan Grecco <hgrecco@gmail.com>2023-05-05 18:54:48 -0300
committerHernan Grecco <hgrecco@gmail.com>2023-05-05 18:54:48 -0300
commit10ac784342b2503a4f1b153ba2cbc4be72f75122 (patch)
treeeca6e8aa03f2753bdb142abaea1ba5c4b9aa3b91
parent578e21210ef3a3932c0260654e241dff891e42b1 (diff)
downloadpint-10ac784342b2503a4f1b153ba2cbc4be72f75122.tar.gz
Remove deprecated usage in docs and fix introduced bug during refactoring.
-rw-r--r--docs/getting/tutorial.rst12
-rw-r--r--pint/facets/plain/registry.py3
2 files changed, 7 insertions, 8 deletions
diff --git a/docs/getting/tutorial.rst b/docs/getting/tutorial.rst
index 76ba30d..853aa27 100644
--- a/docs/getting/tutorial.rst
+++ b/docs/getting/tutorial.rst
@@ -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
@@ -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
@@ -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}')
@@ -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}
@@ -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'
@@ -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
diff --git a/pint/facets/plain/registry.py b/pint/facets/plain/registry.py
index aca553f..c0264de 100644
--- a/pint/facets/plain/registry.py
+++ b/pint/facets/plain/registry.py
@@ -348,8 +348,7 @@ class GenericPlainRegistry(Generic[QuantityT, UnitT], metaclass=RegistryMeta):
"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"""