-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get_parameters_dict() method possibility #1150
Comments
For now you can retrieve the two private attributes |
This kind of exists but it's ocult: |
Oh, @hsinfan1996 beat me to it :) |
@hsinfan1996 @fjaviersanchez brill! much obliged!! |
|
@tilmantroester ah I see you also prefer to have a method rather then calling cosmology._params_init_kwargs yeah actually makes sense (going back to my initial request) |
You shouldn't use private APIs (eg anything with a leading underscore) outside of CCL, since they can change at any point. Better to add a proper API than hack something together. |
Yeah totally makes sense, you are right. And this is not some elaborate code that requires 3 days (it's a few min in Python at least) and it is beyond useful to have. I have my own version of it and use it constantly. |
We should look into how to make |
I am having precisely that difficulty with the blinding library. I found a very dirty temporary solution that is similar to what has been suggested in this issue: def _create_blinded_cosmo(self):
"""
Creates a blinded cosmology object with the shifts applied.
FIXME: Unsure this is the best way of doing this but it is similar to what is done in Augur.
"""
blinded_cosmo_dict = deepcopy(self.cosmo._params_init_kwargs)
# sometimes we have this extra paramters that can cause problems:
try:
del blinded_cosmo_dict['extra_parameters']
except KeyError:
pass
for k in self.__shifts.keys():
blinded_cosmo_dict[k] = self.__shifts[k]
blinded_cosmo = ccl.Cosmology(**blinded_cosmo_dict)
return blinded_cosmo A safer, more "off the shelf" solution would be great. I am not super happy with the solution I found. (Note that HORRIBLE, inexcusable |
I was wondering, can we have an option to draw a param dict from the cosmology object?
cosmology = ccl.Cosmology(Omega_m=0.3, h=0.67...)
params = cosmology.get_parameters_dict()
params = {
'Omega_c': cosmology['Omega_c'],
'Omega_b': cosmology['Omega_b'],
'h': cosmology['h'],
'sigma8': cosmology['sigma8'],
'n_s': cosmology['n_s'],
# Add any other relevant parameters here
}
@hsinfan1996
The text was updated successfully, but these errors were encountered: