Skip to content

Commit 3f0af5e

Browse files
authored
DEPR: Remove ABC(Int|Uint|Float)64Index (#50775)
1 parent 96fc51f commit 3f0af5e

File tree

5 files changed

+26
-44
lines changed

5 files changed

+26
-44
lines changed

pandas/compat/pickle_compat.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,20 @@ def load_reduce(self):
120120
),
121121
("pandas.indexes.numeric", "Float64Index"): (
122122
"pandas.core.indexes.numeric",
123-
"Float64Index",
123+
"Index", # updated in 50775
124+
),
125+
# 50775, remove Int64Index, UInt64Index & Float64Index from codabase
126+
("pandas.core.indexes.numeric", "Int64Index"): (
127+
"pandas.core.indexes.base",
128+
"Index",
129+
),
130+
("pandas.core.indexes.numeric", "UInt64Index"): (
131+
"pandas.core.indexes.base",
132+
"Index",
133+
),
134+
("pandas.core.indexes.numeric", "Float64Index"): (
135+
"pandas.core.indexes.base",
136+
"Index",
124137
),
125138
}
126139

pandas/core/dtypes/generic.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@
2929
TimedeltaArray,
3030
)
3131
from pandas.core.generic import NDFrame
32-
from pandas.core.indexes.api import (
33-
Float64Index,
34-
Int64Index,
35-
UInt64Index,
36-
)
3732

3833

3934
# define abstract base classes to enable isinstance type checking on our
@@ -62,22 +57,10 @@ def _subclasscheck(cls, inst) -> bool:
6257
return meta(name, (), dct)
6358

6459

