Skip to content

Expose top-level xarray.indexes in __init__ #10435

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ v2025.07.0 (unreleased)

New Features
~~~~~~~~~~~~
- Expose :py:class:`~xarray.indexes.RangeIndex`, and :py:class:`~xarray.indexes.CoordinateTransformIndex` as public api
under the ``xarray.indexes`` namespace. By `Deepak Cherian <https://github.com/dcherian>`_.


Breaking changes
Expand Down
3 changes: 2 additions & 1 deletion xarray/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from importlib.metadata import version as _version

from xarray import coders, groupers, testing, tutorial, ufuncs
from xarray import coders, groupers, indexes, testing, tutorial, ufuncs
from xarray.backends.api import (
load_dataarray,
load_dataset,
Expand Down Expand Up @@ -70,6 +70,7 @@
# Sub-packages
"coders",
"groupers",
"indexes",
"testing",
"tutorial",
"ufuncs",
Expand Down
11 changes: 10 additions & 1 deletion xarray/indexes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@

"""

from xarray.core.coordinate_transform import CoordinateTransform
from xarray.core.indexes import (
CoordinateTransformIndex,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benbovy does this seem OK to you? Would be good for SciPy...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! We should also expose xarray.core.coordinate_transform.CoordinateTransform since we already subclass it externally (not sure in which namespace... indexes as well?).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I put it under indexes as well

Index,
PandasIndex,
PandasMultiIndex,
)
from xarray.indexes.range_index import RangeIndex

__all__ = ["Index", "PandasIndex", "PandasMultiIndex", "RangeIndex"]
__all__ = [
"CoordinateTransform",
"CoordinateTransformIndex",
"Index",
"PandasIndex",
"PandasMultiIndex",
"RangeIndex",
]
Loading