Skip to content

Commit 5be8b25

Browse files
committed
if empty dont bug
1 parent 32b09cd commit 5be8b25

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

abnet3/sampler.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,10 @@ def sample_batch(self,
645645
}
646646
for config in p_spk_types.keys():
647647
keys = np.array(list(p_spk_types[config].keys()))
648-
sample_idx = sample_searchidx(cdf[config], sampled_ratio[config])
648+
if sampled_ratio[config] > 0:
649+
sample_idx = sample_searchidx(cdf[config], sampled_ratio[config])
650+
else:
651+
continue
649652
sample = keys[sample_idx]
650653
if config == 'Stype_Sspk':
651654
for key in sample:
@@ -754,7 +757,8 @@ def export_pairs(self, out_dir=None,
754757
print("Cumulative distribution")
755758
cdf = {}
756759
for key in proba.keys():
757-
cdf[key] = cumulative_distribution(proba[key])
760+
if proba[key]: # sometimes distribution is empty
761+
cdf[key] = cumulative_distribution(proba[key])
758762

759763
# This computation is important for the total number of batches/pairs
760764
# Number of possible pairs in the smallest count

0 commit comments

Comments
 (0)