Skip to content

Commit 2555aac

Browse files
Dr-Irvtwoertwein
authored andcommitted
fix NumericIndex for nightly (pandas-dev#528)
* fix NumericIndex for nightly * import Index as NumericIndex
1 parent 76c505a commit 2555aac

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

tests/test_indexes.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,30 @@
1212
import numpy as np
1313
from numpy import typing as npt
1414
import pandas as pd
15-
from pandas.core.indexes.numeric import NumericIndex
1615
from typing_extensions import (
1716
Never,
1817
assert_type,
1918
)
2019

2120
from pandas._typing import Scalar
2221

23-
if TYPE_CHECKING:
24-
from pandas._typing import IndexIterScalar
25-
2622
from tests import (
23+
PD_LTE_15,
2724
TYPE_CHECKING_INVALID_USAGE,
2825
check,
2926
pytest_warns_bounded,
3027
)
3128

29+
if TYPE_CHECKING:
30+
from pandas.core.indexes.numeric import NumericIndex
31+
32+
from pandas._typing import IndexIterScalar
33+
else:
34+
if not PD_LTE_15:
35+
from pandas import Index as NumericIndex
36+
else:
37+
from pandas.core.indexes.numeric import NumericIndex
38+
3239

3340
def test_index_unique() -> None:
3441
df = pd.DataFrame({"x": [1, 2, 3, 4]}, index=pd.Index([1, 2, 3, 2]))

tests/test_timefuncs.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import numpy as np
1313
from numpy import typing as npt
1414
import pandas as pd
15-
from pandas.core.indexes.numeric import NumericIndex
1615
import pytz
1716
from typing_extensions import assert_type
1817

@@ -25,6 +24,7 @@
2524
else:
2625
FulldatetimeDict = Any
2726
from tests import (
27+
PD_LTE_15,
2828
TYPE_CHECKING_INVALID_USAGE,
2929
check,
3030
pytest_warns_bounded,
@@ -46,6 +46,15 @@
4646
TimestampSeries,
4747
)
4848

49+
if TYPE_CHECKING:
50+
from pandas.core.indexes.numeric import NumericIndex
51+
52+
else:
53+
if not PD_LTE_15:
54+
from pandas import Index as NumericIndex
55+
else:
56+
from pandas.core.indexes.numeric import NumericIndex
57+
4958
# Separately define here so pytest works
5059
np_ndarray_bool = npt.NDArray[np.bool_]
5160

0 commit comments

Comments
 (0)