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

Skip to content

Commit e3796c2

Browse files
handle NaN case nicely in _is_sorted
Previously, the `>=` comparison would cause a "RuntimeWarning: invalid value encountered in greater_equal". Here, `np.amin` propagates NaN values appropriately and doesn't cause the warning to throw.
1 parent e6f8993 commit e3796c2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/matplotlib/lines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ def _is_sorted(self, x):
504504
"""return true if x is sorted"""
505505
if len(x) < 2:
506506
return 1
507-
return np.alltrue(x[1:] - x[0:-1] >= 0)
507+
return np.amin(x[1:] - x[0:-1]) >= 0
508508

509509
@allow_rasterization
510510
def draw(self, renderer):

0 commit comments

Comments
 (0)