Skip to content

Commit

Permalink
Grind (#75)
Browse files Browse the repository at this point in the history
* feat : grind parameter added

* feat : --grind argument added

* fix : verified_test.py updated

* fix : tests updated

* fix : MESSAGE_TEMPLATE updated

* fix : print_result function updated

* fix : tests updated

* doc : CHANGELOG.md updated

* doc : README.md updated

* doc : CHANGELOG.md updated

* doc : white-space bug in README.md fixed

* doc : README.md reference section updated
  • Loading branch information
sepandhaghighi authored Jan 6, 2025
1 parent 80ba0d5 commit a90e70e
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1. Troy Pounds (`t lb`)
- 1 new coffee unit
1. Troy Pounds (`t lb`)
- `--grind` argument
### Changed
- `README.md` updated
## [1.1] - 2025-01-02
### Added
- 5 new water units
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Water: 250 g

Ratio: 3/50

Grind: 550 um

Info: V60 method
```

Expand All @@ -109,7 +111,7 @@ Info: V60 method
ℹ️ You can run `mycoffee --water-units-list` to view the supported water units

```shell
> mycoffee --method=chemex --water=20 --cups=3 --coffee-ratio=2 --water-ratio=37 --coffee-unit=g --water-unit=g
> mycoffee --method=chemex --water=20 --cups=3 --coffee-ratio=2 --water-ratio=37 --coffee-unit=g --water-unit=g --grind=750

__ __ _ _ ___ _____ ____ ____ ____ ____
( \/ )( \/ ) / __)( _ )( ___)( ___)( ___)( ___)
Expand All @@ -128,6 +130,8 @@ Water: 20 g

Ratio: 2/37

Grind: 750 um

