From a114888f003567d8fb2b29e197efbacd80617212 Mon Sep 17 00:00:00 2001 From: Peter Willendrup Date: Sun, 18 Oct 2026 11:57:11 +0200 Subject: [PATCH] mctest: say that -n on a %Test/%Example line is ignored A %Test/%Example always runs at the global --ncount (scaled by --statfactor). Only %Scan/%TestScan uses its own -n. This has always been the case: before split_test_line, the line's -n was passed to mcrun ahead of the global -n, which won. About 40 shipped %Example lines carry a -n (1e3 to 1e8) that has never been used, which misled test authors. - log one line per %Test/%Example whose -n is ignored - comment and mctest.md now say -n is scan-only and point to the instrument (e.g. SPLIT) for better test statistics No change to how tests run or to their results. Co-Authored-By: Claude Opus 5.5 --- tools/Python/mctest.md | 10 +++++++--- tools/Python/mctest/mctest.py | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/Python/mctest.md b/tools/Python/mctest.md index 9e7d15896..5d92bdeb8 100644 --- a/tools/Python/mctest.md +++ b/tools/Python/mctest.md @@ -21,9 +21,13 @@ target value per scan point, which may span several header lines: 86.04,101.892,108.731,..., 85.406 } -`mcrun`/`mxrun` and `*.instr` tokens on test lines are ignored. A scan uses its -own `-n` if given, otherwise at most `1e5` per point, and runs its points in -parallel (`--scan_split=auto`) unless MPI is used. A value, or every point of a +`mcrun`/`mxrun` and `*.instr` tokens on test lines are ignored. A `%Test:` +always runs at the global `--ncount` (scaled by `--statfactor`): a `-n` on its +line is only a hint for users (`mcdoc` shows it) and is ignored, with a log +message. To get better statistics in a `%Test:`, change the instrument (e.g. +`SPLIT`) rather than adding `-n`. A scan uses its own `-n` if given, otherwise +at most `1e5` per point, and runs its points in parallel (`--scan_split=auto`) +unless MPI is used. A value, or every point of a scan, passes when it is within 20 % of its target, or, with `--nsigma` or `--pvalue`, within the statistical tolerance described below. diff --git a/tools/Python/mctest/mctest.py b/tools/Python/mctest/mctest.py index cfaa111c7..2efcaaaef 100644 --- a/tools/Python/mctest/mctest.py +++ b/tools/Python/mctest/mctest.py @@ -117,6 +117,8 @@ def create_instr_test_objs(sourcefile, localfile, header, noscans=False): # Detector: NAME_I=2.00752e+08 NAME_ERR=2.28872e+06 NAME_N=50752 "NAME.L_U1" for m in re.findall(r"\%(?:Example|Test):([^\n]*)Detector\:([^\n]*)_I=([0-9.+-e]+)([^\n]*)", header): parvals, ncount = split_test_line(m[0]) + if ncount: + logging.info("%s: -n%s on a %%Test/%%Example line is ignored, the test runs at the global --ncount" % (sourcefile, ncount)) detector = m[1].strip() err = re.search(r"%s_ERR=([0-9.+-eE]+)" % re.escape(detector), m[3]) tests.append(InstrExampleTest(sourcefile, localfile, parvals, detector, float(m[2].strip()), len(tests) + 1, ncount=ncount, @@ -567,6 +569,7 @@ def mccode_test(branchdir, testdir, limitinstrs=None, instrfilter=None, compfilt # told to use the default values (-y can not be combined with # parameter values, since the instrument then ignores those): parvals = test.parvals if test.parvals else "-y" + # A %Test/%Example always runs at the global ncount (its own -n is ignored). # A %Scan uses its own -n if given, else at most 1e5 pr. point, and runs # its points in parallel unless MPI already does that within each point testncount = ncount