Skip to content
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

TST: test UInt64Index in tests/indexes/interval/test_constructors.py #49785

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions pandas/tests/indexes/interval/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
timedelta_range,
)
import pandas._testing as tm
from pandas.api.types import is_unsigned_integer_dtype
from pandas.core.api import (
Float64Index,
Int64Index,
UInt64Index,
)
from pandas.core.arrays import IntervalArray
import pandas.core.common as com
Expand All @@ -38,19 +40,27 @@ class ConstructorTests:
get_kwargs_from_breaks to the expected format.
"""

# get_kwargs_from_breaks in TestFromTuples and TestClassconstructors just return
# tuples of ints, so IntervalIndex can't know the original dtype was uint
_skip_test_constructor_if_uint = False

@pytest.mark.parametrize(
"breaks",
[
[3, 14, 15, 92, 653],
np.arange(10, dtype="int64"),
Int64Index(range(-10, 11)),
UInt64Index(range(10, 31)),
Float64Index(np.arange(20, 30, 0.5)),
date_range("20180101", periods=10),
date_range("20180101", periods=10, tz="US/Eastern"),
timedelta_range("1 day", periods=10),
],
)
def test_constructor(self, constructor, breaks, closed, name):
if self._skip_test_constructor_if_uint and is_unsigned_integer_dtype(breaks):
pytest.skip(reason=f"uint dtype isn't kept for tests in class {type(self)}")

result_kwargs = self.get_kwargs_from_breaks(breaks, closed)
result = constructor(closed=closed, name=name, **result_kwargs)

Expand Down Expand Up @@ -294,6 +304,8 @@ def test_left_right_dont_share_data(self):
class TestFromTuples(ConstructorTests):
"""Tests specific to IntervalIndex.from_tuples"""

_skip_test_constructor_if_uint = True

@pytest.fixture
def constructor(self):
return IntervalIndex.from_tuples
Expand Down Expand Up @@ -341,6 +353,8 @@ def test_na_tuples(self):
class TestClassConstructors(ConstructorTests):
"""Tests specific to the IntervalIndex/Index constructors"""

_skip_test_constructor_if_uint = True

@pytest.fixture(
params=[IntervalIndex, partial(Index, dtype="interval")],
ids=["IntervalIndex", "Index"],
Expand Down