File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -290,11 +290,21 @@ def create_adaptive_mass_function(
290
290
np .sqrt (n ) / (width * box_volume ) for n , width in zip (number_in_bin , bin_widths )
291
291
]
292
292
293
- mass_function = unyt .unyt_array (mass_function , units = mass_function [0 ].units ,)
293
+ try :
294
+ mass_function_units = mass_function [0 ].units
295
+ except IndexError :
296
+ mass_function_units = (1 / box_volume ).units
297
+
298
+ try :
299
+ error_units = error [0 ].units
300
+ except IndexError :
301
+ error_units = mass_function_units
302
+
303
+ mass_function = unyt .unyt_array (mass_function , units = mass_function_units )
294
304
# For some reason when using a name= argument here this ends up as None?
295
305
mass_function .name = get_mass_function_label_no_units ("{}" )
296
306
297
- error = unyt .unyt_array (error , units = error [ 0 ]. units )
307
+ error = unyt .unyt_array (error , units = error_units )
298
308
299
309
bin_centers = unyt .unyt_array (
300
310
[10 ** x for x in bin_medians ], units = masses .units , name = masses .name
You can’t perform that action at this time.
0 commit comments