From 52c3de5d669bad5de0557a6e4a85fb3ceafa4f68 Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Fri, 25 Sep 2020 18:41:01 +0200 Subject: [PATCH 01/10] Update pitch.py added distance_to_point function to the Pointt class --- kloppy/domain/models/pitch.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index 7e982fb4..b40ea895 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -1,6 +1,5 @@ from dataclasses import dataclass - @dataclass class Dimension: min: float @@ -25,3 +24,7 @@ class PitchDimensions: class Point: x: float y: float + + def distance_to_point(self, Point) -> int: + # returns the euclidean distance between the point and another provided point + return int(round(sum([(a - b)**2 for a, b in zip((self.x, self.y), (Point.x, Point.y))])**(1/2), 0)) From fd4d59ebe7971c1b9d495fef27a8b9f034311d03 Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Fri, 25 Sep 2020 20:18:26 +0200 Subject: [PATCH 02/10] Update pitch.py add usage of matth sqrt function --- kloppy/domain/models/pitch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index b40ea895..0dc992ea 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -1,4 +1,5 @@ from dataclasses import dataclass +from math import sqrt @dataclass class Dimension: @@ -27,4 +28,4 @@ class Point: def distance_to_point(self, Point) -> int: # returns the euclidean distance between the point and another provided point - return int(round(sum([(a - b)**2 for a, b in zip((self.x, self.y), (Point.x, Point.y))])**(1/2), 0)) + return int(round(sqrt(sum([(a - b)**2 for a, b in zip((self.x, self.y), (Point.x, Point.y))])), 0)) From 834e1a415559ff3b430836760f1c00de97e14f75 Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Fri, 25 Sep 2020 20:23:01 +0200 Subject: [PATCH 03/10] Update pitch.py edited distance_to_point function --- kloppy/domain/models/pitch.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index 0dc992ea..ce6c0659 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -26,6 +26,9 @@ class Point: x: float y: float - def distance_to_point(self, Point) -> int: + def distance_to_point(self, Point) -> float: # returns the euclidean distance between the point and another provided point - return int(round(sqrt(sum([(a - b)**2 for a, b in zip((self.x, self.y), (Point.x, Point.y))])), 0)) + return sqrt(sum(((self.x, self.y)-(Point.x, Point.y))**2)) + + + From cd30575c36e75752c7dacc67a2337a672e69fcef Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Fri, 25 Sep 2020 20:24:42 +0200 Subject: [PATCH 04/10] Update pitch.py edit of distance_to_point function --- kloppy/domain/models/pitch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index ce6c0659..c3c29caf 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -26,9 +26,9 @@ class Point: x: float y: float - def distance_to_point(self, Point) -> float: + def distance_to_point(self, other: Point) -> float: # returns the euclidean distance between the point and another provided point - return sqrt(sum(((self.x, self.y)-(Point.x, Point.y))**2)) + return sqrt(sum(((self.x, self.y)-(other.x, other.y))**2)) From e3a02d70f82a7ec6edc2c662a3bec26910932ea2 Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Fri, 25 Sep 2020 20:27:56 +0200 Subject: [PATCH 05/10] Update pitch.py another update --- kloppy/domain/models/pitch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index c3c29caf..77319019 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -28,7 +28,7 @@ class Point: def distance_to_point(self, other: Point) -> float: # returns the euclidean distance between the point and another provided point - return sqrt(sum(((self.x, self.y)-(other.x, other.y))**2)) + return sqrt(sum(((self.x, self.y)-(Point.x, Point.y))**2)) From 49110ee945512904a402735795f74453f4380b50 Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Fri, 25 Sep 2020 20:44:28 +0200 Subject: [PATCH 06/10] Update pitch.py trying to get code formatting right --- kloppy/domain/models/pitch.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index 77319019..2a06558d 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -26,9 +26,6 @@ class Point: x: float y: float - def distance_to_point(self, other: Point) -> float: + def distance_to(self, other) -> float: # returns the euclidean distance between the point and another provided point - return sqrt(sum(((self.x, self.y)-(Point.x, Point.y))**2)) - - - + return sqrt(sum([(a - b) ** 2 for a, b in zip((self.x, self.y), (other.x, other.y))])) From ff51d107f7699b628af28008feeee90cb41dd48e Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Fri, 25 Sep 2020 21:03:51 +0200 Subject: [PATCH 07/10] Update pitch.py final * hopefully --- kloppy/domain/models/pitch.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index 2a06558d..a2102e51 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -26,6 +26,6 @@ class Point: x: float y: float - def distance_to(self, other) -> float: + def distance_to(self, other: Point) -> float: # returns the euclidean distance between the point and another provided point - return sqrt(sum([(a - b) ** 2 for a, b in zip((self.x, self.y), (other.x, other.y))])) + return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2) From 5218b0a33194a7829fa3c0c2b5a015f00e2508dc Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Sat, 26 Sep 2020 06:27:28 +0200 Subject: [PATCH 08/10] Update pitch.py reformatted with black --- kloppy/domain/models/pitch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index a2102e51..7b1a8026 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -1,6 +1,7 @@ from dataclasses import dataclass from math import sqrt + @dataclass class Dimension: min: float @@ -28,4 +29,4 @@ class Point: def distance_to(self, other: Point) -> float: # returns the euclidean distance between the point and another provided point - return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2) + return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2) From 8027446e840ff3c3975663386622ac05fc2cf7d8 Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Sat, 26 Sep 2020 06:30:19 +0200 Subject: [PATCH 09/10] Update pitch.py correct point not defined --- kloppy/domain/models/pitch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index 7b1a8026..d0dbcec2 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -27,6 +27,6 @@ class Point: x: float y: float - def distance_to(self, other: Point) -> float: + def distance_to(self, other) -> float: # returns the euclidean distance between the point and another provided point return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2) From e305e0ffd15b39b7b716045b54ec35eb5b9bd546 Mon Sep 17 00:00:00 2001 From: FCrSTATS Date: Sat, 26 Sep 2020 06:44:58 +0200 Subject: [PATCH 10/10] Update pitch.py complete --- kloppy/domain/models/pitch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index d0dbcec2..582b01d2 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -27,6 +27,6 @@ class Point: x: float y: float - def distance_to(self, other) -> float: + def distance_to(self, other: "Point") -> float: # returns the euclidean distance between the point and another provided point return sqrt((self.x - other.x) ** 2 + (self.y - other.y) ** 2)