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

Align Index __init__ APIs with pandas 2.x #16362

Merged
merged 6 commits into from
Jul 24, 2024
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
1 change: 1 addition & 0 deletions docs/cudf/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ def on_missing_reference(app, env, node, contnode):
("py:class", "Dtype"),
# The following are erroneously warned due to
# https://github.com/sphinx-doc/sphinx/issues/11225
("py:obj", "cudf.Index.values_host"),
("py:class", "pa.Array"),
("py:class", "ScalarLike"),
("py:class", "ParentType"),
Expand Down
48 changes: 37 additions & 11 deletions python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ class IndexMeta(type):
"""Custom metaclass for Index that overrides instance/subclass tests."""

def __call__(cls, data, *args, **kwargs):
if kwargs.get("tupleize_cols", True) is not True:
raise NotImplementedError(
"tupleize_cols is currently not supported."
)

if cls is Index:
return as_index(
arbitrary=data,
Expand Down Expand Up @@ -997,21 +1002,23 @@ def __dask_tokenize__(self):

class Index(SingleColumnFrame, BaseIndex, metaclass=IndexMeta):
"""
An array of orderable values that represent the indices of another Column
Immutable sequence used for indexing and alignment.

Attributes
----------
_values: A Column object
name: A string
The basic object storing axis labels for all pandas objects.

Parameters
----------
data : Column
The Column of data for this index
name : str optional
The name of the Index. If not provided, the Index adopts the value
Column's name. Otherwise if this name is different from the value
Column's, the data Column will be cloned to adopt this name.
data : array-like (1-dimensional)
dtype : str, numpy.dtype, or ExtensionDtype, optional
Data type for the output Index. If not specified, this will be
inferred from `data`.
copy : bool, default False
Copy input data.
name : object
Name to be stored in the index.
tupleize_cols : bool (default: True)
When True, attempt to create a MultiIndex if possible.
Currently not supported.
"""

@_performance_tracking
Expand Down Expand Up @@ -1735,8 +1742,18 @@ def __init__(
if tz is not None:
raise NotImplementedError("tz is not yet supported")
if normalize is not False:
warnings.warn(
"The 'normalize' keyword is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
raise NotImplementedError("normalize == True is not yet supported")
if closed is not None:
warnings.warn(
"The 'closed' keyword is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
raise NotImplementedError("closed is not yet supported")
if ambiguous != "raise":
raise NotImplementedError("ambiguous is not yet supported")
Expand Down Expand Up @@ -2480,6 +2497,14 @@ def __init__(
if freq is not None:
raise NotImplementedError("freq is not yet supported")

if closed is not None:
warnings.warn(
"The 'closed' keyword is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
raise NotImplementedError("closed is not yet supported")

if unit is not None:
warnings.warn(
"The 'unit' keyword is "
Expand Down Expand Up @@ -2863,6 +2888,7 @@ def __init__(
dtype=None,
copy: bool = False,
name=None,
verify_integrity: bool = True,
):
name = _getdefault_name(data, name=name)

Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def __init__(
dtype=None,
copy=False,
name=None,
**kwargs,
verify_integrity=True,
):
if sortorder is not None:
raise NotImplementedError("sortorder is not yet supported")
Expand Down
Loading