@@ -7,17 +7,14 @@ from numpy cimport import_array
7
7
8
8
import_array()
9
9
10
+ from pandas._libs.missing cimport checknull
10
11
from pandas._libs.util cimport (
11
12
is_array,
12
13
is_complex_object,
13
14
is_real_number_object,
14
15
)
15
16
16
- from pandas.core.dtypes.common import is_dtype_equal
17
- from pandas.core.dtypes.missing import (
18
- array_equivalent,
19
- isna,
20
- )
17
+ from pandas.core.dtypes.missing import array_equivalent
21
18
22
19
23
20
cdef bint isiterable(obj):
@@ -133,7 +130,7 @@ cpdef assert_almost_equal(a, b,
133
130
raise_assert_detail(
134
131
obj, f" {obj} shapes are different" , a.shape, b.shape)
135
132
136
- if check_dtype and not is_dtype_equal( a.dtype, b.dtype) :
133
+ if check_dtype and a.dtype ! = b.dtype:
137
134
from pandas._testing import assert_attr_equal
138
135
assert_attr_equal(" dtype" , a, b, obj = obj)
139
136
@@ -181,12 +178,12 @@ cpdef assert_almost_equal(a, b,
181
178
# classes can't be the same, to raise error
182
179
assert_class_equal(a, b, obj = obj)
183
180
184
- if isna (a) and isna (b):
181
+ if checknull (a) and checknull (b):
185
182
# TODO: Should require same-dtype NA?
186
183
# nan / None comparison
187
184
return True
188
185
189
- if isna( a) and not isna (b) or not isna (a) and isna(b ):
186
+ if (checknull( a) and not checknull (b)) or ( not checknull (a) and checknull(b) ):
190
187
# boolean value of pd.NA is ambiguous
191
188
raise AssertionError (f" {a} != {b}" )
192
189
@@ -195,10 +192,6 @@ cpdef assert_almost_equal(a, b,
195
192
return True
196
193
197
194
if is_real_number_object(a) and is_real_number_object(b):
198
- if array_equivalent(a, b, strict_nan = True ):
199
- # inf comparison
200
- return True
201
-
202
195
fa, fb = a, b
203
196
204
197
if not math.isclose(fa, fb, rel_tol = rtol, abs_tol = atol):
@@ -207,10 +200,6 @@ cpdef assert_almost_equal(a, b,
207
200
return True
208
201
209
202
if is_complex_object(a) and is_complex_object(b):
210
- if array_equivalent(a, b, strict_nan = True ):
211
- # inf comparison
212
- return True
213
-
214
203
if not cmath.isclose(a, b, rel_tol = rtol, abs_tol = atol):
215
204
assert False , (f" expected {b:.5f} but got {a:.5f}, "
216
205
f" with rtol={rtol}, atol={atol}" )
0 commit comments