Skip to content

Commit 247c081

Browse files
committed
Document internal representation of Quantity objects as floats
Closes #531 Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 4009eec commit 247c081

File tree

1 file changed

+60
-6
lines changed

1 file changed

+60
-6
lines changed

src/frequenz/sdk/timeseries/_quantities.py

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,16 @@ class Power(
393393
6: "MW",
394394
},
395395
):
396-
"""A power quantity."""
396+
"""A power quantity.
397+
398+
Objects of this type are wrappers around `float` values.
399+
400+
The constructors accept a single `float` value, the `as_*()` methods return a
401+
`float` value, and each of the arithmetic operators supported by this type are
402+
actually implemented using floating-point arithmetic.
403+
404+
So all considerations about floating-point arithmetic apply to this type as well.
405+
"""
397406

398407
@classmethod
399408
def from_watts(cls, watts: float) -> Self:
@@ -557,7 +566,16 @@ class Current(
557566
0: "A",
558567
},
559568
):
560-
"""A current quantity."""
569+
"""A current quantity.
570+
571+
Objects of this type are wrappers around `float` values.
572+
573+
The constructors accept a single `float` value, the `as_*()` methods return a
574+
`float` value, and each of the arithmetic operators supported by this type are
575+
actually implemented using floating-point arithmetic.
576+
577+
So all considerations about floating-point arithmetic apply to this type as well.
578+
"""
561579

562580
@classmethod
563581
def from_amperes(cls, amperes: float) -> Self:
@@ -644,7 +662,16 @@ class Voltage(
644662
metaclass=_NoDefaultConstructible,
645663
exponent_unit_map={0: "V", -3: "mV", 3: "kV"},
646664
):
647-
"""A voltage quantity."""
665+
"""A voltage quantity.
666+
667+
Objects of this type are wrappers around `float` values.
668+
669+
The constructors accept a single `float` value, the `as_*()` methods return a
670+
`float` value, and each of the arithmetic operators supported by this type are
671+
actually implemented using floating-point arithmetic.
672+
673+
So all considerations about floating-point arithmetic apply to this type as well.
674+
"""
648675

649676
@classmethod
650677
def from_volts(cls, volts: float) -> Self:
@@ -757,7 +784,16 @@ class Energy(
757784
6: "MWh",
758785
},
759786
):
760-
"""An energy quantity."""
787+
"""An energy quantity.
788+
789+
Objects of this type are wrappers around `float` values.
790+
791+
The constructors accept a single `float` value, the `as_*()` methods return a
792+
`float` value, and each of the arithmetic operators supported by this type are
793+
actually implemented using floating-point arithmetic.
794+
795+
So all considerations about floating-point arithmetic apply to this type as well.
796+
"""
761797

762798
@classmethod
763799
def from_watt_hours(cls, watt_hours: float) -> Self:
@@ -867,7 +903,16 @@ class Frequency(
867903
metaclass=_NoDefaultConstructible,
868904
exponent_unit_map={0: "Hz", 3: "kHz", 6: "MHz", 9: "GHz"},
869905
):
870-
"""A frequency quantity."""
906+
"""A frequency quantity.
907+
908+
Objects of this type are wrappers around `float` values.
909+
910+
The constructors accept a single `float` value, the `as_*()` methods return a
911+
`float` value, and each of the arithmetic operators supported by this type are
912+
actually implemented using floating-point arithmetic.
913+
914+
So all considerations about floating-point arithmetic apply to this type as well.
915+
"""
871916

872917
@classmethod
873918
def from_hertz(cls, hertz: float) -> Self:
@@ -971,7 +1016,16 @@ class Percentage(
9711016
metaclass=_NoDefaultConstructible,
9721017
exponent_unit_map={0: "%"},
9731018
):
974-
"""A percentage quantity."""
1019+
"""A percentage quantity.
1020+
1021+
Objects of this type are wrappers around `float` values.
1022+
1023+
The constructors accept a single `float` value, the `as_*()` methods return a
1024+
`float` value, and each of the arithmetic operators supported by this type are
1025+
actually implemented using floating-point arithmetic.
1026+
1027+
So all considerations about floating-point arithmetic apply to this type as well.
1028+
"""
9751029

9761030
@classmethod
9771031
def from_percent(cls, percent: float) -> Self:

0 commit comments

Comments
 (0)