@@ -209,69 +209,70 @@ def decompress_file(path, compression):
209
209
f .close ()
210
210
211
211
212
- def assert_almost_equal (left , right , check_exact = False ,
213
- check_dtype = 'equiv' , check_less_precise = False ,
214
- ** kwargs ):
212
+ def assert_almost_equal (left , right , check_dtype = "equiv" ,
213
+ check_less_precise = False , ** kwargs ):
215
214
"""
216
215
Check that the left and right objects are approximately equal.
217
216
217
+ By approximately equal, we refer to objects that are numbers or that
218
+ contain numbers which may be equivalent to specific levels of precision.
219
+
218
220
Parameters
219
221
----------
220
222
left : object
221
223
right : object
222
- check_exact : bool, default False
223
- Whether to compare number exactly.
224
224
check_dtype : bool / string {'equiv'}, default False
225
225
Check dtype if both a and b are the same type. If 'equiv' is passed in,
226
226
then `RangeIndex` and `Int64Index` are also considered equivalent
227
227
when doing type checking.
228
228
check_less_precise : bool or int, default False
229
- Specify comparison precision. Only used when `check_exact` is False.
230
- 5 digits (False) or 3 digits (True) after decimal points are compared.
231
- If int, then specify the digits to compare.
229
+ Specify comparison precision. 5 digits (False) or 3 digits (True)
230
+ after decimal points are compared. If int, then specify the number
231
+ of digits to compare.
232
232
233
233
When comparing two numbers, if the first number has magnitude less
234
234
than 1e-5, we compare the two numbers directly and check whether
235
235
they are equivalent within the specified precision. Otherwise, we
236
236
compare the **ratio** of the second number to the first number and
237
237
check whether it is equivalent to 1 within the specified precision.
238
238
"""
239
+
239
240
if isinstance (left , pd .Index ):
240
241
return assert_index_equal (left , right ,
241
- check_exact = check_exact ,
242
+ check_exact = False ,
242
243
exact = check_dtype ,
243
244
check_less_precise = check_less_precise ,
244
245
** kwargs )
245
246
246
247
elif isinstance (left , pd .Series ):
247
248
return assert_series_equal (left , right ,
248
- check_exact = check_exact ,
249
+ check_exact = False ,
249
250
check_dtype = check_dtype ,
250
251
check_less_precise = check_less_precise ,
251
252
** kwargs )
252
253
253
254
elif isinstance (left , pd .DataFrame ):
254
255
return assert_frame_equal (left , right ,
255
- check_exact = check_exact ,
256
+ check_exact = False ,
256
257
check_dtype = check_dtype ,
257
258
check_less_precise = check_less_precise ,
258
259
** kwargs )
259
260
260
261
else :
261
- # other sequences
262
+ # Other sequences.
262
263
if check_dtype :
263
264
if is_number (left ) and is_number (right ):
264
- # do not compare numeric classes, like np.float64 and float
265
+ # Do not compare numeric classes, like np.float64 and float.
265
266
pass
266
267
elif is_bool (left ) and is_bool (right ):
267
- # do not compare bool classes, like np.bool_ and bool
268
+ # Do not compare bool classes, like np.bool_ and bool.
268
269
pass
269
270
else :
270
271
if (isinstance (left , np .ndarray ) or
271
272
isinstance (right , np .ndarray )):
272
- obj = ' numpy array'
273
+ obj = " numpy array"
273
274
else :
274
- obj = ' Input'
275
+ obj = " Input"
275
276
assert_class_equal (left , right , obj = obj )
276
277
return _testing .assert_almost_equal (
277
278
left , right ,
0 commit comments