From 5b86dc6868140535760be3a037403d41f4f9f04f Mon Sep 17 00:00:00 2001 From: Timothy Lee Date: Mon, 15 Jun 2020 14:17:03 -0400 Subject: [PATCH] Removed check on len(idx_max) --- dream/utilities.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dream/utilities.py b/dream/utilities.py index cd2cc88..d64369e 100644 --- a/dream/utilities.py +++ b/dream/utilities.py @@ -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