Skip to content

Commit 7559c8e

Browse files
authored
Add multigrid-only option to test.py (#357)
this also renames some options for consistency and updates some notebooks due to roundoff
1 parent 0d853c7 commit 7559c8e

5 files changed

Lines changed: 44 additions & 36 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
python-version: ["3.10", "3.11", "3.12", "3.13"]
19+
python-version: ["3.11", "3.12", "3.13"]
2020

2121
steps:
2222
- uses: actions/checkout@v6

pyro/multigrid/multigrid-constant-coefficients.ipynb

Lines changed: 7 additions & 7 deletions
Large diffs are not rendered by default.

pyro/multigrid/multigrid-general-linear.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@
636636
"name": "python",
637637
"nbconvert_exporter": "python",
638638
"pygments_lexer": "ipython3",
639-
"version": "3.11.2"
639+
"version": "3.14.2"
640640
}
641641
},
642642
"nbformat": 4,

pyro/multigrid/multigrid-variable-coeff.ipynb

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

pyro/test.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def run_test_star(args):
8282

8383
def do_tests(out_file,
8484
reset_fails=False, store_all_benchmarks=False,
85+
multigrid_only=False,
8586
single=None, solver=None, rtol=1e-12, nproc=1):
8687

8788
opts = {"driver.verbose": 0, "vis.dovis": 0, "io.do_io": 0, "io.force_final_output": 1}
@@ -111,26 +112,28 @@ def do_tests(out_file,
111112
tests.append(PyroTest("lm_atm", "bubble", "inputs.bubble", opts))
112113
tests.append(PyroTest("swe", "dam", "inputs.dam.x", opts))
113114

114-
if single is not None:
115-
tests_to_run = [q for q in tests if str(q) == single]
116-
elif solver is not None:
117-
tests_to_run = [q for q in tests if q.solver == solver]
118-
else:
119-
tests_to_run = tests
120-
121-
if nproc == 0:
122-
nproc = os.cpu_count()
123-
# don't create more processes than needed
124-
nproc = min(nproc, len(tests_to_run))
125-
with Pool(processes=nproc) as pool:
126-
tasks = ((t, reset_fails, store_all_benchmarks, rtol, nproc) for t in tests_to_run)
127-
imap_it = pool.imap_unordered(run_test_star, tasks)
128-
# collect run results
129-
for name, err in imap_it:
130-
results[name] = err
131-
132-
# standalone tests
133-
if single is None and solver is None:
115+
if not multigrid_only:
116+
117+
if single is not None:
118+
tests_to_run = [q for q in tests if str(q) == single]
119+
elif solver is not None:
120+
tests_to_run = [q for q in tests if q.solver == solver]
121+
else:
122+
tests_to_run = tests
123+
124+
if nproc == 0:
125+
nproc = os.cpu_count()
126+
# don't create more processes than needed
127+
nproc = min(nproc, len(tests_to_run))
128+
with Pool(processes=nproc) as pool:
129+
tasks = ((t, reset_fails, store_all_benchmarks, rtol, nproc) for t in tests_to_run)
130+
imap_it = pool.imap_unordered(run_test_star, tasks)
131+
# collect run results
132+
for name, err in imap_it:
133+
results[name] = err
134+
135+
# multigrid tests
136+
if (single is None and solver is None) or multigrid_only:
134137
bench_dir = os.path.dirname(os.path.realpath(__file__)) + "/multigrid/tests/"
135138
err = mg_test_simple.test_poisson_dirichlet(256, comp_bench=True, bench_dir=bench_dir,
136139
store_bench=store_all_benchmarks, verbose=0)
@@ -193,11 +196,15 @@ def main():
193196
help="only test the solver specified",
194197
type=str, default=None)
195198

196-
p.add_argument("--reset_failures", "-r",
199+
p.add_argument("--multigrid-only",
200+
help="only run the multigrid tests",
201+
action="store_true")
202+
203+
p.add_argument("--reset-failures", "-r",
197204
help="if a test fails, reset the benchmark",
198205
action="store_true")
199206

200-
p.add_argument("--store_all_benchmarks",
207+
p.add_argument("--store-all-benchmarks",
201208
help="rewrite all the benchmarks, regardless of pass / fail",
202209
action="store_true")
203210

@@ -214,6 +221,7 @@ def main():
214221
failed = do_tests(args.outfile,
215222
reset_fails=args.reset_failures,
216223
store_all_benchmarks=args.store_all_benchmarks,
224+
multigrid_only=args.multigrid_only,
217225
single=args.single, solver=args.solver, rtol=args.rtol,
218226
nproc=args.nproc)
219227

0 commit comments

Comments
 (0)