Skip to content

Commit 768adf2

Browse files
committed
fix issue #21654
1 parent 0828c25 commit 768adf2

File tree

6 files changed

+5
-220
lines changed

6 files changed

+5
-220
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ Missing
510510
MultiIndex
511511
^^^^^^^^^^
512512

513-
-
513+
- Removing legacy MultiIndex internal formats
514514
-
515515
-
516516

pandas/core/indexes/multi.py

-25
Original file line numberDiff line numberDiff line change
@@ -824,15 +824,6 @@ def values(self):
824824
self._tuples = lib.fast_zip(values)
825825
return self._tuples
826826

827-
# fml
828-
@property
829-
def _is_v1(self):
830-
return False
831-
832-
@property
833-
def _is_v2(self):
834-
return False
835-
836827
@property
837828
def _has_complex_internals(self):
838829
# to disable groupby tricks
@@ -2843,22 +2834,6 @@ def delete(self, loc):
28432834
return MultiIndex(levels=self.levels, labels=new_labels,
28442835
names=self.names, verify_integrity=False)
28452836

2846-
get_major_bounds = slice_locs
2847-
2848-
__bounds = None
2849-
2850-
@property
2851-
def _bounds(self):
2852-
"""
2853-
Return or compute and return slice points for level 0, assuming
2854-
sortedness
2855-
"""
2856-
if self.__bounds is None:
2857-
inds = np.arange(len(self.levels[0]))
2858-
self.__bounds = self.labels[0].searchsorted(inds)
2859-
2860-
return self.__bounds
2861-
28622837
def _wrap_joined_index(self, joined, other):
28632838
names = self.names if self.names == other.names else None
28642839
return MultiIndex.from_tuples(joined, names=names)
-670 Bytes
Binary file not shown.

pandas/tests/indexes/multi/data/multiindex_v1.pickle

-149
This file was deleted.

pandas/tests/indexes/multi/test_conversion.py

+2-43
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
import numpy as np
55
import pandas as pd
66
import pandas.util.testing as tm
7-
import pytest
87
from pandas import DataFrame, MultiIndex, date_range
9-
from pandas.compat import PY3, range
10-
from pandas.util.testing import assert_almost_equal
8+
from pandas.compat import range
119

1210

1311
def test_tolist(idx):
@@ -93,46 +91,6 @@ def test_to_hierarchical():
9391
assert result.names == index.names
9492

9593

96-
@pytest.mark.skipif(PY3, reason="testing legacy pickles not support on py3")
97-
def test_legacy_pickle(datapath):
98-
99-
path = datapath('indexes', 'multi', 'data', 'multiindex_v1.pickle')
100-
obj = pd.read_pickle(path)
101-
102-
obj2 = MultiIndex.from_tuples(obj.values)
103-
assert obj.equals(obj2)
104-
105-
res = obj.get_indexer(obj)
106-
exp = np.arange(len(obj), dtype=np.intp)
107-
assert_almost_equal(res, exp)
108-
109-
res = obj.get_indexer(obj2[::-1])
110-
exp = obj.get_indexer(obj[::-1])
111-
exp2 = obj2.get_indexer(obj2[::-1])
112-
assert_almost_equal(res, exp)
113-
assert_almost_equal(exp, exp2)
114-
115-
116-
def test_legacy_v2_unpickle(datapath):
117-
118-
# 0.7.3 -> 0.8.0 format manage
119-
path = datapath('indexes', 'multi', 'data', 'mindex_073.pickle')
120-
obj = pd.read_pickle(path)
121-
122-
obj2 = MultiIndex.from_tuples(obj.values)
123-
assert obj.equals(obj2)
124-
125-
res = obj.get_indexer(obj)
126-
exp = np.arange(len(obj), dtype=np.intp)
127-
assert_almost_equal(res, exp)
128-
129-
res = obj.get_indexer(obj2[::-1])
130-
exp = obj.get_indexer(obj[::-1])
131-
exp2 = obj2.get_indexer(obj2[::-1])
132-
assert_almost_equal(res, exp)
133-
assert_almost_equal(exp, exp2)
134-
135-
13694
def test_roundtrip_pickle_with_tz():
13795

13896
# GH 8367
@@ -146,6 +104,7 @@ def test_roundtrip_pickle_with_tz():
146104

147105

148106
def test_pickle(indices):
107+
149108
unpickled = tm.round_trip_pickle(indices)
150109
assert indices.equals(unpickled)
151110
original_name, indices.name = indices.name, 'foo'

pandas/tests/indexes/multi/test_operations.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def test_insert(idx):
8484
tm.assert_series_equal(left, right)
8585

8686

87-
def test_bounds(idx):
88-
idx._bounds
87+
# def test_bounds(idx):
88+
# idx._bounds
8989

9090

9191
def test_append(idx):

0 commit comments

Comments
 (0)