From 807c3e71d724a05ec20137ec24a70cdb1ff8b45d Mon Sep 17 00:00:00 2001 From: unexcellent <> Date: Tue, 19 Nov 2024 09:49:02 +0100 Subject: [PATCH] feat: implement ElectricCurrent --- generate/generate_boilerplate.py | 7 ++++ quantio/__init__.py | 2 ++ quantio/quantities.py | 56 ++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/generate/generate_boilerplate.py b/generate/generate_boilerplate.py index 20f133a..1f458e1 100644 --- a/generate/generate_boilerplate.py +++ b/generate/generate_boilerplate.py @@ -128,6 +128,13 @@ def _generat_zero_function(current_class: str) -> list[str]: "ohm": "1", "milliohm": "10**-3", }, + "ElectricCurrent": { + "gigaamperes": "10**9", + "megaamperes": "10**6", + "kiloamperes": "10**3", + "amperes": "1", + "milliamperes": "10**-3", + }, "Energy": { "gigajoules": "10**9", "megajoules": "10**6", diff --git a/quantio/__init__.py b/quantio/__init__.py index c87bb59..ed6920a 100644 --- a/quantio/__init__.py +++ b/quantio/__init__.py @@ -6,6 +6,7 @@ Angle, Area, ElectricalResistance, + ElectricCurrent, Energy, Frequency, Length, @@ -21,6 +22,7 @@ "Angle", "Area", "ElectricalResistance", + "ElectricCurrent", "Energy", "Frequency", "Length", diff --git a/quantio/quantities.py b/quantio/quantities.py index 922d0a0..cb4e33e 100644 --- a/quantio/quantities.py +++ b/quantio/quantities.py @@ -206,6 +206,62 @@ def zero(cls) -> ElectricalResistance: # --- End of auto generated part. --- +class ElectricCurrent(_QuantityBase): + """The flow of charged particles moving through an electrical conductor or space.""" + + # --- This part is auto generated. Do not change manually. --- + + BASE_UNIT = "amperes" + + @property + def gigaamperes(self) -> float: + """The electriccurrent in gigaamperes.""" + return self._base_value / 10**9 + + @property + def megaamperes(self) -> float: + """The electriccurrent in megaamperes.""" + return self._base_value / 10**6 + + @property + def kiloamperes(self) -> float: + """The electriccurrent in kiloamperes.""" + return self._base_value / 10**3 + + @property + def amperes(self) -> float: + """The electriccurrent in amperes.""" + return self._base_value / 1 + + @property + def milliamperes(self) -> float: + """The electriccurrent in milliamperes.""" + return self._base_value / 10**-3 + + def __init__( + self, + _base_value: float = 0.0, + gigaamperes: float = 0.0, + megaamperes: float = 0.0, + kiloamperes: float = 0.0, + amperes: float = 0.0, + milliamperes: float = 0.0, + ) -> None: + self._base_value = _base_value + self._base_value += gigaamperes * 10**9 + self._base_value += megaamperes * 10**6 + self._base_value += kiloamperes * 10**3 + self._base_value += amperes * 1 + self._base_value += milliamperes * 10**-3 + + @classmethod + def zero(cls) -> ElectricCurrent: + """Create a ElectricCurrent with a value of zero.""" + return ElectricCurrent() + + # --- End of auto generated part. --- + + class Energy(_QuantityBase): """Energy describes the ability of an object to perform work."""