@@ -551,6 +551,96 @@ Function GetSizeOfAllWavesInExperiment()
551551 Edit / K=1 root: list
552552End
553553
554+ /// @brief Check that all stored waves (permanent and free) adhere to the liberal naming rules.
555+ ///
556+ /// These are only enforced since IP9 beta9 or later.
557+ ///
558+ /// @return Number of waves not matching
559+ Function CheckAllDimensionLabels ()
560+ string msg, path
561+ variable i , numWaves, failures
562+
563+ WAVE /T allWaves = ListToTextWave ( GetListOfObjects ( $ "root:" , ".*" , fullPath=1, recursive=1 ) , ";" )
564+ WAVE /T allWavesUnique = GetUniqueEntries ( allWaves)
565+ WaveClear allWaves
566+
567+ numWaves = DimSize ( allWavesUnique, ROWS)
568+ for ( i = 0; i < numWaves; i += 1 )
569+ path = allWavesUnique[ i ]
570+ WAVE wv = $ path
571+ msg = CheckDimensionLabels ( wv)
572+
573+ if ( ! IsEmpty ( msg))
574+ printf "Wave %s:\r " , path
575+ print msg
576+ failures += 1
577+ endif
578+ endfor
579+
580+ return failures
581+ End
582+
583+ threadsafe static Function/S CheckDimensionLabels ( WAVE /Z wv)
584+ variable i , numDims, j, size, numMatches, numEntries, idx
585+ string entry
586+ string msg = ""
587+ string text = ""
588+
589+ if ( ! WaveExists ( wv))
590+ return msg
591+ endif
592+
593+ numDims = WaveDims ( wv)
594+
595+ for ( i = 0; i < numDims; i += 1 )
596+ size = DimSize ( wv, i )
597+
598+ Make / FREE/ T/ N= ( size + 1 ) lbls
599+ Multithread lbls[] = GetDimLabel ( wv, i , p - 1 )
600+ Make / FREE/ N= ( size + 1 ) valid
601+ Multithread valid[] = IsValidLiberalObjectName ( lbls[ p])
602+
603+ FindValue / UOFV/ V=0 valid
604+
605+ if ( V_Value >= 0 )
606+ WAVE /Z indizes = FindIndizes ( valid, col = 0, var = 0 )
607+ numMatches = WaveExists ( indizes) ? DimSize ( indizes, ROWS) : 0
608+
609+ for ( j = 0; j < numMatches; j += 1 )
610+ sprintf text, "dimension %d, element %d, label %s\r " , i , indizes[ j] , lbls[ indizes[ j]]
611+ msg += text
612+ endfor
613+ endif
614+ endfor
615+
616+ // call recursively if it is a wave reference wave
617+ if ( IsWaveRefWave ( wv))
618+ WAVE /WAVE waveRef = wv
619+ // use a linearized index to check all holded waves
620+ numEntries = numpnts ( waveRef)
621+ Make / FREE/ T/ N= ( numEntries) results
622+ Multithread results[] = CheckDimensionLabels ( waveRef[ p])
623+
624+ if ( HasOneValidEntry ( results))
625+ WAVE /Z indizes = FindIndizes ( results, col = 0, prop = PROP_NON_EMPTY)
626+ numMatches = WaveExists ( indizes) ? DimSize ( indizes, ROWS) : 0
627+
628+ for ( i = 0; i < numMatches; i += 1 )
629+ idx = indizes[ i ]
630+ entry = results[ idx]
631+
632+ if ( IsEmpty ( entry))
633+ continue
634+ endif
635+
636+ sprintf text, "Wave ref wave has wave with the following invalid dimension label (invalid linear index %d): %s" , idx, entry
637+ endfor
638+ endif
639+ endif
640+
641+ return msg
642+ End
643+
554644// see tools/functionprofiling.sh
555645Function DEBUG_STOREFUNCTION ()
556646 string funcName = GetRTStackInfo ( 2 )
0 commit comments