test_TableOfReal_and_Permutation.praat 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # test_TableOfReal_and_Permutation.praat
  2. # djmw 20050713, 20070829
  3. nrows = 30
  4. Create TableOfReal... test nrows 2
  5. testtab = selected ("TableOfReal")
  6. Formula... row*col
  7. labels$ = "aabbccddeeffgghhiijjk"
  8. printline test: TableOfReal_and_Permutation.praat
  9. for itry to 10
  10. select testtab
  11. for i to nrows
  12. randomIndex = randomInteger (1,20)
  13. label$ = mid$ (labels$, randomIndex, 1)
  14. Set row label (index)... i 'label$'
  15. endfor
  16. To Permutation (sort row labels)
  17. pid = selected ("Permutation")
  18. plus testtab
  19. Permute rows
  20. testtabp = selected ("TableOfReal")
  21. label$ = Get row label... 1
  22. for i from 2 to nrows
  23. lab$ = Get row label... i
  24. assert lab$ >= label$ ; i='i' 'lab$' > 'label$'
  25. label$ = lab$
  26. endfor
  27. select pid
  28. Invert
  29. pidi = selected ("Permutation")
  30. plus testtabp
  31. Permute rows
  32. testtabpi = selected ("TableOfReal")
  33. Formula... self - TableOfReal_test[]
  34. stdev = Get column stdev (index)... 1
  35. assert stdev = 0
  36. select pid
  37. plus testtabp
  38. plus pidi
  39. plus testtabpi
  40. Remove
  41. print .
  42. endfor
  43. printline o.k.
  44. select testtab
  45. Remove