Skip to content

Commit 5497583

Browse files
committed
MIES_SweepFormula_PSX.ipf: Resurrect resolved range checking
Taken from 6d10790 (PSX_OperationStatsImpl: Assert on intersecting ranges, 2024-02-06).
1 parent dfc8ca4 commit 5497583

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Packages/MIES/MIES_SweepFormula_PSX.ipf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,6 +4551,55 @@ static Function PSX_OperationSetDimensionLabels(WAVE/WAVE output, variable numCo
45514551
endfor
45524552
End
45534553

4554+
/// @brief Collect all resolved ranges in allResolvedRanges together with a hash of the select data
4555+
Function PSX_CollectResolvedRanges(string graph, WAVE range, WAVE singleSelectData, WAVE allResolvedRanges, WAVE/T allSelectHashes)
4556+
4557+
variable numRows
4558+
4559+
[WAVE resolvedRanges, WAVE/T epochRangeNames] = SFH_GetNumericRangeFromEpochFromSingleSelect(graph, singleSelectData, range)
4560+
4561+
numRows = DimSize(allSelectHashes, ROWS)
4562+
Redimension/N=(numRows + 1) allSelectHashes
4563+
allSelectHashes[numRows] = WaveHash(singleSelectData, HASH_SHA2_256)
4564+
4565+
Concatenate/NP/FREE {resolvedRanges}, allResolvedRanges
4566+
4567+
if(DimSize(allResolvedRanges, COLS) == 0)
4568+
Redimension/N=(-1, 1) allResolvedRanges
4569+
endif
4570+
End
4571+
4572+
/// @brief Check that the 2xN wave allResolvedRanges has only
4573+
/// non-intersecting ranges for the same select data hash
4574+
static Function PSX_CheckResolvedRangesWithSelectHashes(WAVE allResolvedRanges, WAVE/T allSelectHashes)
4575+
4576+
string selectHash
4577+
variable numRows, numColumns, i, idx
4578+
4579+
numRows = DimSize(allResolvedRanges, ROWS)
4580+
numColumns = DimSize(allResolvedRanges, COLS)
4581+
4582+
ASSERT(numColumns == DimSize(allSelectHashes, ROWS), "Mismatched row sizes")
4583+
4584+
for(selectHash : GetUniqueEntries(allSelectHashes))
4585+
Make/N=(numRows, numColumns)/FREE work
4586+
4587+
for(i = 0, idx = 0; i < numColumns; i += 1)
4588+
if(!cmpstr(selectHash, allSelectHashes[i]))
4589+
work[][idx] = allResolvedRanges[p][i]
4590+
idx += 1
4591+
endif
4592+
endfor
4593+
4594+
MatrixOp/FREE workTransposed = work^t
4595+
4596+
ASSERT(idx > 0, "Invalid idx after searching")
4597+
Redimension/N=(idx, -1) workTransposed
4598+
4599+
ASSERT(!AreIntervalsIntersecting(workTransposed), "Can't work with multiple intersecting ranges")
4600+
endfor
4601+
End
4602+
45544603
/// @brief Implementation of the `psx` operation
45554604
///
45564605
// Returns a SweepFormula dataset with n * PSX_OPERATION_OUTPUT_WAVES_PER_ENTRY

0 commit comments

Comments
 (0)