Skip to content

TST: fix 217 incorrect skips #44810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ class DatetimeIndexOpsMixin(NDArrayBackedExtensionIndex):
freq: BaseOffset | None
freqstr: str | None
_resolution_obj: Resolution
_bool_ops: list[str] = []
_field_ops: list[str] = []

# error: "Callable[[Any], Any]" has no attribute "fget"
hasnans = cast(
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/arrays/floating/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def test_floating_array_disallows_float16(request):
):
# the locale condition may need to be refined; this fails on
# the CI in the ZH_CN build
# https://github.com/numpy/numpy/issues/20512
mark = pytest.mark.xfail(reason="numpy does not raise on np.dtype('Float16')")
request.node.add_marker(mark)

Expand Down
16 changes: 10 additions & 6 deletions pandas/tests/arrays/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ def test_to_period_2d(self, arr1d):
expected = arr1d.to_period("D").reshape(1, -1)
tm.assert_period_array_equal(result, expected)

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

tm.assert_numpy_array_equal(result, expected)

@pytest.mark.parametrize("propname", DatetimeIndex._field_ops)
@pytest.mark.parametrize("propname", DatetimeArray._field_ops)
def test_int_properties(self, arr1d, propname):
warn = None
msg = "weekofyear and week have been deprecated, please use"
if propname in ["week", "weekofyear"]:
# GH#33595 Deprecate week and weekofyear
return
warn = FutureWarning

dti = self.index_cls(arr1d)
arr = arr1d

result = getattr(arr, propname)
expected = np.array(getattr(dti, propname), dtype=result.dtype)
with tm.assert_produces_warning(warn, match=msg):
result = getattr(arr, propname)
expected = np.array(getattr(dti, propname), dtype=result.dtype)

tm.assert_numpy_array_equal(result, expected)

Expand Down Expand Up @@ -979,7 +983,7 @@ def test_total_seconds(self, timedelta_index):

tm.assert_numpy_array_equal(result, expected.values)

@pytest.mark.parametrize("propname", TimedeltaIndex._field_ops)
@pytest.mark.parametrize("propname", TimedeltaArray._field_ops)
def test_int_properties(self, timedelta_index, propname):
tdi = timedelta_index
arr = TimedeltaArray(tdi)
Expand Down
36 changes: 13 additions & 23 deletions pandas/tests/extension/base/dim2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
import pytest

from pandas._libs.missing import is_matching_na
from pandas.compat import (
IS64,
is_platform_windows,
)

import pandas as pd
from pandas.core.arrays.integer import INT_STR_TO_DTYPE
from pandas.tests.extension.base.base import BaseExtensionTests


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

def get_reduction_result_dtype(dtype):
# windows and 32bit builds will in some cases have int32/uint32
# where other builds will have int64/uint64.
if dtype.itemsize == 8:
return dtype
elif dtype.kind in "ib":
return INT_STR_TO_DTYPE[np.dtype(int).name]
else:
# i.e. dtype.kind == "u"
return INT_STR_TO_DTYPE[np.dtype(np.uint).name]

if method in ["mean", "median", "sum", "prod"]:
# std and var are not dtype-preserving
expected = data
if method in ["sum", "prod"] and data.dtype.kind in "iub":
# FIXME: kludge
if data.dtype.kind in ["i", "b"]:
if is_platform_windows() or not IS64:
# FIXME: kludge for 32bit builds
if result.dtype.itemsize == 4:
dtype = pd.Int32Dtype()
else:
dtype = pd.Int64Dtype()
else:
dtype = pd.Int64Dtype()
elif data.dtype.kind == "u":
if is_platform_windows() or not IS64:
# FIXME: kludge for 32bit builds
if result.dtype.itemsize == 4:
dtype = pd.UInt32Dtype()
else:
dtype = pd.UInt64Dtype()
else:
dtype = pd.UInt64Dtype()
dtype = get_reduction_result_dtype(data.dtype)

expected = data.astype(dtype)
if data.dtype.kind == "b" and method in ["sum", "prod"]:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/scalar/test_nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"nat,idx",
[
(Timestamp("NaT"), DatetimeArray),
(Timedelta("NaT"), TimedeltaIndex),
(Timedelta("NaT"), TimedeltaArray),
(Period("NaT", freq="M"), PeriodArray),
],
)
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_nat_fields(nat, idx):
def test_nat_vector_field_access():
idx = DatetimeIndex(["1/1/2000", None, None, "1/4/2000"])

for field in DatetimeIndex._field_ops:
for field in DatetimeArray._field_ops:
# weekday is a property of DTI, but a method
# on NaT/Timestamp for compat with datetime
if field == "weekday":
Expand Down