Skip to content

Commit

Permalink
Update to version 0.1.122 [skip-ci]
Browse files Browse the repository at this point in the history
Files changed:
M	setup.py
M	unitsnet_py/units/power.py
  • Loading branch information
haimkastner committed Aug 23, 2024
1 parent 02d227e commit dc92942
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@

# The UnitNet definition version that the current package is based on to generate units classes
# see
definition_version = '5.56.0'
definition_version = '5.57.0'

setup_kwargs = {
'name': 'unitsnet-py',
'version': '0.1.121',
'version': '0.1.122',
'license': 'MIT',
'keywords': 'conversion, units-of-measure, units, quantities, unit-converter, converter, unit, measure, measures, measurement, measurements',
'description': 'A better way to hold unit variables and easily convert to the destination unit',
Expand Down
45 changes: 45 additions & 0 deletions unitsnet_py/units/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ class PowerUnits(Enum):
"""

TonOfRefrigeration = 'TonOfRefrigeration'
"""
"""

Femtowatt = 'Femtowatt'
"""
Expand Down Expand Up @@ -222,6 +227,8 @@ def __init__(self, value: float, from_unit: PowerUnits = PowerUnits.Watt):

self.__joules_per_hour = None

self.__tons_of_refrigeration = None

self.__femtowatts = None

self.__picowatts = None
Expand Down Expand Up @@ -337,6 +344,9 @@ def __convert_from_base(self, from_unit: PowerUnits) -> float:
if from_unit == PowerUnits.JoulePerHour:
return (value * 3600)

if from_unit == PowerUnits.TonOfRefrigeration:
return (value / 3516.853)

if from_unit == PowerUnits.Femtowatt:
return ((value) / 1e-15)

Expand Down Expand Up @@ -420,6 +430,9 @@ def __convert_to_base(self, value: float, to_unit: PowerUnits) -> float:
if to_unit == PowerUnits.JoulePerHour:
return (value / 3600)

if to_unit == PowerUnits.TonOfRefrigeration:
return (value * 3516.853)

if to_unit == PowerUnits.Femtowatt:
return ((value) * 1e-15)

Expand Down Expand Up @@ -602,6 +615,21 @@ def from_joules_per_hour(joules_per_hour: float):
return Power(joules_per_hour, PowerUnits.JoulePerHour)


@staticmethod
def from_tons_of_refrigeration(tons_of_refrigeration: float):
"""
Create a new instance of Power from a value in tons_of_refrigeration.
:param meters: The Power value in tons_of_refrigeration.
:type tons_of_refrigeration: float
:return: A new instance of Power.
:rtype: Power
"""
return Power(tons_of_refrigeration, PowerUnits.TonOfRefrigeration)


@staticmethod
def from_femtowatts(femtowatts: float):
"""
Expand Down Expand Up @@ -960,6 +988,17 @@ def joules_per_hour(self) -> float:
return self.__joules_per_hour


@property
def tons_of_refrigeration(self) -> float:
"""
"""
if self.__tons_of_refrigeration != None:
return self.__tons_of_refrigeration
self.__tons_of_refrigeration = self.__convert_from_base(PowerUnits.TonOfRefrigeration)
return self.__tons_of_refrigeration


@property
def femtowatts(self) -> float:
"""
Expand Down Expand Up @@ -1197,6 +1236,9 @@ def to_string(self, unit: PowerUnits = PowerUnits.Watt, fractional_digits: int =
if unit == PowerUnits.JoulePerHour:
return f"""{super()._truncate_fraction_digits(self.joules_per_hour, fractional_digits)} J/h"""

if unit == PowerUnits.TonOfRefrigeration:
return f"""{super()._truncate_fraction_digits(self.tons_of_refrigeration, fractional_digits)} TR"""

if unit == PowerUnits.Femtowatt:
return f"""{super()._truncate_fraction_digits(self.femtowatts, fractional_digits)} fW"""

Expand Down Expand Up @@ -1285,6 +1327,9 @@ def get_unit_abbreviation(self, unit_abbreviation: PowerUnits = PowerUnits.Watt)
if unit_abbreviation == PowerUnits.JoulePerHour:
return """J/h"""

if unit_abbreviation == PowerUnits.TonOfRefrigeration:
return """TR"""

if unit_abbreviation == PowerUnits.Femtowatt:
return """fW"""

Expand Down

0 comments on commit dc92942

Please sign in to comment.