Skip to content

Commit bf23a2b

Browse files
committed
Use np.isclose(_, 0) for negative/positive/nozero
1 parent f33edfe commit bf23a2b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

proplot/axes/plot.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,12 +2489,15 @@ def _parse_level_list(
24892489
# NOTE: This should have no effect if levels were generated automatically.
24902490
# However want to apply these to manual-input levels as well.
24912491
def _restrict_levels(levels):
2492+
kw = {}
2493+
if len(levels) > 2:
2494+
kw['atol'] = 1e-5 * np.min(np.diff(levels))
24922495
if nozero:
2493-
levels = levels[levels != 0]
2496+
levels = [lev for lev in levels if not np.isclose(lev, 0, **kw)]
24942497
if positive:
2495-
levels = levels[levels >= 0]
2498+
levels = [lev for lev in levels if lev > 0 or np.isclose(lev, 0, **kw)]
24962499
if negative:
2497-
levels = levels[levels <= 0]
2500+
levels = [lev for lev in levels if lev < 0 or np.isclose(lev, 0, **kw)]
24982501
return levels
24992502

25002503
# Helper function to sanitize input levels

0 commit comments

Comments
 (0)