File tree 2 files changed +24
-10
lines changed
2 files changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -190,11 +190,18 @@ def create_adaptive_bins(
190
190
number_in_bin .append (current_bin_count )
191
191
elif current_bin_count == 1 :
192
192
# Extend the previous bin (otherwise error is consistent with zero)
193
- bin_edges_right [- 1 ] = value
194
- number_in_bin [- 1 ] += 1
195
- bin_medians [- 1 ] = np .median (sorted_values [- number_in_bin [- 1 ] :])
196
- # We don't need the next bin now.
197
- bin_edges_left = bin_edges_left [:- 1 ]
193
+ try :
194
+ bin_edges_right [- 1 ] = value
195
+ number_in_bin [- 1 ] += 1
196
+ bin_medians [- 1 ] = np .median (sorted_values [- number_in_bin [- 1 ]:])
197
+ # We don't need the next bin now.
198
+ bin_edges_left = bin_edges_left [:- 1 ]
199
+
200
+ # There is no previous bin because we have just one bin in total
201
+ except IndexError :
202
+ bin_edges_right .append (value )
203
+ number_in_bin .append (1 )
204
+ bin_medians .append (sorted_values [- 1 ])
198
205
else :
199
206
# This bin doesn't exist anyway, boo...
200
207
bin_edges_left = bin_edges_left [:- 1 ]
Original file line number Diff line number Diff line change @@ -272,11 +272,18 @@ def create_adaptive_mass_function(
272
272
number_in_bin .append (current_bin_count )
273
273
elif current_bin_count == 1 :
274
274
# Extend the previous bin (otherwise error is consistent with zero)
275
- bin_edges_right [- 1 ] = mass
276
- number_in_bin [- 1 ] += 1
277
- bin_medians [- 1 ] = np .median (sorted_masses [- number_in_bin [- 1 ] :])
278
- # We don't need the next bin now.
279
- bin_edges_left = bin_edges_left [:- 1 ]
275
+ try :
276
+ bin_edges_right [- 1 ] = mass
277
+ number_in_bin [- 1 ] += 1
278
+ bin_medians [- 1 ] = np .median (sorted_masses [- number_in_bin [- 1 ] :])
279
+ # We don't need the next bin now.
280
+ bin_edges_left = bin_edges_left [:- 1 ]
281
+
282
+ # There is no previous bin because we have just one bin in total
283
+ except IndexError :
284
+ bin_edges_right .append (mass )
285
+ number_in_bin .append (1 )
286
+ bin_medians .append (sorted_masses [- 1 ])
280
287
else :
281
288
# This bin doesn't exist anyway, boo...
282
289
bin_edges_left = bin_edges_left [:- 1 ]
You can’t perform that action at this time.
0 commit comments