unitcorn 0.9.0__py3-none-any.whl

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.

Potentially problematic release.


This version of unitcorn might be problematic. Click here for more details.

Files changed (59) hide show
  1. unitcorn/__init__.py +110 -0
  2. unitcorn/airQuality/__init__.py +99 -0
  3. unitcorn/area/__init__.py +3 -0
  4. unitcorn/area/area.py +103 -0
  5. unitcorn/base/Decorators.py +72 -0
  6. unitcorn/base/Registry.py +75 -0
  7. unitcorn/base/SmartBases.py +26 -0
  8. unitcorn/base/_Algebra.py +205 -0
  9. unitcorn/base/_Measurement.py +1122 -0
  10. unitcorn/base/_ScalingMeasurement.py +398 -0
  11. unitcorn/base/_SmartFloat.py +1635 -0
  12. unitcorn/base/__init__.py +6 -0
  13. unitcorn/config/__init__.py +318 -0
  14. unitcorn/config/__main__.py +8 -0
  15. unitcorn/config/si.toml +53 -0
  16. unitcorn/config/template.toml +146 -0
  17. unitcorn/config/us.toml +53 -0
  18. unitcorn/defaults/WeatherFlow/__init__.py +176 -0
  19. unitcorn/defaults/__init__.py +1 -0
  20. unitcorn/derived/__init__.py +16 -0
  21. unitcorn/derived/density.py +26 -0
  22. unitcorn/derived/partsPer.py +96 -0
  23. unitcorn/derived/precipitation.py +96 -0
  24. unitcorn/derived/rate.py +80 -0
  25. unitcorn/derived/volume.py +122 -0
  26. unitcorn/derived/wind.py +54 -0
  27. unitcorn/digital/__init__.py +21 -0
  28. unitcorn/energy/__init__.py +4 -0
  29. unitcorn/energy/energy.py +120 -0
  30. unitcorn/energy/power.py +83 -0
  31. unitcorn/errors/Conversion.py +12 -0
  32. unitcorn/errors/Unit.py +4 -0
  33. unitcorn/errors/__init__.py +7 -0
  34. unitcorn/length/__init__.py +19 -0
  35. unitcorn/length/imperial.py +46 -0
  36. unitcorn/length/length.py +74 -0
  37. unitcorn/length/metric.py +56 -0
  38. unitcorn/mass/__init__.py +15 -0
  39. unitcorn/mass/imperial.py +47 -0
  40. unitcorn/mass/mass.py +57 -0
  41. unitcorn/mass/metric.py +47 -0
  42. unitcorn/others/__init__.py +338 -0
  43. unitcorn/others/light.py +51 -0
  44. unitcorn/pressure/__init__.py +3 -0
  45. unitcorn/pressure/pressure.py +189 -0
  46. unitcorn/py.typed +0 -0
  47. unitcorn/temperature/__init__.py +19 -0
  48. unitcorn/temperature/celsius.py +23 -0
  49. unitcorn/temperature/change.py +156 -0
  50. unitcorn/temperature/fahrenheit.py +24 -0
  51. unitcorn/temperature/kelvin.py +25 -0
  52. unitcorn/temperature/temperature.py +154 -0
  53. unitcorn/time_/__init__.py +1 -0
  54. unitcorn/time_/time.py +387 -0
  55. unitcorn/utils.py +399 -0
  56. unitcorn-0.9.0.dist-info/METADATA +536 -0
  57. unitcorn-0.9.0.dist-info/RECORD +59 -0
  58. unitcorn-0.9.0.dist-info/WHEEL +4 -0
  59. unitcorn-0.9.0.dist-info/licenses/LICENSE.txt +17 -0
