You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a new instance of one of the camb.model.*Params classes, the attributes are set to zero by default instead of the sensible defaults in model.f90. For example, in case of camb.model.AccuracyParams:
>>> import camb
>>> acc = camb.model.AccuracyParams()
>>> print(acc)
class: <AccuracyParams>
AccuracyBoost = 0.0
lSampleBoost = 0.0
lAccuracyBoost = 0.0
AccuratePolarization = False
AccurateBB = False
AccurateReionization = False
TimeStepBoost = 0.0
BackgroundTimeStepBoost = 0.0
IntTolBoost = 0.0
SourcekAccuracyBoost = 0.0
IntkAccuracyBoost = 0.0
TransferkBoost = 0.0
NonFlatIntAccuracyBoost = 0.0
BessIntBoost = 0.0
LensingBoost = 0.0
NonlinSourceBoost = 0.0
BesselBoost = 0.0
LimberBoost = 0.0
SourceLimberBoost = 0.0
KmaxBoost = 0.0
neutrino_q_boost = 0.0```
This then leads to obscure errors when computing anything. It would be nice if the python class gets populated with the Fortran defaults or at least that an error is thrown if not all attributes are specified.
The text was updated successfully, but these errors were encountered:
I agree it is odd. But currently only objects descended from F2003Class can be expected to initialize as the Fortran in python generated instances. It wasn't really intended that people make separate instances of CAMBstructure types as these are basically just standard ctypes memory and only used as elements of containing F2003Class instances. I think the only obvious solution is to convert all CAMBstructure types to F2003Class or add custom init methods for each subclass declared. For me this is not a priority, but happy to consider pull requests if you think it would be useful.
For now I've just avoided the use of the CAMBstructure derived classes. At some point it would be nice to be able to create instances to pass to camb.model.CAMBparams without having to maintain a list of default values (which might diverge from the CAMB ones over time).
Would replacing CAMBstructure with F2003Class and adding the @fortran_class decorator and a _fortran_class_name_ class attribute be all that needs to be done?
When creating a new instance of one of the
camb.model.*Params
classes, the attributes are set to zero by default instead of the sensible defaults inmodel.f90
. For example, in case ofcamb.model.AccuracyParams
:The text was updated successfully, but these errors were encountered: