From 80ba0d591c0fd6ee8ccb49a5d63007a2907bfc67 Mon Sep 17 00:00:00 2001 From: Sadra Sabouri <43045767+sadrasabouri@users.noreply.github.com> Date: Fri, 3 Jan 2025 07:25:21 -0800 Subject: [PATCH] Troy pounds added for water and coffee (#73) * add : Troy pounds (`t lb`) unit added for water and coffee. * test : tests updated. * log : changes logged. --- CHANGELOG.md | 5 +++++ mycoffee/params.py | 2 ++ test/functions_test.py | 28 ++++++++++++++++------------ test/verified_test.py | 6 ++++++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 742757e..0ca57bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ 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 +- 1 new water unit + 1. Troy Pounds (`t lb`) +- 1 new coffee unit + 1. Troy Pounds (`t lb`) ## [1.1] - 2025-01-02 ### Added - 5 new water units diff --git a/mycoffee/params.py b/mycoffee/params.py index 297c7d5..16afc17 100644 --- a/mycoffee/params.py +++ b/mycoffee/params.py @@ -205,6 +205,7 @@ "t oz": {"name": "troy ounce", "rate": 0.032151}, "gr": {"name": "grain", "rate": 15.4324}, "ct": {"name": "carat", "rate": 5}, + "t lb": {"name": "troy pound", "rate": 0.0026792289}, } WATER_UNITS_MAP = { @@ -227,4 +228,5 @@ "t oz": {"name": "troy ounce", "rate": 0.032151}, "gr": {"name": "grain", "rate": 15.4324}, "ct": {"name": "carat", "rate": 5}, + "t lb": {"name": "troy pound", "rate": 0.0026792289}, } diff --git a/test/functions_test.py b/test/functions_test.py index 6b70857..5c699ec 100644 --- a/test/functions_test.py +++ b/test/functions_test.py @@ -151,9 +151,10 @@ 8. `lb` - pound 9. `mg` - milligram 10. `oz` - ounce -11. `t oz` - troy ounce -12. `tbsp` - tablespoon -13. `tsp` - teaspoon +11. `t lb` - troy pound +12. `t oz` - troy ounce +13. `tbsp` - tablespoon +14. `tsp` - teaspoon >>> show_water_units_list() Water units list: @@ -173,9 +174,10 @@ 14. `oz` - ounce 15. `pt` - pint 16. `qt` - quart -17. `t oz` - troy ounce -18. `tbsp` - tablespoon -19. `tsp` - teaspoon +17. `t lb` - troy pound +18. `t oz` - troy ounce +19. `tbsp` - tablespoon +20. `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 @@ -409,9 +411,10 @@ 8. `lb` - pound 9. `mg` - milligram 10. `oz` - ounce -11. `t oz` - troy ounce -12. `tbsp` - tablespoon -13. `tsp` - teaspoon +11. `t lb` - troy pound +12. `t oz` - troy ounce +13. `tbsp` - tablespoon +14. `tsp` - teaspoon >>> args = parser.parse_args(["--water-units-list"]) >>> run(args) Water units list: @@ -432,7 +435,8 @@ 14. `oz` - ounce 15. `pt` - pint 16. `qt` - quart -17. `t oz` - troy ounce -18. `tbsp` - tablespoon -19. `tsp` - teaspoon +17. `t lb` - troy pound +18. `t oz` - troy ounce +19. `tbsp` - tablespoon +20. `tsp` - teaspoon """ diff --git a/test/verified_test.py b/test/verified_test.py index 48a64e0..e1c4c3e 100644 --- a/test/verified_test.py +++ b/test/verified_test.py @@ -385,4 +385,10 @@ True >>> round(convert_water(240, "cl", True), 1) == 2400.0 # https://www.metric-conversions.org/volume/centiliters-to-milliliters.htm True +>>> round(convert_coffee(240, "t lb"), 3) == 0.643 # https://www.metric-conversions.org/weight/grams-to-troy-pounds.htm +True +>>> round(convert_water(240, "t lb"), 3) == 0.643 # https://www.metric-conversions.org/weight/grams-to-troy-pounds.htm +True +>>> round(convert_water(240, "t lb", True), 1) == 89578.0 # https://www.metric-conversions.org/weight/troy-pounds-to-grams.htm +True """