Skip to content

Commit 87b3e3d

Browse files
authored
Merge pull request #2428 from AllenInstitute/bugfix/2428-sf-check-input-backport
[Backport] SF_CheckInputCode: Preprocess code
2 parents 89df386 + 754799a commit 87b3e3d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Packages/MIES/MIES_SweepFormula.ipf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2899,16 +2899,18 @@ End
28992899
static Function SF_CheckInputCode(string code, string graph)
29002900

29012901
variable i, numGraphs, jsonIDy, jsonIDx, subFormulaCnt
2902-
string jsonPath, xFormula, yFormula, formulasRemain, subPath, yAndXFormula
2902+
string jsonPath, xFormula, yFormula, formulasRemain, subPath, yAndXFormula, codeWithoutVariables, preProcCode
29032903

29042904
NVAR jsonID = $GetSweepFormulaJSONid(SF_GetBrowserDF(graph))
29052905
JSON_Release(jsonID, ignoreErr = 1)
29062906
jsonID = JSON_New()
29072907
JSON_AddObjects(jsonID, "")
29082908

2909-
code = SF_CheckVariableAssignments(code, jsonID)
2909+
preProcCode = SF_PreprocessInput(code)
29102910

2911-
WAVE/T graphCode = SF_SplitCodeToGraphs(SF_PreprocessInput(code))
2911+
codeWithoutVariables = SF_CheckVariableAssignments(preProcCode, jsonID)
2912+
2913+
WAVE/T graphCode = SF_SplitCodeToGraphs(codeWithoutVariables)
29122914

29132915
numGraphs = DimSize(graphCode, ROWS)
29142916
for(i = 0; i < numGraphs; i += 1)

Packages/tests/Basic/UTF_SweepFormula.ipf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,13 @@ static Function TestInputCodeCheck()
12671267
JSON_Release(jsonId)
12681268
CHECK_EQUAL_STR(jsonRef, jsonTxt)
12691269

1270+
formula = "# comment\r var = 1\r\r $var"
1271+
jsonRef = "{\n\"graph_0\": {\n\"pair_0\": {\n\"formula_y\": \"$var\"\n}\n},\n\"variable:var\": 1\n}"
1272+
MIES_SF#SF_CheckInputCode(formula, win)
1273+
jsonTxt = JSON_Dump(jsonId)
1274+
JSON_Release(jsonId)
1275+
CHECK_EQUAL_STR(jsonRef, jsonTxt)
1276+
12701277
formula = "[*]"
12711278
try
12721279
MIES_SF#SF_CheckInputCode(formula, win)

0 commit comments

Comments
 (0)