Skip to content

Commit

Permalink
Update test_quantity.py
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage authored and jules-ch committed Dec 13, 2024
1 parent b053a48 commit 9c082fa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Pint Changelog

- Add docs to the functions in ``pint.testing`` (PR #2070)
- Fix round function returning float instead of int (#2081)
- Change Quantity repr to include magnitude repr & units. (PR #1579)


0.24.4 (2024-11-07)
Expand Down Expand Up @@ -215,7 +216,6 @@ Pint Changelog
- Fix masked arrays (with multiple values) incorrectly being passed through
setitem (Issue #1584)
- Add Quantity.to_preferred
- Change Quantity repr to include magnitude repr & units.


0.19.2 (2022-04-23)
Expand Down
8 changes: 4 additions & 4 deletions pint/facets/plain/quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ def __bytes__(self) -> bytes:
def __repr__(self) -> str:
if HAS_UNCERTAINTIES:
if isinstance(self._magnitude, UFloat):
return f"<Quantity({self._magnitude:.6}, '{self._units}')>"
return f"<Quantity({self._magnitude:.6}, units='{self._units}')>"
else:
return f"<Quantity({self._magnitude}, '{self._units}')>"
return f"<Quantity({self._magnitude}, units='{self._units}')>"
elif isinstance(self._magnitude, float):
return f"<Quantity({self._magnitude:.9}, '{self._units}')>"
return f"<Quantity({self._magnitude:.9}, units='{self._units}')>"

return f"<Quantity({self._magnitude}, '{self._units}')>"
return f"<Quantity({self._magnitude!r}, units='{self._units}')>"

def __hash__(self) -> int:
self_base = self.to_base_units()
Expand Down
2 changes: 1 addition & 1 deletion pint/testsuite/test_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_quantity_repr(self):
assert str(x) == "4.2 meter"
assert repr(x) == "<Quantity(4.2, units='meter')>"
x = self.Q_(2.9325156461464651456456545649)
assert repr(x) == "<Quantity(2.932515646146465, units='dimensionless')>"
assert repr(x) == "<Quantity(2.93251565, units='dimensionless')>"

@helpers.requires_numpy
def test_quantity_repr_numpy(self):
Expand Down

0 comments on commit 9c082fa

Please sign in to comment.