File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -440,7 +440,10 @@ def assert_is_sorted(seq) -> None:
440440 if isinstance (seq , (Index , Series )):
441441 seq = seq .values
442442 # sorting does not change precisions
443- assert_numpy_array_equal (seq , np .sort (np .array (seq )))
443+ if isinstance (seq , np .ndarray ):
444+ assert_numpy_array_equal (seq , np .sort (np .array (seq )))
445+ else :
446+ assert_extension_array_equal (seq , seq [seq .argsort ()])
444447
445448
446449def assert_categorical_equal (
Original file line number Diff line number Diff line change 22
33import pytest
44
5- from pandas import compat
5+ from pandas import (
6+ array ,
7+ compat ,
8+ )
69import pandas ._testing as tm
710
811
@@ -44,3 +47,12 @@ def test_datapath(datapath):
4447def test_external_error_raised ():
4548 with tm .external_error_raised (TypeError ):
4649 raise TypeError ("Should not check this error message, so it will pass" )
50+
51+
52+ def test_is_sorted ():
53+ arr = array ([1 , 2 , 3 ], dtype = "Int64" )
54+ tm .assert_is_sorted (arr )
55+
56+ arr = array ([4 , 2 , 3 ], dtype = "Int64" )
57+ with pytest .raises (AssertionError , match = "ExtensionArray are different" ):
58+ tm .assert_is_sorted (arr )
You can’t perform that action at this time.
0 commit comments