From 35a89e1819b68d13a55baeefbaa947d855a4f7e7 Mon Sep 17 00:00:00 2001 From: PAUL ADUTWUM Date: Wed, 5 Mar 2025 19:06:17 -0500 Subject: [PATCH 1/4] Imporved test coverage in decimal_to_fraction.py --- maths/decimal_to_fraction.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/maths/decimal_to_fraction.py b/maths/decimal_to_fraction.py index 2aa8e3c3dfd6..cd8583cfa364 100644 --- a/maths/decimal_to_fraction.py +++ b/maths/decimal_to_fraction.py @@ -14,8 +14,23 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]: >>> decimal_to_fraction("6.25") (25, 4) >>> decimal_to_fraction("78td") + Traceback (most recent call last): ValueError: Please enter a valid number + >>> decimal_to_fraction(0) + (0,1) + >>>decima_to_fraction(-2.5) + (-5,2) + >>> >>> decimal_to_fraction(0.125) + (1,8) + >>> decimal_to_fraction(1000000.25) + (4000001, 400) + >>> decimal_to_fraction(1.3333) + (133333, 10000) + >>> decimal_to_fraction(1.23e2) + (123, 1) + >>> decimal_to_fraction("0.0500") + (1,2) """ try: decimal = float(decimal) From 2bf88ec7f18819e2cba1d7d4a70f443a2fdaa890 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 00:07:56 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- maths/decimal_to_fraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/decimal_to_fraction.py b/maths/decimal_to_fraction.py index cd8583cfa364..beadd204a3f4 100644 --- a/maths/decimal_to_fraction.py +++ b/maths/decimal_to_fraction.py @@ -14,7 +14,7 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]: >>> decimal_to_fraction("6.25") (25, 4) >>> decimal_to_fraction("78td") - + Traceback (most recent call last): ValueError: Please enter a valid number >>> decimal_to_fraction(0) From ef8ec4366feccf1e5063bcc7bb9f367c58a70636 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sun, 9 Mar 2025 00:42:13 +0300 Subject: [PATCH 3/4] Update decimal_to_fraction.py --- maths/decimal_to_fraction.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/maths/decimal_to_fraction.py b/maths/decimal_to_fraction.py index beadd204a3f4..cf91d470ca73 100644 --- a/maths/decimal_to_fraction.py +++ b/maths/decimal_to_fraction.py @@ -14,23 +14,22 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]: >>> decimal_to_fraction("6.25") (25, 4) >>> decimal_to_fraction("78td") - Traceback (most recent call last): ValueError: Please enter a valid number >>> decimal_to_fraction(0) - (0,1) - >>>decima_to_fraction(-2.5) - (-5,2) - >>> >>> decimal_to_fraction(0.125) - (1,8) + (0, 1) + >>> decimal_to_fraction(-2.5) + (-5, 2) + >>> decimal_to_fraction(0.125) + (1, 8) >>> decimal_to_fraction(1000000.25) - (4000001, 400) + (4000001, 4000) >>> decimal_to_fraction(1.3333) - (133333, 10000) - >>> decimal_to_fraction(1.23e2) + (13333, 10000) + >>> decimal_to_fraction("1.23e2") (123, 1) - >>> decimal_to_fraction("0.0500") - (1,2) + >>> decimal_to_fraction("0.500") + (1, 2) """ try: decimal = float(decimal) From d8c0514410f2df7f799737199bfb91fbc1744146 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sun, 9 Mar 2025 00:44:27 +0300 Subject: [PATCH 4/4] Update decimal_to_fraction.py --- maths/decimal_to_fraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/decimal_to_fraction.py b/maths/decimal_to_fraction.py index cf91d470ca73..7f1299b33c5c 100644 --- a/maths/decimal_to_fraction.py +++ b/maths/decimal_to_fraction.py @@ -23,7 +23,7 @@ def decimal_to_fraction(decimal: float | str) -> tuple[int, int]: >>> decimal_to_fraction(0.125) (1, 8) >>> decimal_to_fraction(1000000.25) - (4000001, 4000) + (4000001, 4) >>> decimal_to_fraction(1.3333) (13333, 10000) >>> decimal_to_fraction("1.23e2")