Skip to content

Commit 41680b1

Browse files
authored
TST: fix 217 incorrect skips (#44810)
1 parent 2b756ad commit 41680b1

File tree

5 files changed

+26
-33
lines changed

5 files changed

+26
-33
lines changed

pandas/core/indexes/datetimelike.py

-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ class DatetimeIndexOpsMixin(NDArrayBackedExtensionIndex):
9292
freq: BaseOffset | None
9393
freqstr: str | None
9494
_resolution_obj: Resolution
95-
_bool_ops: list[str] = []
96-
_field_ops: list[str] = []
9795

9896
# error: "Callable[[Any], Any]" has no attribute "fget"
9997
hasnans = cast(

pandas/tests/arrays/floating/test_construction.py

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_floating_array_disallows_float16(request):
6161
):
6262
# the locale condition may need to be refined; this fails on
6363
# the CI in the ZH_CN build
64+
# https://github.com/numpy/numpy/issues/20512
6465
mark = pytest.mark.xfail(reason="numpy does not raise on np.dtype('Float16')")
6566
request.node.add_marker(mark)
6667

pandas/tests/arrays/test_datetimelike.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ def test_to_period_2d(self, arr1d):
814814
expected = arr1d.to_period("D").reshape(1, -1)
815815
tm.assert_period_array_equal(result, expected)
816816

817-
@pytest.mark.parametrize("propname", DatetimeIndex._bool_ops)
817+
@pytest.mark.parametrize("propname", DatetimeArray._bool_ops)
818818
def test_bool_properties(self, arr1d, propname):
819819
# in this case _bool_ops is just `is_leap_year`
820820
dti = self.index_cls(arr1d)
@@ -826,16 +826,20 @@ def test_bool_properties(self, arr1d, propname):
826826

827827
tm.assert_numpy_array_equal(result, expected)
828828

829-
@pytest.mark.parametrize("propname", DatetimeIndex._field_ops)
829+
@pytest.mark.parametrize("propname", DatetimeArray._field_ops)
830830
def test_int_properties(self, arr1d, propname):
831+
warn = None
832+
msg = "weekofyear and week have been deprecated, please use"
831833
if propname in ["week", "weekofyear"]:
832834
# GH#33595 Deprecate week and weekofyear
833-
return
835+
warn = FutureWarning
836+
834837
dti = self.index_cls(arr1d)
835838
arr = arr1d
836839

837-
result = getattr(arr, propname)
838-
expected = np.array(getattr(dti, propname), dtype=result.dtype)
840+
with tm.assert_produces_warning(warn, match=msg):
841+
result = getattr(arr, propname)
842+
expected = np.array(getattr(dti, propname), dtype=result.dtype)
839843

840844
tm.assert_numpy_array_equal(result, expected)
841845

@@ -979,7 +983,7 @@ def test_total_seconds(self, timedelta_index):
979983

980984
tm.assert_numpy_array_equal(result, expected.values)
981985

982-
@pytest.mark.parametrize("propname", TimedeltaIndex._field_ops)
986+
@pytest.mark.parametrize("propname", TimedeltaArray._field_ops)
983987
def test_int_properties(self, timedelta_index, propname):
984988
tdi = timedelta_index
985989
arr = TimedeltaArray(tdi)

pandas/tests/extension/base/dim2.py

+13-23
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
import pytest
66

77
from pandas._libs.missing import is_matching_na
8-
from pandas.compat import (
9-
IS64,
10-
is_platform_windows,
11-
)
128

139
import pandas as pd
10+
from pandas.core.arrays.integer import INT_STR_TO_DTYPE
1411
from pandas.tests.extension.base.base import BaseExtensionTests
1512

1613

@@ -203,29 +200,22 @@ def test_reductions_2d_axis0(self, data, method, request):
203200
else:
204201
raise AssertionError("Both reductions should raise or neither")
205202

203+
def get_reduction_result_dtype(dtype):
204+
# windows and 32bit builds will in some cases have int32/uint32
205+
# where other builds will have int64/uint64.
206+
if dtype.itemsize == 8:
207+
return dtype
208+
elif dtype.kind in "ib":
209+
return INT_STR_TO_DTYPE[np.dtype(int).name]
210+
else:
211+
# i.e. dtype.kind == "u"
212+
return INT_STR_TO_DTYPE[np.dtype(np.uint).name]
213+
206214
if method in ["mean", "median", "sum", "prod"]:
207215
# std and var are not dtype-preserving
208216
expected = data
209217
if method in ["sum", "prod"] and data.dtype.kind in "iub":
210-
# FIXME: kludge
211-
if data.dtype.kind in ["i", "b"]:
212-
if is_platform_windows() or not IS64:
213-
# FIXME: kludge for 32bit builds
214-
if result.dtype.itemsize == 4:
215-
dtype = pd.Int32Dtype()
216-
else:
217-
dtype = pd.Int64Dtype()
218-
else:
219-
dtype = pd.Int64Dtype()
220-
elif data.dtype.kind == "u":
221-
if is_platform_windows() or not IS64:
222-
# FIXME: kludge for 32bit builds
223-
if result.dtype.itemsize == 4:
224-
dtype = pd.UInt32Dtype()
225-
else:
226-
dtype = pd.UInt64Dtype()
227-
else:
228-
dtype = pd.UInt64Dtype()
218+
dtype = get_reduction_result_dtype(data.dtype)
229219

230220
expected = data.astype(dtype)
231221
if data.dtype.kind == "b" and method in ["sum", "prod"]:

pandas/tests/scalar/test_nat.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"nat,idx",
3939
[
4040
(Timestamp("NaT"), DatetimeArray),
41-
(Timedelta("NaT"), TimedeltaIndex),
41+
(Timedelta("NaT"), TimedeltaArray),
4242
(Period("NaT", freq="M"), PeriodArray),
4343
],
4444
)
@@ -68,7 +68,7 @@ def test_nat_fields(nat, idx):
6868
def test_nat_vector_field_access():
6969
idx = DatetimeIndex(["1/1/2000", None, None, "1/4/2000"])
7070

71-
for field in DatetimeIndex._field_ops:
71+
for field in DatetimeArray._field_ops:
7272
# weekday is a property of DTI, but a method
7373
# on NaT/Timestamp for compat with datetime
7474
if field == "weekday":

0 commit comments

Comments
 (0)