From a25c3b45390d3d7fab163bb5604dd26889db0362 Mon Sep 17 00:00:00 2001 From: Sagarika Kadambi Date: Sun, 7 Feb 2016 13:06:47 -0700 Subject: [PATCH 1/5] Assignment 3 functions all implemented to pass test cases --- point_pattern.py | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/point_pattern.py b/point_pattern.py index 9ae56ee..06a1337 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 @@ -11,23 +11,9 @@ """ def manhattan_distance(a, b): - """ - Compute the Manhattan distance between two points - Parameters - ---------- - a : tuple - A point in the form (x,y) - - b : tuple - A point in the form (x,y) - Returns - ------- - distance : float - The Manhattan distance between the two points - """ - distance = None # Add the algorithm to compute manhattan distance here + distance = abs(a[0]-b[0]) + abs(a[1]-b[1]) return distance @@ -49,7 +35,8 @@ def euclidean_distance(a, b): distance : float The Euclidean distance between the two points """ - distance = None # Add the euclidean distance algorithm here + sq = (a[0]-b[0])**2 + (a[1]-b[1])**2 + distance = math.sqrt(sq) return distance @@ -87,8 +74,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 +96,12 @@ def check_coincident(a, b): equal : bool Whether the points are equal """ - return None # Add the logic to check if coincident here + + if (a[0]==b[0] and a[1]==b[1]): + equal = True; + else: + equal = False; + return equal # Add the logic to check if coincident here def check_in(point, point_list): @@ -124,7 +116,12 @@ 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): + result = True + + else: + result = False + return result # Add the logic to check if a point is in the point list here def getx(point): From dd7dac24639fd2cde6a2c90503f8da7432558c44 Mon Sep 17 00:00:00 2001 From: Sagarika Kadambi Date: Mon, 8 Feb 2016 13:36:19 -0700 Subject: [PATCH 2/5] Create travis.yml --- travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 travis.yml diff --git a/travis.yml b/travis.yml new file mode 100644 index 0000000..89ffaf0 --- /dev/null +++ b/travis.yml @@ -0,0 +1,7 @@ +yml +language: python +python: + - "3.5" + +#command to run tests +script: nosetests From e02b13aad7503c3392fbd27e0c77d530151be265 Mon Sep 17 00:00:00 2001 From: Sagarika Kadambi Date: Mon, 8 Feb 2016 13:42:47 -0700 Subject: [PATCH 3/5] Delete travis.yml --- travis.yml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 travis.yml diff --git a/travis.yml b/travis.yml deleted file mode 100644 index 89ffaf0..0000000 --- a/travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -yml -language: python -python: - - "3.5" - -#command to run tests -script: nosetests From f77c05719031c2de1bcf906897a0c96a06a09661 Mon Sep 17 00:00:00 2001 From: Sagarika Kadambi Date: Mon, 8 Feb 2016 14:15:31 -0700 Subject: [PATCH 4/5] add travis.yml --- travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 travis.yml diff --git a/travis.yml b/travis.yml new file mode 100644 index 0000000..bef559c --- /dev/null +++ b/travis.yml @@ -0,0 +1,7 @@ +yml +language: python +python: + - "3.5" + +#command to run tests +script: nosetests \ No newline at end of file From ba7e3705b3ebb261c8dc73acf56403db76307ae3 Mon Sep 17 00:00:00 2001 From: Sagarika Kadambi Date: Mon, 8 Feb 2016 19:18:16 -0700 Subject: [PATCH 5/5] deleting travis.yml --- travis.yml | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 travis.yml diff --git a/travis.yml b/travis.yml deleted file mode 100644 index bef559c..0000000 --- a/travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -yml -language: python -python: - - "3.5" - -#command to run tests -script: nosetests \ No newline at end of file