Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ratio limits #28

Merged
merged 13 commits into from
Oct 4, 2024
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Added
- Ratio upper limit
- Ratio lower limit
- `check_ratio_limits` function
### Changed
- Test system modified
## [0.4] - 2024-10-01
Expand Down
42 changes: 41 additions & 1 deletion METHODS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,140 +4,180 @@
<tr align="center">
<th>Title</th>
<th>Code</th>
<th>Ratio</th>
<th>Ratio(Recommended)</th>
<th>Ratio(Lower Limit)</th>
<th>Ratio(Upper Limit)</th>
<th>Water(gr)</th>
<th>Version</th>
</tr>
<tr align="center">
<td>Custom</td>
<td><code>custom</code></td>
<td>1/17</td>
<td>--</td>
<td>--</td>
<td>240</td>
<td>>=0.1</td>
</tr>
<tr align="center">
<td>V60</td>
<td><code>v60</code></td>
<td>3/50</td>
<td>1/18</td>
<td>1/14</td>
<td>250</td>
<td>>=0.1</td>
</tr>
<tr align="center">
<td>Chemex</td>
<td><code>chemex</code></td>
<td>1/15</td>
<td>1/21</td>
<td>1/10</td>
<td>240</td>
<td>>=0.1</td>
</tr>
<tr align="center">
<td>Espresso</td>
<td><code>espresso</code></td>
<td>1/2</td>
<td>1/2.5</td>
<td>1/1.5</td>
<td>36</td>
<td>>=0.1</td>
</tr>
<tr align="center">
<td>French press</td>
<td><code>french-press</code></td>
<td>1/15</td>
<td>1/18</td>
<td>1/12</td>
<td>120</td>
<td>>=0.1</td>
</tr>
<tr align="center">
<td>Siphon</td>
<td><code>siphon</code></td>
<td>1/15</td>
<td>1/16</td>
<td>1/12</td>
<td>240</td>
<td>>=0.1</td>
</tr>
<tr align="center">
<td>Pour-over</td>
<td><code>pour-over</code></td>
<td>1/15</td>
<td>1/16</td>
<td>1/14</td>
<td>240</td>
<td>>=0.2</td>
</tr>
<tr align="center">
<td>Auto drip</td>
<td><code>auto-drip</code></td>
<td>1/16</td>
<td>1/17</td>
<td>1/14</td>
<td>128</td>
<td>>=0.2</td>
</tr>
<tr align="center">
<td>Cold brew</td>
<td><code>cold-brew</code></td>
<td>1/11</td>
<td>1/15</td>
<td>1/8</td>
<td>242</td>
<td>>=0.2</td>
</tr>
<tr align="center">
<td>Cold brew concentrate</td>
<td><code>cold-brew-conc</code></td>
<td>1/5</td>
<td>1/6</td>
<td>1/4</td>
<td>120</td>
<td>>=0.2</td>
</tr>
<tr align="center">
<td>Moka pot</td>
<td><code>moka-pot</code></td>
<td>1/10</td>
<td>1/12</td>
<td>1/7</td>
<td>60</td>
<td>>=0.2</td>
</tr>
<tr align="center">
<td>Ristretto</td>
<td><code>ristretto</code></td>
<td>1/1</td>
<td>1/1.5</td>
<td>1/1</td>
<td>18</td>
<td>>=0.3</td>
</tr>
<tr align="center">
<td>Lungo</td>
<td><code>lungo</code></td>
<td>1/4</td>
<td>1/4</td>
<td>1/2.5</td>
<td>72</td>
<td>>=0.3</td>
</tr>
<tr align="center">
<td>Turkish</td>
<td><code>turkish</code></td>
<td>1/10</td>
<td>1/12</td>
<td>1/8</td>
<td>50</td>
<td>>=0.3</td>
</tr>
<tr align="center">
<td>Cupping</td>
<td><code>cupping</code></td>
<td>11/200</td>
<td>1/19</td>
<td>1/17</td>
<td>150</td>
<td>>=0.3</td>
</tr>
<tr align="center">
<td>AeroPress standard</td>
<td><code>aero-press</code></td>
<td>1/15</td>
<td>1/18</td>
<td>1/12</td>
<td>135</td>
<td>>=0.4</td>
</tr>
<tr align="center">
<td>AeroPress concentrate</td>
<td><code>aero-press-conc</code></td>
<td>1/6</td>
<td>1/7</td>
<td>1/5</td>
<td>90</td>
<td>>=0.4</td>
</tr>
<tr align="center">
<td>AeroPress inverted</td>
<td><code>aero-press-inv</code></td>
<td>1/12</td>
<td>1/14</td>
<td>1/10</td>
<td>132</td>
<td>>=0.4</td>
</tr>
<tr align="center">
<td>Steep-and-release</td>
<td><code>steep-and-release</code></td>
<td>1/16</td>
<td>1/17</td>
<td>1/14</td>
<td>255</td>
<td>>=0.4</td>
</tr>
Expand Down
19 changes: 19 additions & 0 deletions mycoffee/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""mycoffee functions."""
from mycoffee.params import MESSAGE_TEMPLATE, METHODS_LIST_TEMPLATE, EMPTY_INFO
from mycoffee.params import MY_COFFEE_VERSION, DEFAULT_PARAMS, METHODS_MAP
from mycoffee.params import RATIO_WARNING_MESSAGE
from art import tprint


Expand Down Expand Up @@ -36,6 +37,7 @@ def print_message(params):
params["coffee_ratio"],
params["water_ratio"],
params["info"]))
check_ratio_limits(params)


def load_method_params(method_name):
Expand Down Expand Up @@ -109,6 +111,23 @@ def filter_params(params):
return params


def check_ratio_limits(params):
"""
Check ratio limits.

