Skip to content

Commit

Permalink
checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mavaylon1 committed Nov 1, 2023
1 parent e0d540c commit 1f516dc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/hdmf/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,16 @@ def __gather_columns(cls, name, bases, classdict):
raise TypeError(msg)

if len(bases) and 'DynamicTable' in globals():
for item in bases:
for item in bases[::-1]: # reverse the bases tuple as the code suggest it should be last
if issubclass(item, Container):
try:
if item.__columns__ is not cls.__columns__:
if cls.__name__ == 'PlaneSegmentation':
breakpoint()
new_columns = list(cls.__columns__)
new_columns[0:0] = item.__columns__ # prepend superclass columns to new_columns
cls.__columns__ = tuple(new_columns)
break
except AttributeError: # raises error when "__columns__" is not an attr of item
continue

Expand Down
25 changes: 25 additions & 0 deletions tests/unit/helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,3 +653,28 @@ class CustomSpecNamespace(SpecNamespace):
@classmethod
def types_key(cls):
return cls.__types_key

class FooExtendDynamicTable0(DynamicTable):
"""
Within PyNWB, PlaneSegmentation extends DynamicTable and sets __columns__. This class is a helper
class for testing and is directly meant to test __gather_columns, i.e., class generation, downstream.
"""
__columns__ = (
{'name': 'col1', 'description': '...'},
{'name': 'col2', 'description': '...'},
)


class FooExtendDynamicTable1(FooExtendDynamicTable0):
"""
In extensions, users can create new classes that inherit from classes that inherit from DynamicTable.
This is a helper class for testing and is directly meant to test __gather_columns, i.e.,
class generation, downstream.
"""
__columns__ = (
{'name': 'col3', 'description': '...'},
{'name': 'col4', 'description': '...'},
)

class FooExtendDynamicTable2(FooExtendDynamicTable2):
pass

0 comments on commit 1f516dc

Please sign in to comment.