Skip to content

Commit

Permalink
PSX_OperationStatsImpl: Assert on intersecting ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
t-b committed Feb 5, 2024
1 parent 51f6b24 commit ae4b8e8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Packages/MIES/MIES_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,8 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE r
numRanges = DimSize(allRanges, ROWS)
WaveClear rangeParam
Make/D/FREE/N=(0, 2) allResolvedRanges
WAVE/Z eventContainerFromResults = PSX_GetEventContainerFromResults(id)
WAVE/Z eventContainer = PSX_GetEventContainer(graph, requestID = id)
Expand Down Expand Up @@ -1161,8 +1163,16 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE r
EnsureLargeEnoughWave(allEvents, indexShouldExist = idx)
allEvents[idx] = events
idx += 1
WaveClear events
WAVE/Z numericalValues = BSP_GetLogbookWave(graph, LBT_LABNOTEBOOK, LBN_NUMERICAL_VALUES, sweepNumber = sweepNo)
WAVE/Z textualValues = BSP_GetLogbookWave(graph, LBT_LABNOTEBOOK, LBN_TEXTUAL_VALUES, sweepNumber = sweepNo)
SFH_ASSERT(WaveExists(textualValues) && WaveExists(numericalValues), "LBN not found for sweep " + num2istr(sweepNo))
[WAVE resolvedRanges, WAVE/T epochRangeNames] = SFH_GetNumericRangeFromEpoch(numericalValues, textualValues, range, sweepNo, chanType, chanNr)
ASSERT(DimSize(resolvedRanges, COLS) == 1, "psxStats does not support epoch wildcards")
Concatenate/NP {resolvedRanges}, allResolvedRanges
endfor
Redimension/N=(idx) allEvents
Expand Down Expand Up @@ -1362,6 +1372,8 @@ static Function/WAVE PSX_OperationStatsImpl(string graph, string id, WAVE/WAVE r
Redimension/N=(index) output
ASSERT(AreIntervalsIntersecting(allResolvedRanges), "Can't work with multiple intersecting ranges")
// PSX_MouseEventSelection works for "nothing" and "log10" post processing
// we assume here that all event waves have the same X/Y data units
Expand Down
33 changes: 33 additions & 0 deletions Packages/tests/Basic/UTF_SweepFormula_PSX.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,39 @@ static Function StatsWorksWithResultsSpecialCases([STRUCT IUTF_mData &m])
endfor
End

static Function StatsComplainsAboutIntersectingRanges()

string browser, device, formulaGraph, comboKey, id

[browser, device, formulaGraph] = CreateFakeDataBrowserWithSweepFormulaGraph()

[WAVE range0, WAVE selectData] = GetFakeRangeAndSelectData()

// 1st event wave
WAVE/Z psxEvent = GetEventWave(comboIndex = 0)
comboKey = MIES_PSX#PSX_GenerateComboKey(browser, selectData, range0)
id = "myID"
FillEventWave_IGNORE(psxEvent, id, comboKey)

Duplicate/FREE range0, range1

// 2nd event wave where we shift the range
WAVE/Z psxEvent = CreateEventWaveInComboFolder_IGNORE(comboIndex = 1)
range1[] += 0.5 * (range0[1] - range0[0])
comboKey = MIES_PSX#PSX_GenerateComboKey(browser, selectData, range1)
id = "myID"
FillEventWave_IGNORE(psxEvent, id, comboKey)

Make/FREE/WAVE allRanges = {range0, range1}

try
MIES_PSX#PSX_OperationStatsImpl(browser, id, allRanges, selectData, "amp", "all", "nothing")
FAIL()
catch
CHECK_NO_RTE()
endtry
End

Function/WAVE FakeSweepDataGeneratorPSXKernel(WAVE sweep, variable numChannels)

variable pnts = 1001
Expand Down

0 comments on commit ae4b8e8

Please sign in to comment.