Skip to content

Commit bc3abed

Browse files
misc. small fixes
1 parent 7a7418a commit bc3abed

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

pandas/tests/libs/test_ops.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import operator
2+
from platform import architecture
23

34
import numpy as np
45
import pytest
@@ -17,12 +18,12 @@ def fixture_int_min() -> int:
1718

1819

1920
@pytest.fixture(name="float_max", scope="module")
20-
def fixture_float_max() -> int:
21+
def fixture_float_max() -> np.float64:
2122
return np.finfo(np.float64).max
2223

2324

2425
@pytest.fixture(name="float_min", scope="module")
25-
def fixture_float_min() -> int:
26+
def fixture_float_min() -> np.float64:
2627
return np.finfo(np.float64).min
2728

2829

@@ -130,7 +131,15 @@ def test_raises_for_too_large_result(
130131
strict=True,
131132
),
132133
),
133-
1024.1,
134+
pytest.param(
135+
1024.1,
136+
marks=pytest.mark.xfail(
137+
condition=architecture()[0] == "32bit",
138+
reason="overflows earlier",
139+
raises=pytest.fail.Exception,
140+
strict=True,
141+
),
142+
),
134143
),
135144
)
136145
def test_raises_for_most_too_small_results(

pandas/tests/scalar/timedelta/test_arithmetic.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import numpy as np
1515
import pytest
1616

17-
from pandas._libs.tslibs import OutOfBoundsTimedelta
17+
from pandas._libs.tslibs import (
18+
NaTType,
19+
OutOfBoundsTimedelta,
20+
)
1821

1922
import pandas as pd
2023
from pandas import (
@@ -33,6 +36,7 @@ def fixture_tdlike_cls(request) -> type:
3336
return request.param
3437

3538

39+
# Tick, too?
3640
@pytest.fixture(
3741
name="tdlike_or_offset_cls",
3842
params=(Timedelta, timedelta, np.timedelta64, offsets.Nano),
@@ -437,9 +441,9 @@ def test_numeric(self, ten_days, mul_op, factor, expected, box_with_array):
437441
@pytest.mark.parametrize("factor", (1.01, 2), ids=("int", "float"))
438442
def test_returns_nat_if_result_overflows(self, mul_op, factor, box_with_array):
439443
numeric_box = tm.box_expected((1, factor), box_with_array, transpose=False)
440-
result = mul_op(pd.Timedelta.max, numeric_box)
444+
result = mul_op(Timedelta.max, numeric_box)
441445
expected = tm.box_expected(
442-
(pd.Timedelta.max, NaT),
446+
(Timedelta.max, NaT),
443447
box_with_array,
444448
transpose=False,
445449
)
@@ -574,22 +578,25 @@ def test_offset(self, ten_days: Timedelta, div_op, expected):
574578
assert result == expected
575579

576580
def test_na(self, request, ten_days: Timedelta, truediv_op, na_value):
577-
expected = NaT
578-
if na_value is NA or (
581+
expected: NaTType | float = NaT
582+
583+
if na_value is None or na_value is NaT:
584+
expected = np.nan
585+
elif na_value is NA or (
579586
truediv_op is ops.rtruediv and isinstance(na_value, float)
580587
):
581588
request.applymarker(xfail_type_error)
582-
elif na_value is None or na_value is NaT:
583-
expected = np.nan
589+
584590
result = truediv_op(ten_days, na_value)
585591
assert result is expected
586592

587593
def test_floordiv_na(self, request, ten_days: Timedelta, na_value):
588-
expected = NaT
589-
if na_value is NA:
590-
request.applymarker(xfail_type_error)
591-
elif na_value is None or na_value is NaT:
594+
expected: NaTType | float = NaT
595+
596+
if na_value is None or na_value is NaT:
592597
expected = np.nan
598+
elif na_value is NA:
599+
request.applymarker(xfail_type_error)
593600

594601
result = ten_days // na_value
595602
assert result is expected
@@ -618,7 +625,8 @@ def test_rmod_na(self, request, ten_days: Timedelta, na_value):
618625
assert result is NaT
619626

620627
def test_divmod_na(self, request, ten_days: Timedelta, na_value):
621-
expected = (NaT, NaT)
628+
expected: tuple[NaTType | float, NaTType] = (NaT, NaT)
629+
622630
if na_value is None or na_value is NA:
623631
request.applymarker(xfail_type_error)
624632
elif na_value is NaT:

0 commit comments

Comments
 (0)