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

Input_file_handling_robustness #107

Merged
merged 6 commits into from
Sep 19, 2024
Merged

Conversation

tbody-cfs
Copy link
Collaborator

@tbody-cfs tbody-cfs commented Sep 16, 2024

This PR makes the input file handling routines more flexible and robust.

  1. Lets you not specify any grid entry in the input file. You can now run a scalar case.
  2. Let's you not specify any algorithm entry in the input file. This makes a Algorithm.empty which does nothing at all (neater than handling no algorithms as some special case).
  3. As a consequence of allowing scalar cases, adds a minor modification to sanitize_variable which works around scalar-valued coordinates (see Multiple methods fail on a DataArray with scalar dimension pydata/xarray#1709). This has the pleasing side-effect of getting the correct dimension name in the regression JSON.
  4. Adds cfspopcon as an entry point, equivalent to popcon. Now you can either poetry run popcon or poetry run cfspopcon — these do the same thing.
  5. Lets you pass dictionaries to input_file_handling instead of just filepaths, in case you want to programmatically set input values.
  6. Runs ruff on tests to tidy this up

@tbody-cfs tbody-cfs requested a review from hassec September 16, 2024 13:30
Copy link
Collaborator

@hassec hassec left a comment

Choose a reason for hiding this comment

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

Looks good, just some small comments.

Regarding the Alogrithm.empty(), I'm not sure if I follow how it would be used. If you have a case that doesn't specify any algorithms, what would you do with that case?

cfspopcon/file_io.py Outdated Show resolved Hide resolved
cfspopcon/file_io.py Outdated Show resolved Hide resolved
cfspopcon/input_file_handling.py Outdated Show resolved Hide resolved
pyproject.toml Show resolved Hide resolved
@tbody-cfs tbody-cfs force-pushed the input_file_handling_robustness branch from 19a2721 to 6ba77c4 Compare September 19, 2024 18:10
@tbody-cfs
Copy link
Collaborator Author

Algorithm.empty() is useful if you want to set up a dataset based on an input file. Often useful in a development step, where you want to load up a case and then develop an algorithm in a jupyter notebook.

@tbody-cfs tbody-cfs requested a review from hassec September 19, 2024 18:34
Copy link
Collaborator

@hassec hassec left a comment

Choose a reason for hiding this comment

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

Just one more tiny comment, otherwise looks great 👍

@tbody-cfs tbody-cfs enabled auto-merge (squash) September 19, 2024 19:27
@tbody-cfs tbody-cfs merged commit f4c3431 into main Sep 19, 2024
6 checks passed
@tbody-cfs tbody-cfs deleted the input_file_handling_robustness branch September 19, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants