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:
440
440
if isinstance (seq , (Index , Series )):
441
441
seq = seq .values
442
442
# 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 ()])
444
447
445
448
446
449
def assert_categorical_equal (
Original file line number Diff line number Diff line change 2
2
3
3
import pytest
4
4
5
- from pandas import compat
5
+ from pandas import (
6
+ array ,
7
+ compat ,
8
+ )
6
9
import pandas ._testing as tm
7
10
8
11
@@ -44,3 +47,12 @@ def test_datapath(datapath):
44
47
def test_external_error_raised ():
45
48
with tm .external_error_raised (TypeError ):
46
49
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