Skip to content

Commit

Permalink
Relax error check for missing columns in DynamicTable.__init__ when r…
Browse files Browse the repository at this point in the history
…eading from file
  • Loading branch information
oruebel committed Jul 26, 2023
1 parent 64a444f commit feb3070
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/hdmf/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,16 @@ def __init__(self, **kwargs): # noqa: C901
else:
# Calculate the order of column names
if columns is None:
raise ValueError("Must supply 'columns' if specifying 'colnames'")
# Invalid table. Custom colnames are given but the VectorData for those columns are missing.
if self._in_construct_mode: # Relax error checking when reading from an existing file
# To allow reading of bad files and since we don't have any actual data for the
# custom columns, we can try to just ignore the columns and warn instead of raising a ValueError.
self.colnames = tuple()
self.columns = tuple()
warn("Ignoring custom named columns. Must supply 'columns' if specifying"
" 'colnames'=%s for table name=%s" % (str(colnames), self.name))
else: # be strict when constructing a new table
raise ValueError("Must supply 'columns' if specifying 'colnames'")
else:
# order the columns according to the column names, which does not include indices
self.colnames = tuple(pystr(c) for c in colnames)
Expand Down

0 comments on commit feb3070

Please sign in to comment.