Skip to content

Commit cf60236

Browse files
gfyoungvictor
authored and
victor
committed
TST: Remove check_exact from assert_almost_equal (pandas-dev#21756)
1 parent 10abc40 commit cf60236

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

pandas/util/testing.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -209,69 +209,70 @@ def decompress_file(path, compression):
209209
f.close()
210210

211211

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):
215214
"""
216215
Check that the left and right objects are approximately equal.
217216
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+
218220
Parameters
219221
----------
220222
left : object
221223
right : object
222-
check_exact : bool, default False
223-
Whether to compare number exactly.
224224
check_dtype : bool / string {'equiv'}, default False
225225
Check dtype if both a and b are the same type. If 'equiv' is passed in,
226226
then `RangeIndex` and `Int64Index` are also considered equivalent
227227
when doing type checking.
228228
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.
232232
233233
When comparing two numbers, if the first number has magnitude less
234234
than 1e-5, we compare the two numbers directly and check whether
235235
they are equivalent within the specified precision. Otherwise, we
236236
compare the **ratio** of the second number to the first number and
237237
check whether it is equivalent to 1 within the specified precision.
238238
"""
239+
239240
if isinstance(left, pd.Index):
240241
return assert_index_equal(left, right,
241-
check_exact=check_exact,
242+
check_exact=False,
242243
exact=check_dtype,
243244
check_less_precise=check_less_precise,
244245
**kwargs)
245246

246247
elif isinstance(left, pd.Series):
247248
return assert_series_equal(left, right,
248-
check_exact=check_exact,
249+
check_exact=False,
249250
check_dtype=check_dtype,
250251
check_less_precise=check_less_precise,
251252
**kwargs)
252253

253254
elif isinstance(left, pd.DataFrame):
254255
return assert_frame_equal(left, right,
255-
check_exact=check_exact,
256+
check_exact=False,
256257
check_dtype=check_dtype,
257258
check_less_precise=check_less_precise,
258259
**kwargs)
259260

260261
else:
261-
# other sequences
262+
# Other sequences.
262263
if check_dtype:
263264
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.
265266
pass
266267
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.
268269
pass
269270
else:
270271
if (isinstance(left, np.ndarray) or
271272
isinstance(right, np.ndarray)):
272-
obj = 'numpy array'
273+
obj = "numpy array"
273274
else:
274-
obj = 'Input'
275+
obj = "Input"
275276
assert_class_equal(left, right, obj=obj)
276277
return _testing.assert_almost_equal(
277278
left, right,

0 commit comments

Comments
 (0)