65-
ABCInt64Index = cast(
66-
"Type[Int64Index]",
67-
create_pandas_abc_type("ABCInt64Index", "_typ", ("int64index",)),
68-
)
69-
ABCUInt64Index = cast(
70-
"Type[UInt64Index]",
71-
create_pandas_abc_type("ABCUInt64Index", "_typ", ("uint64index",)),
72-
)
7360
ABCRangeIndex = cast(
7461
"Type[RangeIndex]",
7562
create_pandas_abc_type("ABCRangeIndex", "_typ", ("rangeindex",)),
7663
)
77-
ABCFloat64Index = cast(
78-
"Type[Float64Index]",
79-
create_pandas_abc_type("ABCFloat64Index", "_typ", ("float64index",)),
80-
)
8164
ABCMultiIndex = cast(
8265
"Type[MultiIndex]",
8366
create_pandas_abc_type("ABCMultiIndex", "_typ", ("multiindex",)),
@@ -109,10 +92,7 @@ def _subclasscheck(cls, inst) -> bool:
10992
"_typ",
11093
{
11194
"index",
112-
"int64index",
11395
"rangeindex",
114-
"float64index",
115-
"uint64index",
11696
"numericindex",
11797
"multiindex",
11898
"datetimeindex",

pandas/tests/arithmetic/conftest.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
import pandas as pd
55
from pandas import RangeIndex
66
import pandas._testing as tm
7-
from pandas.core.api import (
8-
Float64Index,
9-
Int64Index,
10-
UInt64Index,
11-
)
7+
from pandas.core.api import NumericIndex
128
from pandas.core.computation import expressions as expr
139

1410

@@ -90,9 +86,10 @@ def zero(request):
9086

9187
@pytest.fixture(
9288
params=[
93-
Float64Index(np.arange(5, dtype="float64")),
94-
Int64Index(np.arange(5, dtype="int64")),
95-
UInt64Index(np.arange(5, dtype="uint64")),
89+
# TODO: add more dtypes here
90+
NumericIndex(np.arange(5, dtype="float64")),
91+
NumericIndex(np.arange(5, dtype="int64")),
92+
NumericIndex(np.arange(5, dtype="uint64")),
9693
RangeIndex(5),
9794
],
9895
ids=lambda x: type(x).__name__,

pandas/tests/arithmetic/test_numeric.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def test_divmod_zero(self, zero, numeric_idx):
377377
@pytest.mark.parametrize("op", [operator.truediv, operator.floordiv])
378378
def test_div_negative_zero(self, zero, numeric_idx, op):
379379
# Check that -1 / -0.0 returns np.inf, not -np.inf
380-
if isinstance(numeric_idx, UInt64Index):
380+
if numeric_idx.dtype == np.uint64:
381381
return
382382
idx = numeric_idx - 3
383383

@@ -669,15 +669,15 @@ def test_mul_int_array(self, numeric_idx):
669669
result = idx * np.array(5, dtype="int64")
670670
tm.assert_index_equal(result, idx * 5)
671671

672-
arr_dtype = "uint64" if isinstance(idx, UInt64Index) else "int64"
672+
arr_dtype = "uint64" if idx.dtype == np.uint64 else "int64"
673673
result = idx * np.arange(5, dtype=arr_dtype)
674674
tm.assert_index_equal(result, didx)
675675

676676
def test_mul_int_series(self, numeric_idx):
677677
idx = numeric_idx
678678
didx = idx * idx
679679

680-
arr_dtype = "uint64" if isinstance(idx, UInt64Index) else "int64"
680+
arr_dtype = "uint64" if idx.dtype == np.uint64 else "int64"
681681
result = idx * Series(np.arange(5, dtype=arr_dtype))
682682
tm.assert_series_equal(result, Series(didx))
683683

@@ -714,7 +714,7 @@ def test_pow_float(self, op, numeric_idx, box_with_array):
714714
# test power calculations both ways, GH#14973
715715
box = box_with_array
716716
idx = numeric_idx
717-
expected = Float64Index(op(idx.values, 2.0))
717+
expected = Index(op(idx.values, 2.0))
718718

719719
idx = tm.box_expected(idx, box)
720720
expected = tm.box_expected(expected, box)
@@ -1216,7 +1216,7 @@ def test_binops_index(self, op, idx1, idx2):
12161216
idx1 = idx1._rename("foo")
12171217
idx2 = idx2._rename("bar")
12181218
result = op(idx1, idx2)
1219-
expected = op(Int64Index(idx1), Int64Index(idx2))
1219+
expected = op(Index(idx1.to_numpy()), Index(idx2.to_numpy()))
12201220
tm.assert_index_equal(result, expected, exact="equiv")
12211221

12221222
@pytest.mark.parametrize(
@@ -1252,7 +1252,7 @@ def test_binops_index_pow(self, idx1, idx2):
12521252
idx1 = idx1._rename("foo")
12531253
idx2 = idx2._rename("bar")
12541254
result = pow(idx1, idx2)
1255-
expected = pow(Int64Index(idx1), Int64Index(idx2))
1255+
expected = pow(Index(idx1.to_numpy()), Index(idx2.to_numpy()))
12561256
tm.assert_index_equal(result, expected, exact="equiv")
12571257

12581258
@pytest.mark.parametrize("idx", [RangeIndex(0, 10, 1), RangeIndex(0, 20, 2)])
@@ -1330,7 +1330,7 @@ def test_numeric_compat2(self):
13301330
# __pow__
13311331
idx = RangeIndex(0, 1000, 2)
13321332
result = idx**2
1333-
expected = Int64Index(idx._values) ** 2
1333+
expected = Index(idx._values) ** 2
13341334
tm.assert_index_equal(Index(result.values), expected, exact=True)
13351335

13361336
@pytest.mark.parametrize(

pandas/tests/dtypes/test_generic.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@
88

99
import pandas as pd
1010
import pandas._testing as tm
11-
from pandas.core.api import (
12-
Float64Index,
13-
Int64Index,
14-
UInt64Index,
15-
)
1611

1712

1813
class TestABCClasses:
@@ -29,9 +24,6 @@ class TestABCClasses:
2924
timedelta_array = pd.core.arrays.TimedeltaArray(timedelta_index)
3025

3126
abc_pairs = [
32-
("ABCInt64Index", Int64Index([1, 2, 3])),
33-
("ABCUInt64Index", UInt64Index([1, 2, 3])),
34-
("ABCFloat64Index", Float64Index([1, 2, 3])),
3527
("ABCMultiIndex", multi_index),
3628
("ABCDatetimeIndex", datetime_index),
3729
("ABCRangeIndex", pd.RangeIndex(3)),

0 commit comments

Comments
 (0)