openbrewing 0.0.1a0__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.
@@ -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,32 @@
1
+ # OpenBrewing
2
+
3
+ OpenBrewing is a work in progress. This experimental first release provides
4
+ dependency-free temperature and volume conversions for brewing tools. The API
5
+ may change in future releases.
6
+
7
+ ```sh
8
+ python -m pip install --pre openbrewing
9
+ ```
10
+
11
+ ```python
12
+ from openbrewing import celsius_to_fahrenheit, us_gallons_to_litres
13
+
14
+ celsius_to_fahrenheit(20) # 68.0
15
+ us_gallons_to_litres(5) # 18.92705892
16
+ ```
17
+
18
+ ## Functions
19
+
20
+ - `litres_to_us_gallons(value)`
21
+ - `us_gallons_to_litres(value)`
22
+ - `celsius_to_fahrenheit(value)`
23
+ - `fahrenheit_to_celsius(value)`
24
+
25
+ All functions accept finite `int` or `float` values (excluding booleans) and
26
+ return floats without rounding. Other types raise `TypeError`; non-finite or
27
+ unrepresentable inputs raise `ValueError`.
28
+ Gallons always mean **US liquid gallons** (one gallon is exactly
29
+ 3.785411784 litres). Signed values are supported; these helpers convert units,
30
+ not physical validity.
31
+
32
+ Licensing has not yet been selected. All rights reserved.
@@ -0,0 +1,19 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "openbrewing"
7
+ version = "0.0.1a0"
8
+ description = "Experimental OpenBrewing utilities for brewing temperature and volume conversions."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ keywords = ["brewing", "homebrewing", "units", "conversion"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Programming Language :: Python :: 3",
15
+ "Topic :: Scientific/Engineering",
16
+ ]
17
+
18
+ [tool.setuptools.packages.find]
19
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/openbrewing/__init__.py
4
+ src/openbrewing.egg-info/PKG-INFO
5
+ src/openbrewing.egg-info/SOURCES.txt
6
+ src/openbrewing.egg-info/dependency_links.txt
7
+ src/openbrewing.egg-info/top_level.txt
8
+ tests/test_units.py
@@ -0,0 +1 @@
1
+ openbrewing
@@ -0,0 +1,34 @@
1
+ import unittest
2
+
3
+ import openbrewing as units
4
+
5
+
6
+ class UnitConversionsTest(unittest.TestCase):
7
+ def test_temperature_reference_points(self):
8
+ self.assertEqual(units.celsius_to_fahrenheit(0), 32)
9
+ self.assertEqual(units.celsius_to_fahrenheit(100), 212)
10
+ self.assertEqual(units.fahrenheit_to_celsius(-40), -40)
11
+
12
+ def test_us_liquid_gallon_definition(self):
13
+ self.assertEqual(units.us_gallons_to_litres(1), 3.785411784)
14
+ self.assertEqual(units.litres_to_us_gallons(3.785411784), 1)
15
+ self.assertAlmostEqual(units.us_gallons_to_litres(5), 18.92705892)
16
+
17
+ def test_round_trip(self):
18
+ for value in [-40, 0, 20, 65.5, 100]:
19
+ self.assertAlmostEqual(units.fahrenheit_to_celsius(units.celsius_to_fahrenheit(value)), value)
20
+ self.assertAlmostEqual(units.litres_to_us_gallons(units.us_gallons_to_litres(value)), value)
21
+
22
+ def test_invalid_inputs(self):
23
+ for name in units.__all__:
24
+ convert = getattr(units, name)
25
+ for value in [None, True, "20", []]:
26
+ with self.assertRaises(TypeError):
27
+ convert(value)
28
+ for value in [float("nan"), float("inf"), float("-inf"), 10**1000]:
29
+ with self.assertRaises(ValueError):
30
+ convert(value)
31
+
32
+
33
+ if __name__ == "__main__":
34
+ unittest.main()