Type checking of C1, C2, C3 values fails for Compton gamma photon flux profile
Closed this issue · 2 comments
verifySettings()
in DREAM/py/DREAM/Settings/Equations/RunawayElectrons.py
raises EquationException("Invalid type for 'C1_Compton'. Expected float.")
error when restarting the simulation, due to the values being read from the HDF5 file.
Suggested solution is to change the verifySettings()
function to check type(self.C1_Compton) not in [float, np.double]
instead.
I would suggest a somewhat different solution! Instead of modifying verifySettings()
(and thereby patching an error which has already occurred) it would be better to prevent the type of C1_Compton
etc from ever being anything other than a Python float
. This can be achieved by explicitly casting them to float
s when loading the coefficients in the fromdict()
routine. It would look something like:
self.C1_Compton = float(data['compton']['C1'])
...
It is definitely the fromdict()
routine which is giving rise to your problem, so it's better to fix it there than in code which is called later.