Skip to content

Commit

Permalink
Remove exception-based control flow
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodar01 committed Sep 14, 2023
1 parent 9505f1f commit 4992952
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions cellprofiler/modules/exporttospreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,16 +1408,13 @@ def make_object_file(
writer.writerow([x[i] for x in features])

for img_number in image_set_numbers:
try:
object_count = numpy.max(
[
m.get_measurement(IMAGE, "Count_%s" % name, img_number)
for name in object_names
]
)
except TypeError:
#If no objects are found in the image, we can't find the max of nan's - 4653
object_count = 0
object_count = numpy.max(
[
# If no objects are found in the image, we can't find the max of None - 4653
m.get_measurement(IMAGE, "Count_%s" % name, img_number) or 0
for name in object_names
]
)
object_count = int(object_count) if object_count and not numpy.isnan(object_count) else 0
columns = [
numpy.repeat(img_number, object_count)
Expand Down

0 comments on commit 4992952

Please sign in to comment.