-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: finish setting pytables IndexCol attrs in constructor #30161
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2120,10 +2120,6 @@ def set_info(self, info): | |
if idx is not None: | ||
self.__dict__.update(idx) | ||
|
||
def get_attr(self): | ||
""" set the kind for this column """ | ||
self.kind = getattr(self.attrs, self.kind_attr, None) | ||
|
||
def set_attr(self): | ||
""" set the kind for this column """ | ||
setattr(self.attrs, self.kind_attr, self.kind) | ||
|
@@ -2170,9 +2166,6 @@ def convert(self, values: np.ndarray, nan_rep, encoding: str, errors: str): | |
assert isinstance(values, np.ndarray), type(values) | ||
self.values = Int64Index(np.arange(len(values))) | ||
|
||
def get_attr(self): | ||
pass | ||
|
||
def set_attr(self): | ||
pass | ||
|
||
|
@@ -2207,6 +2200,7 @@ def __init__( | |
table=None, | ||
meta=None, | ||
metadata=None, | ||
dtype=None, | ||
): | ||
super().__init__( | ||
name=name, | ||
|
@@ -2221,7 +2215,7 @@ def __init__( | |
meta=meta, | ||
metadata=metadata, | ||
) | ||
self.dtype = None | ||
self.dtype = dtype | ||
self.data = None | ||
|
||
@property | ||
|
@@ -2443,15 +2437,6 @@ def convert(self, values: np.ndarray, nan_rep, encoding: str, errors: str): | |
|
||
self.data = own_data | ||
|
||
def get_attr(self): | ||
""" get the data for this column """ | ||
self.values = getattr(self.attrs, self.kind_attr, None) | ||
self.dtype = getattr(self.attrs, self.dtype_attr, None) | ||
self.meta = getattr(self.attrs, self.meta_attr, None) | ||
assert self.typ is not None | ||
assert self.dtype is not None | ||
self.kind = _dtype_to_kind(self.dtype) | ||
|
||
def set_attr(self): | ||
""" set the data for this column """ | ||
setattr(self.attrs, self.kind_attr, self.values) | ||
|
@@ -2490,8 +2475,7 @@ def get_atom_timedelta64(cls, shape): | |
class GenericDataIndexableCol(DataIndexableCol): | ||
""" represent a generic pytables data column """ | ||
|
||
def get_attr(self): | ||
pass | ||
pass | ||
|
||
|
||
class Fixed: | ||
|
@@ -3437,6 +3421,7 @@ def indexables(self): | |
_indexables = [] | ||
|
||
desc = self.description | ||
table_attrs = self.table.attrs | ||
|
||
# Note: each of the `name` kwargs below are str, ensured | ||
# by the definition in index_cols. | ||
|
@@ -3445,16 +3430,20 @@ def indexables(self): | |
atom = getattr(desc, name) | ||
md = self.read_metadata(name) | ||
meta = "category" if md is not None else None | ||
|
||
kind_attr = f"{name}_kind" | ||
kind = getattr(table_attrs, kind_attr, None) | ||
|
||
index_col = IndexCol( | ||
name=name, | ||
axis=axis, | ||
pos=i, | ||
kind=kind, | ||
typ=atom, | ||
table=self.table, | ||
meta=meta, | ||
metadata=md, | ||
) | ||
index_col.get_attr() | ||
_indexables.append(index_col) | ||
|
||
# values columns | ||
|
@@ -3469,18 +3458,29 @@ def f(i, c): | |
|
||
atom = getattr(desc, c) | ||
adj_name = _maybe_adjust_name(c, self.version) | ||
|
||
# TODO: why kind_attr here? | ||
values = getattr(table_attrs, f"{adj_name}_kind", None) | ||
dtype = getattr(table_attrs, f"{adj_name}_dtype", None) | ||
kind = _dtype_to_kind(dtype) | ||
|
||
md = self.read_metadata(c) | ||
meta = "category" if md is not None else None | ||
# TODO: figure out why these two versions of `meta` dont always match. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is going on here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So ever place where we set if/when that is resolved, |
||
# meta = "category" if md is not None else None | ||
meta = getattr(table_attrs, f"{adj_name}_meta", None) | ||
|
||
obj = klass( | ||
name=adj_name, | ||
cname=c, | ||
values=values, | ||
kind=kind, | ||
pos=base_pos + i, | ||
typ=atom, | ||
table=self.table, | ||
meta=meta, | ||
metadata=md, | ||
dtype=dtype, | ||
) | ||
obj.get_attr() | ||
return obj | ||
|
||
# Note: the definition of `values_cols` ensures that each | ||
|
@@ -4501,7 +4501,6 @@ def indexables(self): | |
index_col = GenericIndexCol( | ||
name="index", axis=0, table=self.table, meta=meta, metadata=md | ||
) | ||
index_col.get_attr() | ||
|
||
_indexables = [index_col] | ||
|
||
|
@@ -4520,7 +4519,6 @@ def indexables(self): | |
meta=meta, | ||
metadata=md, | ||
) | ||
dc.get_attr() | ||
_indexables.append(dc) | ||
|
||
return _indexables | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just blow this class away altogether now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth a shot