From d567d407075ef60ebb2e8e4eef3be038fbfba98d Mon Sep 17 00:00:00 2001 From: BenjaminLarrousse Date: Tue, 22 Dec 2020 15:46:02 +0100 Subject: [PATCH] Fixing length and width to handle both None and 0 --- kloppy/domain/models/pitch.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kloppy/domain/models/pitch.py b/kloppy/domain/models/pitch.py index b659ebee..fb75752b 100644 --- a/kloppy/domain/models/pitch.py +++ b/kloppy/domain/models/pitch.py @@ -23,11 +23,19 @@ class PitchDimensions: @property def length(self) -> float: - return (self.x_dim.max - self.x_dim.min) / self.x_per_meter + return ( + (self.x_dim.max - self.x_dim.min) / self.x_per_meter + if self.x_per_meter + else None + ) @property def width(self) -> float: - return (self.y_dim.max - self.y_dim.min) / self.y_per_meter + return ( + (self.y_dim.max - self.y_dim.min) / self.y_per_meter + if self.y_per_meter + else None + ) @dataclass(frozen=True)