Skip to content

Commit 36855d4

Browse files
committed
exceptions instead of asserts
1 parent 3fcfcb7 commit 36855d4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

label_maker/package.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def package_directory(dest_folder, classes, imagery, ml_type, seed=False, split_
3535
Percentage of data to put in each catagory listed in split_names.
3636
Must be floats and must sum to one.
3737
split_names: list
38-
Default: ['train', 'test']
38+
Default: ['train', 'test']
3939
List of names for each subset of the data.
4040
**kwargs: dict
4141
Other properties from CLI config passed as keywords to other utility functions
@@ -44,9 +44,10 @@ def package_directory(dest_folder, classes, imagery, ml_type, seed=False, split_
4444
if seed:
4545
np.random.seed(seed)
4646

47-
#assert len(split_names) == 2 or len(split_names) == 3.
48-
assert len(split_names) == len(split_vals), "split_names and split_vals must be the same length."
49-
assert np.isclose(sum(split_vals), 1), "split_vals must sum to one."
47+
if len(split_names) != len(split_vals):
48+
raise ValueError('`split_names` and `split_vals` must be the same length. Please update your config.')
49+
if not np.isclose(sum(split_vals), 1):
50+
raise ValueError('`split_vals` must sum to one. Please update your config.')
5051

5152
# open labels file, create tile array
5253
labels_file = op.join(dest_folder, 'labels.npz')

0 commit comments

Comments
 (0)