Skip to content

Commit 2da62af

Browse files
AmirAmir
authored andcommitted
Modified top-level name object for all Indexes classes
1 parent d028f95 commit 2da62af

File tree

9 files changed

+25
-2
lines changed

9 files changed

+25
-2
lines changed

pandas/core/indexes/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
Appender,
7272
cache_readonly,
7373
doc,
74+
set_module,
7475
)
7576
from pandas.util._exceptions import (
7677
find_stack_level,
@@ -314,7 +315,7 @@ def _new_Index(cls, d):
314315
d["dtype"] = d["data"].dtype
315316
return cls.__new__(cls, **d)
316317

317-
318+
@set_module("pandas")
318319
class Index(IndexOpsMixin, PandasObject):
319320
"""
320321
Immutable sequence used for indexing and alignment.

pandas/core/indexes/datetimes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from pandas.util._decorators import (
2727
cache_readonly,
2828
doc,
29+
set_module,
2930
)
3031

3132
from pandas.core.dtypes.common import is_scalar
@@ -126,6 +127,7 @@ def _new_DatetimeIndex(cls, d):
126127
+ DatetimeArray._bool_ops,
127128
DatetimeArray,
128129
)
130+
@set_module("pandas")
129131
class DatetimeIndex(DatetimeTimedeltaMixin):
130132
"""
131133
Immutable ndarray-like of datetime64 data.

pandas/core/indexes/extension.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
TypeVar,
1111
)
1212

13-
from pandas.util._decorators import cache_readonly
13+
from pandas.util._decorators import (
14+
cache_readonly,
15+
)
1416

1517
from pandas.core.dtypes.generic import ABCDataFrame
1618

pandas/core/indexes/interval.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from pandas.util._decorators import (
3333
Appender,
3434
cache_readonly,
35+
set_module,
3536
)
3637
from pandas.util._exceptions import rewrite_exception
3738

@@ -202,6 +203,7 @@ def _new_IntervalIndex(cls, d):
202203
IntervalArray,
203204
)
204205
@inherit_names(["is_non_overlapping_monotonic", "closed"], IntervalArray, cache=True)
206+
@set_module("pandas")
205207
class IntervalIndex(ExtensionIndex):
206208
_typ = "intervalindex"
207209

pandas/core/indexes/multi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
Appender,
5454
cache_readonly,
5555
doc,
56+
set_module,
5657
)
5758
from pandas.util._exceptions import find_stack_level
5859

@@ -194,6 +195,7 @@ def new_meth(self_or_cls, *args, **kwargs):
194195
return cast(F, new_meth)
195196

196197

198+
@set_module("pandas")
197199
class MultiIndex(Index):
198200
"""
199201
A multi-level, or hierarchical, index object for pandas objects.

pandas/core/indexes/period.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from pandas.util._decorators import (
2121
cache_readonly,
2222
doc,
23+
set_module,
2324
)
2425

2526
from pandas.core.dtypes.common import is_integer
@@ -81,6 +82,7 @@ def _new_PeriodIndex(cls, **d):
8182
wrap=True,
8283
)
8384
@inherit_names(["is_leap_year"], PeriodArray)
85+
@set_module("pandas")
8486
class PeriodIndex(DatetimeIndexOpsMixin):
8587
"""
8688
Immutable ndarray holding ordinal values indicating regular periods in time.

pandas/core/indexes/range.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from pandas.util._decorators import (
2828
cache_readonly,
2929
doc,
30+
set_module,
3031
)
3132

3233
from pandas.core.dtypes.base import ExtensionDtype
@@ -74,6 +75,7 @@ def min_fitting_element(start: int, step: int, lower_limit: int) -> int:
7475
return start + abs(step) * no_steps
7576

7677

78+
@set_module("pandas")
7779
class RangeIndex(Index):
7880
"""
7981
Immutable Index implementing a monotonic integer range.

pandas/core/indexes/timedeltas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
Timedelta,
1414
to_offset,
1515
)
16+
from pandas.util._decorators import set_module
1617

1718
from pandas.core.dtypes.common import (
1819
is_scalar,
@@ -50,6 +51,7 @@
5051
],
5152
TimedeltaArray,
5253
)
54+
@set_module("pandas")
5355
class TimedeltaIndex(DatetimeTimedeltaMixin):
5456
"""
5557
Immutable Index of timedelta64 data.

pandas/tests/api/test_api.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,11 @@ def test_set_module():
405405
assert pd.IntervalDtype.__module__ == "pandas"
406406
assert pd.SparseDtype.__module__ == "pandas"
407407
assert pd.ArrowDtype.__module__ == "pandas"
408+
assert pd.Index.__module__ == "pandas"
409+
assert pd.CategoricalIndex.__module__ == "pandas"
410+
assert pd.DatetimeIndex.__module__ == "pandas"
411+
assert pd.IntervalIndex.__module__ == "pandas"
412+
assert pd.MultiIndex.__module__ == "pandas"
413+
assert pd.PeriodIndex.__module__ == "pandas"
414+
assert pd.RangeIndex.__module__ == "pandas"
415+
assert pd.TimedeltaIndex.__module__ == "pandas"

0 commit comments

Comments
 (0)