Skip to content

Commit

Permalink
Maintain support for base pint Unit objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kroenlein committed Apr 2, 2024
1 parent 941ee06 commit 4c38728
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gemd/units/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ def _format_clean(unit, registry, **options):


@functools.lru_cache(maxsize=1024)
def parse_units(units: Union[str, _ScaleFactorUnit, None],
def parse_units(units: Union[str, UnitRegistry.Unit, None],
*,
return_unit: bool = False
) -> Union[str, _ScaleFactorUnit, None]:
) -> Union[str, UnitRegistry.Unit, None]:
"""
Parse a string or Unit into a standard string representation of the unit.
Expand Down Expand Up @@ -346,14 +346,14 @@ def parse_units(units: Union[str, _ScaleFactorUnit, None],
return parsed
else:
return f"{parsed}"
elif isinstance(units, _ScaleFactorUnit):
elif isinstance(units, UnitRegistry.Unit):
return units
else:
raise UndefinedUnitError("Units must be given as a recognized unit string or Units object")


@functools.lru_cache(maxsize=1024)
def get_base_units(units: Union[str, _ScaleFactorUnit]) -> Tuple[_ScaleFactorUnit, float, float]:
def get_base_units(units: Union[str, UnitRegistry.Unit]) -> Tuple[UnitRegistry.Unit, float, float]:
"""
Get the base units and conversion factors for the given unit.
Expand Down

0 comments on commit 4c38728

Please sign in to comment.