Skip to content

Commit

Permalink
Fixing length and width to handle both None and 0
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminLarrousse committed Dec 22, 2020
1 parent 489cb7c commit d567d40
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kloppy/domain/models/pitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d567d40

Please sign in to comment.