@@ -687,6 +687,8 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
687
687
equal_inf = True ):
688
688
__tracebackhide__ = True # Hide traceback for py.test
689
689
from numpy .core import array , isnan , inf , bool_
690
+ from numpy .core .fromnumeric import all as npall
691
+
690
692
x = array (x , copy = False , subok = True )
691
693
y = array (y , copy = False , subok = True )
692
694
@@ -697,14 +699,21 @@ def istime(x):
697
699
return x .dtype .char in "Mm"
698
700
699
701
def func_assert_same_pos (x , y , func = isnan , hasval = 'nan' ):
700
- """Handling nan/inf: combine results of running func on x and y,
701
- checking that they are True at the same locations."""
702
- # Both the != True comparison here and the cast to bool_ at
703
- # the end are done to deal with `masked`, which cannot be
704
- # compared usefully, and for which .all() yields masked.
702
+ """Handling nan/inf.
703
+
704
+ Combine results of running func on x and y, checking that they are True
705
+ at the same locations.
706
+
707
+ """
708
+ # Both the != True comparison here and the cast to bool_ at the end are
709
+ # done to deal with `masked`, which cannot be compared usefully, and
710
+ # for which np.all yields masked. The use of the function np.all is
711
+ # for back compatibility with ndarray subclasses that changed the
712
+ # return values of the all method. We are not committed to supporting
713
+ # such subclasses, but some used to work.
705
714
x_id = func (x )
706
715
y_id = func (y )
707
- if (x_id == y_id ). all ( ) != True :
716
+ if npall (x_id == y_id ) != True :
708
717
msg = build_err_msg ([x , y ],
709
718
err_msg + '\n x and y %s location mismatch:'
710
719
% (hasval ), verbose = verbose , header = header ,
0 commit comments