:param params: parameters
:type params: dict
:return: None
"""
method = params["method"]
if "ratio_lower_limit" in METHODS_MAP[method] and "ratio_upper_limit" in METHODS_MAP[method]:
ratio = params["coffee_ratio"] / params["water_ratio"]
ratio_lower_limit = METHODS_MAP[method]["ratio_lower_limit"]
ratio_upper_limit = METHODS_MAP[method]["ratio_upper_limit"]
if ratio < ratio_lower_limit or ratio > ratio_upper_limit:
print(RATIO_WARNING_MESSAGE.format(method, str(ratio_lower_limit), str(ratio_upper_limit)))


def calc_coffee(params):
"""
Calculate coffee.
Expand Down
38 changes: 38 additions & 0 deletions mycoffee/params.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
"""mycoffee params."""
from fractions import Fraction

MY_COFFEE_VERSION = "0.4"
INPUT_ERROR_MESSAGE = "[Error] Wrong input"
RATIO_WARNING_MESSAGE = "[Warning] The ratio is not within the standard range. For `{0}`, the ratio can be anywhere between `{1}` and `{2}`"
INPUT_EXAMPLE = "Example: mycoffee --method=v60"
EXIT_MESSAGE = "See you. Bye!"
EMPTY_INFO = "Nothing :)"
Expand Down Expand Up @@ -44,108 +46,144 @@
"v60": {
"coffee_ratio": 3,
"water_ratio": 50,
"ratio_lower_limit": Fraction(1, 18),
"ratio_upper_limit": Fraction(1, 14),
"water": 250,
"info": "V60 method"
},
"espresso": {
"coffee_ratio": 1,
"water_ratio": 2,
"ratio_lower_limit": Fraction(2, 5),
"ratio_upper_limit": Fraction(2, 3),
"water": 36,
"info": "Espresso method"
},
"ristretto": {
"coffee_ratio": 1,
"water_ratio": 1,
"ratio_lower_limit": Fraction(2, 3),
"ratio_upper_limit": Fraction(1, 1),
"water": 18,
"info": "Ristretto method"
},
"lungo": {
"coffee_ratio": 1,
"water_ratio": 4,
"ratio_lower_limit": Fraction(1, 4),
"ratio_upper_limit": Fraction(2, 5),
"water": 72,
"info": "Lungo method"
},
"chemex": {
"coffee_ratio": 1,
"water_ratio": 15,
"ratio_lower_limit": Fraction(1, 21),
"ratio_upper_limit": Fraction(1, 10),
"water": 240,
"info": "Chemex method"
},
"french-press": {
"coffee_ratio": 1,
"water_ratio": 15,
"ratio_lower_limit": Fraction(1, 18),
"ratio_upper_limit": Fraction(1, 12),
"water": 120,
"info": "French press method"
},
"siphon": {
"coffee_ratio": 1,
"water_ratio": 15,
"ratio_lower_limit": Fraction(1, 16),
"ratio_upper_limit": Fraction(1, 12),
"water": 240,
"info": "Siphon method"
},
"pour-over": {
"coffee_ratio": 1,
"water_ratio": 15,
"ratio_lower_limit": Fraction(1, 16),
"ratio_upper_limit": Fraction(1, 14),
"water": 240,
"info": "Pour-over method"
},
"auto-drip": {
"coffee_ratio": 1,
"water_ratio": 16,
"ratio_lower_limit": Fraction(1, 17),
"ratio_upper_limit": Fraction(1, 14),
"water": 128,
"info": "Auto drip method"
},
"cold-brew": {
"coffee_ratio": 1,
"water_ratio": 11,
"ratio_lower_limit": Fraction(1, 15),
"ratio_upper_limit": Fraction(1, 8),
"water": 242,
"info": "Cold brew method"
},
"cold-brew-conc": {
"coffee_ratio": 1,
"water_ratio": 5,
"ratio_lower_limit": Fraction(1, 6),
"ratio_upper_limit": Fraction(1, 4),
"water": 120,
"info": "Cold brew concentrate method"
},
"moka-pot": {
"coffee_ratio": 1,
"water_ratio": 10,
"ratio_lower_limit": Fraction(1, 12),
"ratio_upper_limit": Fraction(1, 7),
"water": 60,
"info": "Moka pot method"
},
"turkish": {
"coffee_ratio": 1,
"water_ratio": 10,
"ratio_lower_limit": Fraction(1, 12),
"ratio_upper_limit": Fraction(1, 8),
"water": 50,
"info": "Turkish method"
},
"cupping": {
"coffee_ratio": 11,
"water_ratio": 200,
"ratio_lower_limit": Fraction(1, 19),
"ratio_upper_limit": Fraction(1, 17),
"water": 150,
"info": "Cupping method"
},
"aero-press": {
"coffee_ratio": 1,
"water_ratio": 15,
"ratio_lower_limit": Fraction(1, 18),
"ratio_upper_limit": Fraction(1, 12),
"water": 135,
"info": "AeroPress standard method"
},
"aero-press-conc": {
"coffee_ratio": 1,
"water_ratio": 6,
"ratio_lower_limit": Fraction(1, 7),
"ratio_upper_limit": Fraction(1, 5),
"water": 90,
"info": "AeroPress concentrate method"
},
"aero-press-inv": {
"coffee_ratio": 1,
"water_ratio": 12,
"ratio_lower_limit": Fraction(1, 14),
"ratio_upper_limit": Fraction(1, 10),
"water": 132,
"info": "AeroPress inverted method"
},
"steep-and-release": {
"coffee_ratio": 1,
"water_ratio": 16,
"ratio_lower_limit": Fraction(1, 17),
"ratio_upper_limit": Fraction(1, 14),
"water": 255,
"info": "Steep-and-release method"
}
Expand Down
Loading
Loading