u 3.0__tar.gz → 4.0__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.
- {u-3.0 → u-4.0}/PKG-INFO +1 -1
- {u-3.0 → u-4.0}/changelog.md +11 -0
- {u-3.0 → u-4.0}/tests/test_quantities.py +5 -0
- {u-3.0 → u-4.0}/u/__init__.py +1 -1
- {u-3.0 → u-4.0}/u/quantity.py +8 -5
- {u-3.0 → u-4.0}/.gitignore +0 -0
- {u-3.0 → u-4.0}/LICENSE.txt +0 -0
- {u-3.0 → u-4.0}/README.md +0 -0
- {u-3.0 → u-4.0}/docs/api/quantity.md +0 -0
- {u-3.0 → u-4.0}/docs/api/unit.md +0 -0
- {u-3.0 → u-4.0}/docs/index.md +0 -0
- {u-3.0 → u-4.0}/mkdocs.yml +0 -0
- {u-3.0 → u-4.0}/pyproject.toml +0 -0
- {u-3.0 → u-4.0}/tests/static_tests.py +0 -0
- {u-3.0 → u-4.0}/tests/test_conversions.py +0 -0
- {u-3.0 → u-4.0}/tests/test_decimal.py +0 -0
- {u-3.0 → u-4.0}/tests/test_math.py +0 -0
- {u-3.0 → u-4.0}/tests/test_prefixes.py +0 -0
- {u-3.0 → u-4.0}/tests/test_typing.py +0 -0
- {u-3.0 → u-4.0}/tests/test_units.py +0 -0
- {u-3.0 → u-4.0}/u/_utils.py +0 -0
- {u-3.0 → u-4.0}/u/capital_quantities.py +0 -0
- {u-3.0 → u-4.0}/u/cli/__init__.py +0 -0
- {u-3.0 → u-4.0}/u/cli/make_derived_quantity.py +0 -0
- {u-3.0 → u-4.0}/u/maths.py +0 -0
- {u-3.0 → u-4.0}/u/prefixes.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/__init__.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/acceleration.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/amount_of_substance.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/angle.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/area.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/data_transfer_speed.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/data_volume.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/distance.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/duration.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/electric_charge.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/electric_current.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/electric_resistance.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/energy.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/force.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/frequency.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/luminous_intensity.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/mass.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/one.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/pixels.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/power.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/pressure.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/solid_angle.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/speed.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/temperature.py +0 -0
- {u-3.0 → u-4.0}/u/quantities/volume.py +0 -0
- {u-3.0 → u-4.0}/u/unit.py +0 -0
- {u-3.0 → u-4.0}/uv.lock +0 -0
{u-3.0 → u-4.0}/PKG-INFO
RENAMED
{u-3.0 → u-4.0}/changelog.md
RENAMED
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
# 4.0
|
|
2
|
+
|
|
3
|
+
- Comparison operators in `Quantity` no longer use `math.isclose`, and hashing no longer rounds.
|
|
4
|
+
Basically, comparing `Quantity` objects is now just as unpredictable as comparing floats. The
|
|
5
|
+
upside is that equality is now transitive. (i.e. if `a == b` and `b == c`, then `a == c`.)
|
|
6
|
+
|
|
7
|
+
# 3.1
|
|
8
|
+
|
|
9
|
+
- Add `__hash__` method
|
|
10
|
+
|
|
1
11
|
# 3.0
|
|
2
12
|
|
|
3
13
|
- Add support for `decimal.Decimal`. Unlike floats and Decimals, which throw a TypeError when used
|
|
4
14
|
together, `Quantity`s remain interoperable regardless of whether they were created with a float or
|
|
5
15
|
a Decimal.
|
|
6
16
|
- `Unit.multiplier` is now a Decimal.
|
|
17
|
+
- Add `systems` parameter and attribute to `Unit`
|
|
7
18
|
|
|
8
19
|
# 2.1
|
|
9
20
|
|
{u-3.0 → u-4.0}/u/__init__.py
RENAMED
{u-3.0 → u-4.0}/u/quantity.py
RENAMED
|
@@ -417,6 +417,9 @@ 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
|
+
def __hash__(self) -> int:
|
|
421
|
+
return hash((self._value, self._unit))
|
|
422
|
+
|
|
420
423
|
def __eq__(self, quantity: object, /) -> bool:
|
|
421
424
|
if quantity == 0:
|
|
422
425
|
num = float(self)
|
|
@@ -429,7 +432,7 @@ class Quantity(t.Generic[Q_co], metaclass=QuantityMeta):
|
|
|
429
432
|
num = self.to_number(quantity._unit)
|
|
430
433
|
expected = float(quantity._value)
|
|
431
434
|
|
|
432
|
-
return
|
|
435
|
+
return num == expected
|
|
433
436
|
|
|
434
437
|
def __lt__(self, quantity: NullableQuantity[Q_co], /) -> bool:
|
|
435
438
|
if quantity == 0:
|
|
@@ -443,7 +446,7 @@ class Quantity(t.Generic[Q_co], metaclass=QuantityMeta):
|
|
|
443
446
|
num = self.to_number(quantity._unit)
|
|
444
447
|
expected = float(quantity._value)
|
|
445
448
|
|
|
446
|
-
return num < expected
|
|
449
|
+
return num < expected
|
|
447
450
|
|
|
448
451
|
def __le__(self, quantity: object, /) -> bool:
|
|
449
452
|
if quantity == 0:
|
|
@@ -457,7 +460,7 @@ class Quantity(t.Generic[Q_co], metaclass=QuantityMeta):
|
|
|
457
460
|
num = self.to_number(quantity._unit)
|
|
458
461
|
expected = float(quantity._value)
|
|
459
462
|
|
|
460
|
-
return num
|
|
463
|
+
return num <= expected
|
|
461
464
|
|
|
462
465
|
def __gt__(self, quantity: object, /) -> bool:
|
|
463
466
|
if quantity == 0:
|
|
@@ -471,7 +474,7 @@ class Quantity(t.Generic[Q_co], metaclass=QuantityMeta):
|
|
|
471
474
|
num = self.to_number(quantity._unit)
|
|
472
475
|
expected = float(quantity._value)
|
|
473
476
|
|
|
474
|
-
return num > expected
|
|
477
|
+
return num > expected
|
|
475
478
|
|
|
476
479
|
def __ge__(self, quantity: object, /) -> bool:
|
|
477
480
|
if quantity == 0:
|
|
@@ -485,7 +488,7 @@ class Quantity(t.Generic[Q_co], metaclass=QuantityMeta):
|
|
|
485
488
|
num = self.to_number(quantity._unit)
|
|
486
489
|
expected = float(quantity._value)
|
|
487
490
|
|
|
488
|
-
return num
|
|
491
|
+
return num >= expected
|
|
489
492
|
|
|
490
493
|
def __add__(self, quantity: NullableQuantity[Q_co], /) -> Quantity[Q_co]:
|
|
491
494
|
if quantity == 0:
|
{u-3.0 → u-4.0}/.gitignore
RENAMED
|
File without changes
|
{u-3.0 → u-4.0}/LICENSE.txt
RENAMED
|
File without changes
|
{u-3.0 → u-4.0}/README.md
RENAMED
|
File without changes
|
|
File without changes
|
{u-3.0 → u-4.0}/docs/api/unit.md
RENAMED
|
File without changes
|
{u-3.0 → u-4.0}/docs/index.md
RENAMED
|
File without changes
|
{u-3.0 → u-4.0}/mkdocs.yml
RENAMED
|
File without changes
|
{u-3.0 → u-4.0}/pyproject.toml
RENAMED
|
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-4.0}/u/_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{u-3.0 → u-4.0}/u/maths.py
RENAMED
|
File without changes
|
{u-3.0 → u-4.0}/u/prefixes.py
RENAMED
|
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-4.0}/u/unit.py
RENAMED
|
File without changes
|
{u-3.0 → u-4.0}/uv.lock
RENAMED
|
File without changes
|