[BUG] Make Gizmo's creation_time field robust against empty chunks#5440
[BUG] Make Gizmo's creation_time field robust against empty chunks#5440chummels wants to merge 3 commits into
creation_time field robust against empty chunks#5440Conversation
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
|
This looks reasonable to me, but I want to just verify that I understand -- does the same error happen if you use a field that doesn't explicitly call the cosmology routine? I just want to know if, for instance, a particle filter will fail if the chunk is empty even if the cosmology routines aren't used. From my reading it's explicitly from calling |
|
I'll bet that at least for the GIZMO frontend this bug was never encountered for a non-cosmo sim, but if the array is zero-shaped so long as some internal function is called you should pass the field fine. But yes, some downstream things will cause errors. In any case, @chummels's fix works for either case. |
|
@matthewturk I think your reading of this is correct. Normally, a particle field is just applying some sort of boolean mask based on a condition (e.g., |
PR Summary
The gizmo frontend's
creation_timederived field assumes that each data chunk contains at least one star particle. When evaluating particle filters over chunked data, some chunks may contain zero particles of the filtered parent type. In this case, thecreation_timefield is evaluated on an empty array, which propagates into a call to:data.ds.cosmology.t_from_z(z_form)and ultimately raises the erorr:
ValueError: zero-size array to reduction operation minimum which has no identityThis issue arises in workflows that combine: particle filters, derived quantities, and chunked data access.
This PR modifies the GIZMO
creation_timefield to explicitly handle empty inputs:If
StellarFormationTimehas zero size, return an empty yt array with appropriate time units.Otherwise, proceed with the existing cosmological or non-cosmological calculation.
This ensures that downstream derived fields and particle filters behave correctly when applied to chunks with zero particles.
This PR resolves Issue #5439 .
PR Checklist