File tree 3 files changed +14
-0
lines changed
3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ from pandas._libs.lib import is_complex
11
11
from pandas._libs.util cimport is_array, is_real_number_object
12
12
13
13
from pandas.core.dtypes.common import is_dtype_equal
14
+ from pandas.core.dtypes.inference import is_array_like
14
15
from pandas.core.dtypes.missing import array_equivalent, isna
15
16
16
17
Original file line number Diff line number Diff line change @@ -424,6 +424,11 @@ def array_equivalent(
424
424
# Slow path when we allow comparing different dtypes.
425
425
# Object arrays can contain None, NaN and NaT.
426
426
# string dtypes must be come to this path for NumPy 1.7.1 compat
427
+ try :
428
+ return np .array_equal (left , right )
429
+ except :
430
+ pass
431
+
427
432
if is_string_dtype (left .dtype ) or is_string_dtype (right .dtype ):
428
433
return _array_equivalent_object (left , right , strict_nan )
429
434
Original file line number Diff line number Diff line change @@ -209,6 +209,8 @@ def test_is_array_like():
209
209
assert inference .is_array_like (Series ([1 , 2 ]))
210
210
assert inference .is_array_like (np .array (["a" , "b" ]))
211
211
assert inference .is_array_like (Index (["2016-01-01" ]))
212
+ assert inference .is_array_like (np .array ([2 , 3 ]))
213
+ assert inference .is_array_like (MockNumpyLikeArray (np .array ([2 , 3 ])))
212
214
213
215
class DtypeList (list ):
214
216
dtype = "special"
@@ -221,6 +223,12 @@ class DtypeList(list):
221
223
assert not inference .is_array_like (123 )
222
224
223
225
226
+ def test_assert_almost_equal ():
227
+ tm .assert_almost_equal (np .array (2 ), np .array (2 ))
228
+ eg = MockNumpyLikeArray (np .array (2 ))
229
+ tm .assert_almost_equal (eg , eg )
230
+
231
+
224
232
@pytest .mark .parametrize (
225
233
"eg" ,
226
234
(
You can’t perform that action at this time.
0 commit comments