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

Pennyweights (dwt) unit added for water and coffee #78

Merged
merged 3 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Pounds (`t lb`)
- 1 new coffee unit
2. Pennyweight (`dwt`)
- 2 new coffee units
1. Troy Pounds (`t lb`)
2. Pennyweight (`dwt`)
- `--grind` argument
- Grind upper limit
- Grind lower limit
Expand Down
2 changes: 2 additions & 0 deletions mycoffee/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@
"gr": {"name": "grain", "rate": 15.4324},
"ct": {"name": "carat", "rate": 5},
"t lb": {"name": "troy pound", "rate": 0.0026792289},
"dwt": {"name": "pennyweight", "rate": 0.643015},
}

WATER_UNITS_MAP = {
Expand All @@ -288,4 +289,5 @@
"gr": {"name": "grain", "rate": 15.4324},
"ct": {"name": "carat", "rate": 5},
"t lb": {"name": "troy pound", "rate": 0.0026792289},
"dwt": {"name": "pennyweight", "rate": 0.643015},
}
104 changes: 54 additions & 50 deletions test/functions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,17 @@
2. `ct` - carat
3. `cup` - cup
4. `dsp` - dessertspoon
5. `g` - gram
6. `gr` - grain
7. `kg` - kilogram
8. `lb` - pound
9. `mg` - milligram
10. `oz` - ounce
11. `t lb` - troy pound
12. `t oz` - troy ounce
13. `tbsp` - tablespoon
14. `tsp` - teaspoon
5. `dwt` - pennyweight
6. `g` - gram
7. `gr` - grain
8. `kg` - kilogram
9. `lb` - pound
10. `mg` - milligram
11. `oz` - ounce
12. `t lb` - troy pound
13. `t oz` - troy ounce
14. `tbsp` - tablespoon
15. `tsp` - teaspoon
>>> show_water_units_list()
Water units list:
<BLANKLINE>
Expand All @@ -237,21 +238,22 @@
3. `ct` - carat
4. `cup` - cup
5. `dsp` - dessertspoon
6. `fl oz` - fluid ounce
7. `g` - gram
8. `gr` - grain
9. `kg` - kilogram
10. `l` - liter
11. `lb` - pound
12. `mg` - milligram
13. `ml` - milliliter
14. `oz` - ounce
15. `pt` - pint
16. `qt` - quart
17. `t lb` - troy pound
18. `t oz` - troy ounce
19. `tbsp` - tablespoon
20. `tsp` - teaspoon
6. `dwt` - pennyweight
7. `fl oz` - fluid ounce
8. `g` - gram
9. `gr` - grain
10. `kg` - kilogram
11. `l` - liter
12. `lb` - pound
13. `mg` - milligram
14. `ml` - milliliter
15. `oz` - ounce
16. `pt` - pint
17. `qt` - quart
18. `t lb` - troy pound
19. `t oz` - troy ounce
20. `tbsp` - tablespoon
21. `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 @@ -482,16 +484,17 @@
2. `ct` - carat
3. `cup` - cup
4. `dsp` - dessertspoon
5. `g` - gram
6. `gr` - grain
7. `kg` - kilogram
8. `lb` - pound
9. `mg` - milligram
10. `oz` - ounce
11. `t lb` - troy pound
12. `t oz` - troy ounce
13. `tbsp` - tablespoon
14. `tsp` - teaspoon
5. `dwt` - pennyweight
6. `g` - gram
7. `gr` - grain
8. `kg` - kilogram
9. `lb` - pound
10. `mg` - milligram
11. `oz` - ounce
12. `t lb` - troy pound
13. `t oz` - troy ounce
14. `tbsp` - tablespoon
15. `tsp` - teaspoon
>>> args = parser.parse_args(["--water-units-list"])
>>> run(args)
Water units list:
Expand All @@ -501,19 +504,20 @@
3. `ct` - carat
4. `cup` - cup
5. `dsp` - dessertspoon
6. `fl oz` - fluid ounce
7. `g` - gram
8. `gr` - grain
9. `kg` - kilogram
10. `l` - liter
11. `lb` - pound
12. `mg` - milligram
13. `ml` - milliliter
14. `oz` - ounce
15. `pt` - pint
16. `qt` - quart
17. `t lb` - troy pound
18. `t oz` - troy ounce
19. `tbsp` - tablespoon
20. `tsp` - teaspoon
6. `dwt` - pennyweight
7. `fl oz` - fluid ounce
8. `g` - gram
9. `gr` - grain
10. `kg` - kilogram
11. `l` - liter
12. `lb` - pound
13. `mg` - milligram
14. `ml` - milliliter
15. `oz` - ounce
16. `pt` - pint
17. `qt` - quart
18. `t lb` - troy pound
19. `t oz` - troy ounce
20. `tbsp` - tablespoon
21. `tsp` - teaspoon
"""
6 changes: 6 additions & 0 deletions test/verified_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,4 +499,10 @@
True
>>> round(convert_water(240, "t lb", True), 1) == 89578.0 # https://www.metric-conversions.org/weight/troy-pounds-to-grams.htm
True
>>> round(convert_coffee(240, "dwt"), 2) == 154.32 # https://www.metric-conversions.org/weight/grams-to-pennyweights.htm
True
>>> round(convert_water(240, "dwt"), 2) == 154.32 # https://www.metric-conversions.org/weight/grams-to-pennyweights.htm
True
>>> round(convert_water(240, "dwt", True), 2) == 373.24 # https://www.metric-conversions.org/weight/pennyweights-to-grams.htm
True
"""