Skip to content

Commit 9bb7c75

Browse files
committed
Updated point to check as a list rather than a tuple
1 parent 63ff53c commit 9bb7c75

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/fb_library/point.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ def Y(self):
2828
return self.y
2929

3030
def __init__(
31-
self, x: Union[float, Tuple[float, float]] = None, y: float = None
31+
self, x: Union[float, list[float, float]] = None, y: float = None
3232
):
3333
"""initialze the point with x and y coordinates passed as a tuple or idividual values"""
34-
if isinstance(x, tuple):
34+
if isinstance(x, list) and len(x) >= 2:
3535
self.x, self.y = x
3636
else:
3737
self.x = x
@@ -53,7 +53,7 @@ def __getitem__(self, index):
5353

5454
def angle_to(self, point: "Point") -> float:
5555
"""from the point, identify the angle to a second point"""
56-
return degrees(atan2(point.y - self.y, point.x - self.x))
56+
return degrees(atan2(point.y - self.y, point.x - self.x)) % 360
5757

5858
def distance_to(self, point: "Point") -> float:
5959
"""from the point, identify the distance to a second point"""

tests/test_point.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ def test_creation(self):
1414
assert x.X == 1
1515
assert x.Y == 2
1616

17-
def test_tuple(self):
18-
x = Point((1, 2))
17+
def test_list(self):
18+
x = Point([1, 2])
1919
assert x[0] == 1
2020
assert x[1] == 2
2121
with pytest.raises(IndexError):

0 commit comments

Comments
 (0)