Skip to content

Commit

Permalink
pythongh-111277: In summarize_stats.py, don't fail fast on invalid ra…
Browse files Browse the repository at this point in the history
…tios (python#111278)
  • Loading branch information
mdboom committed Oct 31, 2023
1 parent 84b4533 commit 9495bca
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Tools/scripts/summarize_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,6 @@ def __init__(self, num: int, den: int | None, percentage: bool = True):
self.num = num
self.den = den
self.percentage = percentage
if den == 0 and num != 0:
raise ValueError("Invalid denominator")

def __float__(self):
if self.den == 0:
Expand All @@ -433,7 +431,11 @@ def __float__(self):
return self.num / self.den

def markdown(self) -> str:
if self.den == 0 or self.den is None:
if self.den is None:
return ""
elif self.den == 0:
if self.num != 0:
return f"{self.num:,} / 0 !!"
return ""
elif self.percentage:
return f"{self.num / self.den:,.01%}"
Expand Down

0 comments on commit 9495bca

Please sign in to comment.