@@ -0,0 +1,338 @@
1
+ from fractions import Fraction
2
+ from math import isnan, nan
3
+ from functools import cached_property
4
+ from typing import Optional, Tuple, Mapping
5
+
6
+ from ..base import Dimensionless, NonPlural, Measurement, Quantity, FiniteField, UnitType
7
+ from ..utils import getFrom
8
+ from . import light
9
+
10
+ Light = light.Light
11
+
12
+ __all__ = ['Light', 'Angle', 'Direction', 'Humidity', 'Voltage', 'LightningStrike', 'Probability', 'Coverage', 'Percentage']
13
+
14
+
15
+ @UnitType
16
+ class Percentage(Dimensionless, NonPlural):
17
+ _unit_symbol = '%'
18
+ _digit_budget = 3
19
+ _precision = 2
20
+
21
+ def __new__(cls, value, isPercentage: bool = None, *args, **kwargs):
22
+ """Build a percentage from a fraction or from a percent figure.
23
+
24
+ The class stores a fraction (0-1) and shows it as a percent. What the
25
+ caller's number *means* has to come from the caller:
26
+
27
+ - ``isPercentage=True``: ``value`` is on the 0-100 scale, so 0.1 is
28
+ 0.1 %. Use this for a source that reports percent.
29
+ - ``isPercentage=False``: ``value`` is already a fraction, so 0.1 is
30
+ 10 %. Use this for a source that reports 0-1.
31
+ - ``isPercentage=None`` (default): no source to ask, as with a literal
32
+ written in code. The scale is guessed from the magnitude: a value
33
+ above the upper limit, or an int other than 1, is read as percent.
34
+ A float at or below 1 is read as a fraction, so 0.1 is 10 % here.
35
+ Never rely on this for data from a sensor or an API.
36
+ """
37
+ if value is None:
38
+ value = nan
39
+ if isnan(value):
40
+ pass
41
+ elif isPercentage is None:
42
+ if value > cls._limits[1] or isinstance(value, int) and value != 1:
43
+ value /= 100
44
+ elif isPercentage:
45
+ value /= 100
46
+
47
+ return super(Percentage, cls).__new__(cls, value, *args, **kwargs)
48
+
49
+ def __init__(self, value, isPercentage: bool = None, *args, **kwargs):
50
+ # `isPercentage` is consumed by __new__; Measurement.__init__ has no use for it
51
+ super().__init__(value, *args, **kwargs)
52
+
53
+ def __format__(self, format_spec: str, **extras) -> str:
54
+ return super().__format__(format_spec, **extras)
55
+
56
+ def __int__(self) -> int:
57
+ return int(float(self)*100)
58
+
59
+ @cached_property
60
+ def valuePrecision(self) -> int:
61
+ value = super().valuePrecision
62
+ return value + 2
63
+
64
+ # @property
65
+ # def defaultFormatParams(self):
66
+ # sup = super().defaultFormatParams
67
+ # sup['type'] = '%'
68
+ # return sup
69
+
70
+ @classmethod
71
+ def fromFloat(cls, value: float) -> 'Percentage':
72
+ return cls(value, isPercentage=False)
73
+
74
+ @classmethod
75
+ def fromFraction(cls, value: float) -> 'Percentage':
76
+ """``value`` is on the 0-1 scale: 0.1 is 10 %."""
77
+ return cls(value, isPercentage=False)
78
+
79
+ @classmethod
80
+ def fromPercent(cls, value: float) -> 'Percentage':
81
+ """``value`` is on the 0-100 scale: 0.1 is 0.1 %."""
82
+ return cls(value, isPercentage=True)
83
+
84
+ @property
85
+ def formatValue(self) -> float:
86
+ return float(self)*100
87
+
88
+
89
+ class Humidity(Percentage, limits=(0.0, 1.0)):
90
+ _unit_symbol = '%'
91
+ _id = '%h'
92
+
93
+
94
+ class Probability(Percentage, limits=(0.0, 1.0)):
95
+ _unit_symbol = '%'
96
+ _id = '%p'
97
+ _fraction: Optional[Fraction]
98
+ _denominatorLimit: int = 10
99
+
100
+ @property
101
+ def fraction(self) -> Fraction:
102
+ if (fraction := getattr(self, '_fraction', None)) is None:
103
+ self._fraction = Fraction(self).limit_denominator(self._denominatorLimit)
104
+ return fraction
105
+
106
+
107
+ class Coverage(Percentage, limits=(0.0, 1.0)):
108
+ _unit_symbol = '%'
109
+ _id = '%c'
110
+
111
+
112
+ class BatteryPercentage(Percentage, limits=(0.0, 1.0)):
113
+ _voltageLimits: Optional[Tuple[float, float]]
114
+ _unit_symbol = '%'
115
+ _id = '%bat'
116
+
117
+ def __init__(self, value, voltageLimits: Optional[Tuple[float, float]] = None, *args, **kwargs):
118
+ self._voltageLimits = voltageLimits
119
+ super(BatteryPercentage, self).__init__(value, *args, **kwargs)
120
+
121
+
122
+ @UnitType
123
+ class Angle(Dimensionless):
124
+ _precision = 0
125
+ _unit_symbol = '°'
126
+ _shorten = True
127
+ _id = '°'
128
+
129
+
130
+ class Direction(Angle, FiniteField, limits=(0, 360)):
131
+ _cardinal = True
132
+ _unit_symbol = '°'
133
+ _id = '°d'
134
+ _digit_budget = 3
135
+
136
+ @cached_property
137
+ def cardinal(self) -> 'Cardinal':
138
+ return Cardinal(self)
139
+
140
+ @property
141
+ def angle(self) -> Angle:
142
+ return Angle(self)
143
+
144
+ @property
145
+ def decoratedInt(self) -> str:
146
+ # `forceUnit=`/`asInt=` were never parameters of _string - this raised
147
+ # TypeError for anyone who called it. Expressed against the real
148
+ # signature: no unit, integer precision, decorator kept.
149
+ return super()._string(unit=False, formatSpec='.0f')
150
+
151
+ @property
152
+ def defaultFormatParams(self):
153
+ return {
154
+ 'cardinal': self._cardinal if self._cardinal else False,
155
+ 'show_cardinal': self._cardinal,
156
+ **super().defaultFormatParams
157
+ }
158
+
159
+ @property
160
+ def properties(self):
161
+ measurement = super().properties
162
+ return {'cardinal': self.cardinal, 'show_cardinal': self._cardinal, **measurement, }
163
+
164
+ def __repr_value__(self) -> str:
165
+ return f'{self: cardinal: False}'
166
+
167
+ def __format_value__(self, params: Mapping) -> str:
168
+ show_cardinal = getFrom(('show_cardinal', 'cardinal'), *params.maps, default=self._cardinal, expectedType=(bool, str))
169
+ if show_cardinal:
170
+ return self.cardinal.__format_value__(params)
171
+ return super().__format_value__(params)
172
+
173
+ def __format_template__(self, params: Mapping) -> str:
174
+ template = super().__format_template__(params)
175
+ show_cardinal = getFrom(('show_cardinal', 'cardinal'), *params.maps, default=self._cardinal, expectedType=(bool, str))
176
+ if show_cardinal and '{cardinal}' not in template:
177
+ template = template.replace('{unit_symbol}', '')
178
+ return template
179
+
180
+
181
+ class Cardinal:
182
+ """A compass heading, rendered at whatever detail the budget allows.
183
+
184
+ `digit_budget` counts **compass components**, and the atom it counts
185
+ depends on the form: a letter when abbreviated, a word when spelled out.
186
+ So the same budget means the same amount of information either way.
187
+
188
+ budget | shorten=True | shorten=False
189
+ -------|--------------|--------------------
190
+ 1 | N | North
191
+ 2 | NE | North East
192
+ 3 | SSW | South South West
193
+
194
+ The word forms are *derived* from the abbreviations rather than kept in
195
+ a parallel list. A hardcoded list drifts out of alignment: the previous
196
+ one spelled the 2-component 'NE' as the single word 'Northeast' and the
197
+ 3-component 'SSW' as the 2-word 'South Southwest', so word count never
198
+ matched the budget and the two forms disagreed about how much detail
199
+ they were showing.
200
+ """
201
+ __slots__ = '__direction'
202
+ __dirsAbbrv = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']
203
+ __components = {'N': 'North', 'E': 'East', 'S': 'South', 'W': 'West'}
204
+ __direction: Direction
205
+ direction: Direction
206
+
207
+ def __init__(self, direction: Direction):
208
+ self.__direction = direction
209
+
210
+ def __str__(self):
211
+ if self.shorten:
212
+ return self.abbrivated
213
+ else:
214
+ return self.spelled
215
+
216
+ def __format_value__(self, params: Mapping) -> str:
217
+ # Two independent axes:
218
+ # `shorten` picks the FORM - letters vs words
219
+ # digit_budget picks the DETAIL - how many compass components
220
+ # Both forms read the same budget through the same index ladder, so
221
+ # they always name the same heading and differ only in spelling.
222
+ shorten = getFrom('shorten', *getattr(params, 'maps', (params,)),
223
+ default=self.shorten, expectedType=(bool, str))
224
+ if shorten:
225
+ return self.abbrivated
226
+ return self.spelled
227
+
228
+ def __repr__(self):
229
+ return f'Cardinal({self!s} {self.direction: cardinal: False})'
230
+
231
+ @property
232
+ def direction(self) -> Direction:
233
+ return self.__direction
234
+
235
+ @property
236
+ def __quarterIndex(self):
237
+ return int(round(self.direction/90)%4)*4
238
+
239
+ @property
240
+ def __shortIndex(self):
241
+ return int(round(self.direction/45)%8)*2
242
+
243
+ @property
244
+ def __longIndex(self):
245
+ return int(round(self.direction/22.5)%16)
246
+
247
+ def _indexFor(self, components: int) -> int:
248
+ """The compass index at a given number of components.
249
+
250
+ One index ladder, shared by both forms, so letters and words always
251
+ name the same heading at the same budget.
252
+ """
253
+ if components <= 1:
254
+ return self.__quarterIndex # 4-point: N E S W
255
+ if components == 2:
256
+ return self.__shortIndex # 8-point: NE SE SW NW
257
+ return self.__longIndex # 16-point: NNE ESE SSW WNW
258
+
259
+ def letters(self, components: int) -> str:
260
+ return self.__dirsAbbrv[self._indexFor(components)]
261
+
262
+ def words(self, components: int) -> str:
263
+ """Spelled out, one word per component - 'SSW' -> 'South South West'."""
264
+ return ' '.join(self.__components[c] for c in self.letters(components))
265
+
266
+ @property
267
+ def oneLetter(self):
268
+ """The 4-point compass: N, E, S, W. Always exactly one character."""
269
+ return self.letters(1)
270
+
271
+ @property
272
+ def twoLetter(self):
273
+ return self.letters(2)
274
+
275
+ @property
276
+ def threeLetter(self):
277
+ return self.letters(3)
278
+
279
+ @property
280
+ def abbrivated(self):
281
+ return self.letters(self.direction.digit_budget)
282
+
283
+ @property
284
+ def spelled(self):
285
+ return self.words(self.direction.digit_budget)
286
+
287
+ @property
288
+ def full(self):
289
+ """Every component spelled out, regardless of budget."""
290
+ return self.words(3)
291
+
292
+ @property
293
+ def shorten(self):
294
+ return self.direction.shorten
295
+
296
+ @shorten.setter
297
+ def shorten(self, value: bool):
298
+ self.direction.shorten = value
299
+
300
+
301
+ class Voltage(Measurement):
302
+ _digit_budget = 3
303
+ _precision = 2
304
+ _unit = 'v'
305
+
306
+
307
+ class LightningStrike(Quantity, altName='Strike'):
308
+ ...
309
+
310
+
311
+ # class OzoneThickness(Millimeter, altName='Dobson'):
312
+ # _unit = 'DU'
313
+ # _precision = 0
314
+ #
315
+ # @property
316
+ # def ppm(self) -> 'Ozone':
317
+ # return Ozone(float(self) * 2.69e-5)
318
+ #
319
+ #
320
+ # class Ozone(PartPerMillion, altName='O3'):
321
+ # _unit = 'ppm'
322
+ # _precision = 0
323
+ #
324
+ # @property
325
+ # def du(self) -> 'OzoneThickness':
326
+ # return OzoneThickness(float(self) / 2.69e-5)
327
+
328
+
329
+
330
+
331
+ Percentage.Humidity = Humidity
332
+ Percentage.Probability = Probability
333
+ Percentage.Coverage = Coverage
334
+ Percentage.BatteryPercentage = BatteryPercentage
335
+
336
+ Angle.Direction = Direction
337
+ Direction.Cardinal = Cardinal
338
+ Angle.Cardinal = Cardinal
@@ -0,0 +1,51 @@
1
+ from ..base.Decorators import UnitType
2
+ from ..base import Index, Measurement
3
+
4
+ __all__ = ['Light']
5
+
6
+
7
+ @UnitType
8
+ class Light(Measurement):
9
+ _dimension = 'J'
10
+ UVI: type
11
+ Illuminance: type
12
+ Irradiance: type
13
+ RadiantFlux: type
14
+ Lux: type
15
+ Brightness: type
16
+
17
+
18
+ class UVI(Index, Light, alias='UVI Index'):
19
+ _id = 'uvi'
20
+ _digit_budget = 2
21
+
22
+
23
+ class Irradiance(Light):
24
+ _unit = 'W/m²'
25
+
26
+ @property
27
+ def lux(self) -> 'Illuminance':
28
+ """Peter Michael, September 20, 2019, "A Conversion Guide: Solar Irradiance and Lux Illuminance ", IEEE Dataport, doi: https://dx.doi.org/10.21227/mxr7-p365."""
29
+ return Illuminance(float(self)*120)
30
+
31
+
32
+ class Illuminance(Light):
33
+ _unit = 'lux'
34
+
35
+ @property
36
+ def wpm2(self) -> Irradiance:
37
+ """Peter Michael, September 20, 2019, "A Conversion Guide: Solar Irradiance and Lux Illuminance ", IEEE Dataport, doi: https://dx.doi.org/10.21227/mxr7-p365."""
38
+ return Irradiance(float(self)/120)
39
+
40
+
41
+ RadiantFlux = Irradiance
42
+ Lux = Illuminance
43
+ Brightness = Illuminance
44
+
45
+ Light.UVI = UVI
46
+ Light.Illuminance = Illuminance
47
+ Light.Irradiance = Irradiance
48
+
49
+ Light.RadiantFlux = Irradiance
50
+ Light.Lux = Illuminance
51
+ Light.Brightness = Illuminance
@@ -0,0 +1,3 @@
1
+ from .pressure import *
2
+
3
+ __all__ = ['Pressure']
@@ -0,0 +1,189 @@
1
+ from enum import Enum
2
+
3
+ from ..base.Decorators import UnitType, Tiny, Small, Medium, Large, Huge, Synonym
4
+ from ..base import both, Scale, ScalingMeasurement, SystemVariant
5
+
6
+
7
+ @UnitType
8
+ class Pressure(ScalingMeasurement, baseUnit='Pascal', system=both):
9
+ Pascal: type
10
+ Decapascal: type
11
+ Hectopascal: type
12
+ Kilopascal: type
13
+ Gigapascal: type
14
+ Atmosphere: type
15
+ TechnicalAtmosphere: type
16
+ PoundsPerSquareInch: type
17
+ MillimeterOfMercury: type
18
+ InchOfMercury: type
19
+ Bar: type
20
+ Kilopascal: type
21
+ Millibar: type
22
+ PoundsPerSquareInch: type
23
+
24
+ class Trend(Enum):
25
+ Falling = -1
26
+ Steady = 0
27
+ Rising = 1
28
+
29
+ class _Scale(Scale):
30
+ Pascal = 1
31
+ Decapascal = 10
32
+ Hectopascal = 10
33
+ Kilopascal = 10
34
+ Megapascal = 1000
35
+ Gigapascal = 1000
36
+ Base = 'Pascal'
37
+ Bar = 1000.
38
+ Atmosphere = 101325.
39
+ TechnicalAtmosphere = 98066.5
40
+ PoundsPerSquareInch = 6894.757293168
41
+ MillimeterOfMercury = 1 / 0.00750062
42
+ InchOfMercury = 1 / 0.00029530
43
+
44
+ @property
45
+ def pascal(self):
46
+ return Pascal(self)
47
+
48
+ @property
49
+ def decapascal(self):
50
+ return Decapascal(self)
51
+
52
+ @property
53
+ def hectopascal(self):
54
+ return Hectopascal(self)
55
+
56
+ @property
57
+ def kilopascal(self):
58
+ return Kilopascal(self)
59
+
60
+ @property
61
+ def megapascal(self):
62
+ return Megapascal(self)
63
+
64
+ @property
65
+ def gigapascal(self):
66
+ return Gigapascal(self)
67
+
68
+ @property
69
+ def bar(self):
70
+ return Bar(self)
71
+
72
+ @property
73
+ def millimeterOfMercury(self):
74
+ return MillimeterOfMercury(self)
75
+
76
+ @property
77
+ def inchOfMercury(self):
78
+ return InchOfMercury(self)
79
+
80
+ @property
81
+ def atmosphere(self):
82
+ return Atmosphere(self)
83
+
84
+ @property
85
+ def technicalAtmosphere(self):
86
+ return TechnicalAtmosphere(self)
87
+
88
+ @property
89
+ def poundsPerSquareInch(self):
90
+ return PoundsPerSquareInch(self)
91
+
92
+ @property
93
+ def millibar(self):
94
+ return Millibar(self)
95
+
96
+
97
+ @Tiny
98
+ class Pascal(Pressure):
99
+ _unit = 'Pa'
100
+
101
+
102
+ @Small
103
+ class Decapascal(Pressure):
104
+ _unit = 'daPa'
105
+
106
+
107
+ @Medium
108
+ class Hectopascal(Pressure):
109
+ _unit = 'hPa'
110
+ # The compact default - drop padding zeros - is right for inches and
111
+ # wrong here: hPa is conventionally shown as whole numbers. 1013.2 is a
112
+ # reading; on a dial face it reads 1000, 1010, 1020. So the convention
113
+ # is declared here, on the unit that has it, rather than in config.
114
+ _compact_format = {'precision': 0}
115
+
116
+
117
+ @Large
118
+ class Kilopascal(Pressure):
119
+ _unit = 'kPa'
120
+
121
+
122
+ @Huge
123
+ class Megapascal(Pressure):
124
+ _unit = 'MPa'
125
+
126
+
127
+ @Huge
128
+ class Gigapascal(Pressure):
129
+ _unit = 'GPa'
130
+
131
+
132
+ class Bar(Pascal):
133
+ _unit = 'bar'
134
+
135
+
136
+ class MillimeterOfMercury(Pascal):
137
+ _unit = "mmHg"
138
+
139
+
140
+ class InchOfMercury(Pascal):
141
+ _unit = 'inHg'
142
+
143
+
144
+ class Atmosphere(Pascal):
145
+ _unit = 'atm'
146
+
147
+
148
+ class TechnicalAtmosphere(Pascal):
149
+ _unit = 'at'
150
+
151
+
152
+ class PoundsPerSquareInch(Pascal):
153
+ _unit = 'psi'
154
+
155
+
156
+ @Synonym
157
+ class Millibar(Hectopascal):
158
+ _unit = 'mBar'
159
+ _digit_budget = 4
160
+ # No _compact_format here: Millibar is a @Synonym of Hectopascal, so it
161
+ # inherits the whole-number dial convention along with everything else
162
+ # Hectopascal declares. Re-stating it would be a second place to keep in
163
+ # step for no gain.
164
+
165
+
166
+ Pressure.Pascal = Pascal
167
+ Pressure.Decapascal = Decapascal
168
+ Pressure.Hectopascal = Hectopascal
169
+ Pressure.Kilopascal = Kilopascal
170
+ Pressure.Gigapascal = Gigapascal
171
+ Pressure.Atmosphere = Atmosphere
172
+ Pressure.Bar = Bar
173
+ Pressure.Millibar = Millibar
174
+ Pressure.InchOfMercury = InchOfMercury
175
+ Pressure.MillimeterOfMercury = MillimeterOfMercury
176
+ Pressure.Atmosphere = Atmosphere
177
+ Pressure.TechnicalAtmosphere = TechnicalAtmosphere
178
+ Pressure.PoundsPerSquareInch = PoundsPerSquareInch
179
+ Pressure.mbar = Pressure.mBar = Pressure.millibar
180
+ Pressure.psi = Pressure.poundsPerSquareInch
181
+ Pressure.at = Pressure.technicalAtmosphere
182
+ Pressure.atm = Pressure.atmosphere
183
+ Pressure.inHg = Pressure.inchOfMercury
184
+ Pressure.mmHg = Pressure.millimeterOfMercury
185
+ Pressure.gPa = Pressure.gigapascal
186
+ Pressure.kPa = Pressure.kilopascal
187
+ Pressure.hPa = Pressure.hectopascal
188
+ Pressure.p = Pressure.pascal
189
+ Pressure.dPa = Pressure.decapascal
unitcorn/py.typed ADDED
File without changes
@@ -0,0 +1,19 @@
1
+ from .temperature import Temperature
2
+ from .fahrenheit import Fahrenheit
3
+ from .celsius import Celsius
4
+ from .kelvin import Kelvin
5
+ from .change import TemperatureChange, CelsiusChange, FahrenheitChange, KelvinChange, summingReadings
6
+
7
+ __all__ = ['Temperature', 'TemperatureChange', 'CelsiusChange', 'FahrenheitChange', 'KelvinChange', 'summingReadings']
8
+
9
+ Temperature.Fahrenheit = Fahrenheit
10
+ Temperature.Celsius = Celsius
11
+ Temperature.Kelvin = Kelvin
12
+
13
+ Temperature.Change = TemperatureChange
14
+ Temperature.CelsiusChange = CelsiusChange
15
+ Temperature.FahrenheitChange = FahrenheitChange
16
+ Temperature.KelvinChange = KelvinChange
17
+ Celsius.change = CelsiusChange
18
+ Fahrenheit.change = FahrenheitChange
19
+ Kelvin.change = KelvinChange
@@ -0,0 +1,23 @@
1
+ from math import inf
2
+
3
+ from ..base import metric
4
+ from .temperature import Temperature
5
+
6
+ __all__ = ['Celsius']
7
+
8
+
9
+ class Celsius(Temperature, system=metric):
10
+ _limits = (-273.15, inf)
11
+ _unit = 'c'
12
+
13
+ def _celsius(self, delta: bool = False):
14
+ return self
15
+
16
+ def _fahrenheit(self, delta: bool = False):
17
+ if delta:
18
+ return float(self)*1.8
19
+ else:
20
+ return (float(self)*1.8) + 32
21
+
22
+ def _kelvin(self):
23
+ return float(self) + 273.15