UnitValues 0.1.4__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {unitvalues-0.1.4/src/UnitValues.egg-info → unitvalues-0.1.5}/PKG-INFO +3 -2
- {unitvalues-0.1.4 → unitvalues-0.1.5}/pyproject.toml +1 -1
- {unitvalues-0.1.4 → unitvalues-0.1.5/src/UnitValues.egg-info}/PKG-INFO +3 -2
- {unitvalues-0.1.4 → unitvalues-0.1.5}/src/unitvalue/units.py +17 -3
- {unitvalues-0.1.4 → unitvalues-0.1.5}/LICENSE +0 -0
- {unitvalues-0.1.4 → unitvalues-0.1.5}/README.md +0 -0
- {unitvalues-0.1.4 → unitvalues-0.1.5}/setup.cfg +0 -0
- {unitvalues-0.1.4 → unitvalues-0.1.5}/src/UnitValues.egg-info/SOURCES.txt +0 -0
- {unitvalues-0.1.4 → unitvalues-0.1.5}/src/UnitValues.egg-info/dependency_links.txt +0 -0
- {unitvalues-0.1.4 → unitvalues-0.1.5}/src/UnitValues.egg-info/requires.txt +0 -0
- {unitvalues-0.1.4 → unitvalues-0.1.5}/src/UnitValues.egg-info/top_level.txt +0 -0
- {unitvalues-0.1.4 → unitvalues-0.1.5}/src/unitvalue/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: UnitValues
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: A small package for using units in Python. Allows for computation with dimensioned qauntities and allows you to convert between different units. Do anything you would do with regular floats or integers in Python except now with units. Package is compatible with NumPy, SciPy + Pandas are in the works. I think you'll find this implementation more elegant then most other unit packages.
|
|
5
5
|
Author-email: Brody Howard <brody.howard@mail.utoronto.ca>
|
|
6
6
|
Project-URL: Homepage, https://github.com/BroRocket/unitvalue/
|
|
@@ -12,6 +12,7 @@ Requires-Python: >=3.10
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: numpy>=1.23.2
|
|
15
|
+
Dynamic: license-file
|
|
15
16
|
|
|
16
17
|
# UnitValues Package
|
|
17
18
|
## Introduction
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: UnitValues
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: A small package for using units in Python. Allows for computation with dimensioned qauntities and allows you to convert between different units. Do anything you would do with regular floats or integers in Python except now with units. Package is compatible with NumPy, SciPy + Pandas are in the works. I think you'll find this implementation more elegant then most other unit packages.
|
|
5
5
|
Author-email: Brody Howard <brody.howard@mail.utoronto.ca>
|
|
6
6
|
Project-URL: Homepage, https://github.com/BroRocket/unitvalue/
|
|
@@ -12,6 +12,7 @@ Requires-Python: >=3.10
|
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
14
|
Requires-Dist: numpy>=1.23.2
|
|
15
|
+
Dynamic: license-file
|
|
15
16
|
|
|
16
17
|
# UnitValues Package
|
|
17
18
|
## Introduction
|
|
@@ -612,6 +612,10 @@ class UnitValue:
|
|
|
612
612
|
if self.__unit != a.__unit:
|
|
613
613
|
raise TypeError(f"Cannot add unit {self.__unit} and unit {a.__unit}")
|
|
614
614
|
return UnitValue(self.__system, self.__dimension, self.__unit, self.value + a.value)
|
|
615
|
+
if self.__dimension == "TEMPERATURE" and self.__unit != "K" or a.__unit != "K":
|
|
616
|
+
self.convert_base_metric()
|
|
617
|
+
a.convert_base_metric()
|
|
618
|
+
return UnitValue(self.__system, self.__dimension, self.__unit, self.value + a.value - 273.15)
|
|
615
619
|
self.convert_base_metric()
|
|
616
620
|
a.convert_base_metric()
|
|
617
621
|
return UnitValue(self.__system, self.__dimension, self.__unit, self.value + a.value)
|
|
@@ -636,6 +640,10 @@ class UnitValue:
|
|
|
636
640
|
if self.__unit != s.__unit:
|
|
637
641
|
raise TypeError(f"Cannot subtract unit {self.__unit} and unit {s.__unit}")
|
|
638
642
|
return UnitValue(self.__system, self.__dimension, self.__unit, self.value - s.value)
|
|
643
|
+
if self.__dimension == "TEMPERATURE" and self.__unit != "K" or s.__unit != "K":
|
|
644
|
+
self.convert_base_metric()
|
|
645
|
+
s.convert_base_metric()
|
|
646
|
+
return UnitValue(self.__system, self.__dimension, self.__unit, self.value - s.value + 273.15)
|
|
639
647
|
self.convert_base_metric()
|
|
640
648
|
s.convert_base_metric()
|
|
641
649
|
return UnitValue(self.__system, self.__dimension, self.__unit, self.value - s.value)
|
|
@@ -926,10 +934,15 @@ class UnitValue:
|
|
|
926
934
|
|
|
927
935
|
if unit == self.unit: return self
|
|
928
936
|
|
|
937
|
+
other_system = "IMPERIAL" if self.__system == "METRIC" else "METRIC"
|
|
938
|
+
|
|
929
939
|
cache_key = (self.__system, self.__dimension, self.__unit, unit)
|
|
930
940
|
if cache_key in self._conversion_cache:
|
|
931
941
|
cached_value = self._conversion_cache[cache_key]
|
|
932
|
-
|
|
942
|
+
if unit in UnitValue.UNITS[self.__system][self.__dimension]:
|
|
943
|
+
return UnitValue(self.__system, self.__dimension, unit, cached_value)
|
|
944
|
+
else:
|
|
945
|
+
return UnitValue(other_system, self.__dimension, unit, cached_value)
|
|
933
946
|
|
|
934
947
|
if unit == "SCFM" or unit == "SLPM" or self.__unit == "SCFM" or self.__unit == "SLPM":
|
|
935
948
|
try:
|
|
@@ -937,7 +950,6 @@ class UnitValue:
|
|
|
937
950
|
except Exception as e:
|
|
938
951
|
raise ValueError(f"Was unable to convert flow rate to standard metric unit. You have ommited the required key word arguments (temperature and pressure) when converting from or to SLPM or SCFM. Occured Error: {e}")
|
|
939
952
|
|
|
940
|
-
other_system = "IMPERIAL" if self.__system == "METRIC" else "METRIC"
|
|
941
953
|
if self.__system is None:
|
|
942
954
|
raise Exception(f"Invalid unit {self.__unit}: this unit is not currently supported by the module")
|
|
943
955
|
else:
|
|
@@ -979,4 +991,6 @@ class UnitValue:
|
|
|
979
991
|
|
|
980
992
|
@property
|
|
981
993
|
def system(self) -> str:
|
|
982
|
-
return self.__system
|
|
994
|
+
return self.__system
|
|
995
|
+
|
|
996
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|