From 89a00f835f37a47c9e759069ef345598414b208a Mon Sep 17 00:00:00 2001 From: Bryant Hansen Date: Wed, 14 Aug 2024 22:29:49 -0700 Subject: [PATCH 1/2] FIX: empty set does not equal None --- coco_data_split.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coco_data_split.py b/coco_data_split.py index 845fa83..60c1d81 100644 --- a/coco_data_split.py +++ b/coco_data_split.py @@ -37,7 +37,7 @@ def plot_label_frequencies(coco, data_path, title, ax, labels_common=None): - if labels_common is not None: + if len(labels_common) > 0: label_freqs = {l: 0 for l in labels_common} else: label_freqs = {l: 0 for l in CROP_ENCODING.values()} @@ -162,6 +162,9 @@ def create_dataframe(data_path, tiles, years, common_labels=None): common_lbls = common_labels(train_tiles | test_tiles) + # Correct bugs + if common_lbls is not None and len(common_lbls) == 0: + common_lbls = None # Define prefix if args.prefix is None: # No prefix given, use current timestamp From a46c17849128286e5f7408179d2b09d22e56a297 Mon Sep 17 00:00:00 2001 From: Bryant Hansen Date: Wed, 14 Aug 2024 22:33:12 -0700 Subject: [PATCH 2/2] FIX: propagate use of keyword 'all' --- coco_data_split.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/coco_data_split.py b/coco_data_split.py index 60c1d81..5926483 100644 --- a/coco_data_split.py +++ b/coco_data_split.py @@ -162,9 +162,22 @@ def create_dataframe(data_path, tiles, years, common_labels=None): common_lbls = common_labels(train_tiles | test_tiles) - # Correct bugs + # If common_lbls is an empty set, it is expected to equal None later if common_lbls is not None and len(common_lbls) == 0: common_lbls = None + + # If args.tiles is 'all', then train_tiles and test_tiles is also expected + # to be 'all' + if args.tiles == 'all': + train_tiles = 'all' + test_tiles = 'all' + + # If args.years is 'all', then train_years and test_years is also expected + # to be 'all' + if args.years == 'all': + train_years = 'all' + test_years = 'all' + # Define prefix if args.prefix is None: # No prefix given, use current timestamp