Skip to content

Commit

Permalink
Liter (#43)
Browse files Browse the repository at this point in the history
* feat : liter unit added

* feat : milliliter unit added

* fix : tests updated

* fix : functions_test.py updated

* doc : CHANGELOG.md updated

* doc : CHANGELOG.md updated

* fix : verified_test.py updated
  • Loading branch information
sepandhaghighi authored Nov 26, 2024
1 parent b2bc090 commit ce43bdf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- 1 new coffee unit
1. Cup (`cup`)
- 6 new water units
1. Milliliter (`ml`)
2. Liter (`l`)
3. Ounce (`oz`)
4. Pound (`lb`)
5. Milligram (`mg`)
6. Kilogram (`kg`)
- `convert_water` function
- `show_water_units_list` function
- `--water-unit` argument
Expand Down
2 changes: 2 additions & 0 deletions mycoffee/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@

WATER_UNITS_MAP = {
"g": {"name": "gram", "rate": 1},
"ml": {"name": "milliliter", "rate": 1},
"l": {"name": "liter", "rate": 0.001},
"oz": {"name": "ounce", "rate": 0.03527396195},
"lb": {"name": "pound", "rate": 0.00220462262185},
"mg": {"name": "milligram", "rate": 1000},
Expand Down
16 changes: 10 additions & 6 deletions test/functions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@
<BLANKLINE>
1. `g` - gram
2. `kg` - kilogram
3. `lb` - pound
4. `mg` - milligram
5. `oz` - ounce
3. `l` - liter
4. `lb` - pound
5. `mg` - milligram
6. `ml` - milliliter
7. `oz` - ounce
>>> test_params = {"method":"v60", "cups":1, "water":335, "coffee_ratio": 3, "water_ratio":50, "info":"V60 method", 'coffee_unit': 'g'}
>>> calc_coffee(test_params)
20.1
Expand Down Expand Up @@ -398,7 +400,9 @@
<BLANKLINE>
1. `g` - gram
2. `kg` - kilogram
3. `lb` - pound
4. `mg` - milligram
5. `oz` - ounce
3. `l` - liter
4. `lb` - pound
5. `mg` - milligram
6. `ml` - milliliter
7. `oz` - ounce
"""
8 changes: 8 additions & 0 deletions test/verified_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,12 @@
True
>>> convert_water(240, "lb", True) == 108862.16879993954 # https://www.calculator.net/weight-calculator.html
True
>>> convert_water(240, "ml") == 240 # https://www.howmany.wiki/wv/
True
>>> convert_water(240, "ml", True) == 240.0 # https://www.howmany.wiki/wv/
True
>>> convert_water(240, "l") == 0.24 # https://www.howmany.wiki/wv/
True
>>> convert_water(240, "l", True) == 240000.0 # https://www.howmany.wiki/wv/
True
"""

0 comments on commit ce43bdf

Please sign in to comment.