gh-111277: In summarize_stats.py, don't fail fast on invalid ratios (#111278)

This commit is contained in:
Michael Droettboom 2023-10-30 20:10:07 -04:00 committed by GitHub
parent 84b4533e84
commit 9495bcaf59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -421,8 +421,6 @@ class Ratio:
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:
@ -433,7 +431,11 @@ class Ratio:
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%}"