Skip to content

Commit

Permalink
fix flake8 issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jburel committed Jan 10, 2024
1 parent d12b86f commit 12a5dba
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 40 deletions.
10 changes: 5 additions & 5 deletions omero/analysis_scripts/Kymograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ def plane_gen():
line_data = []
points = shape['points']
the_z = shape['theZ']
for l in range(len(points)-1):
x1, y1 = points[l]
x2, y2 = points[l+1]
for point in range(len(points)-1):
x1, y1 = points[point]
x2, y2 = points[point+1]
ld = get_line_data(image, x1, y1, x2, y2,
line_width, the_z, the_c, the_t)
line_data.append(ld)
Expand Down Expand Up @@ -334,15 +334,15 @@ def process_images(conn, script_params):
z = the_z
# TODO: Add some filter of shapes. E.g. text? / 'lines' only
# etc.
if type(s) == omero.model.LineI:
if isinstance(s, omero.model.LineI):
x1 = s.getX1().getValue()
x2 = s.getX2().getValue()
y1 = s.getY1().getValue()
y2 = s.getY2().getValue()
lines[t] = {'theZ': z, 'x1': x1, 'y1': y1, 'x2': x2,
'y2': y2}

elif type(s) == omero.model.PolylineI:
elif isinstance(s, omero.model.PolylineI):
v = s.getPoints().getValue()
points = roi_utils.points_string_to_xy_list(v)
polylines[t] = {'theZ': z, 'points': points}
Expand Down
4 changes: 2 additions & 2 deletions omero/analysis_scripts/Kymograph_Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def process_images(conn, script_params):
for s in roi.copyShapes():
if s is None:
continue # seems possible in some situations
if type(s) == omero.model.LineI:
if isinstance(s, omero.model.LineI):
table_data += "\nLine ID: %s" % s.getId().getValue()
x1 = s.getX1().getValue()
x2 = s.getX2().getValue()
Expand All @@ -103,7 +103,7 @@ def process_images(conn, script_params):
[str(x) for x in (y1, x1, y2, x2, dy, dx, dx_per_y,
speed)])

