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

getGridSize() handles plates with no Wells #398

Merged
merged 2 commits into from
Apr 24, 2024
Merged
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
6 changes: 5 additions & 1 deletion src/omero/gateway/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6645,6 +6645,7 @@ def getGridSize(self):
"""
Iterates all wells on plate to retrieve grid size as {'rows': rSize,
'columns':cSize} dict.
If the Plate has no Wells, it will return {'rows': 0, 'columns': 0}

:rtype: dict of {'rows': rSize, 'columns':cSize}
"""
Expand All @@ -6656,7 +6657,10 @@ def getGridSize(self):
"where plate.id = :id"
res = q.projection(query, params, self._conn.SERVICE_OPTS)
(row, col) = res[0]
self._gridSize = {'rows': row.val+1, 'columns': col.val+1}
if row is None or col is None:
self._gridSize = {'rows': 0, 'columns': 0}
Copy link
Member

Choose a reason for hiding this comment

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

The handling makes sense. An alternative would be to store and return self._gridSize = None. In case the wells are being added in between calls, this would allow subsequent calls to self.getGridSize() to retry the plate query. I do not know enough about consumers of this API and how a None return value would be handled.

Either way, it's probably good practice to update the docstring and document the expectation in case the plate has no wells.

Copy link
Member Author

Choose a reason for hiding this comment

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

@sbesson - apologies for the delay...
I think the expectation is not to return None - Returning sizes of 0 is more consistent and doesn't need special handling of None by consumers.
Docstring updated.

else:
self._gridSize = {'rows': row.val+1, 'columns': col.val+1}
return self._gridSize

def getWellGrid(self, index=0):
Expand Down
Loading