Skip to content

Commit

Permalink
Removed check on len(idx_max)
Browse files Browse the repository at this point in the history
  • Loading branch information
tabula-rosa committed Jun 15, 2020
1 parent 4a74c81 commit 5b86dc6
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions dream/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,15 @@ def find_ndds_data_in_dir(

if image_extension is None:
# Auto detect based on list of image extensions to try
# In case there is a tie, prefer the first in this list
# In case there is a tie, prefer the extensions that are closer to the front
image_exts_to_try = ["png", "jpg"]
num_image_exts = []
for image_ext in image_exts_to_try:
num_image_exts.append(len([f for f in dirlist if f.endswith(image_ext)]))
max_num_image_exts = np.max(num_image_exts)
idx_max = np.where(num_image_exts == max_num_image_exts)[0]
if len(idx_max) == 1:
# Max exists once, so use the corresponding image extension
image_extension = image_exts_to_try[idx_max[0]]
else:
# Multiple cases of the same image extension
image_extension = image_exts_to_try[0]
# If there are multiple indices due to ties, this uses the one closest to the front
image_extension = image_exts_to_try[idx_max[0]]
else:
assert isinstance(
image_extension, str
Expand Down

0 comments on commit 5b86dc6

Please sign in to comment.