Skip to content

Commit ed4cee0

Browse files
authored
GH-45926: [Python] Use pytest.approx for float values on unbiased skew and kurtosis tests (#45929)
### Rationale for this change The test fails on test-debian-12-python-3-i386 due to accuracy ### What changes are included in this PR? Use pytest.approx instead of hardcoded float value ### Are these changes tested? Yes via CI ### Are there any user-facing changes? No * GitHub Issue: #45926 Authored-by: Raúl Cumplido <[email protected]> Signed-off-by: Raúl Cumplido <[email protected]>
1 parent ae801e1 commit ed4cee0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

python/pyarrow/tests/test_compute.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,17 @@ def test_kurtosis():
461461
@pytest.mark.parametrize("input, expected", (
462462
(
463463
[1.0, 2.0, 3.0, 40.0, None],
464-
{'skew': 1.988947740397821, 'kurtosis': 3.9631931024230695}
464+
{'skew': pytest.approx(1.988947740397821),
465+
'kurtosis': pytest.approx(3.9631931024230695)}
465466
),
466-
([1, 2, 40], {'skew': 1.7281098503730385, 'kurtosis': None}),
467+
([1, 2, 40], {'skew': pytest.approx(1.7281098503730385), 'kurtosis': None}),
467468
([1, 40], {'skew': None, 'kurtosis': None}),
468469
))
469470
def test_unbiased_skew_and_kurtosis(input, expected):
470471
arrow_skew = pc.skew(input, skip_nulls=True, biased=False)
471472
arrow_kurtosis = pc.kurtosis(input, skip_nulls=True, biased=False)
472-
assert arrow_skew == pa.scalar(expected['skew'], type=pa.float64())
473-
assert arrow_kurtosis == pa.scalar(expected['kurtosis'], type=pa.float64())
473+
assert arrow_skew.as_py() == expected['skew']
474+
assert arrow_kurtosis.as_py() == expected['kurtosis']
474475

475476

476477
def test_count_substring():

0 commit comments

Comments
 (0)