Skip to content

Commit

Permalink
Merge pull request #2153 from AllenInstitute/bugfix/2153-enforce-empt…
Browse files Browse the repository at this point in the history
…y-CDF-in-tests

Tests: Ensure that the CDF is empty after the test case
  • Loading branch information
t-b authored Jul 8, 2024
2 parents c0a67e0 + eed775f commit 358f594
Show file tree
Hide file tree
Showing 50 changed files with 532 additions and 262 deletions.
1 change: 1 addition & 0 deletions Packages/MIES/MIES_AnalysisBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,7 @@ Function AB_BrowserStartupSettings()

Execute/P/Z "DoWindow/R " + panel
Execute/P/Q/Z "COMPILEPROCEDURES "
CleanupOperationQueueResult()
End

/// @brief Button "Expand all"
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_AnalysisFunctions.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ Function FitResistance(string device, variable headstage, [variable showPlot, va

Make/FREE/N=2 coefWave
CurveFit/Q/N=1/NTHR=1/M=0/W=2 line, kwCWave=coefWave, storageDeltaV[][i]/D/X=storageDeltaI[][i]
WAVE W_sigma
WAVE/Z W_sigma = MakeWaveFree($"W_sigma")

storageResist[i][%Value] = coefWave[1]
storageResist[i][%Error] = W_sigma[1]
Expand Down
9 changes: 6 additions & 3 deletions Packages/MIES/MIES_AnalysisFunctions_PatchSeq.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2600,8 +2600,8 @@ static Function [WAVE futureDAScales, WAVE apfreq, WAVE DAScales] PSQ_DS_GatherF
endif

if(WaveExists(apfreqCurrentSCIClean) && WaveExists(DAScaleCurrentSCIClean))
Concatenate/NP=(ROWS) {apfreqCurrentSCIClean}, apfreq
Concatenate/NP=(ROWS) {DAScaleCurrentSCIClean}, DAScales
Concatenate/NP=(ROWS)/FREE {apfreqCurrentSCIClean}, apfreq
Concatenate/NP=(ROWS)/FREE {DAScaleCurrentSCIClean}, DAScales

WAVE/D/Z futureDAScalesFromLastSweep = PSQ_DS_GatherOvershootCorrection(cdp, apfreq, DAScales, futureDAScalesHistoric)

Expand Down Expand Up @@ -3644,7 +3644,8 @@ Function PSQ_DAScale(device, s)
Make/FREE/D/N=2 coefWave
CurveFit/Q/N=1/NTHR=1/M=0/W=2 line, kwCWave=coefWave, spikeFrequencies[]/D/X=DAScalesPlot[]; AbortOnRTE

WAVE/D/Z W_sigma
WAVE/D/Z W_sigma = MakeWaveFree($"W_sigma")

if(!WaveExists(W_sigma))
Make/FREE/D/N=2 W_sigma = NaN
endif
Expand Down Expand Up @@ -3687,6 +3688,8 @@ Function PSQ_DAScale(device, s)
sprintf str, "Fitted Slope: %.0W1P%%\r", fISlope[s.headstage]
textBoxString += str
TextBox/A=RB/C/N=text/W=$SPIKE_FREQ_GRAPH RemoveEnding(textBoxString, "\r")

MakeWaveFree(fitWave)
endif
catch
err = ClearRTError()
Expand Down
6 changes: 2 additions & 4 deletions Packages/MIES/MIES_ArtefactRemoval.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ static Function/WAVE AR_ComputeRanges(sweepDFR, sweepNo, numericalValues)
level = V_max * AR_MIN_RANGE_FACTOR

FindLevels/Q wv, level
WAVE W_FindLevels
WAVE posLevels = MakeWaveFree(W_FindLevels)
WAVE posLevels = MakeWaveFree($"W_FindLevels")

index = GetNumberFromWaveNote(ranges, NOTE_INDEX)
total = index + V_LevelsFound
Expand All @@ -75,8 +74,7 @@ static Function/WAVE AR_ComputeRanges(sweepDFR, sweepNo, numericalValues)
level = V_min * AR_MIN_RANGE_FACTOR

FindLevels/Q wv, level
WAVE W_FindLevels
WAVE negLevels = MakeWaveFree(W_FindLevels)
WAVE negLevels = MakeWaveFree($"W_FindLevels")

index = GetNumberFromWaveNote(ranges, NOTE_INDEX)
total = index + V_LevelsFound
Expand Down
2 changes: 1 addition & 1 deletion Packages/MIES/MIES_CheckInstallation.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ static StrConstant CHI_NIDAQ_XOP_64_HASH = "92427feeec9d330d410452b15ff1b6da90fe
static StrConstant CHI_NIDAQ_XOP_HASH = "ed7f5bc51553608bcf7850b06d472dc739952a32939c1b196b80d131a87f2527"
static StrConstant CHI_JSON_XOP_VERSION = "version-882-gad839a0"
static StrConstant CHI_TUF_XOP_VERSION = "version-163-g686effb"
static StrConstant CHI_ITC_XOP_VERSION = "latest-170-g1dfb5c5"
static StrConstant CHI_ITC_XOP_VERSION = "latest-174-gb9915a9"

/// @brief Collection of counters used for installation checking
static Structure CHI_InstallationState
Expand Down
1 change: 1 addition & 0 deletions Packages/MIES/MIES_DAEphys.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@ Function DAP_EphysPanelStartUpSettings()

Execute/P/Z "DoWindow/R " + BASE_WINDOW_NAME
Execute/P/Q/Z "COMPILEPROCEDURES "
CleanupOperationQueueResult()
End

Function DAP_WindowHook(s)
Expand Down
1 change: 1 addition & 0 deletions Packages/MIES/MIES_DataBrowser.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ Function DB_ResetAndStoreCurrentDBPanel()

Execute/P/Z "DoWindow/R " + DATABROWSER_WINDOW_NAME
Execute/P/Q/Z "COMPILEPROCEDURES "
CleanupOperationQueueResult()
End

Function/S DB_GetMainGraph(win)
Expand Down
15 changes: 15 additions & 0 deletions Packages/MIES/MIES_Debugging.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,21 @@ Function EnableDangerousDebugging()
variable/G root:V_debugDangerously = 1
End

// Return the status of an `SetIgorOption` setting
Function QueryIgorOption(option)
string option

variable state

Execute/Q "SetIgorOption " + option + "=?"
NVAR V_Flag

state = V_Flag
KillVariables/Z V_Flag

return state
End

threadsafe static Function ReportBugToLogfile(string msg, WAVE/T/Z keys, WAVE/T/Z values)

variable size
Expand Down
4 changes: 4 additions & 0 deletions Packages/MIES/MIES_PulseAveraging.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -3699,11 +3699,13 @@ Function PA_TraceWindowHook(s)
case EVENT_WINDOW_HOOK_RESIZE:
traceGraph = s.winName
Execute/P/Q/Z "PA_UpdateScaleBars(\"" + traceGraph + "\", 0)"
CleanupOperationQueueResult()
break
case EVENT_WINDOW_HOOK_MENU:
if(!cmpstr(s.menuName, "Graph") && !cmpstr(s.menuItem, "Autoscale Axes"))
traceGraph = s.winName
Execute/P/Q/Z "PA_UpdateScaleBars(\"" + traceGraph + "\", 1)"
CleanupOperationQueueResult()
endif
break
endswitch
Expand All @@ -3721,11 +3723,13 @@ Function PA_ImageWindowHook(s)
imageGraph = s.winName
PA_ResizeColorScalePanel(imageGraph)
Execute/P/Q/Z "PA_UpdateScaleBars(\"" + imageGraph + "\", 0)"
CleanupOperationQueueResult()
break
case EVENT_WINDOW_HOOK_MENU:
if(!cmpstr(s.menuName, "Graph") && !cmpstr(s.menuItem, "Autoscale Axes"))
imageGraph = s.winName
Execute/P/Q/Z "PA_UpdateScaleBars(\"" + imageGraph + "\", 1)"
CleanupOperationQueueResult()
endif
break
endswitch
Expand Down
31 changes: 14 additions & 17 deletions Packages/MIES/MIES_SweepFormula.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1623,9 +1623,8 @@ End
///
/// @param graph graph to pass to SF_FormulaExecutor
/// @param formula formula to plot
/// @param dfr [optional, default current] working dataFolder
/// @param dmMode [optional, default DM_SUBWINDOWS] display mode that defines how multiple sweepformula graphs are arranged
static Function SF_FormulaPlotter(string graph, string formula, [DFREF dfr, variable dmMode])
static Function SF_FormulaPlotter(string graph, string formula, [variable dmMode])

string trace, customLegend
variable i, j, k, l, numTraces, splitTraces, splitY, splitX, numGraphs, numWins, numData, dataCnt, traceCnt
Expand All @@ -1640,9 +1639,7 @@ static Function SF_FormulaPlotter(string graph, string formula, [DFREF dfr, vari
winDisplayMode = ParamIsDefault(dmMode) ? SF_DM_SUBWINDOWS : dmMode
ASSERT(winDisplaymode == SF_DM_NORMAL || winDisplaymode == SF_DM_SUBWINDOWS, "Invalid display mode.")

if(ParamIsDefault(dfr))
dfr = GetDataFolderDFR()
endif
DFREF dfr = SF_GetBrowserDF(graph)

WAVE/T graphCode = SF_SplitCodeToGraphs(formula)

Expand Down Expand Up @@ -2547,8 +2544,6 @@ Function SF_button_sweepFormula_display(STRUCT WMButtonAction &ba) : ButtonContr
break
endif

DFREF dfr = SF_GetBrowserDF(mainPanel)

SVAR result = $GetSweepFormulaParseErrorMessage()
result = ""

Expand All @@ -2561,9 +2556,10 @@ Function SF_button_sweepFormula_display(STRUCT WMButtonAction &ba) : ButtonContr
if(IsEmpty(preProcCode))
break
endif
SF_FormulaPlotter(mainPanel, preProcCode, dfr = dfr)
SF_FormulaPlotter(mainPanel, preProcCode)

SVAR lastCode = $GetLastSweepFormulaCode(dfr)
DFREF dfr = SF_GetBrowserDF(mainPanel)
SVAR lastCode = $GetLastSweepFormulaCode(dfr)
lastCode = preProcCode

[WAVE/T keys, WAVE/T values] = SFH_CreateResultsWaveWithCode(mainPanel, rawCode)
Expand Down Expand Up @@ -2986,6 +2982,9 @@ static Function/WAVE SF_OperationTPImpl(string graph, WAVE/WAVE mode, WAVE/Z sel
fitResults[j] = fitResult
endfor

MakeWaveFree($"W_sigma")
MakeWaveFree($"W_fitConstants")

#ifdef AUTOMATED_TESTING
JWN_SetWaveInWaveNote(fitResults, "/begintrails", beginTrails)
JWN_SetWaveInWaveNote(fitResults, "/endtrails", endTrails)
Expand Down Expand Up @@ -4286,15 +4285,19 @@ static Function/WAVE SF_PowerSpectrumRatio(WAVE/Z input, variable ratioFreq, var
#else
FuncFit/Q SF_LineNoiseFit, kwCWave=wCoef, input(minFreq, maxFreq)/C=wConstraints; err = GetRTError(1)
#endif
MakeWaveFree($"W_sigma")

Redimension/N=1 input
input[0] = 0

#ifdef DEBUGGING_ENABLED
if(DP_DebuggingEnabledForCaller())
SetScale/P x, ratioFreq, 1, WaveUnits(input, ROWS), input
endif
#else
SetScale/P x, wCoef[3], 1, WaveUnits(input, ROWS), input
#endif

SetScale/P d, 0, 1, "power ratio", input

if(err)
Expand Down Expand Up @@ -5590,14 +5593,8 @@ Function/WAVE SF_OperationFitImpl(WAVE xData, WAVE yData, string fitFunc, WAVE h
return $""
endif

WAVE/Z fit = fit__free_

if(WaveExists(fit))
MakeWaveFree(fit)
endif

WAVE W_sigma
MakeWaveFree(W_sigma)
WAVE W_sigma = MakeWaveFree($"W_sigma")
WAVE fit = MakeWaveFree($"fit__free_")

JWN_CreatePath(fit, SF_META_USER_GROUP + SF_META_FIT_PARAMETER)
JWN_SetWaveInWaveNote(fit, SF_META_USER_GROUP + SF_META_FIT_PARAMETER, params)
Expand Down
12 changes: 8 additions & 4 deletions Packages/MIES/MIES_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ static Function [WAVE coef, WAVE fit] PSX_FitHistogram(WAVE input)
return [$"", $""]
endif

MakeWaveFree($"W_sigma")

return [coefWave, MakeWaveFree(fit)]
End

Expand Down Expand Up @@ -622,11 +624,8 @@ static Function PSX_FitEventDecay(WAVE sweepDataFiltOff, WAVE psxEvent, variable

AssertOnAndClearRTError()
CurveFit/Q/N=1/NTHR=1/M=0/W=2 exp_XOffset, kwCWave=coefWave, sweepDataFiltOff(post_min_t, n_min_t)/D/C=constraints; err = GetRTError(1)
WAVE/Z fit = fit__free_

if(WaveExists(fit))
MakeWaveFree(fit)
endif
WAVE fit = MakeWaveFree($"fit__free_")

SetDataFolder currDFR

Expand Down Expand Up @@ -1276,6 +1275,7 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE r
AssertonAndClearRTError()
StatsQuantiles/Q/Z resultsRawClean; err = GetRTError(1)
MakeWaveFree($"W_StatsQuantiles")
if(!err)
results[1] = V_Median
Expand Down Expand Up @@ -5154,6 +5154,7 @@ Function PSX_PlotStartupSettings()
Execute/P/Q/Z "DoWindow/R " + PSX_PANEL_MACRO
Execute/P/Q/Z "COMPILEPROCEDURES "
CleanupOperationQueueResult()
End
/// @brief Apply the macro `mac` onto the panel `win`
Expand Down Expand Up @@ -5194,4 +5195,7 @@ Function PSX_ApplyMacroToExistingPanel(string win, string mac)
endfor
SetActiveSubwindow $currWindow
KillVariables/Z V_flag
KillStrings/Z S_name
End
3 changes: 3 additions & 0 deletions Packages/MIES/MIES_TestPulse.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ static Function [variable result, variable tau, variable baseline] TP_AutoFitBas
ASSERT(0, "CurveFit failed with error: " + msg)
endtry

MakeWaveFree($"W_Sigma")
MakeWaveFree($"W_FitConstants")

sprintf msg, "Fit result: tau %g, V_FitError %g, V_FitQuitReason %g\r", coefWave[2], V_FitError, V_FitQuitReason
DEBUGPRINT(msg)

Expand Down
39 changes: 24 additions & 15 deletions Packages/MIES/MIES_Utilities.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -355,38 +355,29 @@ threadsafe Function/S GetListOfObjects(dfr, matchExpr, [typeFlag, fullPath, recu
End

/// @brief Return a list of all objects of the given type from dfr
///
/// Does not work for datafolders which have a comma (`,`) in them.
threadsafe static Function/S GetAllObjects(dfr, typeFlag)
DFREF dfr
variable typeFlag

string list

DFREF oldDFR = GetDataFolderDFR()

SetDataFolder dfr

switch(typeFlag)
case COUNTOBJECTS_WAVES:
list = WaveList("*", ";", "")
list = WaveList("*", ";", "", dfr)
break
case COUNTOBJECTS_VAR:
list = VariableList("*", ";", 11)
list = VariableList("*", ";", 4, dfr) + VariableList("*", ";", 5, dfr)
break
case COUNTOBJECTS_STR:
list = StringList("*", ";")
list = StringList("*", ";", dfr)
break
case COUNTOBJECTS_DATAFOLDER:
list = DataFolderList("*", ";")
list = DataFolderList("*", ";", dfr)
break
default:
SetDataFolder oldDFR
ASSERT_TS(0, "Invalid type flag")
endswitch

SetDataFolder oldDFR

return list
End

Expand Down Expand Up @@ -2622,7 +2613,7 @@ End
///
/// Uses the "Operation Queue".
Function ForceRecompile()
Execute/P/Q/Z "Silent 100"
Execute/P/Q "Silent 100"
End

/// @brief Parse a ISO8601 timestamp, e.g. created by GetISO8601TimeStamp(), and returns the number
Expand Down Expand Up @@ -3229,7 +3220,11 @@ End

/// @brief Turn a persistent wave into a free wave
Function/WAVE MakeWaveFree(wv)
WAVE wv
WAVE/Z wv

if(!WaveExists(wv))
return $""
endif

DFREF dfr = NewFreeDataFolder()

Expand Down Expand Up @@ -7079,3 +7074,17 @@ End
threadsafe Function DFREFClear(DFREF &dfr)
DFREF dfr = $""
End

/// @brief Allows to remove V_flag which will be present after using the operation queue with `/Z`
///
/// Example usage:
/// \rst
/// .. code-block:: igorpro
///
/// Execute/P/Q/Z "SomeFunction()"
/// CleanupOperationQueueResult()
/// \endrst
///
Function CleanupOperationQueueResult()
Execute/P/Q "KillVariables/Z V_flag"
End
2 changes: 2 additions & 0 deletions Packages/MIES/MIES_WaveBuilderPanel.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ Function WBP_StartupSettings()

Execute/P/Q/Z "DoWindow/R " + panel
Execute/P/Q/Z "COMPILEPROCEDURES "
CleanupOperationQueueResult()
End

static Constant EPOCH_HL_TYPE_LEFT = 0x01
Expand Down Expand Up @@ -1416,6 +1417,7 @@ Function WBP_ButtonProc_OpenAnaFuncs(ba) : ButtonControl
Execute/P/Q/Z "INSERTINCLUDE \"" + baseName + "\""
Execute/P/Q/Z "COMPILEPROCEDURES "
Execute/P/Q/Z "DisplayProcedure/W=$\"" + fileName + "\""
CleanupOperationQueueResult()
break
endswitch

Expand Down
2 changes: 1 addition & 1 deletion Packages/tests/Basic/UTF_AnalysisFunctionHelpers.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static Constant NUM_REPEATS = 10
static Function TEST_CASE_BEGIN_OVERRIDE(testCase)
string testCase

TestCaseBeginCommon()
TestCaseBeginCommon(testcase)

// fake one existing sweep
DFREF dfr = GetDeviceDataPath(device)
Expand Down
Loading

0 comments on commit 358f594

Please sign in to comment.