Skip to content

Commit

Permalink
Update to version 0.1.73 [skip-ci]
Browse files Browse the repository at this point in the history
Files changed:
M	pyproject.toml
M	setup.py
M	unitsnet_py/units/length.py
  • Loading branch information
haimkastner committed Dec 19, 2023
1 parent db1457b commit 32ef9fb
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "unitsnet_py"
version = "0.1.72"
version = "0.1.73"
description = "A better way to hold unit variables and easily convert to the destination unit"
repository = "https://github.com/haimkastner/unitsnet-py"
authors = ["Haim Kastner <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup_kwargs = {
'name': 'unitsnet-py',
'version': '0.1.72',
'version': '0.1.73',
'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/length.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ class LengthUnits(Enum):
"""

Kiloyard = 'kiloyard'
"""
"""

Kilofoot = 'kilofoot'
"""
Expand Down Expand Up @@ -303,6 +308,8 @@ def __init__(self, value: float, from_unit: LengthUnits = LengthUnits.Meter):

self.__gigameters = None

self.__kiloyards = None

self.__kilofeet = None

self.__kiloparsecs = None
Expand Down Expand Up @@ -428,6 +435,9 @@ def __convert_from_base(self, from_unit: LengthUnits) -> float:
if from_unit == LengthUnits.Gigameter:
return ((value) / 1000000000.0)

if from_unit == LengthUnits.Kiloyard:
return ((value / 0.9144) / 1000.0)

if from_unit == LengthUnits.Kilofoot:
return ((value / 0.3048) / 1000.0)

Expand Down Expand Up @@ -556,6 +566,9 @@ def __convert_to_base(self, value: float, to_unit: LengthUnits) -> float:
if to_unit == LengthUnits.Gigameter:
return ((value) * 1000000000.0)

if to_unit == LengthUnits.Kiloyard:
return ((value * 0.9144) * 1000.0)

if to_unit == LengthUnits.Kilofoot:
return ((value * 0.3048) * 1000.0)

Expand Down Expand Up @@ -1119,6 +1132,21 @@ def from_gigameters(gigameters: float):
return Length(gigameters, LengthUnits.Gigameter)


@staticmethod
def from_kiloyards(kiloyards: float):
"""
Create a new instance of Length from a value in kiloyards.
:param meters: The Length value in kiloyards.
:type kiloyards: float
:return: A new instance of Length.
:rtype: Length
"""
return Length(kiloyards, LengthUnits.Kiloyard)


@staticmethod
def from_kilofeet(kilofeet: float):
"""
Expand Down Expand Up @@ -1590,6 +1618,17 @@ def gigameters(self) -> float:
return self.__gigameters


@property
def kiloyards(self) -> float:
"""
"""
if self.__kiloyards != None:
return self.__kiloyards
self.__kiloyards = self.__convert_from_base(LengthUnits.Kiloyard)
return self.__kiloyards


@property
def kilofeet(self) -> float:
"""
Expand Down Expand Up @@ -1760,6 +1799,9 @@ def to_string(self, unit: LengthUnits = LengthUnits.Meter) -> str:
if unit == LengthUnits.Gigameter:
return f"""{self.gigameters} Gm"""

if unit == LengthUnits.Kiloyard:
return f"""{self.kiloyards} kyd"""

if unit == LengthUnits.Kilofoot:
return f"""{self.kilofeet} kft"""

Expand Down Expand Up @@ -1893,6 +1935,9 @@ def get_unit_abbreviation(self, unit_abbreviation: LengthUnits = LengthUnits.Met
if unit_abbreviation == LengthUnits.Gigameter:
return """Gm"""

if unit_abbreviation == LengthUnits.Kiloyard:
return """kyd"""

if unit_abbreviation == LengthUnits.Kilofoot:
return """kft"""

Expand Down

0 comments on commit 32ef9fb

Please sign in to comment.