diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..87a047a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +language: python +python: + - "3.5" + +#command to run tests + script: nosetests + diff --git a/point_pattern.py b/point_pattern.py index 9ae56ee..d7dca57 100644 --- a/point_pattern.py +++ b/point_pattern.py @@ -1,4 +1,4 @@ -import math # I am guessing that you will need to use the math module +import math """ Below are 5 functions (we will talk about what @@ -27,7 +27,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 = (abs(b[0]-a[0]) + abs(b[1]-a[1])) return distance @@ -49,7 +49,7 @@ def euclidean_distance(a, b): distance : float The Euclidean distance between the two points """ - distance = None # Add the euclidean distance algorithm here + distance = math.sqrt((a[0] - b[0])**2) + ((a[1] - b[1])**2)) # Add the euclidean distance algorithm here return distance @@ -71,7 +71,7 @@ def shift_point(point, x_shift, y_shift): Returns ------- new_x : int or float - shited x coordinate + shifted x coordinate new_y : int or float shifted y coordinate @@ -87,8 +87,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 + x_shift # Add the logic to shift x here + y_new = y + y_shift # Add the logic to shift y here return x_new, y_new @@ -109,7 +109,11 @@ 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: + coincident_parameters = True + + return coincident_parameters + def check_in(point, point_list): @@ -124,8 +128,10 @@ 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 + return point in point_list + + def getx(point): """