Skip to content

Commit

Permalink
Grains Unit for Water and Coffee (#63)
Browse files Browse the repository at this point in the history
* add : `grains` unit added for water and coffee.

* test : tests added.

* log : changes logged.
  • Loading branch information
sadrasabouri authored Dec 26, 2024
1 parent a9fd5ff commit 6cae5c4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 38 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]
### Added
- 1 new water unit
- 2 new water units
1. Troy Ounce (`t oz`)
- 1 new coffee unit
2. Grain (`gr`)
- 2 new coffee units
1. Troy Ounce (`t oz`)
2. Grain (`gr`)
## [1.0] - 2024-12-17
### Added
- 3 new water units
Expand Down
2 changes: 2 additions & 0 deletions mycoffee/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"dsp": {"name": "dessertspoon", "rate": 0.27792},
"cup": {"name": "cup", "rate": 0.01158},
"t oz": {"name": "troy ounce", "rate": 0.032151},
"gr": {"name": "grain", "rate": 15.4324},
}

WATER_UNITS_MAP = {
Expand All @@ -221,4 +222,5 @@
"qt": {"name": "quart", "rate": 0.00105669},
"fl oz": {"name": "fluid ounce", "rate": 0.033814},
"t oz": {"name": "troy ounce", "rate": 0.032151},
"gr": {"name": "grain", "rate": 15.4324},
}
76 changes: 40 additions & 36 deletions test/functions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,31 +145,33 @@
2. `cup` - cup
3. `dsp` - dessertspoon
4. `g` - gram
5. `kg` - kilogram
6. `lb` - pound
7. `mg` - milligram
8. `oz` - ounce
9. `t oz` - troy ounce
10. `tbsp` - tablespoon
11. `tsp` - teaspoon
5. `gr` - grain
6. `kg` - kilogram
7. `lb` - pound
8. `mg` - milligram
9. `oz` - ounce
10. `t oz` - troy ounce
11. `tbsp` - tablespoon
12. `tsp` - teaspoon
>>> show_water_units_list()
Water units list:
<BLANKLINE>
1. `cup` - cup
2. `dsp` - dessertspoon
3. `fl oz` - fluid ounce
4. `g` - gram
5. `kg` - kilogram
6. `l` - liter
7. `lb` - pound
8. `mg` - milligram
9. `ml` - milliliter
10. `oz` - ounce
11. `pt` - pint
12. `qt` - quart
13. `t oz` - troy ounce
14. `tbsp` - tablespoon
15. `tsp` - teaspoon
5. `gr` - grain
6. `kg` - kilogram
7. `l` - liter
8. `lb` - pound
9. `mg` - milligram
10. `ml` - milliliter
11. `oz` - ounce
12. `pt` - pint
13. `qt` - quart
14. `t oz` - troy ounce
15. `tbsp` - tablespoon
16. `tsp` - teaspoon
>>> 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 @@ -397,13 +399,14 @@
2. `cup` - cup
3. `dsp` - dessertspoon
4. `g` - gram
5. `kg` - kilogram
6. `lb` - pound
7. `mg` - milligram
8. `oz` - ounce
9. `t oz` - troy ounce
10. `tbsp` - tablespoon
11. `tsp` - teaspoon
5. `gr` - grain
6. `kg` - kilogram
7. `lb` - pound
8. `mg` - milligram
9. `oz` - ounce
10. `t oz` - troy ounce
11. `tbsp` - tablespoon
12. `tsp` - teaspoon
>>> args = parser.parse_args(["--water-units-list"])
>>> run(args)
Water units list:
Expand All @@ -412,15 +415,16 @@
2. `dsp` - dessertspoon
3. `fl oz` - fluid ounce
4. `g` - gram
5. `kg` - kilogram
6. `l` - liter
7. `lb` - pound
8. `mg` - milligram
9. `ml` - milliliter
10. `oz` - ounce
11. `pt` - pint
12. `qt` - quart
13. `t oz` - troy ounce
14. `tbsp` - tablespoon
15. `tsp` - teaspoon
5. `gr` - grain
6. `kg` - kilogram
7. `l` - liter
8. `lb` - pound
9. `mg` - milligram
10. `ml` - milliliter
11. `oz` - ounce
12. `pt` - pint
13. `qt` - quart
14. `t oz` - troy ounce
15. `tbsp` - tablespoon
16. `tsp` - teaspoon
"""
6 changes: 6 additions & 0 deletions test/verified_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,4 +365,10 @@
True
>>> round(convert_coffee(240, "t oz"), 4) == 7.7162 # https://www.metric-conversions.org/weight/grams-to-troy-ounces.htm
True
>>> round(convert_coffee(240, "gr"), 1) == 3703.8 # https://www.metric-conversions.org/weight/grams-to-grains.htm
True
>>> round(convert_water(240, "gr"), 1) == 3703.8 # https://www.metric-conversions.org/weight/grams-to-grains.htm
True
>>> round(convert_water(240, "gr", True), 3) == 15.552 # https://www.metric-conversions.org/weight/grains-to-grams.htm
True
"""

0 comments on commit 6cae5c4

Please sign in to comment.