Skip to content

Commit

Permalink
Merge pull request #188 from will-moore/images_from_rois_python3_fixes
Browse files Browse the repository at this point in the history
python3 fixes to Images_From_ROIs.py
  • Loading branch information
joshmoore authored Jun 21, 2021
2 parents dddc749 + 249c433 commit d75f050
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
6 changes: 3 additions & 3 deletions omero/util_scripts/Images_From_ROIs.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def create_image():
for c in range(0, size_c):
for z in range(0, size_z):
for tile_offset_y in range(
0, ((size_y + tile_height - 1) / tile_height)):
0, ((size_y + tile_height - 1) // tile_height)):
for tile_offset_x in range(
0, ((size_x + tile_width - 1) / tile_width)):
0, ((size_x + tile_width - 1) // tile_width)):
x = tile_offset_x * tile_width
y = tile_offset_y * tile_height
w = tile_width
Expand All @@ -104,7 +104,7 @@ def create_image():
tile_gen = primary_pixels.getTiles(zct_tile_list)

def next_tile():
return tile_gen.next()
return next(tile_gen)

class Iteration(TileLoopIteration):

Expand Down
30 changes: 18 additions & 12 deletions test/integration/test_util_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,29 +87,35 @@ def test_combine_images(self):
assert combine_img.getValue().id.val > 0

@pytest.mark.parametrize("image_stack", [True, False])
def test_images_from_rois(self, image_stack):
@pytest.mark.parametrize("size", [100, 4000])
def test_images_from_rois(self, image_stack, size, tmpdir):
if image_stack and size > 3000:
# Not supported
return
script_id = super(TestUtilScripts, self).get_script(images_from_rois)
assert script_id > 0
# root session is root.sf
session = self.root.sf
client = self.root

size_x = 100
size_y = 100
size_x = size + 100
size_y = size + 50
size_z = 5
image = self.create_test_image(size_x, size_y, size_z, 1, 1)
image_id = image.id.val
name = "test&sizeX=%s&sizeY=%s&sizeZ=%s.fake" % (size_x, size_y,
size_z)
# Supports import of big and small images
image_id = self.import_pyramid(tmpdir, name=name, client=client)
image_ids = []
image_ids.append(omero.rtypes.rlong(image_id))

# Add rectangle
roi = omero.model.RoiI()
roi.setImage(omero.model.ImageI(image_id, False))
rect = omero.model.RectangleI()
rect.x = omero.rtypes.rdouble(0)
rect.y = omero.rtypes.rdouble(0)
rect.width = omero.rtypes.rdouble(size_x / 2)
rect.height = omero.rtypes.rdouble(size_y / 2)
rect.x = omero.rtypes.rdouble(5)
rect.y = omero.rtypes.rdouble(10)
rect.width = omero.rtypes.rdouble(size)
rect.height = omero.rtypes.rdouble(size)
roi.addShape(rect)
session.getUpdateService().saveAndReturnObject(roi)
args = {
Expand Down Expand Up @@ -254,10 +260,10 @@ def test_move_annotations(self, remove, script_runner):
" where l.parent.id in (:ids)")
params = omero.sys.ParametersI().addIds(well_ids)
links = query_service.findAllByQuery(query, params)
link_ids = [l.id.val for l in links]
link_ids = [link.id.val for link in links]
assert len(link_ids) == field_count * 3
for l in links:
assert l.getDetails().owner.id.val == user_id
for link in links:
assert link.getDetails().owner.id.val == user_id
delete = Delete2(targetObjects={'WellAnnotationLink': link_ids})
handle = client.sf.submit(delete)
client.waitOnCmd(handle, loops=10, ms=500, failonerror=True,
Expand Down

0 comments on commit d75f050

Please sign in to comment.