Skip to content

Commit e9efa0d

Browse files
authored
fix a bug that made auc_per_energy fail when there where no gamma or cosmic in a bin
1 parent d68dc60 commit e9efa0d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

ctaplot/ana/ana.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ def roc_auc_per_energy(true_type, gammaness, true_energy, energy_bins=None, gamm
13861386
cosmic_mask = (true_type != gamma_label)
13871387
mask = gamma_mask | cosmic_mask
13881388

1389-
if np.count_nonzero(mask) > 0:
1389+
if np.count_nonzero(gamma_mask) > 0 and np.count_nonzero(cosmic_mask) > 0: # be sure to have both gamma and cosmic to be able to compute an auc
13901390
auc_score = metrics.roc_auc_score(binarized_label[mask], gammaness[mask], **roc_auc_score_opt)
13911391
if auc_score < 0.5:
13921392
auc_score = 1 - auc_score

0 commit comments

Comments
 (0)