NeurodataWithoutBorders / pynwb

A Python API for working with Neurodata stored in the NWB Format
https://pynwb.readthedocs.io
Other
178 stars 84 forks source link

Round Trip Integration Tests Don't Check Array Contents. #815

Closed lawrence-mbf closed 5 years ago

lawrence-mbf commented 5 years ago

Steps to Reproduce

Note: This is all under pynwb\tests\integration\ui_write\base.py where pynwb is wherever the repository lives. The environment was created following the tutorial for running tests in pynwb (https://pynwb.readthedocs.io/en/stable/getting_started.html#installation)

Relevant MatNWB Issue 1) TestMapNWBContainer.assertContainerEqual() expects the first argument to be the actual read data and the second argument to be the expected data. This is flipped in the subclass TestMapRoundTrip when assertContainerEqual is called at the end of test_roundtrip(). 2) Fixing the above inconsistency revealed that h5py.Dataset classes are not accounted for when validation occurs. The error message snippet looks like this:

FAIL: test_roundtrip (ui_write.test_base.TestTimeSeriesIO) (container_type='TimeSeries', nwbfield='data')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "...\pynwb\tests\integration\ui_write\base.py", line 129, in assertContainerEqual
    self.assertEqual(f1, f2)
AssertionError: <HDF5 dataset "data": shape (10,), type "<i4"> != [100, 110, 120, 130, 140, 150, 160, 170, 180, 190]

The reason why this didn't break tests earlier was because if the first argument is array data, then it will only validate if its contents are NWBContainers or NWBData. In the expected data, the contents were numeric.

Environment

Please describe your environment according to the following bullet points.

bendichter commented 5 years ago

Thanks @ajtritt!

@ln-vidrio this bug has been fixed in the latest dev.