summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHernan Grecco <hgrecco@gmail.com>2023-04-29 19:20:54 -0300
committerHernan Grecco <hgrecco@gmail.com>2023-04-29 19:20:54 -0300
commit10f69c4870ef9acda1b5dd21f2bf87f15855d3ea (patch)
tree01d2af512f86656703a09e59ef8aabba1c3cc5f1
parent1208b3d503913eabe8ac96db18ee2ad14af1bdd6 (diff)
downloadpint-10f69c4870ef9acda1b5dd21f2bf87f15855d3ea.tar.gz
Remove deprecated use_decimal
-rw-r--r--pint/facets/plain/registry.py30
-rw-r--r--pint/testsuite/test_util.py4
-rw-r--r--pint/util.py10
3 files changed, 5 insertions, 39 deletions
diff --git a/pint/facets/plain/registry.py b/pint/facets/plain/registry.py
index 0bf1545..dbe755d 100644
--- a/pint/facets/plain/registry.py
+++ b/pint/facets/plain/registry.py
@@ -1124,15 +1124,7 @@ class PlainRegistry(metaclass=RegistryMeta):
return ret
- def _eval_token(self, token, case_sensitive=None, use_decimal=False, **values):
- # TODO: remove this code when use_decimal is deprecated
- if use_decimal:
- raise DeprecationWarning(
- "`use_decimal` is deprecated, use `non_int_type` keyword argument when instantiating the registry.\n"
- ">>> from decimal import Decimal\n"
- ">>> ureg = UnitRegistry(non_int_type=Decimal)"
- )
-
+ def _eval_token(self, token, case_sensitive=None, **values):
token_type = token[0]
token_text = token[1]
if token_type == NAME:
@@ -1161,7 +1153,6 @@ class PlainRegistry(metaclass=RegistryMeta):
input_string: str,
pattern: str,
case_sensitive: Optional[bool] = None,
- use_decimal: bool = False,
many: bool = False,
) -> Union[List[str], str, None]:
"""Parse a string with a given regex pattern and returns result.
@@ -1174,8 +1165,6 @@ class PlainRegistry(metaclass=RegistryMeta):
The regex parse string
case_sensitive :
(Default value = None, which uses registry setting)
- use_decimal :
- (Default value = False)
many :
Match many results
(Default value = False)
@@ -1203,10 +1192,7 @@ class PlainRegistry(metaclass=RegistryMeta):
units = []
for unit, value in match.items():
# Construct measure by multiplying value by unit
- units.append(
- float(value)
- * self.parse_expression(unit, case_sensitive, use_decimal)
- )
+ units.append(float(value) * self.parse_expression(unit, case_sensitive))
# Add to results
results.append(units)
@@ -1221,7 +1207,6 @@ class PlainRegistry(metaclass=RegistryMeta):
self,
input_string: str,
case_sensitive: Optional[bool] = None,
- use_decimal: bool = False,
**values,
) -> Quantity:
"""Parse a mathematical expression including units and return a quantity object.
@@ -1235,8 +1220,6 @@ class PlainRegistry(metaclass=RegistryMeta):
case_sensitive :
(Default value = None, which uses registry setting)
- use_decimal :
- (Default value = False)
**values :
@@ -1244,15 +1227,6 @@ class PlainRegistry(metaclass=RegistryMeta):
-------
"""
-
- # TODO: remove this code when use_decimal is deprecated
- if use_decimal:
- raise DeprecationWarning(
- "`use_decimal` is deprecated, use `non_int_type` keyword argument when instantiating the registry.\n"
- ">>> from decimal import Decimal\n"
- ">>> ureg = UnitRegistry(non_int_type=Decimal)"
- )
-
if not input_string:
return self.Quantity(1)
diff --git a/pint/testsuite/test_util.py b/pint/testsuite/test_util.py
index fd6494a..bfbc55d 100644
--- a/pint/testsuite/test_util.py
+++ b/pint/testsuite/test_util.py
@@ -193,9 +193,9 @@ class TestParseHelper:
assert "seconds" / z() == ParserHelper(0.5, seconds=1, meter=-2)
assert dict(seconds=1) / z() == ParserHelper(0.5, seconds=1, meter=-2)
- def _test_eval_token(self, expected, expression, use_decimal=False):
+ def _test_eval_token(self, expected, expression):
token = next(tokenizer(expression))
- actual = ParserHelper.eval_token(token, use_decimal=use_decimal)
+ actual = ParserHelper.eval_token(token)
assert expected == actual
assert type(expected) == type(actual)
diff --git a/pint/util.py b/pint/util.py
index 8b62009..eff3670 100644
--- a/pint/util.py
+++ b/pint/util.py
@@ -569,15 +569,7 @@ class ParserHelper(UnitsContainer):
return cls(ONE, [(input_word, ONE)], non_int_type=non_int_type)
@classmethod
- def eval_token(cls, token, use_decimal=False, non_int_type=float):
- # TODO: remove this code when use_decimal is deprecated
- if use_decimal:
- raise DeprecationWarning(
- "`use_decimal` is deprecated, use `non_int_type` keyword argument when instantiating the registry.\n"
- ">>> from decimal import Decimal\n"
- ">>> ureg = UnitRegistry(non_int_type=Decimal)"
- )
-
+ def eval_token(cls, token, non_int_type=float):
token_type = token.type
token_text = token.string
if token_type == NUMBER: