mirror of https://github.com/python/cpython
gh-111277: In summarize_stats.py, don't fail fast on invalid ratios (#111278)
This commit is contained in:
parent
84b4533e84
commit
9495bcaf59
|
@ -421,8 +421,6 @@ class Ratio:
|
||||||
self.num = num
|
self.num = num
|
||||||
self.den = den
|
self.den = den
|
||||||
self.percentage = percentage
|
self.percentage = percentage
|
||||||
if den == 0 and num != 0:
|
|
||||||
raise ValueError("Invalid denominator")
|
|
||||||
|
|
||||||
def __float__(self):
|
def __float__(self):
|
||||||
if self.den == 0:
|
if self.den == 0:
|
||||||
|
@ -433,7 +431,11 @@ class Ratio:
|
||||||
return self.num / self.den
|
return self.num / self.den
|
||||||
|
|
||||||
def markdown(self) -> str:
|
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 ""
|
return ""
|
||||||
elif self.percentage:
|
elif self.percentage:
|
||||||
return f"{self.num / self.den:,.01%}"
|
return f"{self.num / self.den:,.01%}"
|
||||||
|
|
Loading…
Reference in New Issue