diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..d4d7f04 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +language: python +python: + - "3.5" + +#command to run tests +script: nosetests \ No newline at end of file diff --git a/point_pattern.py b/point_pattern.py index 9ae56ee..e37d063 100644 --- a/point_pattern.py +++ b/point_pattern.py @@ -1,4 +1,7 @@ import math # I am guessing that you will need to use the math module +import pdb + +from math import sqrt """ Below are 5 functions (we will talk about what @@ -27,7 +30,7 @@ def manhattan_distance(a, b): distance : float The Manhattan distance between the two points """ - distance = None # Add the algorithm to compute manhattan distance here + distance = sum(abs(a-b) for a,b in zip(a,b)) # Add the algorithm to compute manhattan distance here return distance @@ -49,7 +52,8 @@ def euclidean_distance(a, b): distance : float The Euclidean distance between the two points """ - distance = None # Add the euclidean distance algorithm here + # pdb.set_trace() + distance = sqrt(sum((a - b) ** 2 for a, b in zip(a, b))) # Add the euclidean distance algorithm here return distance @@ -87,8 +91,8 @@ def shift_point(point, x_shift, y_shift): x = getx(point) y = gety(point) - x_new = None # Add the logic to shift x here - y_new = None # Add the logic to shift y here + x_new = x_shift + x # Add the logic to shift x here + y_new = y_shift + y# Add the logic to shift y here return x_new, y_new @@ -109,8 +113,10 @@ def check_coincident(a, b): equal : bool Whether the points are equal """ - return None # Add the logic to check if coincident here - + if a == b: + return True + else: + return False def check_in(point, point_list): """ @@ -124,7 +130,11 @@ def check_in(point, point_list): point_list : list in the form [point, point_1, point_2, ..., point_n] """ - return None # Add the logic to check if a point is in the point list here + + if point in point_list: + return point + else: + return None # Add the logic to check if a point is in the point list here def getx(point): @@ -143,6 +153,7 @@ def getx(point): : int or float x coordinate """ + return point[0]