Skip to content

CLN: remove unused legacy pickle compat code #31078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1928,9 +1928,9 @@ def __setstate__(self, state):
object.__setattr__(self, k, v)

else:
self._unpickle_series_compat(state)
raise NotImplementedError("Pre-0.12 pickles are no longer supported")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually might want to change the message to Pre-0.20.3 pickles consistently

elif len(state) == 2:
self._unpickle_series_compat(state)
raise NotImplementedError("Pre-0.12 pickles are no longer supported")

self._item_cache = {}

Expand Down
25 changes: 1 addition & 24 deletions pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,30 +279,7 @@ def unpickle_block(values, mgr_locs):
unpickle_block(b["values"], b["mgr_locs"]) for b in state["blocks"]
)
else:
# discard anything after 3rd, support beta pickling format for a
# little while longer
ax_arrays, bvalues, bitems = state[:3]

self.axes = [ensure_index(ax) for ax in ax_arrays]

if len(bitems) == 1 and self.axes[0].equals(bitems[0]):
# This is a workaround for pre-0.14.1 pickles that didn't
# support unpickling multi-block frames/panels with non-unique
# columns/items, because given a manager with items ["a", "b",
# "a"] there's no way of knowing which block's "a" is where.
#
# Single-block case can be supported under the assumption that
# block items corresponded to manager items 1-to-1.
all_mgr_locs = [slice(0, len(bitems[0]))]
else:
all_mgr_locs = [
self.axes[0].get_indexer(blk_items) for blk_items in bitems
]

self.blocks = tuple(
unpickle_block(values, mgr_locs)
for values, mgr_locs in zip(bvalues, all_mgr_locs)
)
raise NotImplementedError("pre-0.14.1 pickles are no longer supported")

self._post_setstate()

Expand Down
29 changes: 0 additions & 29 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,35 +744,6 @@ def __array__(self, dtype=None) -> np.ndarray:

# ----------------------------------------------------------------------

def _unpickle_series_compat(self, state) -> None:
if isinstance(state, dict):
self._data = state["_data"]
self.name = state["name"]
self.index = self._data.index

elif isinstance(state, tuple):

# < 0.12 series pickle

nd_state, own_state = state

# recreate the ndarray
data = np.empty(nd_state[1], dtype=nd_state[2])
np.ndarray.__setstate__(data, nd_state)

# backwards compat
index, name = own_state[0], None
if len(own_state) > 1:
name = own_state[1]

# recreate
self._data = SingleBlockManager(data, index, fastpath=True)
self._index = index
self.name = name

else:
raise Exception(f"cannot unpickle legacy formats -> [{state}]")

# indexers
@property
def axes(self) -> List[Index]:
Expand Down