Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed
- Fixed copying of `TypeMap` and `TypeConfigurator`. Previously, the same global `TypeConfigurator` instance was used in all copies of a `TypeMap`. @rly [#1302](https://github.com/hdmf-dev/hdmf/pull/1302)
- Fixed `get_data_shape` to use `Data.data.shape` instead of `Data.shape`, which may be overridden by subclasses. @rly [#1311](https://github.com/hdmf-dev/hdmf/pull/1311)
- Fixed a broken test and refactored `VectorIndex.get`. @rly, @mavaylon1 [#1293](https://github.com/hdmf-dev/hdmf/pull/1293)

### Added
- Added a check for a compound datatype that is not defined in the schema or spec. This is currently not supported. @mavaylon1 [#1276](https://github.com/hdmf-dev/hdmf/pull/1276)
Expand Down
17 changes: 2 additions & 15 deletions src/hdmf/common/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,21 +204,8 @@ def get(self, arg, **kwargs):
indices = arg
ret = list()
if len(indices) > 0:
# Note: len(indices) == 0 for test_to_hierarchical_dataframe_empty_tables.
# This is an edge case test for to_hierarchical_dataframe() on empty tables.
# When len(indices) == 0, ret is expected to be an empty list, defined above.
try:
data = self.target.get(slice(None), **kwargs)
except IndexError:
"""
Note: TODO: test_to_hierarchical_dataframe_indexed_dtr_on_last_level.
This is the old way to get the data and not an untested feature.
"""
for i in indices:
ret.append(self.__getitem_helper(i, **kwargs))

return ret

# Load the entire target table at once to avoid multiple I/O calls
data = self.target.get(slice(None), **kwargs)
slices = [self.__get_slice(i) for i in indices]
if isinstance(data, pd.DataFrame):
ret = [data.iloc[s] for s in slices]
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/common/test_linkedtables.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def test_to_hierarchical_dataframe_indexed_dtr_on_last_level(self):
p1 = DynamicTable(name='parent_table', description='parent_table',
columns=[VectorData(name='p1', description='p1', data=np.arange(3)), dtr_p1, vi_dtr_p1])
# Super-parent table
dtr_sp = DynamicTableRegion(name='sl1', description='sl1', data=np.arange(4), table=p1)
dtr_sp = DynamicTableRegion(name='sl1', description='sl1', data=np.arange(3), table=p1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous data range was invalid because the target table only has 3 rows. This was causing an IndexError in VectorIndex.get.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oruebel since you set up this test originally, please confirm that I am not missing something

vi_dtr_sp = VectorIndex(name='sl1_index', data=[1, 2, 3], target=dtr_sp)
spt = DynamicTable(name='super_parent_table', description='super_parent_table',
columns=[VectorData(name='sp1', description='sp1', data=np.arange(3)), dtr_sp, vi_dtr_sp])
Expand Down
Loading