Skip to content
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

[Bug]: Generation of table where there are colum names that don't correspond to any columns does not fail. #574

Open
2 tasks done
achilleasNP opened this issue Jun 24, 2024 · 2 comments
Labels
status: need more info unclear what the issue is or what needs to be done

Comments

@achilleasNP
Copy link

What happened?

I was allowed to create a types.hdmf_common.DynamicTable where one of the columns that were stated in colnames was not declared. An error was thrown only when trying to view the rows. I was expecting that creating the table would fail with an error.

Steps to Reproduce

col1 = types.hdmf_common.VectorData( ...
    'description', 'column #1', ...
    'data', [1;2;3] ...
    );

my_table = types.hdmf_common.DynamicTable( ...
    'description', 'an_example table', ...
    'colnames', {'col1', 'col2'}, ...
    'col1', col1, ...
    'id', types.hdmf_common.ElementIdentifiers('data', [0;1;2]) ...
    );
% The above works but then the statement below fails.
% my_table.getRow(1)

Error Message

No response

Operating System

Windows

Matlab Version

'24.1.0.2603908 (R2024a) Update 3'

Code of Conduct

@ehennestad
Copy link
Collaborator

I think that this does not fail because there are scenarios where you might want to declare a set of columns for a table and then gradually fill in column data as data becomes available.

The following statement would work:
my_table.getRow(1, 'columns', {'col1'})

One thing that could be done is to generate a more specific error message when running my_table.getRow(1), for example:

There is no row data for the column named 'col2'
instead of
The specified key is not present in this container.

@bendichter
Copy link
Contributor

Yes, we have this workflow in the intro tutorial:

trials = types.core.TimeIntervals( ...
    'colnames', {'start_time', 'stop_time', 'correct'}, ...
    'description', 'trial data and properties');

trials.addRow('start_time', 0.1, 'stop_time', 1.0, 'correct', false)
trials.addRow('start_time', 1.5, 'stop_time', 2.0, 'correct', true)
trials.addRow('start_time', 2.5, 'stop_time', 3.0, 'correct', false)

where the data is not added in the constructor. However, I do think it would be strange to add some columns in the constructor but not others. How would you add the other columns later? Is that possible right now?

@ehennestad ehennestad added the status: need more info unclear what the issue is or what needs to be done label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: need more info unclear what the issue is or what needs to be done
Projects
None yet
Development

No branches or pull requests

3 participants