Skip to content

Commit fba4e46

Browse files
jbrockmendelroberthdevries
authored andcommitted
CLN: remove unused from MultiIndex (pandas-dev#32030)
1 parent 6a051ce commit fba4e46

File tree

2 files changed

+1
-83
lines changed

2 files changed

+1
-83
lines changed

pandas/core/indexes/multi.py

+1-66
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
indexer_from_factorized,
5959
lexsort_indexer,
6060
)
61-
from pandas.core.util.hashing import hash_tuple, hash_tuples
6261

6362
from pandas.io.formats.printing import (
6463
format_object_attrs,
@@ -247,6 +246,7 @@ class MultiIndex(Index):
247246
rename = Index.set_names
248247

249248
_tuples = None
249+
sortorder: Optional[int]
250250

251251
# --------------------------------------------------------------------
252252
# Constructors
@@ -1430,55 +1430,11 @@ def is_monotonic_decreasing(self) -> bool:
14301430
# monotonic decreasing if and only if reverse is monotonic increasing
14311431
return self[::-1].is_monotonic_increasing
14321432

1433-
@cache_readonly
1434-
def _have_mixed_levels(self):
1435-
""" return a boolean list indicated if we have mixed levels """
1436-
return ["mixed" in l for l in self._inferred_type_levels]
1437-
14381433
@cache_readonly
14391434
def _inferred_type_levels(self):
14401435
""" return a list of the inferred types, one for each level """
14411436
return [i.inferred_type for i in self.levels]
14421437

1443-
@cache_readonly
1444-
def _hashed_values(self):
1445-
""" return a uint64 ndarray of my hashed values """
1446-
return hash_tuples(self)
1447-
1448-
def _hashed_indexing_key(self, key):
1449-
"""
1450-
validate and return the hash for the provided key
1451-
1452-
*this is internal for use for the cython routines*
1453-
1454-
Parameters
1455-
----------
1456-
key : string or tuple
1457-
1458-
Returns
1459-
-------
1460-
np.uint64
1461-
1462-
Notes
1463-
-----
1464-
we need to stringify if we have mixed levels
1465-
"""
1466-
if not isinstance(key, tuple):
1467-
return hash_tuples(key)
1468-
1469-
if not len(key) == self.nlevels:
1470-
raise KeyError
1471-
1472-
def f(k, stringify):
1473-
if stringify and not isinstance(k, str):
1474-
k = str(k)
1475-
return k
1476-
1477-
key = tuple(
1478-
f(k, stringify) for k, stringify in zip(key, self._have_mixed_levels)
1479-
)
1480-
return hash_tuple(key)
1481-
14821438
@Appender(Index.duplicated.__doc__)
14831439
def duplicated(self, keep="first"):
14841440
shape = map(len, self.levels)
@@ -1858,27 +1814,6 @@ def __reduce__(self):
18581814
)
18591815
return ibase._new_Index, (type(self), d), None
18601816

1861-
def __setstate__(self, state):
1862-
"""Necessary for making this object picklable"""
1863-
if isinstance(state, dict):
1864-
levels = state.get("levels")
1865-
codes = state.get("codes")
1866-
sortorder = state.get("sortorder")
1867-
names = state.get("names")
1868-
1869-
elif isinstance(state, tuple):
1870-
1871-
nd_state, own_state = state
1872-
levels, codes, sortorder, names = own_state
1873-
1874-
self._set_levels([Index(x) for x in levels], validate=False)
1875-
self._set_codes(codes)
1876-
new_codes = self._verify_integrity()
1877-
self._set_codes(new_codes)
1878-
self._set_names(names)
1879-
self.sortorder = sortorder
1880-
self._reset_identity()
1881-
18821817
# --------------------------------------------------------------------
18831818

18841819
def __getitem__(self, key):

pandas/tests/util/test_hashing.py

-17
Original file line numberDiff line numberDiff line change
@@ -178,23 +178,6 @@ def test_multiindex_objects():
178178
assert mi.equals(recons)
179179
assert Index(mi.values).equals(Index(recons.values))
180180

181-
# _hashed_values and hash_pandas_object(..., index=False) equivalency.
182-
expected = hash_pandas_object(mi, index=False).values
183-
result = mi._hashed_values
184-
185-
tm.assert_numpy_array_equal(result, expected)
186-
187-
expected = hash_pandas_object(recons, index=False).values
188-
result = recons._hashed_values
189-
190-
tm.assert_numpy_array_equal(result, expected)
191-
192-
expected = mi._hashed_values
193-
result = recons._hashed_values
194-
195-
# Values should match, but in different order.
196-
tm.assert_numpy_array_equal(np.sort(result), np.sort(expected))
197-
198181

199182
@pytest.mark.parametrize(
200183
"obj",

0 commit comments

Comments
 (0)