File MIES_Utilities_Checks.ipf

Utility functions that check for certain properties and return either 1 (TRUE) or 0 (FALSE)

Functions

variable IsFinite(variable var)

Returns 1 if var is a finite/normal number, 0 otherwise.

UTF_NOINSTRUMENTATION

variable IsNaN(variable var)

Returns 1 if var is a NaN, 0 otherwise.

UTF_NOINSTRUMENTATION

variable IsInf(variable var)

Returns 1 if var is +/- inf, 0 otherwise.

UTF_NOINSTRUMENTATION

variable IsNull(string *str)

Returns 1 if str is null, 0 otherwise.

UTF_NOINSTRUMENTATION

Parameters:

str – must not be a SVAR

variable IsEmpty(string str)

Returns one if str is empty, zero otherwise.

UTF_NOINSTRUMENTATION

Parameters:

str – any non-null string variable or text wave element

variable WindowExists(string win)

Checks if the given name exists as window.

UTF_NOINSTRUMENTATION

variable ValueCanBeWritten(WaveOrNull wv, variable value)

Check that the given value can be stored in the wave.

Does currently ignore floating point precision and ranges for integer waves

variable IsInteger(variable var)

Returns one if var is an integer and zero otherwise UTF_NOINSTRUMENTATION.

variable IsEven(variable var)

UTF_NOINSTRUMENTATION.

variable IsOdd(variable var)

UTF_NOINSTRUMENTATION.

variable FuncRefIsAssigned(string funcInfo)

Check wether the function reference points to the prototype function or to an assigned function.

Due to Igor Pro limitations you need to pass the function info from FuncRefInfo and not the function reference itself.

UTF_NOINSTRUMENTATION

Returns:

1 if pointing to prototype function, 0 otherwise

variable CheckIfClose(variable var1, variable var2, variable tol = defaultValue, variable strong_or_weak = defaultValue)

Compare two variables and determines if they are close.

Based on the implementation of “Floating-point comparison algorithms” in the C++ Boost unit testing framework.

Literature:

The art of computer programming (Vol II). Donald. E. Knuth. 0-201-89684-2. Addison-Wesley Professional; 3 edition, page 234 equation (34) and (35).

UTF_NOINSTRUMENTATION

Parameters:
  • var1 – first variable

  • var2 – second variable

  • tol – [optional, defaults to 1e-8] tolerance

  • strong_or_weak – [optional, defaults to strong] type of condition, can be zero for weak or 1 for strong

variable CheckIfSmall(variable var, variable tol = defaultValue)

Test if a variable is small using the inequality \( | var | < | tol | \).

Parameters:
  • var – variable

  • tol – [optional, defaults to 1e-8] tolerance

variable IsTextWave(wave wv)

Return 1 if the wave is a text wave, zero otherwise UTF_NOINSTRUMENTATION.

variable IsNumericWave(wave wv)

Return 1 if the wave is a numeric wave, zero otherwise UTF_NOINSTRUMENTATION.

variable IsWaveRefWave(wave wv)

Return 1 if the wave is a wave reference wave, zero otherwise UTF_NOINSTRUMENTATION.

variable IsFloatingPointWave(wave wv)

Return 1 if the wave is a floating point wave UTF_NOINSTRUMENTATION.

variable IsDoubleFloatingPointWave(wave wv)

Return 1 if the wave is a double (64bit) precision floating point wave.

UTF_NOINSTRUMENTATION

variable IsSingleFloatingPointWave(wave wv)

Return 1 if the wave is a single (32bit) precision floating point wave.

UTF_NOINSTRUMENTATION

variable IsGlobalWave(wave wv)

Return 1 if the wave is a global wave (not a null wave and not a free wave)

variable IsComplexWave(wave wv)

Return 1 if the wave is a complex wave.

variable IsFreeWave(wave wv)

Return true if wv is a free wave, false otherwise.

UTF_NOINSTRUMENTATION

variable HasOneValidEntry(wave wv)

Return true if not all wave entries are NaN, false otherwise.

UTF_NOINSTRUMENTATION

variable HasOneFiniteEntry(wave wv)

Return true if wave has one finite entry (not Inf, -Inf or NaN)

variable HasOneNonFiniteEntry(wave wv)

Return true if wave has one infinite entry (Inf, -Inf or NaN)

variable StringEndsWith(string str, string suffix)

Checks if a string ends with a specific suffix. The check is case-insensitive.

Parameters:
  • str[in] string to check for suffix

  • suffix[in] to check for

Returns:

1 if str ends with suffix, 0 otherwise. If str and/or suffix are empty or null 0 is returned.

variable EqualValuesOrBothNaN(variable left, variable right)

Check wether val1 and val2 are equal or both NaN.

UTF_NOINSTRUMENTATION

variable IsConstant(wave wv, variable val, variable ignoreNaN = defaultValue)

Checks wether wv is constant and has the value val

UTF_NOINSTRUMENTATION

Parameters:
  • wv – wave to check

  • val – value to check

  • ignoreNaN – [optional, defaults to true] ignore NaN in wv

variable IsValidRegexp(string regexp)

Return true if the passed regular expression is well-formed.

static variable AreIntervalsIntersectingImpl(variable index, wave intervals)
variable AreIntervalsIntersecting(wave intervalsParam)

Return the truth if any of the given intervals ]A, B[ intersect.

Parameters:

intervalsParam – Nx2 wave with the intervals

variable HasWildcardSyntax(string str)

Return true if str is in wildcard syntax, false if not.

variable MatchAgainstWildCardPatterns(WaveText patterns, string matchThis)

Attempts matching against a number of wildcard patterns.

Parameters:
  • patterns – text wave with wildcard patterns to match against

  • matchThis – string that is matched

Returns:

Returns 1 if matchThis was successfully matches, 0 otherwise

variable ListHasOnlyOneUniqueEntry(string list, string sep = defaultValue)

Check if all elements of the string list are the same.

Returns true for lists with less than one element