-
Notifications
You must be signed in to change notification settings - Fork 280
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
[BOXLIB] consistent parsing for periodicity parameters #2792
Conversation
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 "reviewed" myself as a means to document the changes, but obvious this shouldn't count as a review !
@@ -733,7 +733,7 @@ def _parse_cparams(self): | |||
elif param == "amr.ref_ratio": | |||
vals = self.refine_by = int(vals[0]) | |||
elif param == "Prob.lo_bc": | |||
vals = self.periodicity = ensure_tuple([i == 0 for i in vals.split()]) | |||
vals = self.periodicity = ensure_tuple([p == "1" for p in vals.split()]) |
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 line is clearly bugged since it relies on comparing a string to an integer. From what I think I understood, this should be the correct version for it.
self.periodicity = [True, True, True] | ||
for i, axis in enumerate("xyz"): | ||
try: | ||
self.periodicity[i] = self.parameters["bc%s_lo" % axis] | ||
except KeyError: | ||
break |
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.
Here is just a refactor to avoid repeated code (bis).
self.periodicity = [True] * 3 | ||
try: | ||
is_periodic = self.parameters["geometry.is_periodic"].split() | ||
self.periodicity[: len(is_periodic)] = [p == "1" for p in is_periodic] | ||
except KeyError: | ||
pass | ||
self.periodicity = ensure_tuple(self.periodicity) |
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 the part addressed originally in #2787
dd6cebb
to
c7e5406
Compare
@@ -1650,11 +1644,13 @@ def _parse_parameter_file(self): | |||
self.parameters[l[0].strip()] = l[1].strip() | |||
|
|||
# set the periodicity based on the integer BC runtime parameters | |||
is_periodic = self.parameters["geometry.is_periodic"].split() |
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 line is the crash that #2787 fixes.
abca996
to
fc5b333
Compare
@@ -621,7 +621,7 @@ class BoxlibDataset(Dataset): | |||
_output_prefix = None | |||
|
|||
# THIS SHOULD BE FIXED: |
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.
@matthewturk can I have your review on this comment you wrote ? I don't know what was there to fix (default value, type, anything else ?) and if that comment should be cleaned up or updated.
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.
tmp[2] = False | ||
self.periodicity = ensure_tuple(tmp) | ||
self.periodicity = list(self.periodicity) | ||
self.periodicity[1:] = False |
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 think I don't understand this line easily, can you please clarify or add a comment? :)
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.
Thanks for reviewing this ! In light of recent developments (especially #2893, where I essentially remove ensure_tuple
), I just gave this another go. The specific line you're commenting here is now gone, and now periodicity should be only parsed once in BoxlibDataset._parse_cparams
, in a dimensionality-agnostic way. Is it clearer now ?
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.
@ax3l We'll wait for your reply before this is merged :)
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.
Is it clearer now ?
yes, thanks a lot.
0c41f93
to
c14baa5
Compare
I can confirm that this works with Castro and correctly detects the periodicity (at least for the data set I tried). |
Thank you @zingale ! 🎉 |
4d70649
to
dadfc43
Compare
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
dadfc43
to
87ef23a
Compare
hi @ax3l, I'm sorry to ask again but I couldn't find another way to contact you: do you approve of this PR in the current state ? thanks ! |
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.
LGTM, thank you!
PR Summary
This supersedes #2787 and adresses the issue at the frontend level. Turns out there is actually more than one place where periodicity is incorrectly or inconsistently parsed.
PR Checklist
flake8 yt/
isort . --check --diff
black --check yt/