Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e356a15

Browse files
committed
Make transforms.nonsingular handle inf and nan sensibly.
Without this, trying to plot a line with all data masked would raise an exception via the autoscaling. svn path=/trunk/matplotlib/; revision=6232
1 parent 321675d commit e356a15

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/matplotlib/transforms.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2157,15 +2157,19 @@ def get_affine(self):
21572157

21582158
def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):
21592159
'''
2160-
Ensure the endpoints of a range are not too close together.
2160+
Ensure the endpoints of a range are finite and not too close together.
21612161
21622162
"too close" means the interval is smaller than 'tiny' times
21632163
the maximum absolute value.
21642164
21652165
If they are too close, each will be moved by the 'expander'.
21662166
If 'increasing' is True and vmin > vmax, they will be swapped,
21672167
regardless of whether they are too close.
2168+
2169+
If either is inf or -inf or nan, return - expander, expander.
21682170
'''
2171+
if (not np.isfinite(vmin)) or (not np.isfinite(vmax)):
2172+
return -expander, expander
21692173
swapped = False
21702174
if vmax < vmin:
21712175
vmin, vmax = vmax, vmin

0 commit comments

Comments
 (0)