Skip to content

Commit

Permalink
DEPR: don't make Index instantiate Int64/Uint64/Flaot64Index
Browse files Browse the repository at this point in the history
  • Loading branch information
Terji Petersen authored and Terji Petersen committed Nov 6, 2022
1 parent 3714e85 commit 844ab1b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
3 changes: 0 additions & 3 deletions pandas/conftest.py
Expand Up @@ -593,10 +593,7 @@ def _create_mi_with_dt64tz_level():
"datetime-tz": tm.makeDateIndex(100, tz="US/Pacific"),
"period": tm.makePeriodIndex(100),
"timedelta": tm.makeTimedeltaIndex(100),
"int": tm.makeIntIndex(100),
"uint": tm.makeUIntIndex(100),
"range": tm.makeRangeIndex(100),
"float": tm.makeFloatIndex(100),
"complex64": tm.makeFloatIndex(100).astype("complex64"),
"complex128": tm.makeFloatIndex(100).astype("complex128"),
"num_int64": tm.makeNumericIndex(100, dtype="int64"),
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/arrays/interval/test_interval.py
Expand Up @@ -287,7 +287,7 @@ def test_arrow_array():
with pytest.raises(TypeError, match="Not supported to convert IntervalArray"):
pa.array(intervals, type="float64")

with pytest.raises(TypeError, match="different 'subtype'"):
with pytest.raises(TypeError, match="Not supported to convert IntervalArray"):
pa.array(intervals, type=ArrowIntervalType(pa.float64(), "left"))


Expand Down
17 changes: 15 additions & 2 deletions pandas/tests/arrays/sparse/test_accessor.py
Expand Up @@ -41,7 +41,12 @@ def test_from_coo(self):
sp_array = scipy.sparse.coo_matrix((data, (row, col)), dtype="int")
result = pd.Series.sparse.from_coo(sp_array)

index = pd.MultiIndex.from_arrays([[0, 0, 1, 3], [0, 2, 1, 3]])
index = pd.MultiIndex.from_arrays(
[
np.array([0, 0, 1, 3], dtype=np.int32),
np.array([0, 2, 1, 3], dtype=np.int32),
],
)
expected = pd.Series([4, 9, 7, 5], index=index, dtype="Sparse[int]")
tm.assert_series_equal(result, expected)

Expand Down Expand Up @@ -212,7 +217,15 @@ def test_series_from_coo(self, dtype, dense_index):

A = scipy.sparse.eye(3, format="coo", dtype=dtype)
result = pd.Series.sparse.from_coo(A, dense_index=dense_index)
index = pd.MultiIndex.from_tuples([(0, 0), (1, 1), (2, 2)])

index_dtype = np.int64 if dense_index else np.int32
index = pd.MultiIndex.from_tuples(
[
np.array([0, 0], dtype=index_dtype),
np.array([1, 1], dtype=index_dtype),
np.array([2, 2], dtype=index_dtype),
],
)
expected = pd.Series(SparseArray(np.array([1, 1, 1], dtype=dtype)), index=index)
if dense_index:
expected = expected.reindex(pd.MultiIndex.from_product(index.levels))
Expand Down

0 comments on commit 844ab1b

Please sign in to comment.