diff --git a/index.html b/index.html
index 6e9d586..b0d3bed 100644
--- a/index.html
+++ b/index.html
@@ -199,12 +199,11 @@
chip to one action at once. -->
diff --git a/muSRFitParameterPlot.js b/muSRFitParameterPlot.js
index f005d22..c0f2413 100644
--- a/muSRFitParameterPlot.js
+++ b/muSRFitParameterPlot.js
@@ -484,7 +484,25 @@ async function readMusrfitParameterData(parameterPath) {
if (typeof platform.readDataSource !== "function") {
throw new Error("No parameter-data reader is available for this platform");
}
- return await platform.readDataSource({ kind: "path", path: parameterPath });
+ let source = normalizeParameterSource(parameterPath);
+ return await platform.readDataSource(source);
+}
+
+// A parameter-data source is normally an on-disk file path string, but it may
+// also be a structured source object with kind "path" or "inline". Normalize
+// either form into a source object so the platforms and panels can consume it
+// uniformly.
+function normalizeParameterSource(parameterPath) {
+ if (parameterPath && typeof parameterPath === "object" && parameterPath.kind) {
+ return parameterPath;
+ }
+ let clean = String(parameterPath || "").split(/[?#]/)[0];
+ let pieces = clean.split(/[\\/]/);
+ return {
+ kind: "path",
+ path: parameterPath,
+ label: pieces[pieces.length - 1] || "Parameter data"
+ };
}
function fillMusrfitParameterSelect(select, dataset, indices, selectedIndex, noneLabel) {
@@ -514,6 +532,7 @@ function musrfitParameterIsEditableTarget(target) {
function showMusrfitParameterAxisDialog(parameterPath, jobName = "", preferredParameters = []) {
if (!parameterPath || !preferredParameters.length) return;
+ parameterPath = normalizeParameterSource(parameterPath);
let dialog = document.createElement("dialog");
let form = document.createElement("form");
@@ -620,6 +639,7 @@ function showMusrfitParameterAxisDialog(parameterPath, jobName = "", preferredPa
function showMusrfitParameterPlotWindow(parameterPath, jobName = "", preferredParameters = [], preferredXColumn = "", preferredTemplate = "") {
if (!parameterPath) return;
+ parameterPath = normalizeParameterSource(parameterPath);
let platform = musrfitParameterPlotPlatform();
if (typeof platform.createPlotWindow !== "function") {
@@ -1187,7 +1207,10 @@ function showMusrfitParameterPlotWindow(parameterPath, jobName = "", preferredPa
}
});
- let source = makePathSource(parameterPath, jobName || sourceLabelFromPath(parameterPath));
+ let source = parameterPath;
+ if (source.kind === "path" && !source.label) {
+ source = makePathSource(source.path, jobName || sourceLabelFromPath(source.path));
+ }
applyTemplateToPanelStates(preferredTemplate || "", source, true);
refreshVisiblePanels(true);
diff --git a/muSRFitParameterPlotElec.js b/muSRFitParameterPlotElec.js
index db9f9e8..6259653 100644
--- a/muSRFitParameterPlotElec.js
+++ b/muSRFitParameterPlotElec.js
@@ -54,6 +54,7 @@
};
platform.readDataSource = async function(source) {
+ if (source && source.kind === "inline") return String(source.text || "");
var parameterPath = source && source.path ? source.path : String(source || "");
if (!parameterPath) throw new Error("No parameter-data path is available");
return nodeFs.readFileSync(parameterPath, "utf8");
diff --git a/muSRFitlib.js b/muSRFitlib.js
index a9574e4..abe9b91 100644
--- a/muSRFitlib.js
+++ b/muSRFitlib.js
@@ -1198,6 +1198,7 @@ async function inspectSeriesFitPlan(config = {}, fileAccess = {}) {
});
let availableDataSet = new Set(plan.availableDataRuns);
+ let skippedMissingMsr = 0;
plan.entries = await Promise.all(runSelection.map(async function(dataSet) {
let msrName = dataSet.main + plan.fileNameSuffix + ".msr";
let msrPath = joinSeriesWorkPath(plan.workPath, msrName);
@@ -1236,15 +1237,26 @@ async function inspectSeriesFitPlan(config = {}, fileAccess = {}) {
if (Object.prototype.hasOwnProperty.call(actionOverrides, dataSet.main)) {
let override = actionOverrides[dataSet.main];
if (override == "refit") {
+ // "refit" means rebuild this run from the live GUI parameters and
+ // replace its on-disk MSR. Replacing nothing is contradictory, so
+ // when the MSR no longer exists (e.g. it was deleted) treat it as a
+ // create/fit instead and still honour the user's "rebuild" intent.
classification.action = "refit";
classification.reusable = false;
classification.useGuiTemplate = true;
useGuiTemplate = true;
- classification.reason = "user-requested-refit";
+ classification.reason = msrExists
+ ? "user-requested-refit" : "user-requested-refit-missing-msr";
+ if (!msrExists) classification.action = "fit";
} else if (override == "skip") {
classification.action = "skip";
classification.reusable = false;
classification.reason = "user-requested-skip";
+ // A skip leaves the run's on-disk MSR untouched. If that file no
+ // longer exists, skip would silently report a missing file as a
+ // healthy reuse, so record it and fail the plan below. The user can
+ // change that run back to a refit or remove it from the fit.
+ if (!msrExists) skippedMissingMsr = skippedMissingMsr || dataSet.main;
}
}
@@ -1269,6 +1281,13 @@ async function inspectSeriesFitPlan(config = {}, fileAccess = {}) {
};
}));
+ if (skippedMissingMsr) {
+ plan.ok = false;
+ plan.reason = "skipped-missing-msr";
+ plan.failed = { run: skippedMissingMsr };
+ plan.summary = summarizeSeriesFitEntries(plan.entries);
+ return plan;
+ }
plan.ok = true;
plan.reason = "series-inventory-ready";
plan.summary = summarizeSeriesFitEntries(plan.entries);
@@ -7794,6 +7813,41 @@ function parameterPlotNamesInTable() {
return names;
}
+// Build a parameter-data table (the same columnar format musrfit/msr2data
+// emit as `*_par.dat`) directly from the live parameter table. This lets the
+// user plot the current table values even when no fit has produced an on-disk
+// artifact yet (e.g. after restoring a shared configuration or when every run
+// was skipped). One row is emitted per run, with the RUN number as the x-axis
+// fallback and one column per (base) parameter carrying that run's value.
+function buildParameterDataFromTable() {
+ let table = document.getElementById("Params");
+ if (!table || typeof table.querySelector !== "function"
+ || !table.querySelector("tr[data-plot-parameter]")) {
+ return null;
+ }
+ let runs = arrayRunNumbers(All.runNumbers || "");
+ if (!runs.length) return null;
+
+ let baseParams = parameterPlotNamesInTable();
+ if (!baseParams.length) return null;
+
+ let columns = ["RUN"].concat(baseParams);
+ let lines = [columns.join("\t")];
+ for (let run of runs) {
+ let runSuffix = runSuffixFromFile(run, All.instrName, All.selYear, All.dataRoot);
+ let row = [run];
+ for (let base of baseParams) {
+ let shared = All["sh" + base] === "1";
+ let qualified = shared ? base : base + "_" + runSuffix;
+ let value = All["val" + qualified];
+ let text = (value === undefined || value === null) ? "" : String(value).trim();
+ row.push(text);
+ }
+ lines.push(row.join("\t"));
+ }
+ return lines.join("\n") + "\n";
+}
+
function updateParameterPlotSelectionUI() {
if (typeof document === "undefined") return;
let table = document.getElementById("Params");
@@ -7809,12 +7863,19 @@ function updateParameterPlotSelectionUI() {
let button = document.getElementById("plotSelectedParameters");
if (!button) return;
let hasData = Boolean(window.MusrfitJob && window.MusrfitJob.parameterDataPath);
+ // A populated parameter table is itself a valid plot source: the fit may
+ // not have produced an on-disk _par.dat artifact yet (for example after
+ // restoring a shared configuration or when every run was skipped), but the
+ // live table values can still be plotted. This lets the user plot whenever
+ // the table is built, regardless of whether a fit has just run.
+ let tablePopulated = parameterPlotNamesInTable().length > 0;
+ let canPlot = hasData || tablePopulated;
// Keep the action available when fit data exist so a click with no
// selection can explain what the user needs to do.
- button.disabled = !hasData;
+ button.disabled = !canPlot;
button.textContent = "Plot parameters...";
- if (!hasData) {
- button.title = "Fit the selected runs first to create parameter data";
+ if (!canPlot) {
+ button.title = "Build the parameter table first";
} else if (selectedParameterPlotNames.length === 0) {
button.title = "Select one or more parameter names";
} else {
@@ -7859,17 +7920,33 @@ function selectParameterForPlot(event, parameterName) {
function openSelectedParameterPlot() {
let job = window.MusrfitJob || {};
- if (!job.parameterDataPath) return;
if (selectedParameterPlotNames.length === 0) {
alert("Please select at least one parameter to plot.");
return;
}
if (typeof showMusrfitParameterAxisDialog !== "function") return;
- let resultName = job.resultMSR || job.parameterDataPath;
+ // Prefer the on-disk parameter-data artifact from a real fit. If none exists
+ // (restored configuration, all runs skipped, or the table was populated
+ // without a preceding fit) generate parameter data inline from the live
+ // table so the user can still plot the current values.
+ let source;
+ let resultName;
+ if (job.parameterDataPath) {
+ source = job.parameterDataPath;
+ resultName = job.resultMSR || job.parameterDataPath;
+ } else {
+ let inline = buildParameterDataFromTable();
+ if (!inline) {
+ alert("The parameter table is not populated. Build the table before plotting.");
+ return;
+ }
+ source = { kind: "inline", text: inline, label: "Parameter table" };
+ resultName = "parameter-table";
+ }
resultName = String(resultName).split(/[?#]/)[0].split(/[\\/]/).pop();
showMusrfitParameterAxisDialog(
- job.parameterDataPath,
+ source,
resultName || "",
selectedParameterPlotNames.slice()
);
@@ -9947,6 +10024,8 @@ function seriesFitFailureMessage(reason, result = {}) {
"web-series-inventory-incomplete": "The web series inventory was incomplete.",
"web-series-inventory-invalid": "The web series inventory was invalid.",
"reusable-reference-not-found": "No reusable series reference was found.",
+ "skipped-missing-msr": "A run is set to skip but has no MSR file on disk "
+ + "(it may have been deleted; change that run to refit, or remove it from the fit)",
"series-bootstrap-first-run-blocked": "The first selected run has no complete data set.",
"series-bootstrap-template-invalid": "The first-run template could not be generated safely.",
"series-bootstrap-result-not-readable": "The fitted first-run MSR could not be read.",
@@ -10252,8 +10331,23 @@ function prepareSeriesBootstrapCandidate(plan, config = {}, fitConfig = null) {
let pendingActions = new Set(["fit", "retry", "refit"]);
if (!entry || !pendingActions.has(entry.action)
|| (Array.isArray(entry.missingDataRuns) && entry.missingDataRuns.length > 0)) {
- result.reason = "series-bootstrap-first-run-blocked";
- return result;
+ // The bootstrap seed is not required to be the first selected run. When
+ // an upstream run is skipped or lacks complete data (e.g. the only run
+ // needing a fit is a later one whose MSR was deleted), seed from the
+ // first pending run that has all its data so the fit can continue.
+ entry = null;
+ for (let candidate of plan.entries) {
+ if (pendingActions.has(candidate.action)
+ && (!Array.isArray(candidate.missingDataRuns)
+ || candidate.missingDataRuns.length === 0)) {
+ entry = candidate;
+ break;
+ }
+ }
+ if (!entry) {
+ result.reason = "series-bootstrap-first-run-blocked";
+ return result;
+ }
}
let all = Object.assign({}, config.all || {});
@@ -10353,7 +10447,17 @@ async function promoteBootstrapAsSeriesReference(plan, config, bootstrapSequence
let fittedMSR = await readAsciiFile(resultPath);
if (typeof fittedMSR !== "string" || fittedMSR.trim() === "") return result;
- let firstEntry = plan.entries[0];
+ // The bootstrapped run is not necessarily the first selected run (upstream
+ // runs may be skipped, or the only run needing a fit may be a later one
+ // whose MSR was deleted). Match the completed bootstrap candidate back to
+ // its plan entry so the reference identity and classification use the run
+ // that was actually fitted.
+ let bootRun = completed.run
+ || (completed.candidate && completed.candidate.run);
+ let bootEntry = bootRun
+ ? plan.entries.find(function(e) { return e.run === bootRun; }) : null;
+ if (!bootEntry) bootEntry = plan.entries[0];
+ let firstEntry = bootEntry;
if (!isValidGeneratedGlobalMSR(fittedMSR)) {
result.reason = "series-bootstrap-reference-invalid";
return result;
@@ -10402,7 +10506,9 @@ async function promoteBootstrapAsSeriesReference(plan, config, bootstrapSequence
result.reason = "series-bootstrap-reference-ready";
result.referenceMSRText = fittedMSR;
result.plan = Object.assign({}, plan, {
- entries: [referenceEntry].concat(plan.entries.slice(1))
+ entries: [referenceEntry].concat(
+ plan.entries.filter(function(e) { return e !== bootEntry; })
+ )
});
result.plan.summary = summarizeSeriesFitEntries(result.plan.entries);
return result;
diff --git a/muSRFitweb.js b/muSRFitweb.js
index e126e0e..0d1dd30 100644
--- a/muSRFitweb.js
+++ b/muSRFitweb.js
@@ -211,6 +211,7 @@ window.MusrfitParameterPlotPlatform.loadPlotly = function() {
};
window.MusrfitParameterPlotPlatform.readDataSource = async function(source) {
+ if (source && source.kind === "inline") return String(source.text || "");
if (source && source.kind === "file" && source.file) {
if (typeof source.file.text === "function") return await source.file.text();
throw new Error("This browser cannot read the selected parameter-data file");
diff --git a/quick-start.html b/quick-start.html
index 71a084c..5a31015 100644
--- a/quick-start.html
+++ b/quick-start.html
@@ -15,6 +15,7 @@
Choose the fit type and add the theory components you need.
Use Fit to generate and fit the MSR, or Plot to inspect the spectra with musrview.
+
When an independent series fit (two or more runs, no shared parameters) is eligible, the Fit options row adds an action chip per run. Click a chip to cycle it: reuse keeps the existing fit, refit rebuilds the MSR from the live GUI parameters, and skip leaves the run untouched. The All dropdown sets every chip at once from Reuse all, Refit all, or Skip all.
Plot, FFT and RRF settings are available from their compact option tickets. Plot options include independent time and Y-axis ranges; leaving a pair empty selects automatic limits. In Electron, machine-specific paths, output suffixes and automatic initial-parameter guessing are under File → Preferences.
diff --git a/tests/msr-generation.test.js b/tests/msr-generation.test.js
index c4f70c6..2d5cd31 100644
--- a/tests/msr-generation.test.js
+++ b/tests/msr-generation.test.js
@@ -567,6 +567,69 @@ function testParameterPlotSelection(lib) {
});
}
+function testInlineParameterPlotFromTable(lib) {
+ // The parameter table is populated but no fit has produced an on-disk
+ // *_par.dat artifact (e.g. after restoring a configuration or when every
+ // run was skipped). Plotting must still be allowed by generating the
+ // parameter-data table inline from the live table values.
+ function makeRow(name) {
+ return {
+ dataset: { plotParameter: name },
+ classList: { toggle: function() {} },
+ setAttribute: function() {}
+ };
+ }
+ const rows = [makeRow("Alpha"), makeRow("Lam")];
+ const params = {
+ querySelector: function(){ return rows[0]; },
+ querySelectorAll: function() { return rows; }
+ };
+ lib.document = {
+ getElementById: function(id) {
+ if (id === "Params") return params;
+ if (id === "plotSelectedParameters") return {};
+ return null;
+ }
+ };
+
+ const previousAll = lib.All;
+ lib.All = {
+ runNumbers: "514,515",
+ instrName: "",
+ selYear: "",
+ dataRoot: "",
+ shAlpha: "1",
+ shLam: "",
+ valAlpha: "0.22",
+ valLam_514: "0.30",
+ valLam_515: "0.27"
+ };
+
+ const built = lib.buildParameterDataFromTable();
+ assert.ok(built, "buildParameterDataFromTable must produce inline data");
+ assert.strictEqual(built.split("\n")[0], "RUN\tAlpha\tLam");
+ const lines = built.trim().split("\n");
+ assert.deepStrictEqual(lines[1].split("\t"), ["514", "0.22", "0.30"]);
+ assert.deepStrictEqual(lines[2].split("\t"), ["515", "0.22", "0.27"]);
+
+ // openSelectedParameterPlot with no parameterDataPath must pass an inline
+ // source into the axis dialog instead of silently returning.
+ lib.window.MusrfitJob.parameterDataPath = "";
+ lib.window.MusrfitJob.resultMSR = "";
+ lib.selectedParameterPlotNames = ["Alpha", "Lam"];
+ let opened = null;
+ lib.showMusrfitParameterAxisDialog = function(source, jobName, names) {
+ opened = { source: source, jobName: jobName, names: Array.from(names) };
+ };
+ lib.openSelectedParameterPlot();
+ assert.ok(opened, "openSelectedParameterPlot must open the axis dialog when the table is populated");
+ assert.strictEqual(opened.source.kind, "inline");
+ assert.ok(opened.source.text.indexOf("514\t0.22\t0.30") >= 0);
+ assert.deepStrictEqual(opened.names, ["Alpha", "Lam"]);
+
+ lib.All = previousAll;
+}
+
function testBeginJobPreparationPreservesParameterDataOnPlot(lib) {
// A Plot-only action does not change the fit, so it must keep both the
// statistic and the existing parameter table. Only a new Fit invalidates
@@ -2791,6 +2854,7 @@ testCompactConstraintsLayout(lib);
testCompactEditorResultsAndStatusLayout(lib);
testCompactJobStatusVisibility(lib);
testParameterPlotSelection(lib);
+testInlineParameterPlotFromTable(lib);
testBeginJobPreparationPreservesParameterDataOnPlot(lib);
testParseMSRParameters(lib);
testParseAndApplyMSRGUISettings(lib);
diff --git a/tests/parameter-plot.test.js b/tests/parameter-plot.test.js
index 9bc7827..c0b692a 100644
--- a/tests/parameter-plot.test.js
+++ b/tests/parameter-plot.test.js
@@ -364,10 +364,39 @@ function testTfTemplateApplication() {
assert.strictEqual(unknown.panels.length, 0);
}
+function testInlineParameterSource() {
+ const lib = loadParameterPlotLibrary();
+
+ // A bare path string normalizes into a "path" source with a display label.
+ const pathSource = lib.normalizeParameterSource("/work/514+series_asy_par.dat");
+ assert.strictEqual(pathSource.kind, "path");
+ assert.strictEqual(pathSource.path, "/work/514+series_asy_par.dat");
+ assert.strictEqual(pathSource.label, "514+series_asy_par.dat");
+
+ // An already-structured inline source is passed through unchanged.
+ const inline = { kind: "inline", text: "RUN\tAlpha\n514\t0.22\n", label: "Parameter table" };
+ assert.strictEqual(lib.normalizeParameterSource(inline), inline);
+
+ // readMusrfitParameterData for an inline source must resolve to its text
+ // without touching any file system.
+ let seen = null;
+ lib.window.MusrfitParameterPlotPlatform = {
+ readDataSource: async function(source) { seen = source; return String(source.text || ""); }
+ };
+ return lib.readMusrfitParameterData(inline).then(function(contents) {
+ assert.strictEqual(contents, "RUN\tAlpha\n514\t0.22\n");
+ assert.strictEqual(seen.kind, "inline");
+ return lib.readMusrfitParameterData("/work/fit_par.dat").then(function() {
+ assert.strictEqual(seen.kind, "path");
+ });
+ });
+}
+
testParserAndSmartDefaults();
testScanVariableDetection();
testTfTemplateApplication();
testIntegratedParameterTableHook();
testPlatformSeparation();
testElectronParameterExport();
+testInlineParameterSource();
console.log("Parameter plot tests passed");
diff --git a/tests/series-fit-inventory.test.js b/tests/series-fit-inventory.test.js
index 9e0eb48..bd85493 100644
--- a/tests/series-fit-inventory.test.js
+++ b/tests/series-fit-inventory.test.js
@@ -128,6 +128,59 @@ async function testInventoryActions(lib) {
}), false);
}
+async function testSkippedMissingMSRFailsPlan(lib) {
+ const files = {
+ [lemPath(2274)]: "data",
+ [lemPath(2275)]: "data",
+ [lemPath(2276)]: "data",
+ "/work/2274_asy.msr": fittedMSR(2274)
+ };
+ const access = memoryAccess(files);
+ const config = seriesConfig("2274-2276");
+ config.actionOverrides = { 2276: "skip" };
+ const plan = await lib.inspectSeriesFitPlan(config, access);
+ assert.strictEqual(plan.ok, false,
+ "a skip with a missing MSR must fail the plan instead of reporting a healthy reuse");
+ assert.strictEqual(plan.reason, "skipped-missing-msr");
+ assert.strictEqual(plan.failed.run, 2276);
+
+ // A skip of a run whose MSR still exists is legitimate and must not fail.
+ const healthyConfig = seriesConfig("2274-2276");
+ healthyConfig.actionOverrides = { 2275: "skip", 2276: "skip" };
+ const files2 = Object.assign({}, files, {
+ "/work/2275_asy.msr": fittedMSR(2275),
+ "/work/2276_asy.msr": fittedMSR(2276)
+ });
+ const healthyPlan = await lib.inspectSeriesFitPlan(healthyConfig, memoryAccess(files2));
+ assert.strictEqual(healthyPlan.ok, true);
+ assert.strictEqual(healthyPlan.reason, "series-inventory-ready");
+ assert.strictEqual(healthyPlan.entries.filter(function(entry) {
+ return entry.action == "skip";
+ }).length, 3);
+}
+
+async function testRefitOfMissingMSRBecomesFit(lib) {
+ const files = {
+ [lemPath(2275)]: "data",
+ [lemPath(2276)]: "data",
+ [lemPath(2277)]: "data",
+ "/work/2275_asy.msr": fittedMSR(2275),
+ "/work/2277_asy.msr": fittedMSR(2277)
+ };
+ const config = seriesConfig("2275-2277");
+ config.actionOverrides = { 2276: "refit" };
+ const plan = await lib.inspectSeriesFitPlan(config, memoryAccess(files));
+ assert.strictEqual(plan.ok, true);
+ const entry = plan.entries.find(function(e) { return e.run === 2276; });
+ assert.strictEqual(entry.msrExists, false);
+ assert.strictEqual(entry.action, "fit",
+ "a refit of a run whose MSR was deleted must become a create/fit, since "
+ + "replacing a file that no longer exists is contradictory");
+ assert.strictEqual(entry.reason, "user-requested-refit-missing-msr");
+ assert.strictEqual(entry.useGuiTemplate, true,
+ "the user's rebuild-from-GUI intent must be preserved for the missing MSR");
+}
+
async function testAddRunAgeBoundary(lib) {
const files = {
[lemPath(2274)]: "data",
@@ -178,6 +231,8 @@ async function testWebRequiresServerDataAdapter(lib) {
(async function() {
const lib = loadLibrary();
await testInventoryActions(lib);
+ await testSkippedMissingMSRFailsPlan(lib);
+ await testRefitOfMissingMSRBecomesFit(lib);
await testAddRunAgeBoundary(lib);
await testNonSeriesDoesNotInspectFiles(lib);
await testWebRequiresServerDataAdapter(lib);
diff --git a/tests/series-fit-msr-preparation.test.js b/tests/series-fit-msr-preparation.test.js
index 17f8a1f..8a411a4 100644
--- a/tests/series-fit-msr-preparation.test.js
+++ b/tests/series-fit-msr-preparation.test.js
@@ -332,6 +332,146 @@ function testFirstRunBootstrapUsesGUIModel(lib) {
assert.doesNotMatch(candidate.text, /^\s*STATISTIC\b/m);
}
+function testBootstrapSeedsFromPendingRunNotFirst(lib) {
+ const setup = bootstrapFitConfig("514-516");
+ // entries[0] is a user skip whose MSR exists, so it can never seed a fit.
+ // The only run that needs a fit is a later run (515) whose MSR is missing,
+ // mirroring the workflow where an upstream chip was set to "skip". The
+ // bootstrap must seed from that pending run instead of failing.
+ const plan = {
+ ok: true,
+ mode: "series",
+ entries: [{
+ run: 514,
+ dataSet: { main: 514, add: [] },
+ action: "skip",
+ state: "converged-complete",
+ reusable: false,
+ reason: "user-requested-skip",
+ missingDataRuns: [],
+ msrName: "514_asy.msr",
+ msrPath: "/work/514_asy.msr",
+ msrExists: true,
+ msrText: "x",
+ msrHash: "h"
+ }, {
+ run: 515,
+ dataSet: { main: 515, add: [] },
+ action: "fit",
+ state: "missing-msr",
+ reusable: false,
+ reason: "msr-not-found",
+ missingDataRuns: [],
+ msrName: "515_asy.msr",
+ msrPath: "/work/515_asy.msr",
+ msrExists: false,
+ msrText: "",
+ msrHash: ""
+ }, {
+ run: 516,
+ dataSet: { main: 516, add: [] },
+ action: "skip",
+ state: "converged-complete",
+ reusable: false,
+ reason: "user-requested-skip",
+ missingDataRuns: [],
+ msrName: "516_asy.msr",
+ msrPath: "/work/516_asy.msr",
+ msrExists: true,
+ msrText: "x",
+ msrHash: "h"
+ }]
+ };
+ const bootstrap = lib.prepareSeriesBootstrapCandidate(
+ plan, setup.config, setup.fitConfig
+ );
+ assert.strictEqual(bootstrap.ok, true);
+ assert.strictEqual(bootstrap.reason, "series-bootstrap-template-ready");
+ assert.strictEqual(bootstrap.candidates.length, 1);
+ assert.strictEqual(bootstrap.candidates[0].run, 515,
+ "the bootstrap seed must be the first pending run with complete data, "
+ + "not blindly the first selected run");
+ assert.strictEqual(bootstrap.candidates[0].action, "fit");
+ assert.strictEqual(bootstrap.candidates[0].targetPath, "/work/515_asy.msr");
+}
+
+async function testBootstrapPromotesNonFirstRunReference(lib) {
+ const setup = bootstrapFitConfig("514-516");
+ const skipEntry = {
+ run: 514,
+ dataSet: { main: 514, add: [] },
+ action: "skip",
+ state: "converged-complete",
+ reusable: false,
+ reason: "user-requested-skip",
+ missingDataRuns: [],
+ msrName: "514_asy.msr",
+ msrPath: "/work/514_asy.msr",
+ msrExists: true,
+ msrText: "x",
+ msrHash: "h"
+ };
+ const missingEntry = {
+ run: 515,
+ dataSet: { main: 515, add: [] },
+ action: "fit",
+ state: "missing-msr",
+ reusable: false,
+ reason: "msr-not-found",
+ missingDataRuns: [],
+ msrName: "515_asy.msr",
+ msrPath: "/work/515_asy.msr",
+ msrExists: false,
+ msrText: "",
+ msrHash: ""
+ };
+ const plan = {
+ ok: true,
+ mode: "series",
+ availableDataRuns: [514, 515, 516],
+ entries: [skipEntry, missingEntry, {
+ run: 516,
+ dataSet: { main: 516, add: [] },
+ action: "skip",
+ state: "converged-complete",
+ reusable: false,
+ reason: "user-requested-skip",
+ missingDataRuns: [],
+ msrName: "516_asy.msr",
+ msrPath: "/work/516_asy.msr",
+ msrExists: true,
+ msrText: "x",
+ msrHash: "h"
+ }]
+ };
+ const fitted = asymmetryMSR(515);
+ lib.readAsciiFile = async function(filePath) {
+ assert.strictEqual(filePath, "/work/515_asy.msr");
+ return fitted;
+ };
+ const promoted = await lib.promoteBootstrapAsSeriesReference(
+ plan,
+ setup.config,
+ { ok: true, completed: [{
+ run: 515,
+ action: "fit",
+ targetPath: "/work/515_asy.msr",
+ runResult: { targetPath: "/work/515_asy.msr" }
+ }] }
+ );
+ assert.strictEqual(promoted.ok, true);
+ assert.strictEqual(promoted.reason, "series-bootstrap-reference-ready");
+ assert.strictEqual(promoted.referenceMSRText, fitted);
+ assert.strictEqual(promoted.plan.entries[0].run, 515,
+ "the bootstrapped run, not the first selected run, must become the reference");
+ assert.strictEqual(promoted.plan.entries[0].action, "skip");
+ assert.strictEqual(promoted.plan.entries[0].reusable, true);
+ assert.strictEqual(promoted.plan.entries[0].classification.sessionReference, true);
+ // The upstream skip entry must survive at its original position.
+ assert.strictEqual(promoted.plan.entries[1], skipEntry);
+ assert.strictEqual(promoted.plan.entries[2].run, 516);
+}
+
async function testFittedBootstrapBecomesSessionReference(lib) {
const setup = bootstrapFitConfig("514-515");
const firstEntry = {
@@ -433,6 +573,8 @@ async function testFittedBootstrapBecomesSessionReference(lib) {
await testCandidatesAlwaysUseReference(lib);
await testRequiresReusableReference(lib);
testFirstRunBootstrapUsesGUIModel(lib);
+ testBootstrapSeedsFromPendingRunNotFirst(lib);
+ await testBootstrapPromotesNonFirstRunReference(lib);
await testFittedBootstrapBecomesSessionReference(lib);
console.log("series fit MSR preparation tests passed");
})().catch(function(error) {