u 3.0__tar.gz → 3.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. {u-3.0 → u-3.1}/PKG-INFO +1 -1
  2. {u-3.0 → u-3.1}/changelog.md +5 -0
  3. {u-3.0 → u-3.1}/tests/test_quantities.py +5 -0
  4. {u-3.0 → u-3.1}/u/__init__.py +1 -1
  5. {u-3.0 → u-3.1}/u/quantity.py +8 -0
  6. {u-3.0 → u-3.1}/.gitignore +0 -0
  7. {u-3.0 → u-3.1}/LICENSE.txt +0 -0
  8. {u-3.0 → u-3.1}/README.md +0 -0
  9. {u-3.0 → u-3.1}/docs/api/quantity.md +0 -0
  10. {u-3.0 → u-3.1}/docs/api/unit.md +0 -0
  11. {u-3.0 → u-3.1}/docs/index.md +0 -0
  12. {u-3.0 → u-3.1}/mkdocs.yml +0 -0
  13. {u-3.0 → u-3.1}/pyproject.toml +0 -0
  14. {u-3.0 → u-3.1}/tests/static_tests.py +0 -0
  15. {u-3.0 → u-3.1}/tests/test_conversions.py +0 -0
  16. {u-3.0 → u-3.1}/tests/test_decimal.py +0 -0
  17. {u-3.0 → u-3.1}/tests/test_math.py +0 -0
  18. {u-3.0 → u-3.1}/tests/test_prefixes.py +0 -0
  19. {u-3.0 → u-3.1}/tests/test_typing.py +0 -0
  20. {u-3.0 → u-3.1}/tests/test_units.py +0 -0
  21. {u-3.0 → u-3.1}/u/_utils.py +0 -0
  22. {u-3.0 → u-3.1}/u/capital_quantities.py +0 -0
  23. {u-3.0 → u-3.1}/u/cli/__init__.py +0 -0
  24. {u-3.0 → u-3.1}/u/cli/make_derived_quantity.py +0 -0
  25. {u-3.0 → u-3.1}/u/maths.py +0 -0
  26. {u-3.0 → u-3.1}/u/prefixes.py +0 -0
  27. {u-3.0 → u-3.1}/u/quantities/__init__.py +0 -0
  28. {u-3.0 → u-3.1}/u/quantities/acceleration.py +0 -0
  29. {u-3.0 → u-3.1}/u/quantities/amount_of_substance.py +0 -0
  30. {u-3.0 → u-3.1}/u/quantities/angle.py +0 -0
  31. {u-3.0 → u-3.1}/u/quantities/area.py +0 -0
  32. {u-3.0 → u-3.1}/u/quantities/data_transfer_speed.py +0 -0
  33. {u-3.0 → u-3.1}/u/quantities/data_volume.py +0 -0
  34. {u-3.0 → u-3.1}/u/quantities/distance.py +0 -0
  35. {u-3.0 → u-3.1}/u/quantities/duration.py +0 -0
  36. {u-3.0 → u-3.1}/u/quantities/electric_charge.py +0 -0
  37. {u-3.0 → u-3.1}/u/quantities/electric_current.py +0 -0
  38. {u-3.0 → u-3.1}/u/quantities/electric_resistance.py +0 -0
  39. {u-3.0 → u-3.1}/u/quantities/energy.py +0 -0
  40. {u-3.0 → u-3.1}/u/quantities/force.py +0 -0
  41. {u-3.0 → u-3.1}/u/quantities/frequency.py +0 -0
  42. {u-3.0 → u-3.1}/u/quantities/luminous_intensity.py +0 -0
  43. {u-3.0 → u-3.1}/u/quantities/mass.py +0 -0
  44. {u-3.0 → u-3.1}/u/quantities/one.py +0 -0
  45. {u-3.0 → u-3.1}/u/quantities/pixels.py +0 -0
  46. {u-3.0 → u-3.1}/u/quantities/power.py +0 -0
  47. {u-3.0 → u-3.1}/u/quantities/pressure.py +0 -0
  48. {u-3.0 → u-3.1}/u/quantities/solid_angle.py +0 -0
  49. {u-3.0 → u-3.1}/u/quantities/speed.py +0 -0
  50. {u-3.0 → u-3.1}/u/quantities/temperature.py +0 -0
  51. {u-3.0 → u-3.1}/u/quantities/volume.py +0 -0
  52. {u-3.0 → u-3.1}/u/unit.py +0 -0
  53. {u-3.0 → u-3.1}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: u
3
- Version: 3.0
3
+ Version: 3.1
4
4
  Summary: Statically typed units
5
5
  Keywords: units,dimensions
6
6
  Author-email: Aran-Fey <rawing7@gmail.com>
@@ -1,9 +1,14 @@
1
+ # 3.1
2
+
3
+ - Add `__hash__` method
4
+
1
5
  # 3.0
2
6
 
3
7
  - Add support for `decimal.Decimal`. Unlike floats and Decimals, which throw a TypeError when used
4
8
  together, `Quantity`s remain interoperable regardless of whether they were created with a float or
5
9
  a Decimal.
6
10
  - `Unit.multiplier` is now a Decimal.
11
+ - Add `systems` parameter and attribute to `Unit`
7
12
 
8
13
  # 2.1
9
14
 
@@ -8,3 +8,8 @@ def test_getitem():
8
8
 
9
9
  def test_equality():
10
10
  assert u.minutes(60) == u.hours(1)
11
+
12
+
13
+ def test_hashing():
14
+ mapping = {u.minutes(60): "foo"}
15
+ assert mapping[u.hours(1)] == "foo"
@@ -1,4 +1,4 @@
1
- __version__ = "3.0"
1
+ __version__ = "3.1"
2
2
 
3
3
  from .prefixes import *
4
4
  from .quantity import *
@@ -417,6 +417,14 @@ class Quantity(t.Generic[Q_co], metaclass=QuantityMeta):
417
417
  def __neg__(self) -> Quantity[Q_co]:
418
418
  return Quantity(-self._value, self._unit)
419
419
 
420
+ # TODO: Rethink equality. I threw in `math.isclose` because I expected problems with floating
421
+ # point precision, but failed to realize that this breaks the "transitive" property of equality.
422
+ # (It's now possible to have 3 quantities A, B, C where B is equal to A and C, but A is not
423
+ # equal to C.)
424
+ def __hash__(self) -> int:
425
+ rounded_value = round(self._value, 10)
426
+ return hash((rounded_value, self._unit))
427
+
420
428
  def __eq__(self, quantity: object, /) -> bool:
421
429
  if quantity == 0:
422
430
  num = float(self)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
{u-3.0 → u-3.1}/uv.lock RENAMED
File without changes