Skip to content

Commit

Permalink
Merge pull request #6 from arokem/diameter
Browse files Browse the repository at this point in the history
Adds implementation of diameter calculation
  • Loading branch information
arokem authored Aug 2, 2024
2 parents 57dde6f + 5762338 commit b4641c1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/geometry/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,18 @@ def calculate_circ(r):
"""
circ = 2 * pi * r
return circ


def calculate_diam(r):
"""
Calculate the diameter of a cirlce
Parameters
----------
r : float, the radius
Returns
-------
float : the diameter
"""
return 2 * r
7 changes: 5 additions & 2 deletions tests/test_circle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from geometry.circle import calculate_area
from geometry.circle import calculate_area, calculate_circ, calculate_diam
from math import pi

def test_calculate_area():
Expand All @@ -8,4 +8,7 @@ def test_calculate_area_zero():
assert calculate_area(0) == 0, "Calculation did not work"

def test_calculate_circ():
assert calculate_circ(1) == 2 * pi
assert calculate_circ(1) == 2 * pi

def test_calculate_diameter():
assert calculate_diam(1) == 2

0 comments on commit b4641c1

Please sign in to comment.