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

Clean up TimedeltaIndex.__init__ constructor #14775

Merged
merged 4 commits into from
Jan 19, 2024
Merged
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
18 changes: 9 additions & 9 deletions python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2838,8 +2838,8 @@ def __init__(
unit=None,
freq=None,
closed=None,
dtype="timedelta64[ns]",
copy=False,
dtype=None,
copy: bool = False,
name=None,
):
if freq is not None:
Expand All @@ -2851,19 +2851,19 @@ def __init__(
"dtype parameter is supported"
)

valid_dtypes = tuple(
f"timedelta64[{res}]" for res in ("s", "ms", "us", "ns")
)
if dtype not in valid_dtypes:
raise TypeError("Invalid dtype")
if dtype is None:
dtype = "timedelta64[ns]"
dtype = cudf.dtype(dtype)
if dtype.kind != "m":
raise TypeError("dtype must be a timedelta type")

kwargs = _setdefault_name(data, name=name)
name = _setdefault_name(data, name=name)["name"]
data = column.as_column(data, dtype=dtype)

if copy:
data = data.copy()

super().__init__(data, **kwargs)
super().__init__(data, name=name)

def __getitem__(self, index):
value = super().__getitem__(index)
Expand Down