make sure the ref patch used in finest_part_data is not empty#1121
make sure the ref patch used in finest_part_data is not empty#1121rochSmets wants to merge 2 commits intoPHAREHUB:masterfrom
Conversation
📝 WalkthroughWalkthrough
Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 910
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:7-7
Timestamp: 2024-10-18T13:23:32.074Z
Learning: In the `pyphare.pharesee.hierarchy` module, importing `PatchHierarchy` and `format_timestamp` from `hierarchy.py` into `hierarchy_utils.py` is acceptable as long as `hierarchy.py` does not import `hierarchy_utils.py`, thereby avoiding a cyclic import.
📚 Learning: 2024-10-18T13:23:32.074Z
Learnt from: PhilipDeegan
Repo: PHAREHUB/PHARE PR: 910
File: pyphare/pyphare/pharesee/hierarchy/hierarchy_utils.py:7-7
Timestamp: 2024-10-18T13:23:32.074Z
Learning: In the `pyphare.pharesee.hierarchy` module, importing `PatchHierarchy` and `format_timestamp` from `hierarchy.py` into `hierarchy_utils.py` is acceptable as long as `hierarchy.py` does not import `hierarchy_utils.py`, thereby avoiding a cyclic import.
Applied to files:
pyphare/pyphare/pharesee/hierarchy/hierarchy.py
🪛 Ruff (0.14.10)
pyphare/pyphare/pharesee/hierarchy/hierarchy.py
628-628: Loop control variable i_ref not used within loop body
(B007)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build (macos-latest)
- GitHub Check: build (macos-14)
- GitHub Check: Analyze (cpp)
- GitHub Check: build (ubuntu-latest, gcc)
- GitHub Check: build (ubuntu-latest, clang)
| from ..particles import remove | ||
|
|
||
| i_ref = None | ||
| for i_ref, p in enumerate(hierarchy.level(0, time=time).patches): |
There was a problem hiding this comment.
this to me indicates another issue, not sure when as can have patches with no data perse
There was a problem hiding this comment.
for particles, some populations may exist only in some parts of the domain.
the question is should python patch datas be created when there is no particles in the patch..?
It probably exists in the cpp hierarchy with size 0 particle arrays, no?
There was a problem hiding this comment.
level ghost can have a bunch of "empty patches"
we could drop these patches here if there's no data
There was a problem hiding this comment.
ok after thinking a bit I think we may have uses cases where we need to keep empty particle patches, for instance if we want to browse two hierarchies, one field, one particles, to calculate, say, the total energy, then we'd like the two hierarchies to have the same patch structure.
In general I think it's probably better to remove patches from a hierarchy only when based on user selections
|
|
||
| i_ref = None | ||
| for i_ref, p in enumerate(hierarchy.level(0, time=time).patches): | ||
| if p.patch_datas.__len__()!=0: |
There was a problem hiding this comment.
any reason not to call len() directly?
When using
finest_part_dataof a particle hierarchy (for example in adist_plotwithfinest=True) we need to iterate through the patches, hence know their names. Then, these names was taken from the firstpatch_data, of index 0. But this one could eventually be empty, hence not able to provide these names.In this version, we hence iterate on all the patches of level 0, and then get the index of the first one that is not empty. This index is then used to get the keys of the patch_data dict, as it is then the first one to know them.
With this fix, we should then be able to make the
dist_plotof a set of particles containing empty patch(es).