openbrewing 0.0.1a0__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.
openbrewing/__init__.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Experimental, dependency-free brewing unit conversions."""
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
|
|
5
|
+
__version__ = "0.0.1a0"
|
|
6
|
+
__all__ = [
|
|
7
|
+
"litres_to_us_gallons",
|
|
8
|
+
"us_gallons_to_litres",
|
|
9
|
+
"celsius_to_fahrenheit",
|
|
10
|
+
"fahrenheit_to_celsius",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
_LITRES_PER_US_GALLON = 3.785411784
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _finite_number(value: float) -> float:
|
|
17
|
+
if isinstance(value, bool) or not isinstance(value, (int, float)):
|
|
18
|
+
raise TypeError("value must be an int or float")
|
|
19
|
+
try:
|
|
20
|
+
converted = float(value)
|
|
21
|
+
except OverflowError:
|
|
22
|
+
raise ValueError("value must be finite") from None
|
|
23
|
+
if not math.isfinite(converted):
|
|
24
|
+
raise ValueError("value must be finite")
|
|
25
|
+
return converted
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def litres_to_us_gallons(value: float) -> float:
|
|
29
|
+
"""Convert litres to US liquid gallons, without rounding."""
|
|
30
|
+
return _finite_number(value) / _LITRES_PER_US_GALLON
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def us_gallons_to_litres(value: float) -> float:
|
|
34
|
+
"""Convert US liquid gallons to litres, without rounding."""
|
|
35
|
+
return _finite_number(value) * _LITRES_PER_US_GALLON
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def celsius_to_fahrenheit(value: float) -> float:
|
|
39
|
+
"""Convert degrees Celsius to degrees Fahrenheit, without rounding."""
|
|
40
|
+
return _finite_number(value) * 9 / 5 + 32
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def fahrenheit_to_celsius(value: float) -> float:
|
|
44
|
+
"""Convert degrees Fahrenheit to degrees Celsius, without rounding."""
|
|
45
|
+
return (_finite_number(value) - 32) * 5 / 9
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openbrewing
|
|
3
|
+
Version: 0.0.1a0
|
|
4
|
+
Summary: Experimental OpenBrewing utilities for brewing temperature and volume conversions.
|
|
5
|
+
Keywords: brewing,homebrewing,units,conversion
|
|
6
|
+
Classifier: Development Status :: 3 - Alpha
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Topic :: Scientific/Engineering
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
|
|
12
|
+
# OpenBrewing
|
|
13
|
+
|
|
14
|
+
OpenBrewing is a work in progress. This experimental first release provides
|
|
15
|
+
dependency-free temperature and volume conversions for brewing tools. The API
|
|
16
|
+
may change in future releases.
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
python -m pip install --pre openbrewing
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from openbrewing import celsius_to_fahrenheit, us_gallons_to_litres
|
|
24
|
+
|
|
25
|
+
celsius_to_fahrenheit(20) # 68.0
|
|
26
|
+
us_gallons_to_litres(5) # 18.92705892
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Functions
|
|
30
|
+
|
|
31
|
+
- `litres_to_us_gallons(value)`
|
|
32
|
+
- `us_gallons_to_litres(value)`
|
|
33
|
+
- `celsius_to_fahrenheit(value)`
|
|
34
|
+
- `fahrenheit_to_celsius(value)`
|
|
35
|
+
|
|
36
|
+
All functions accept finite `int` or `float` values (excluding booleans) and
|
|
37
|
+
return floats without rounding. Other types raise `TypeError`; non-finite or
|
|
38
|
+
unrepresentable inputs raise `ValueError`.
|
|
39
|
+
Gallons always mean **US liquid gallons** (one gallon is exactly
|
|
40
|
+
3.785411784 litres). Signed values are supported; these helpers convert units,
|
|
41
|
+
not physical validity.
|
|
42
|
+
|
|
43
|
+
Licensing has not yet been selected. All rights reserved.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
openbrewing/__init__.py,sha256=AzFhQw3ZSRwVxRa_QcHrehvREHZff-rcXa9AJQzP7_U,1366
|
|
2
|
+
openbrewing-0.0.1a0.dist-info/METADATA,sha256=zqXbiLS43-l1GVXVFpFyYT5vVclw7G9AFhdJaMhunsU,1418
|
|
3
|
+
openbrewing-0.0.1a0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
4
|
+
openbrewing-0.0.1a0.dist-info/top_level.txt,sha256=_CEKUR0SVYUi-YqFLZ9oGAusvKsbT2r2HTmfPtXajs4,12
|
|
5
|
+
openbrewing-0.0.1a0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
openbrewing
|