From 1159bdbbc0cd6f508694597f4ad79c90a651d366 Mon Sep 17 00:00:00 2001 From: Justin Shaw Date: Fri, 14 Jul 2023 17:59:48 -0400 Subject: [PATCH 1/3] fixed docs --- participants/scipy_001/doc/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/participants/scipy_001/doc/README.md b/participants/scipy_001/doc/README.md index a1542d9..d7ebbf8 100644 --- a/participants/scipy_001/doc/README.md +++ b/participants/scipy_001/doc/README.md @@ -1,5 +1,5 @@ -Ok so I guess you are reading this cuz you wanna use my code. There are some -functions that do stuf and thats: +Ok so I guess you are reading this because you would like to use this code. There are some +functions that do things: >>> from simple_functions import factorial >>> factorial(10) From ca03c2e8b60636249732a2e3b91bb94822cbf654 Mon Sep 17 00:00:00 2001 From: Justin Shaw Date: Fri, 14 Jul 2023 18:23:37 -0400 Subject: [PATCH 2/3] added a test to buggy_function --- .../scipy_001/pr_tutorial/buggy_function.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/participants/scipy_001/pr_tutorial/buggy_function.py b/participants/scipy_001/pr_tutorial/buggy_function.py index 6f38a6b..1c0cce2 100644 --- a/participants/scipy_001/pr_tutorial/buggy_function.py +++ b/participants/scipy_001/pr_tutorial/buggy_function.py @@ -20,13 +20,21 @@ def angle_to_sexigesimal(angle_in_degrees, decimals=3): if math.floor(decimals) != decimals: raise OSError('decimals should be an integer!') - hours_num = angle_in_degrees*24/180 + hours_num = angle_in_degrees * 24 / 180 hours = math.floor(hours_num) - min_num = (hours_num - hours)*60 + min_num = (hours_num - hours) * 60 minutes = math.floor(min_num) - seconds = (min_num - minutes)*60 + seconds = (min_num - minutes) * 60 + frac = math.floor((seconds % 1) * 10 ** decimals) + + seconds = math.floor(seconds) + format_string = '{:02d}:{:02d}:{:02d}.{:0' + str(decimals) + 'd}' + return format_string.format(hours, minutes, seconds, frac) - format_string = '{}:{}:{:.' + str(decimals) + 'f}' - return format_string.format(hours, minutes, seconds) +def angle_test(): + sex = angle_to_sexigesimal(32.231515, decimals=3) + assert sex == '04:17:51.127' + +angle_test() From a1fc2390732356a685762f80fdc165be2e61648c Mon Sep 17 00:00:00 2001 From: Justin Shaw Date: Fri, 14 Jul 2023 18:25:00 -0400 Subject: [PATCH 3/3] added a test to buggy_function --- participants/scipy_001/pr_tutorial/tests/test_function.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 participants/scipy_001/pr_tutorial/tests/test_function.py diff --git a/participants/scipy_001/pr_tutorial/tests/test_function.py b/participants/scipy_001/pr_tutorial/tests/test_function.py new file mode 100644 index 0000000..e111fb3 --- /dev/null +++ b/participants/scipy_001/pr_tutorial/tests/test_function.py @@ -0,0 +1,6 @@ +from pr_tutorial.buggy_function import angle_to_sexigesimal + +def test_angle(): + sex = angle_to_sexigesimal(32.231515, decimals=3) + assert sex == '04:17:51.127' +