Skip to content

Commit

Permalink
feat: implement ElectricCurrent
Browse files Browse the repository at this point in the history
  • Loading branch information
unexcellent committed Nov 19, 2024
1 parent 0285238 commit 807c3e7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
7 changes: 7 additions & 0 deletions generate/generate_boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions quantio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Angle,
Area,
ElectricalResistance,
ElectricCurrent,
Energy,
Frequency,
Length,
Expand All @@ -21,6 +22,7 @@
"Angle",
"Area",
"ElectricalResistance",
"ElectricCurrent",
"Energy",
"Frequency",
"Length",
Expand Down
56 changes: 56 additions & 0 deletions quantio/quantities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down

0 comments on commit 807c3e7

Please sign in to comment.