Info: Chemex method
```

Expand Down Expand Up @@ -161,6 +165,12 @@ Info: Chemex method
<td align="center">Integer</td>
<td align="center"><code>1</code></td>
</tr>
<tr>
<td align="center"><code>--grind</code></td>
<td align="center">Grind size (um)</td>
<td align="center">Integer</td>
<td align="center"><code>700</code></td>
</tr>
<tr>
<td align="center"><code>--coffee-ratio</code></td>
<td align="center">Coefficient for the coffee component in the ratio</td>
Expand Down Expand Up @@ -235,6 +245,7 @@ Just fill an issue and describe it. We'll check it ASAP!
<blockquote>22- <a href="https://www.calculator.net/weight-calculator.html">Weight Calculator</a></blockquote>
<blockquote>23- <a href="https://www.inchcalculator.com/convert/volume/">Volume Conversion Calculator - Inch Calculator</a></blockquote>
<blockquote>24- <a href="https://www.metric-conversions.org/">Metric Conversion Charts and Calculators</a></blockquote>
<blockquote>25- <a href="https://honestcoffeeguide.com/coffee-grind-size-chart">Coffee grind size chart</a></blockquote>

## Show Your Support
Expand Down
1 change: 1 addition & 0 deletions mycoffee/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def main():
parser.add_argument('--water-ratio', help='coefficient for the water component in the ratio', type=float)
parser.add_argument('--water', help='amount of water in each cup (gr)', type=float)
parser.add_argument('--cups', help='number of cups', type=int)
parser.add_argument('--grind', help='grind size (um)', type=int)
parser.add_argument(
'--digits',
help='number of digits up to which the result is rounded',
Expand Down
3 changes: 2 additions & 1 deletion mycoffee/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def print_result(params):
params["water_ratio"],
params["info"],
params["coffee_unit"],
params["water_unit"]))
params["water_unit"],
params["grind"]))
if not check_ratio_limits(params):
ratio_lower_limit = METHODS_MAP[method]["ratio_lower_limit"]
ratio_upper_limit = METHODS_MAP[method]["ratio_upper_limit"]
Expand Down
22 changes: 22 additions & 0 deletions mycoffee/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
Ratio: {4}/{5}
Grind: {9} um
Info: {6}
"""

Expand All @@ -31,6 +33,7 @@
"water": 0,
"coffee_ratio": 1,
"water_ratio": 1,
"grind": 700,
"coffee_unit": "g",
"water_unit": "g",
"digits": 3,
Expand All @@ -42,12 +45,14 @@
"custom": {
"coffee_ratio": 1,
"water_ratio": 17,
"grind": 700,
"water": 240,
"info": "Custom brewing method"
},
"v60": {
"coffee_ratio": 3,
"water_ratio": 50,
"grind": 550,
"ratio_lower_limit": Fraction(1, 18),
"ratio_upper_limit": Fraction(1, 14),
"water": 250,
Expand All @@ -56,6 +61,7 @@
"espresso": {
"coffee_ratio": 1,
"water_ratio": 2,
"grind": 280,
"ratio_lower_limit": Fraction(2, 5),
"ratio_upper_limit": Fraction(2, 3),
"water": 36,
Expand All @@ -64,6 +70,7 @@
"ristretto": {
"coffee_ratio": 1,
"water_ratio": 1,
"grind": 280,
"ratio_lower_limit": Fraction(2, 3),
"ratio_upper_limit": Fraction(1, 1),
"water": 18,
Expand All @@ -72,6 +79,7 @@
"lungo": {
"coffee_ratio": 1,
"water_ratio": 4,
"grind": 280,
"ratio_lower_limit": Fraction(1, 4),
"ratio_upper_limit": Fraction(2, 5),
"water": 72,
Expand All @@ -80,6 +88,7 @@
"chemex": {
"coffee_ratio": 1,
"water_ratio": 15,
"grind": 670,
"ratio_lower_limit": Fraction(1, 21),
"ratio_upper_limit": Fraction(1, 10),
"water": 240,
Expand All @@ -88,6 +97,7 @@
"french-press": {
"coffee_ratio": 1,
"water_ratio": 15,
"grind": 995,
"ratio_lower_limit": Fraction(1, 18),
"ratio_upper_limit": Fraction(1, 12),
"water": 120,
Expand All @@ -96,6 +106,7 @@
"siphon": {
"coffee_ratio": 1,
"water_ratio": 15,
"grind": 588,
"ratio_lower_limit": Fraction(1, 16),
"ratio_upper_limit": Fraction(1, 12),
"water": 240,
Expand All @@ -104,6 +115,7 @@
"pour-over": {
"coffee_ratio": 1,
"water_ratio": 15,
"grind": 670,
"ratio_lower_limit": Fraction(1, 16),
"ratio_upper_limit": Fraction(1, 14),
"water": 240,
Expand All @@ -112,6 +124,7 @@
"auto-drip": {
"coffee_ratio": 1,
"water_ratio": 16,
"grind": 600,
"ratio_lower_limit": Fraction(1, 17),
"ratio_upper_limit": Fraction(1, 14),
"water": 128,
Expand All @@ -120,6 +133,7 @@
"cold-brew": {
"coffee_ratio": 1,
"water_ratio": 11,
"grind": 1100,
"ratio_lower_limit": Fraction(1, 15),
"ratio_upper_limit": Fraction(1, 8),
"water": 242,
Expand All @@ -128,6 +142,7 @@
"cold-brew-conc": {
"coffee_ratio": 1,
"water_ratio": 5,
"grind": 1100,
"ratio_lower_limit": Fraction(1, 6),
"ratio_upper_limit": Fraction(1, 4),
"water": 120,
Expand All @@ -136,6 +151,7 @@
"moka-pot": {
"coffee_ratio": 1,
"water_ratio": 10,
"grind": 510,
"ratio_lower_limit": Fraction(1, 12),
"ratio_upper_limit": Fraction(1, 7),
"water": 60,
Expand All @@ -144,6 +160,7 @@
"turkish": {
"coffee_ratio": 1,
"water_ratio": 10,
"grind": 130,
"ratio_lower_limit": Fraction(1, 12),
"ratio_upper_limit": Fraction(1, 8),
"water": 50,
Expand All @@ -152,6 +169,7 @@
"cupping": {
"coffee_ratio": 11,
"water_ratio": 200,
"grind": 655,
"ratio_lower_limit": Fraction(1, 19),
"ratio_upper_limit": Fraction(1, 17),
"water": 150,
Expand All @@ -160,6 +178,7 @@
"aero-press": {
"coffee_ratio": 1,
"water_ratio": 15,
"grind": 640,
"ratio_lower_limit": Fraction(1, 18),
"ratio_upper_limit": Fraction(1, 12),
"water": 135,
Expand All @@ -168,6 +187,7 @@
"aero-press-conc": {
"coffee_ratio": 1,
"water_ratio": 6,
"grind": 640,
"ratio_lower_limit": Fraction(1, 7),
"ratio_upper_limit": Fraction(1, 5),
"water": 90,
Expand All @@ -176,6 +196,7 @@
"aero-press-inv": {
"coffee_ratio": 1,
"water_ratio": 12,
"grind": 640,
"ratio_lower_limit": Fraction(1, 14),
"ratio_upper_limit": Fraction(1, 10),
"water": 132,
Expand All @@ -184,6 +205,7 @@
"steep-and-release": {
"coffee_ratio": 1,
"water_ratio": 16,
"grind": 638,
"ratio_lower_limit": Fraction(1, 17),
"ratio_upper_limit": Fraction(1, 14),
"water": 255,
Expand Down
21 changes: 16 additions & 5 deletions test/functions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
0.001
>>> convert_water(1, "kg", True)
1000.0
>>> test_params = {"method":"v60", "cups":2, "coffee":60, "water":500, "coffee_ratio": 3, "water_ratio":50, "info":"V60 method", "coffee_unit": "g", "water_unit": "g"}
>>> test_params = {"method":"v60", "cups":2, "coffee":60, "water":500, "coffee_ratio": 3, "water_ratio":50, "info":"V60 method", "coffee_unit": "g", "water_unit": "g", "grind": 500}
>>> print_result(test_params)
__ __ _ _ ___ _____ ____ ____ ____ ____
( \/ )( \/ ) / __)( _ )( ___)( ___)( ___)( ___)
Expand All @@ -34,9 +34,11 @@
<BLANKLINE>
Ratio: 3/50
<BLANKLINE>
Grind: 500 um
<BLANKLINE>
Info: V60 method
<BLANKLINE>
>>> test_params = {"method":"v60", "cups":2, "coffee":60, "water":500, "coffee_ratio": 3, "water_ratio":50, "info":"", "digits":3, "coffee_unit": "g", "water_unit": "g"}
>>> test_params = {"method":"v60", "cups":2, "coffee":60, "water":500, "coffee_ratio": 3, "water_ratio":50, "info":"", "digits":3, "coffee_unit": "g", "water_unit": "g", "grind": 600}
>>> test_params = filter_params(test_params)
>>> check_ratio_limits(test_params) == True
True
Expand All @@ -58,9 +60,11 @@
<BLANKLINE>
Ratio: 3/50
<BLANKLINE>
Grind: 600 um
<BLANKLINE>
Info: Nothing :)
<BLANKLINE>
>>> test_params = {"method":"v60", "cups":2, "coffee":60, "water":0.5, "coffee_ratio": 3, "water_ratio":50, "info":"", "digits":3, "coffee_unit": "g", "water_unit": "kg"}
>>> test_params = {"method":"v60", "cups":2, "coffee":60, "water":0.5, "coffee_ratio": 3, "water_ratio":50, "info":"", "digits":3, "coffee_unit": "g", "water_unit": "kg", "grind": 750}
>>> test_params = filter_params(test_params)
>>> check_ratio_limits(test_params) == True
True
Expand All @@ -82,9 +86,11 @@
<BLANKLINE>
Ratio: 3/50
<BLANKLINE>
Grind: 750 um
<BLANKLINE>
Info: Nothing :)
<BLANKLINE>
>>> test_params = {"method":"v60", "cups":2, "coffee":6.0, "water":500, "coffee_ratio": 6, "water_ratio":1000, "info":"", "digits":3, "coffee_unit": "g", "water_unit": "g"}
>>> test_params = {"method":"v60", "cups":2, "coffee":6.0, "water":500, "coffee_ratio": 6, "water_ratio":1000, "info":"", "digits":3, "coffee_unit": "g", "water_unit": "g", "grind": 230}
>>> test_params = filter_params(test_params)
>>> check_ratio_limits(test_params) == False
True
Expand All @@ -106,6 +112,8 @@
<BLANKLINE>
Ratio: 6/1000
<BLANKLINE>
Grind: 230 um
<BLANKLINE>
Info: Nothing :)
<BLANKLINE>
[Warning] The ratio is not within the standard range. For `v60`, the ratio can be anywhere between `1/18` and `1/14`
Expand All @@ -114,7 +122,7 @@
>>> check_ratio_limits(test_params) == True
True
>>> chemex_params = load_method_params("chemex")
>>> chemex_params == {'info': 'Chemex method', 'water': 240, 'cups': 1, 'coffee_ratio': 1, 'water_ratio': 15, 'digits': 3, 'coffee_unit': 'g', 'water_unit': 'g'}
>>> chemex_params == {'info': 'Chemex method', 'water': 240, 'cups': 1, 'coffee_ratio': 1, 'water_ratio': 15, 'digits': 3, 'coffee_unit': 'g', 'water_unit': 'g', 'grind': 670}
True
>>> show_methods_list()
Methods list:
Expand Down Expand Up @@ -221,6 +229,7 @@
>>> _ = parser.add_argument('--water-ratio', help='water ratio', type=float)
>>> _ = parser.add_argument('--water', help='water(ml)', type=float)
>>> _ = parser.add_argument('--cups', help='number of cups', type=int)
>>> _ = parser.add_argument('--grind', help='grind size (um)', type=int)
>>> _ = parser.add_argument('--digits', help='number of digits up to which the result is rounded', type=int, default=3)
>>> _ = parser.add_argument('--coffee-unit', help='coffee unit', type=str, choices=sorted(COFFEE_UNITS_MAP), default="g")
>>> _ = parser.add_argument('--water-unit', help='water unit', type=str, choices=sorted(WATER_UNITS_MAP), default="g")
Expand Down Expand Up @@ -251,6 +260,8 @@
<BLANKLINE>
Ratio: 3/50
<BLANKLINE>
Grind: 550 um
<BLANKLINE>
Info: V60 method
<BLANKLINE>
>>> args = parser.parse_args(["--method", 'v60', "--water-ratio", '500', "--coffee-ratio", '23', "--water", '5000'])
Expand Down
Loading

0 comments on commit a90e70e

Please sign in to comment.