Skip to content

Commit

Permalink
Fix conversion to multi-dimension offset units
Browse files Browse the repository at this point in the history
  • Loading branch information
dalito committed Mar 8, 2024
1 parent ae00988 commit 346145a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Pint Changelog
0.24 (unreleased)
-----------------

- Nothing changed yet.

- Fix converting to offset units of higher dimension e.g. gauge pressure (#1949).
-

0.23 (2023-12-08)
-----------------
Expand Down
7 changes: 6 additions & 1 deletion pint/facets/nonmultiplicative/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _add_ref_of_log_or_offset_unit(
self, offset_unit: str, all_units: UnitsContainer
) -> UnitsContainer:
slct_unit = self._units[offset_unit]
if slct_unit.is_logarithmic or (not slct_unit.is_multiplicative):
if slct_unit.is_logarithmic:
# Extract reference unit
slct_ref = slct_unit.reference

Expand All @@ -205,6 +205,11 @@ def _add_ref_of_log_or_offset_unit(
(u, e) = [(u, e) for u, e in slct_ref.items()].pop()
# Add it back to the unit list
return all_units.add(u, e)

if not slct_unit.is_multiplicative: # is offset unit
# Extract reference unit
return slct_unit.reference

# Otherwise, return the units unmodified
return all_units

Expand Down

0 comments on commit 346145a

Please sign in to comment.