cxcsds/xspec-models-cxc

Use of the out argument for inplace models is dangerous

DougBurke opened this issue · 0 comments

out = np.zeros(egrid.size - 1)
x.apec(energies=egrid, pars=pars, out=out)

will use the memory in out rather than creating a new array [it also returns the out array].

This only works when out has the correct datatype (np.float32 or np.float64) for the model, otherwise it will not be updated (the returned value is correct, but is not the same object as out).

This is crazy and dangerous.