Skip to content

CLN: remove LegacyFoo from io.pytables #29787

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 3 commits into from
Nov 22, 2019
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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)
- :meth:`pandas.Series.str.cat` does not accept list-likes *within* list-likes anymore (:issue:`27611`)
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
- Removed support for legacy HDF5 formats (:issue:`29787`)
- :func:`read_excel` removed support for "skip_footer" argument, use "skipfooter" instead (:issue:`18836`)
- :meth:`DataFrame.to_records` no longer supports the argument "convert_datetime64" (:issue:`18902`)
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)
Expand Down
77 changes: 1 addition & 76 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,6 @@ class DuplicateWarning(Warning):

# storer class map
_STORER_MAP = {
"Series": "LegacySeriesFixed",
"DataFrame": "LegacyFrameFixed",
Copy link
Contributor

Choose a reason for hiding this comment

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

i think Series as well?

"DataMatrix": "LegacyFrameFixed",
"series": "SeriesFixed",
"frame": "FrameFixed",
}
Expand Down Expand Up @@ -3083,35 +3080,6 @@ def write_array(self, key: str, value, items=None):
getattr(self.group, key)._v_attrs.transposed = transposed


class LegacyFixed(GenericFixed):
def read_index_legacy(
self, key: str, start: Optional[int] = None, stop: Optional[int] = None
):
node = getattr(self.group, key)
data = node[start:stop]
kind = node._v_attrs.kind
return _unconvert_index_legacy(
data, kind, encoding=self.encoding, errors=self.errors
)


class LegacySeriesFixed(LegacyFixed):
def read(self, **kwargs):
kwargs = self.validate_read(kwargs)
index = self.read_index_legacy("index")
values = self.read_array("values")
return Series(values, index=index)


class LegacyFrameFixed(LegacyFixed):
def read(self, **kwargs):
kwargs = self.validate_read(kwargs)
index = self.read_index_legacy("index")
columns = self.read_index_legacy("columns")
values = self.read_array("values")
return DataFrame(values, index=index, columns=columns)


class SeriesFixed(GenericFixed):
pandas_kind = "series"
attributes = ["name"]
Expand Down Expand Up @@ -4139,35 +4107,7 @@ def write(self, **kwargs):
raise NotImplementedError("WORKTable needs to implement write")


class LegacyTable(Table):
""" an appendable table: allow append/query/delete operations to a
(possibly) already existing appendable table this table ALLOWS
append (but doesn't require them), and stores the data in a format
that can be easily searched

"""

_indexables: Optional[List[IndexCol]] = [
IndexCol(name="index", axis=1, pos=0),
IndexCol(name="column", axis=2, pos=1, index_kind="columns_kind"),
DataCol(name="fields", cname="values", kind_attr="fields", pos=2),
]
table_type = "legacy"
ndim = 3

def write(self, **kwargs):
raise TypeError("write operations are not allowed on legacy tables!")

def read(self, where=None, columns=None, **kwargs):
"""we have n indexable columns, with an arbitrary number of data
axes
"""

if not self.read_axes(where=where, **kwargs):
return None


class AppendableTable(LegacyTable):
class AppendableTable(Table):
""" support the new appendable table formats """

_indexables = None
Expand Down Expand Up @@ -4866,21 +4806,6 @@ def _unconvert_index(data, kind, encoding=None, errors="strict"):
return index


def _unconvert_index_legacy(data, kind, legacy=False, encoding=None, errors="strict"):
kind = _ensure_decoded(kind)
if kind == "datetime":
index = to_datetime(data)
elif kind in ("integer"):
index = np.asarray(data, dtype=object)
elif kind in ("string"):
index = _unconvert_string_array(
data, nan_rep=None, encoding=encoding, errors=errors
)
else: # pragma: no cover
raise ValueError("unrecognized index type {kind}".format(kind=kind))
return index


def _convert_string_array(data, encoding, errors, itemsize=None):
"""
we take a string-like that is object dtype and coerce to a fixed size
Expand Down