Skip to content

Commit

Permalink
Update to version 0.1.119 [skip-ci]
Browse files Browse the repository at this point in the history
Files changed:
M	setup.py
M	unitsnet_py/units/molality.py
  • Loading branch information
haimkastner committed Jul 25, 2024
1 parent 51c05e8 commit 4a6146a
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.54.0'
definition_version = '5.55.0'

setup_kwargs = {
'name': 'unitsnet-py',
'version': '0.1.118',
'version': '0.1.119',
'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/molality.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class MolalityUnits(Enum):
"""

MillimolePerKilogram = 'MillimolePerKilogram'
"""
"""


class MolalityDto:
"""
Expand Down Expand Up @@ -90,6 +95,8 @@ def __init__(self, value: float, from_unit: MolalityUnits = MolalityUnits.MolePe

self.__moles_per_gram = None

self.__millimoles_per_kilogram = None


def convert(self, unit: MolalityUnits) -> float:
return self.__convert_from_base(unit)
Expand Down Expand Up @@ -151,6 +158,9 @@ def __convert_from_base(self, from_unit: MolalityUnits) -> float:
if from_unit == MolalityUnits.MolePerGram:
return (value * 1e-3)

if from_unit == MolalityUnits.MillimolePerKilogram:
return ((value) / 0.001)

return None


Expand All @@ -162,6 +172,9 @@ def __convert_to_base(self, value: float, to_unit: MolalityUnits) -> float:
if to_unit == MolalityUnits.MolePerGram:
return (value / 1e-3)

if to_unit == MolalityUnits.MillimolePerKilogram:
return ((value) * 0.001)

return None


Expand Down Expand Up @@ -200,6 +213,21 @@ def from_moles_per_gram(moles_per_gram: float):
return Molality(moles_per_gram, MolalityUnits.MolePerGram)


@staticmethod
def from_millimoles_per_kilogram(millimoles_per_kilogram: float):
"""
Create a new instance of Molality from a value in millimoles_per_kilogram.
:param meters: The Molality value in millimoles_per_kilogram.
:type millimoles_per_kilogram: float
:return: A new instance of Molality.
:rtype: Molality
"""
return Molality(millimoles_per_kilogram, MolalityUnits.MillimolePerKilogram)


@property
def moles_per_kilogram(self) -> float:
"""
Expand All @@ -222,6 +250,17 @@ def moles_per_gram(self) -> float:
return self.__moles_per_gram


@property
def millimoles_per_kilogram(self) -> float:
"""
"""
if self.__millimoles_per_kilogram != None:
return self.__millimoles_per_kilogram
self.__millimoles_per_kilogram = self.__convert_from_base(MolalityUnits.MillimolePerKilogram)
return self.__millimoles_per_kilogram


def to_string(self, unit: MolalityUnits = MolalityUnits.MolePerKilogram, fractional_digits: int = None) -> str:
"""
Format the Molality to a string.
Expand All @@ -243,6 +282,9 @@ def to_string(self, unit: MolalityUnits = MolalityUnits.MolePerKilogram, fractio
if unit == MolalityUnits.MolePerGram:
return f"""{super()._truncate_fraction_digits(self.moles_per_gram, fractional_digits)} mol/g"""

if unit == MolalityUnits.MillimolePerKilogram:
return f"""{super()._truncate_fraction_digits(self.millimoles_per_kilogram, fractional_digits)} mmol/kg"""

return f'{self._value}'


Expand All @@ -258,4 +300,7 @@ def get_unit_abbreviation(self, unit_abbreviation: MolalityUnits = MolalityUnits

if unit_abbreviation == MolalityUnits.MolePerGram:
return """mol/g"""

if unit_abbreviation == MolalityUnits.MillimolePerKilogram:
return """mmol/kg"""

0 comments on commit 4a6146a

Please sign in to comment.