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

Use AST module to help post-process assignments in scripts #108

Merged
merged 1 commit into from
Jul 21, 2023

Conversation

mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Jul 21, 2023

The primary changes in this PR is with scripts/process-scripts.py where the ast module is used to identify assignment expressions in the scripts to gather information for the docs. Some of these assignments may span several lines. For instance:

k33_str = (
    "1179., 30., 30., 30., 30."  # Vertical hydraulic conductivity ($ft/d$)
)

will extract the assignment string 1179., 30., 30., 30., 30. and comment Vertical hydraulic conductivity ($ft/d$)

The new refactor will also allow more than one table, however it doesn't seem this feature is currently used.

A minor limitation is that ast.unparse requires Python 3.9+, which is no issue for CI which already uses 3.9.

Other changes to *.ipynb files are minimal updates to sync with the *.py scripts, using the --update option.

@langevin-usgs
Copy link
Contributor

Tables were a little fragile, and it is nice to have the option to have multiple tables, so this looks good to me.

@langevin-usgs langevin-usgs merged commit c698117 into MODFLOW-USGS:master Jul 21, 2023
5 checks passed
@mwtoews mwtoews deleted the process-scripts-ast branch July 21, 2023 18:15
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