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

Validation error in example file #57

Open
rly opened this issue Mar 19, 2020 · 4 comments
Open

Validation error in example file #57

rly opened this issue Mar 19, 2020 · 4 comments

Comments

@rly
Copy link
Collaborator

rly commented Mar 19, 2020

After resolving the validation error in #21 , another validation error appears: the 'colnames' attribute of /general/intracellular_ephys/intracellular_recordings/ is empty which raises an IndexError.

I raised this issue in hdmf-dev/hdmf#317

@oruebel
Copy link
Owner

oruebel commented Mar 19, 2020

Does this mean we currently do not allow DynamicTables with just the id column but no data?

@rly
Copy link
Collaborator Author

rly commented Mar 19, 2020

Correct.

from pynwb import NWBFile, NWBHDF5IO, validate
from pynwb.core import DynamicTable
from datetime import datetime


nwbfile = NWBFile(session_description='ADDME',
                  identifier='ADDME',
                  session_start_time=datetime.now().astimezone())

table = DynamicTable(name='name',
                     description='description')
table.add_row(id=1)

nwbfile.add_acquisition(table)

filename = 'nwbfile.nwb'

with NWBHDF5IO(filename, 'w') as io:
    io.write(nwbfile)

with NWBHDF5IO(filename, 'r') as io:
    validate(io)
    nwbfile = io.read()

results in the error IndexError: index 0 is out of bounds for axis 0 with size 0

@rly
Copy link
Collaborator Author

rly commented Mar 19, 2020

Also note that if no row is added, the table is not even written to disk.

@oruebel
Copy link
Owner

oruebel commented Mar 20, 2020

results in the error IndexError: index 0 is out of bounds for axis 0 with size

although that seems to be just an issue with the get_type function in the validator, i.e., the issue is with the validate(io) call; the io.read() seems to work fine. The fix for that error should be.

diff --git a/src/hdmf/validate/validator.py b/src/hdmf/validate/validator.py
index efcbb26..cea11c5 100644
--- a/src/hdmf/validate/validator.py
+++ b/src/hdmf/validate/validator.py
@@ -105,7 +105,10 @@ def get_type(data):
     elif isinstance(data, ReferenceBuilder):
         return 'object'
     elif isinstance(data, np.ndarray):
-        return get_type(data[0])
+        if len(data) > 0:
+            return get_type(data[0])
+        else:
+            return data.dtype
     if not hasattr(data, '__len__'):
         return type(data).__name__
     else:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants