Skip to content
Open
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
4 changes: 2 additions & 2 deletions participants/scipy_001/doc/README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
18 changes: 13 additions & 5 deletions participants/scipy_001/pr_tutorial/buggy_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
6 changes: 6 additions & 0 deletions participants/scipy_001/pr_tutorial/tests/test_function.py
Original file line number Diff line number Diff line change
@@ -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'