Commit b9c1966
committed
Clamp negative precision in scientific()
scientific() built its format spec as f"{{:.{int(precision)}e}}", so a
negative precision produced an invalid spec ("{:.-1e}") and raised
ValueError. This is reachable from the public API through metric(value,
precision=0): for magnitudes that fall back to scientific notation,
metric() calls scientific(value, precision - 1), i.e. scientific(value,
-1). PR #159 added the same max(0, ...) clamp to metric()'s main path but
not to scientific(). Clamp the precision to zero.1 parent c3a124c commit b9c1966
2 files changed
Lines changed: 11 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
| 419 | + | |
| 420 | + | |
420 | 421 | | |
421 | 422 | | |
422 | 423 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
221 | 225 | | |
222 | 226 | | |
223 | 227 | | |
| |||
310 | 314 | | |
311 | 315 | | |
312 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
313 | 322 | | |
314 | 323 | | |
315 | 324 | | |
| |||
0 commit comments