Skip to content
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

BUG: fix parameter parsing for Castro and MAESTRO #4828

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

yut23
Copy link
Member

@yut23 yut23 commented Feb 23, 2024

PR Summary

Castro (since 18.04), MAESTROeX (since 20.09), and MAESTRO (since 2013) add a prefix [*] before runtime parameters that are changed from their defaults. This was being handled by the Dataset subclasses individually, leading to duplicated and inconsistent logic (CastroDataset wasn't stripping the parameter names, leading to duplicates with trailing spaces).

This PR moves the prefix handling into BoxlibDataset, and removes the prefix so analysis scripts don't need to check for both versions in ds.parameters.

PR Checklist

  • Adds a test for any bugs fixed. Adds tests for new features.

@@ -1128,16 +1132,6 @@ def _parse_parameter_file(self):
self.parameters[fields[0]] = fields[1].strip()
line = next(f)

# runtime parameters that we overrode follow "Inputs File
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not clear to me why this can be removed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doing the same thing as _parse_cparams() in BoxlibDataset, but doesn't strip the trailing space from p or run v through _guess_pcast().

@@ -1199,21 +1193,8 @@ def _parse_parameter_file(self):
fields = line.split(":")
self.parameters[fields[0]] = fields[1].strip()

with open(jobinfo_filename) as f:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice one

Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great. Although, I don't know that we correctly test for this already, do you have a sample dataset that I could use just for manual checking that this is now doing the right thing ?
Also, if I'm reading the top description right, it sounds like this would qualify as a bug fix and should be back ported. Is that right ?

@neutrinoceros neutrinoceros added the code frontends Things related to specific frontends label Feb 24, 2024
@neutrinoceros neutrinoceros added this to the 4.3.1 milestone Feb 24, 2024
@yut23 yut23 force-pushed the castro-parameters-cleanup branch from 2d2dd30 to 6b89ed4 Compare February 26, 2024 19:19
@yut23
Copy link
Member Author

yut23 commented Feb 26, 2024

I did my testing on castro_sedov_1d_cyl_plt00150 from the yt samples.

@yut23
Copy link
Member Author

yut23 commented Feb 26, 2024

There's already a test for the MAESTRO parameters; I'll see if I can add one for Castro shortly.

@yut23 yut23 force-pushed the castro-parameters-cleanup branch from 6b89ed4 to b1a6abb Compare February 26, 2024 19:49
@yut23 yut23 changed the title ENH: simplify parameter parsing for Castro and MAESTRO BUG: simplify parameter parsing for Castro and MAESTRO Feb 26, 2024
Copy link
Member

@neutrinoceros neutrinoceros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried running the test on main and all 6 first assert statements failed there, so I think we can confirm this is indeed a Bugfix :D
I still have one small question about that test, otherwise LGTM

assert "[*] castro.do_hydro" not in ds.parameters

# Not modified from default
assert ds.parameters["castro.pslope_cutoff_density"] == float("-1e+200")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on main and this assert fails there with

E       AssertionError: assert -1e+20 == -1e+200
E        +  where -1e+200 = float('-1e+200')

so I guess this parameter is modified from default ? or maybe I'm missing something ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, just a typo on my part. It's fixed now.

Castro (since 18.04), MAESTROeX (since 20.09), and MAESTRO (since 2013)
add a prefix `[*]` before runtime parameters that are changed from their
defaults. This was being handled by the Dataset subclasses individually,
leading to duplicated and inconsistent logic (CastroDataset wasn't
stripping the parameter names, leading to duplicates with trailing
spaces).

This change moves the prefix handling into BoxlibDataset, and removes
the prefix so analysis scripts don't need to check for both versions in
`ds.parameters`.
@yut23 yut23 force-pushed the castro-parameters-cleanup branch from b1a6abb to b65b3fb Compare February 27, 2024 15:31
@neutrinoceros neutrinoceros changed the title BUG: simplify parameter parsing for Castro and MAESTRO BUG: fix parameter parsing for Castro and MAESTRO Feb 27, 2024
@neutrinoceros
Copy link
Member

I edited the title following the history rewrite so that it matches the commit message. Thanks Eric !

@neutrinoceros
Copy link
Member

@yt-fido test this please

1 similar comment
@neutrinoceros
Copy link
Member

@yt-fido test this please

@neutrinoceros neutrinoceros merged commit 94547d9 into yt-project:main Feb 29, 2024
13 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/yt that referenced this pull request Feb 29, 2024
@yut23 yut23 deleted the castro-parameters-cleanup branch March 1, 2024 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code frontends Things related to specific frontends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants