Skip to content

Commit

Permalink
Extract _init_class_columns for use by DynamicTable subclasses (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
rly authored Mar 26, 2020
1 parent d09e43e commit 9828b91
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/hdmf/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ def __gather_columns(cls, name, bases, classdict):
msg = "'__columns__' must be of type tuple, found %s" % type(cls.__columns__)
raise TypeError(msg)

if len(bases) and 'DynamicTable' in globals() and issubclass(bases[-1], Container) \
and bases[-1].__columns__ is not cls.__columns__:
if (len(bases) and 'DynamicTable' in globals() and issubclass(bases[-1], Container)
and bases[-1].__columns__ is not cls.__columns__):
new_columns = list(cls.__columns__)
new_columns[0:0] = bases[-1].__columns__
cls.__columns__ = tuple(new_columns)
Expand Down Expand Up @@ -294,6 +294,9 @@ def __init__(self, **kwargs): # noqa: C901

self.__df_cols = [self.id] + [col_dict[name] for name in self.colnames]
self.__colids = {name: i+1 for i, name in enumerate(self.colnames)}
self._init_class_columns()

def _init_class_columns(self):
self.__uninit_cols = [] # hold column names that are defined in __columns__ but not yet initialized
for col in self.__columns__:
if col['name'] not in self.__colids:
Expand Down

0 comments on commit 9828b91

Please sign in to comment.