-
Notifications
You must be signed in to change notification settings - Fork 63
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
Enhancements for Pk2D, Tk3D, Tracer. #923
Conversation
Pull Request Test Coverage Report for Build 2796012781
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, a nice one!
Lots of comments, but nothing major.
@damonge back to you. |
Alright @nikfilippas , almost there |
@damonge I think I addressed your final comments, have a look and let me know if you have any more questions/suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
This PR adds a number of features to the
Pk2D
object.Pk2D
s which are initialized withempty=True
never contain attributesextrap_order_hik
andextrap_order_lok
. This is a bug, and it can be fixed by making both attributes properties of the object.has_psp
has to manually be set every time an empty object is populated with apsp
. It makes more sense forhas_psp
to also be a property that peeks intopsp
to see if it's there.apply_halofit
is a class method. It makes more sense for it to be called as an instance method, as it operates using the implicit first argument (which is now passed last, explicitly). Instead ofccl.Pk2D.apply_halofit(cosmo, pk)
, we can now dopk.apply_halofit(cosmo)
. I implemented a descriptor that allows it to work both as a class method and as an instance method, with the ultimate goal to deprecate the class method usage in the future.ccl.Pk2D.pk_from_model
-->ccl.Pk2D.from_model
.eval
andeval_dlogpk_dlogk
are very similar, so I concatenated them, shortening the code base, but keeping both definitions.eval
withoutcosmo
. It will fail if a value outside the scale factor range ofpsp
is requested. This was built in the C code already. For some reason, it wasn't ported to Python.__call__
forPk2D
andTk3D
. Instead ofnp.array([pk.eval(k_arr, a) for a in a_arr])
, we can now dopk(k_arr, a_arr)
.copy
. Initialization is very fast, socopy
will enable us to operate on copies ofPk2D
objects.pk
(ortk
ortr
) have data?bool(pk)
!pk1
within the k- and a- boundaries of anotherpk2
?pk1 in pk2
! (Useful when operating with different supports.)pk1 - pk2
,pk1 / pk2
,pk += 0.05
,pk *= 1.05
,pk -= 0.05
,pk /= 0.95
,pk **= 2
.