Skip to content

Commit 45fe2a5

Browse files
yearsets.sample_events: border case amount_events is 0 and pool is empty
1 parent a4a13e1 commit 45fe2a5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

climada/util/yearsets.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ def sample_events(events_per_year, freqs_orig):
202202

203203
#add the original indices and frequencies to the pool if there are less events
204204
#in the pool than needed to fill the year one is sampling for
205-
if len(np.unique(indices)) < amount_events:
205+
#or if the pool is empty (not covered in case amount_events is 0)
206+
if len(np.unique(indices)) < amount_events or len(indices) == 0:
206207
indices = np.append(indices, indices_orig)
207208
freqs = np.append(freqs, freqs_orig)
208209

0 commit comments

Comments
 (0)