I had some perf suggestions after this popped up in my notifications:
Pre-convert the parameters, and use np.ufunc.at to avoid a temporary
# calculate the model distribution for every parameter varied up and down
# within the respective uncertainties
# ensure float for correct addition
float_parameters = parameters.astype(float)
for i_par in range(model.config.npars):
# central parameter values, but one parameter varied within uncertainties
up_pars = float_parameters.copy()
np.add.at(up_pars, i_par, uncertainty)
down_pars = float_parameters.copy()
np.subtract.at(down_pars, i_par, uncertainty)
Pre-allocate stacked arrays and use in-place assignment (unsure of shapes here, so it's pseudo-code)
Originally posted by @agoose77 in https://github.com/scikit-hep/cabinetry/issues/408#issuecomment-1614454884