Skip to content

Commit a600b23

Browse files
authored
test: avoid exact float comparison in test_apply_lambda (#1795)
* test: avoid exact float comparison in `test_apply_lambda` * use by_row=False in apply_simple_udf too
1 parent 1d45646 commit a600b23

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/system/small/test_series.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4285,13 +4285,16 @@ def test_apply_lambda(scalars_dfs, col, lambda_):
42854285
bf_result = bf_col.apply(lambda_, by_row=False).to_pandas()
42864286

42874287
pd_col = scalars_pandas_df[col]
4288-
if pd.__version__.startswith("2.2"):
4288+
if pd.__version__[:3] in ("2.2", "2.3"):
42894289
pd_result = pd_col.apply(lambda_, by_row=False)
42904290
else:
42914291
pd_result = pd_col.apply(lambda_)
42924292

42934293
# ignore dtype check, which are Int64 and object respectively
4294-
assert_series_equal(bf_result, pd_result, check_dtype=False)
4294+
# Some columns implicitly convert to floating point. Use check_exact=False to ensure we're "close enough"
4295+
assert_series_equal(
4296+
bf_result, pd_result, check_dtype=False, check_exact=False, rtol=0.001
4297+
)
42954298

42964299

42974300
@pytest.mark.parametrize(
@@ -4375,13 +4378,16 @@ def foo(x):
43754378

43764379
pd_col = scalars_pandas_df["int64_col"]
43774380

4378-
if pd.__version__.startswith("2.2"):
4381+
if pd.__version__[:3] in ("2.2", "2.3"):
43794382
pd_result = pd_col.apply(foo, by_row=False)
43804383
else:
43814384
pd_result = pd_col.apply(foo)
43824385

43834386
# ignore dtype check, which are Int64 and object respectively
4384-
assert_series_equal(bf_result, pd_result, check_dtype=False)
4387+
# Some columns implicitly convert to floating point. Use check_exact=False to ensure we're "close enough"
4388+
assert_series_equal(
4389+
bf_result, pd_result, check_dtype=False, check_exact=False, rtol=0.001
4390+
)
43854391

43864392

43874393
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)