Skip to content

Commit

Permalink
Fix rowNumbers when stop=None and update tests accordingly
Browse files Browse the repository at this point in the history
  • Loading branch information
sbesson committed May 28, 2021
1 parent e37d12f commit 2147ffc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/omero/hdfstorageV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def read(self, stamp, colNumbers, start, stop, current):
if start is not None and stop is not None:
rowNumbers = list(range(start, stop))
elif start is not None and stop is None:
rowNumbers = list(range(start, start + 1))
rowNumbers = list(range(start, self.__length()))
elif start is None and stop is None:
rowNumbers = list(range(self.__length()))

Expand Down
25 changes: 13 additions & 12 deletions test/unit/tablestest/test_hdfstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,20 +371,21 @@ def testRead(self):
assert data.columns[1].values[1] == 9
assert data.rowNumbers == [1, 2]

# Reads row 1
data = hdf.read(time.time(), [1], 1, 2, self.current)
assert len(data.columns) == 1
assert len(data.columns[0].values) == 1
assert data.columns[0].name == 'b'
assert data.columns[0].values[0] == 5
assert data.rowNumbers == [1]

# (start=1, stop=1) should return no rows
# Reads no row
data = hdf.read(time.time(), [0, 1, 2], 1, 1, self.current)
assert len(data.columns) == 3
assert len(data.columns[0].values) == 0
assert data.rowNumbers == []

# (start=None, stop=None) should return all rows
# Read all rows
data = hdf.read(time.time(), [0, 1, 2], None, None, self.current)
assert len(data.columns) == 3
assert len(data.columns[0].values) == 3
Expand All @@ -400,19 +401,19 @@ def testRead(self):
assert data.columns[2].values[0] == 7
assert data.columns[2].values[1] == 8
assert data.columns[2].values[2] == 9
assert data.rowNumbers == [1, 2, 3]
assert data.rowNumbers == [0, 1, 2]

# (start=0, stop=None) should return one rows
data = hdf.read(time.time(), [0, 1, 2], 1, None, self.current)
assert len(data.columns) == 3
assert len(data.columns[0].values) == 1
# Read from row 1 until the end of the table
data = hdf.read(time.time(), [0, 2], 1, None, self.current)
assert len(data.columns) == 2
assert len(data.columns[0].values) == 2
assert data.columns[0].name == 'a'
assert data.columns[0].values[0] == 2
assert data.columns[1].name == 'b'
assert data.columns[1].values[0] == 5
assert data.columns[2].name == 'c'
assert data.columns[2].values[0] == 8
assert data.rowNumbers == [1]
assert data.columns[0].values[1] == 3
assert data.columns[1].name == 'c'
assert data.columns[1].values[0] == 8
assert data.columns[1].values[1] == 9
assert data.rowNumbers == [1, 2]
hdf.cleanup()

#
Expand Down

0 comments on commit 2147ffc

Please sign in to comment.