Skip to content

Commit

Permalink
Start subregistry experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
hgrecco committed Dec 2, 2023
1 parent 98fbda4 commit a91667b
Show file tree
Hide file tree
Showing 5 changed files with 676 additions and 17 deletions.
2 changes: 1 addition & 1 deletion pint/facets/plain/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def dimensionality(self) -> UnitsContainerT:
Dimensionality of the PlainQuantity, e.g. ``{length: 1, time: -1}``
"""
if self._dimensionality is None:
self._dimensionality = self._REGISTRY._get_dimensionality(self._units)
self._dimensionality = self._REGISTRY.get_dimensionality(self._units)

return self._dimensionality

Expand Down
20 changes: 17 additions & 3 deletions pint/facets/plain/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1150,11 +1150,25 @@ def parse_units(
pint.Unit
"""
return self.Unit(
self.parse_units_as_container(input_string, as_delta, case_sensitive)
)

units = self._parse_units(input_string, as_delta, case_sensitive)
return self.Unit(units)
def parse_units_as_container(
self,
input_string: str,
as_delta: Optional[bool] = None,
case_sensitive: Optional[bool] = None,
) -> UnitT:
as_delta = (
as_delta if as_delta is not None else self.default_as_delta
) # TODO This only exists in nonmultiplicative
case_sensitive = (
case_sensitive if case_sensitive is not None else self.case_sensitive
)
return self._parse_units_as_container(input_string, as_delta, case_sensitive)

def _parse_units(
def _parse_units_as_container(
self,
input_string: str,
as_delta: bool = True,
Expand Down
2 changes: 1 addition & 1 deletion pint/facets/plain/unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def dimensionality(self) -> UnitsContainer:
try:
return self._dimensionality
except AttributeError:
dim = self._REGISTRY._get_dimensionality(self._units)
dim = self._REGISTRY.get_dimensionality(self._units)
self._dimensionality = dim

return self._dimensionality
Expand Down
Loading

0 comments on commit a91667b

Please sign in to comment.