elif type(s) == omero.model.PolylineI:
elif isinstance(s, omero.model.PolylineI):
table_data += "\nPolyline ID: %s" % s.getId().getValue()
v = s.getPoints().getValue()
points = roi_utils.points_string_to_xy_list(v)
Expand Down
20 changes: 10 additions & 10 deletions omero/analysis_scripts/Plot_Profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def process_polylines(conn, script_params, image, polylines, line_width, fout):
points = pl['points']
for the_c in the_cs:
ldata = []
for l in range(len(points)-1):
x1, y1 = points[l]
x2, y2 = points[l+1]
for point in range(len(points)-1):
x1, y1 = points[point]
x2, y2 = points[point+1]
if round(x1 - x2) == 0 and round(y1 - y2) == 0:
continue
ld = roi_utils.get_line_data(
Expand Down Expand Up @@ -103,11 +103,11 @@ def process_lines(conn, script_params, image, lines, line_width, fout):
pixels = image.getPrimaryPixels()
the_cs = script_params['Channels']

for l in lines:
the_t = l['theT']
the_z = l['theZ']
roi_id = l['id']
if round(l['x1'] - l['x2']) == 0 and round(l['y1'] - l['y2']) == 0:
for line in lines:
the_t = line['theT']
the_z = line['theZ']
roi_id = line['id']
if round(line['x1'] - line['x2']) == 0 and round(line['y1'] - line['y2']) == 0:
continue
for the_c in the_cs:
line_data = []
Expand Down Expand Up @@ -192,15 +192,15 @@ def process_images(conn, script_params):
z = the_z
# TODO: Add some filter of shapes e.g. text? / 'lines' only
# etc.
if type(s) == omero.model.LineI:
if isinstance(s, omero.model.LineI):
x1 = s.getX1().getValue()
x2 = s.getX2().getValue()
y1 = s.getY1().getValue()
y2 = s.getY2().getValue()
lines.append({'id': roi_id, 'theT': t, 'theZ': z,
'x1': x1, 'y1': y1, 'x2': x2, 'y2': y2})

elif type(s) == omero.model.PolylineI:
elif isinstance(s, omero.model.PolylineI):
v = s.getPoints().getValue()
points = roi_utils.points_string_to_xy_list(v)
polylines.append({'id': roi_id, 'theT': t, 'theZ': z,
Expand Down
6 changes: 3 additions & 3 deletions omero/annotation_scripts/KeyVal_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
def get_existing_map_annotions(obj):
ord_dict = OrderedDict()
for ann in obj.listAnnotations():
if(isinstance(ann, omero.gateway.MapAnnotationWrapper)):
if isinstance(ann, omero.gateway.MapAnnotationWrapper):
kvs = ann.getValue()
for k, v in kvs:
if k not in ord_dict:
Expand Down Expand Up @@ -152,8 +152,8 @@ def run_script():

# remove the csv if it exists
for ann in ds.listAnnotations():
if(isinstance(ann, omero.gateway.FileAnnotationWrapper)):
if(ann.getFileName() == csv_name):
if isinstance(ann, omero.gateway.FileAnnotationWrapper):
if ann.getFileName() == csv_name:
# if the name matches delete it
try:
delete = Delete2(
Expand Down
4 changes: 2 additions & 2 deletions omero/export_scripts/Make_Movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,8 @@ def write_movie(command_args, conn):
c_windows = []
c_colours = []
for c in command_args["ChannelsExtended"]:
m = re.match('^(?P<i>\d+)(\|(?P<ws>\d+)' +
'\:(?P<we>\d+))?(\$(?P<c>.+))?$', c)
m = re.match('^(?P<i>\\d+)(\\|(?P<ws>\\d+)' +
'\\:(?P<we>\\d+))?(\\$(?P<c>.+))?$', c)
if m is not None:
c_range.append(int(m.group('i'))-1)
c_windows.append([float(m.group('ws')), float(m.group('we'))])
Expand Down
2 changes: 1 addition & 1 deletion omero/figure_scripts/Movie_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def add_left_labels(panel_canvas, image_labels, row_index, width, spacer):

labels = image_labels[row_index]
py = left_text_height - text_gap # start at bottom
for l, label in enumerate(labels):
for count, label in enumerate(labels):
py = py - text_height # find the top of this row
w = textdraw.textsize(label, font=font)[0]
inset = int((left_text_width - w) / 2)
Expand Down
2 changes: 1 addition & 1 deletion omero/figure_scripts/Movie_ROI_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def get_tags(name, tags_list, pd_list):
try:
height = int(h)
except ValueError:
log("Invalid height: %s Using default value" % (str(h), size_y))
log("Invalid height: %s Using default value %s" % (str(h), size_y))

log("Image dimensions for all panels (pixels): width: %d height: %d"
% (width, height))
Expand Down
4 changes: 2 additions & 2 deletions omero/figure_scripts/ROI_Split_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def get_rectangle(roi_service, image_id, roi_label):
roi_count += 1
# go through all the shapes of the ROI
for shape in roi.copyShapes():
if type(shape) == omero.model.RectangleI:
if isinstance(shape, omero.model.RectangleI):
the_t = unwrap(shape.getTheT())
the_z = unwrap(shape.getTheZ())
t = 0
Expand Down Expand Up @@ -660,7 +660,7 @@ def get_tags(name, tags_list, pd_list):
try:
height = int(h)
except ValueError:
log("Invalid height: %s Using default value" % (str(h), size_y))
log("Invalid height: %s Using default value: %d" % (str(h), size_y))

log("Image dimensions for all panels (pixels): width: %d height: %d"
% (width, height))
Expand Down
2 changes: 1 addition & 1 deletion omero/figure_scripts/Split_View_Figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def make_split_view_figure(conn, pixel_ids, z_start, z_end, split_indexes,
image_labels.reverse()
for row in image_labels:
py = left_text_width - text_gap # start at bottom
for l, label in enumerate(row):
for count, label in enumerate(row):
py = py - text_height # find the top of this row
w = textdraw.textsize(label, font=font)[0]
inset = int((height - w) // 2)
Expand Down
2 changes: 1 addition & 1 deletion omero/util_scripts/Dataset_To_Plate.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def add_images_to_plate(conn, images, plate_id, column, row, remove_from=None):
for image in images:
if remove_from is not None:
links = list(image.getParentLinks(remove_from.id))
link_ids = [l.id for l in links]
link_ids = [link.id for link in links]
conn.deleteObjects('DatasetImageLink', link_ids)
return True

Expand Down
2 changes: 1 addition & 1 deletion omero/util_scripts/Images_From_ROIs.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def get_rectangles(conn, image_id):
# note x and y for every T, to track moving object
xy_by_time = {}
for shape in roi.copyShapes():
if type(shape) == omero.model.RectangleI:
if isinstance(shape, omero.model.RectangleI):
# check t range and z range for every rectangle
# t and z (and c) for shape is optional
# https://www.openmicroscopy.org/site/support/omero5.2/developers/Model/EveryObject.html#shape
Expand Down
22 changes: 11 additions & 11 deletions omero/util_scripts/Move_Annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ def move_well_annotations(conn, well, ann_type, remove_anns, ns):
ns=ns, params=params))

# Filter by type
old_links = [l for l in old_links
old_links = [link for link in old_links
if (ann_type is None
or (l.child.__class__.__name__ == ann_type))]

link_ids = [l.id for l in old_links]
link_ids = [link.id for link in old_links]

def get_key(ann_link, with_owner=False):
# We use ann's 'key' to avoid adding duplicate annotations
Expand All @@ -76,28 +76,28 @@ def get_key(ann_link, with_owner=False):

links_dict = {}
# Remove duplicate annotations according to get_key(l)
for l in old_links:
links_dict[get_key(l, conn.isAdmin())] = l
for link in old_links:
links_dict[get_key(link, conn.isAdmin())] = link

old_links = links_dict.values()

# Find existing links on Well so we don't try to duplicate them
existing_well_links = list(conn.getAnnotationLinks('Well', [well.id],
ns=ns, params=params))
existing_well_keys = [get_key(l) for l in existing_well_links]
existing_well_keys = [get_key(l) for link in existing_well_links]

new_links = []
for l in old_links:
if get_key(l) in existing_well_keys:
for link in old_links:
if get_key(link) in existing_well_keys:
continue
log(" Annotation: %s %s" % (l.child.id.val,
l.child.__class__.__name__))
log(" Annotation: %s %s" % (link.child.id.val,
link.child.__class__.__name__))
link = WellAnnotationLinkI()
link.parent = WellI(well.id, False)
link.child = l.child
link.child = link.child
# If Admin, the new link Owner is same as old link Owner
if conn.isAdmin():
owner_id = l.details.owner.id.val
owner_id = link.details.owner.id.val
link.details.owner = ExperimenterI(owner_id, False)
new_links.append(link)
try:
Expand Down

0 comments on commit 12a5dba

Please sign in to comment.