-
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
Output Struct Overhaul #445
base: v4-prep
Are you sure you want to change the base?
Conversation
for more information, see https://pre-commit.ci
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v4-prep #445 +/- ##
===========================================
- Coverage 79.56% 76.88% -2.69%
===========================================
Files 24 27 +3
Lines 3803 3747 -56
Branches 647 611 -36
===========================================
- Hits 3026 2881 -145
- Misses 558 648 +90
+ Partials 219 218 -1 ☔ View full report in Codecov by Sentry. |
Summary
This changes the output structure interface to be more simple and streamlined.
It is quite a comprehensive set of changes that touch a lot of things on the python-side. I'll try to list as many as I can here for easy reference:
Arrays and Backend mapping
arrays.py
module that implements anArray
object. This object knows about the shape and dtype of an array, without necessarily having it instantiated, but also knows how to instantiate it, pass it to C, and keeps track of theArrayState
.OutputStructs
OutputStruct
is now anattrs
class. More importantly, all of the arrays that it needs to handle are defined directly on the class asArray
parameters, making it easier to track them..new()
classmethod that instantiates it from anInputParameters
object, getting the shape/dtype info (and which arrays need to be present) from theinputs
.Array
objects is that the attributes of theOutputStruct
are no longer numpy arrays, and so you can't do for examplenp.mean(ics.lowres_density)
any more. This is smoothed over a bit by newget()
and set()methods specifically for the arrays, so you can do
np.mean(ics.get('lowres_density'))`. This has the added advantage of transparently loading the array from disk if it exists there. Note that on a Coeval object, any field of any OutputStruct can be accessed directly via attribute name, as an array.OutputStruct
class, instead moving it to the newio
subpackage._compat_hash
attribute on eachOutputStruct
that tells it the level of input-hash required.Caching / IO of single-fields (OutputStruct)
io.caching
module implements classes/functions for dealing with the cache. I think this is a bit more intuitive than in previous versions.OutputCache
object has methods for introspecting a particular cache (defined by some directory the user gives at runtime) and reading/writing OutputStructs to it.RunCache
manages full runs (i.e. all boxes belonging to a full redshift-evolved simulation), allowing simple determination of which cache files are present, and which haven't yet been run (useful for checkpointing).CacheConfig
class simply defines a namespace for defining which boxes to write to cache during a larger run (coeval/lightcone).cache_tools
module has been removed as it is redundant with the above module.io/h5.py
, and so is separated from the OutputStruct class definitions themselves. This might facilitate implementing different cache formats in the future. The file format is also slightly different (I think it's slightly better now -- the format is specified in the docstring of the module, so you can check).Single-Field Computations
single_field
module is a lot simpler. I have moved most of the boiler-plate logic to a class-style decorator in_param_config
.Lightcone / Coeval
run_coeval
andrun_lightcone
into a set of external functions:evolve_perturb_halos
and_redshift_loop_generator
.Coeval
andLightcone
objects are much more slim now. I removed the ability to "gather" the cached files associated with a coeval/lc, instead relying on the improved caching module to let people deal with their full-run caches.Coeval.from_file
instead ofCoeval.read()
which I think is more intuitive.Configuration
CacheConfig
).Other Stuff
InputParameters
fromparam_config
toinputs
just because I was getting circular imports.Meta-info:
Issues Solved