-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add available problems and their runtime parameters to the docs (#269)
this adds a script to the build process to generate the problem definitions. This also fixes a bunch of docs errors and makes the solver pages more consistent
- Loading branch information
Showing
14 changed files
with
388 additions
and
313 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ dist/ | |
inputs.auto | ||
.noseids | ||
|
||
*problems.inc | ||
|
||
.ipynb_checkpoints/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#!/usr/bin/env python | ||
|
||
import importlib | ||
from pathlib import Path | ||
|
||
SOLVERS = ["advection", | ||
"advection_fv4", | ||
"advection_nonuniform", | ||
"advection_rk", | ||
"advection_weno", | ||
"burgers", | ||
"burgers_viscous", | ||
"compressible", | ||
"compressible_fv4", | ||
"compressible_react", | ||
"compressible_rk", | ||
"compressible_sdc", | ||
"diffusion", | ||
"incompressible", | ||
"incompressible_viscous", | ||
"lm_atm", | ||
"swe"] | ||
|
||
MAX_LEN = 36 | ||
|
||
|
||
def doit(pyro_home): | ||
|
||
for s in SOLVERS: | ||
|
||
# check it the problems/ directory is not a softlink to | ||
# a different solver | ||
|
||
p = Path(f"{pyro_home}/pyro/{s}/problems").resolve() | ||
|
||
with open(f"{pyro_home}/docs/source/{s}_problems.inc", "w") as finc: | ||
|
||
finc.write("supported problems\n") | ||
finc.write("------------------\n") | ||
|
||
if (parent_solver := p.parts[-2]) == s: | ||
|
||
# find all the problems | ||
for prob in p.glob("*.py"): | ||
if prob.name == "__init__.py": | ||
continue | ||
|
||
mprob = importlib.import_module(f"pyro.{s}.problems.{prob.stem}") | ||
|
||
if "init_data" not in dir(mprob): | ||
# not a problem setup | ||
continue | ||
|
||
finc.write(f"``{prob.stem}``\n") | ||
finc.write("^" * (len(prob.stem)+4) + "\n\n") | ||
|
||
if mprob.__doc__: | ||
finc.write(mprob.__doc__) | ||
|
||
finc.write("\n") | ||
|
||
try: | ||
params = mprob.PROBLEM_PARAMS | ||
except AttributeError: | ||
params = {} | ||
|
||
if params: | ||
finc.write("parameters: \n\n") | ||
|
||
finc.write("="*MAX_LEN + " " + "="*MAX_LEN + "\n") | ||
finc.write(f"{'name':{MAX_LEN}} {'default':{MAX_LEN}}\n") | ||
finc.write("="*MAX_LEN + " " + "="*MAX_LEN + "\n") | ||
|
||
for k, v in params.items(): | ||
pname = "``" + k + "``" | ||
finc.write(f"{pname:{MAX_LEN}} {v:{MAX_LEN}}\n") | ||
|
||
finc.write("="*MAX_LEN + " " + "="*MAX_LEN + "\n") | ||
|
||
|
||
finc.write("\n\n") | ||
|
||
else: | ||
finc.write(f"``{s}`` uses the problems defined by ``{parent_solver}``.") | ||
|
||
|
||
if __name__ == "__main__": | ||
doit("..") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.