-
Notifications
You must be signed in to change notification settings - Fork 38
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
Remove Recursion #415
base: v4-prep
Are you sure you want to change the base?
Remove Recursion #415
Conversation
brightness_temp, | ||
ts_box, | ||
) | ||
) |
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.
Should these be saved to the struct itself instead of taking the brightness_temp struct's parameters?
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.
We certainly could do that -- at the moment we always require having a brightness_temp
struct in this instance, and the various input structs must be the same for all boxes, so merely referencing them from the brightness_temp
struct makes sense to me
and self.flag_options == other.flag_options | ||
and self.astro_params == other.astro_params | ||
) | ||
|
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.
This is a much older issue but we don't have random seed in __eq__
?
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.
That's true. We should probably ensure that as well -- problematically sometimes you also want to compare without the random seed. But I think you're right that the default equality method should include the random seed.
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.
This looks 95% done to me, I've left some notes for things to look into which I should be able to get to relatively quickly.
"flag_options": inputs.flag_options, | ||
"init_boxes": initial_conditions, | ||
}, | ||
**iokw, |
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.
So we put the init boxes instead of user/cosmo params in the kwargs?
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.
Yes -- because every other low-level function other than initial_conditions
requires passing initial_conditions
instead of the user
and cosmo
params (because they now require the initial conditions to be passed, which already has those params defined in it, so it's easier to take them from there, rather than having two ways to get the params and having to make sure they match.
src/py21cmfast/drivers/coeval.py
Outdated
spin_temp=st2 if inputs.flag_options.USE_TS_FLUCT else None, | ||
z_heat_max=global_params.Z_HEAT_MAX, | ||
# cleanup if its the last time through | ||
cleanup=cleanup and z == redshifts[-1], |
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.
This function doesn't have a cleanup kwarg
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.
the kwarg has been removed
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.
ah yeah, because I don't think you need it once recursion is removed
redshift = redshift.tolist() | ||
|
||
# Get the list of redshift we need to scroll through. | ||
redshifts = _get_required_redshifts_coeval(flag_options, redshift) |
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.
consider renaming redshifts
and redshift
to node_redshifts
and out_redshifts
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.
Great idea -- that would be a lot more clear.
return redshifts.tolist() | ||
|
||
|
||
def _get_coeval_callbacks( |
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.
I can't find where these are used
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.
Yeah, I think we've moved away from using these callbacks -- instead we just do a yield
from the main wrapper so the user can do anything they like with the result. Perhaps we'd still want something like this to exist for a CLI interface or something where the user has less control over what happens at each step.
|
||
return kwargs | ||
|
||
def __eq__(self, other): |
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.
Perhaps I'm missing something but should the random seed be included in __eq__
?
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.
Yeah, same reply as above.
If you know what you are doing, please modify the global parameter: | ||
NU_X_MAX | ||
""" | ||
) |
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.
One thing I think would be nice here is to have different running "modes" which are sets of default parameters we can switch between e.g a default parameter set for the halo model, grid model, and constant zeta model
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.
Absolutely, see #10. But I think not in this PR
testplots/tests.test_integration_features.py--test_power_spectra_coeval[minimize_mem].pdf
Outdated
Show resolved
Hide resolved
Conflicts: src/py21cmfast/__init__.py src/py21cmfast/inputs.py src/py21cmfast/src/21cmFAST.h src/py21cmfast/src/Stochasticity.c src/py21cmfast/wrapper.py src/py21cmfast/wrapper/outputs.py src/py21cmfast/wrapper/structs.py
This PR removes recursion from all the component calculations. It changes a whole bunch of stuff to achieve this well, including:
InputStruct
objects that get subclassed toUserParams
etc. These are now attrs-based classes, which makes them a little more transparent.InputParameter
class that handles collections of the InputStruct objects and their validation.