Skip to content

Commit

Permalink
Merge pull request #2346 from AllenInstitute/bugfix/2346-labnotebook-…
Browse files Browse the repository at this point in the history
…sweepformula-bug-wildcard

SF labnotebook: Fix multiple keys with wildcards
  • Loading branch information
t-b authored Feb 6, 2025
2 parents afa1072 + 1f0f397 commit ae80f90
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 7 additions & 8 deletions Packages/MIES/MIES_SweepFormula.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -6244,19 +6244,18 @@ static Function/WAVE SFH_OperationLabnotebookExpandKeys(string graph, WAVE/T LBN
continue
endif

Duplicate/FREE/T entries, filteredEntries

for(j = 0; j < numKeys; j += 1)
key = LBNKeys[j]
MultiThread filteredEntries = SelectString(stringmatch(entries[p], key), "", entries[p])
endfor

RemoveTextWaveEntry1D(filteredEntries, "", all = 1)
WAVE/Z indizes = FindIndizes(entries, str = key, prop = PROP_WILDCARD)

Concatenate/NP=(ROWS)/T/FREE {filteredEntries}, allLBNKeys
if(WaveExists(indizes))
Make/FREE/N=(DimSize(indizes, ROWS))/T matches = entries[indizes[p]]
Concatenate/NP=(ROWS)/T/FREE {matches}, allLBNKeys
endif
endfor
endfor

if(DimSize(allLBNKeys, ROWS) == 0)
if(!WaveExists(allLBNKeys))
return $""
endif

Expand Down
12 changes: 12 additions & 0 deletions Packages/tests/Basic/UTF_SweepFormula_Operations.ipf
Original file line number Diff line number Diff line change
Expand Up @@ -2159,6 +2159,18 @@ static Function TestOperationLabNotebook()
Make/D/FREE refContents = {1}
CHECK_EQUAL_WAVES(secondEntry, refContents, mode = WAVE_DATA)

// multiple keys with wildcard
str = "labnotebook([\"ADC\", \"Operating *\"], select(selchannels(AD2), selsweeps([0])), DATA_ACQUISITION_MODE)"
WAVE/WAVE dataRef = SF_ExecuteFormula(str, win, useVariables = 0)
CHECK_EQUAL_VAR(DimSize(dataRef, ROWS), 2)
WAVE firstEntry = dataRef[0]
Make/D/FREE refContents = {2}
CHECK_EQUAL_WAVES(firstEntry, refContents, mode = WAVE_DATA)

WAVE secondEntry = dataRef[1]
Make/D/FREE refContents = {1}
CHECK_EQUAL_WAVES(secondEntry, refContents, mode = WAVE_DATA)

// no match with wildcards
str = "labnotebook([\"eee*\"], select(selchannels(AD2), selsweeps([0])), DATA_ACQUISITION_MODE)"
WAVE/WAVE dataRef = SF_ExecuteFormula(str, win, useVariables = 0)
Expand Down

0 comments on commit ae80f90

Please sign in to comment.