Skip to content

Commit 1d68207

Browse files
committed
added assertions (gulp!)
1 parent 06d4f50 commit 1d68207

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Packages/MIES/MIES_SweepFormula_PSX.ipf

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,10 @@ static Function [variable baseline_t, variable baseline] PSX_CalculateEventBasel
623623
elseif(kernelAmp < 0)
624624
baseline_t = V_maxloc
625625
else
626-
ASSERT(0, "Can't handle kernelAmp of zero")
626+
string str
627+
sprintf str, "Can't handle kernelAmp of: %g\r", baseline_t //could be Nan, Inf, or zero
628+
ASSERT(0, str)
629+
ASSERT(isFinite(baseline_t), str)
627630
endif
628631

629632
range = PSX_BASELINE_NUM_POINTS_AVERAGE * DimDelta(sweepDataOffFilt, ROWS)
@@ -780,7 +783,9 @@ static Function [variable first, variable last] PSX_GetSingleEventRange(WAVE psx
780783
else
781784
last = min(first + offset, psxEvent[index + 1][%baseline_t])
782785
endif
783-
786+
787+
assert(first<=last, "range must have first < last")
788+
784789
return [first, last]
785790
End
786791

@@ -794,7 +799,8 @@ static Function [variable start, variable stop] PSX_GetEventFitRange(WAVE sweepD
794799
start = psxEvent[eventIndex][%peak_t]
795800

796801
maxLength = PSX_FIT_RANGE_FACTOR * JWN_GetNumberFromWaveNote(psxEvent, SF_META_USER_GROUP + PSX_JWN_PARAMETERS + "/psxKernel/decayTau")
797-
802+
ASSERT(isFinite(maxLength), "Failed to retrieve finite decay tau")
803+
798804
if(eventIndex == (DimSize(psxEvent, ROWS) - 1))
799805
calcLength = maxLength
800806
else
@@ -807,7 +813,7 @@ static Function [variable start, variable stop] PSX_GetEventFitRange(WAVE sweepD
807813

808814
stop = min(start + calcLength, IndexToScale(sweepDataOffFilt, DimSize(sweepDataOffFilt, ROWS), ROWS))
809815

810-
ASSERT(start < stop, "Invalid fit range calculation")
816+
ASSERT(start <= stop, "Invalid fit range calculation")
811817

812818
return [start, stop]
813819
End

0 commit comments

Comments
 (0)