Closed nikfilippas closed 1 year ago
I haven't seen others chime in. I understand the logic of this, but worry about deprecating Profile2pt
s completely at this point. There are edge cases we haven't really come across yet, in which there are non-trivial covariances between profiles of the same type or even of different types. Those can grow as N^2, and I'd worry that it'll be clunky for users to have to create new bespoke profiles overloading the fourier_2pt
method for each of those (rather than simply coding up a new Profile2pt
).
It may be that we come up with a better way of doing this through fourier_2pt
, and we can deprecate Profile2pt
in the future, but I'd rather not do this blindly (i.e. without first having confronted a real-life scenario).
I'll leave this open so others can chime in, but since this can happen in v3 without delaying it, I will release v2.8 without deprecating Profile2pt
s
You've mentioned this before, but I am not convinced this is actually the case. Particularly with the N^2 argument, like I mentioned, either we are going to have N^2 objects or N^2 if-clauses, so it makes no difference to the amount of code. But maybe I am misunderstanding something, so could you demonstrate that with an example that showcases the need for Profile2pt
for these "nontrivial covariances"?
Nothing will demonstrate the need of Profile2pt
against having lots of if statements. The point is what will be clunkier for users, and we haven't had enough experience with that to make this call.
So, what I don't understand is 1. how will it be clunkier for users, since that would simplify the API and 2. can you elaborate on the N^2 issue you mentioned, as I think that is not actually the case.
OK, since you insist. Here's an example (only one of many different situations we may come across, which we cannot predict right now from CCL): someone has two samples of galaxies represented by an HOD, but galaxies in one sample can also be in the second sample (but not all of them). In that case, the HOD covariance is non-trivial. It's an edge case that we shouldn't have to support in CCL, at least for now.
Currently users just have to subclass their own Profile2pt for this particular correlation and use it to calculate that particular power spectrum.
With the change you propose, users would have to subclass HaloProfileHOD and overload the fourier_2pt function. Then, it's not even clear to me a priori how they would tell the current halo model calculator functions which version/if branch of the fourier_2pt method they should be using for each of the different possible correlations.
I'm sure there may be a workaround, but I see no major issue with keeping the current structure that would justify delaying the move to v3 (which is long, long overdue and delaying the implementation of important new science), since such a workaround could be implemented within v3.
Your example does indeed demonstrate the need to have Profile2pt
as a class handling the binary operation. However, may I just point out that this is a very niche case, and sometimes, having the most general framework for a particular implementation isn't helpful at all (neither for devs nor for users). If it was up to me, I'd get rid of Profile2pt
(the changes are minor really) until it becomes evident through the use-cases, that there needs to be such an implementation (as I doubt there will soon be a need for that).
PS: There is no major issue with the current implementation - it's just slightly awkward in the same way normprof
was peculiar to pass it into the functions. We have a chance to fix that now that we're breaking the API, but it's not the end of the world if we don't.
OK, I'll close this for now, but please feel free to chime in or reopen.
Profile2pt
calculates the profile covariance and implements the 2-point correlator of two halo profiles. In a way, it is akin to a class implementing a binary operation between two profiles, just like__add__
,__mul__
, or evennumpy.correlate
.The base class implements a one-parameter
__init__
acceptingr_corr
, which controls the correlation strength of the two profiles. However, this is not used by any of the subclasses.The subclasses implement special cases (for HOD, and CIB profiles) and override
fourier_2pt
which internally callsHaloProfile._fourier_variance
. They do not actually compute anything, and only act as an interface between theProfile2pt
superclass andHaloProfile
.I think this usage is slightly awkward. It complicates the relations between halo profiles, and makes it so that halo model functions need a 2-point correlator as input. Similarly to
normprof
, which is now implemented under theHaloProfile
class, my opinion is that we should loseProfile2pt
in favour of_fourier_variance
(which will become public and get a better name). It also needlessly creates an object, asProfile2pt
only represents the relation between a halo profile, and another halo profile.Subclasses are particular implementations of 2-point correlations for different profile types, and only work with a certain profile type (i.e. are not generic).
The proposed code would look like this for the default implementation:
And we could explicitly change what the calculation does, depending on the input profile types (
self
andother
),just like we do with most other baseclass-subclass relations implemented throughout CCL.
In essence, instead of creating a new subclass for every special type of correlation, we would now simply add an if-clause to the
HaloProfile
's subclassedfourier_2pt
method. This could easily be extended tofourier_3pt
,fourier_4pt
etc. in the future, without the need to create new subclasses for every possible combination of halo profiles.