| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# This is a simple script that tests autoclass |
| 4 |
# |
| 5 |
# install as: /usr/lib/debian-test/tests/autoclass |
| 6 |
# or else as: /usr/lib/debian-test/tests/autoclass/test-1 |
| 7 |
# In the latter case, /usr/lib/debian-test/tests/autoclass/ can contain |
| 8 |
# other file with test data and/or other scripts named test-2, test-3, etc. |
| 9 |
# |
| 10 |
# You can run this script with the command |
| 11 |
# sh debian/tests |
| 12 |
# After installation, you can run it with the commands |
| 13 |
# /usr/lib/debian-test/tests/autoclass |
| 14 |
# or |
| 15 |
# debian-test -v autoclass |
| 16 |
# see debian-test(1) |
| 17 |
|
| 18 |
. ${DEBIANTEST_LIB:-/usr/lib/debian-test/lib}/functions.sh |
| 19 |
|
| 20 |
if [ -f my-data-file ]; then |
| 21 |
TESTDIR=`pwd`; |
| 22 |
else |
| 23 |
TESTDIR=/usr/lib/debian-test/tests/autoclass; |
| 24 |
fi |
| 25 |
|
| 26 |
|
| 27 |
## we need a scratch directory in which to execute |
| 28 |
|
| 29 |
TMP=/tmp/autoclass-test.$$ |
| 30 |
test -e $TMP && rm -rf $TMP |
| 31 |
mkdir $TMP |
| 32 |
cd $TMP |
| 33 |
trap "rm -rf $TMP" EXIT |
| 34 |
|
| 35 |
test1(){ |
| 36 |
RESULT=0 |
| 37 |
cp /usr/share/doc/autoclass/examples/simple* . |
| 38 |
|
| 39 |
# use autoclass to separate observations into two groups |
| 40 |
|
| 41 |
if [ ! -f simple.db2 ]; then gunzip *.gz; fi |
| 42 |
|
| 43 |
# use autoclass to find the groups |
| 44 |
autoclass -search simple.db2 simple.hd2 simple.model simple.s-params |
| 45 |
|
| 46 |
# ask autoclass to generate reports |
| 47 |
autoclass -reports simple.results simple.search simple.r-params |
| 48 |
## FIXME |
| 49 |
|
| 50 |
# copy the oservations into two files, |
| 51 |
# depending on the group assigned by autoclass |
| 52 |
awk ' |
| 53 |
/^[0-9]/{ |
| 54 |
group_number=$2; |
| 55 |
getline data < "simple.db2"; |
| 56 |
print data > "group" group_number; |
| 57 |
}' simple.case-data-1 |
| 58 |
|
| 59 |
# display the original data (under X windows) |
| 60 |
gnuplot -persist <<EOF |
| 61 |
set key bottom |
| 62 |
set title "original data" |
| 63 |
plot "simple.db2" |
| 64 |
EOF |
| 65 |
|
| 66 |
# display the two groups in different colors (under X windows) |
| 67 |
cat simple.influ-o-data-1 | awk ' |
| 68 |
BEGIN{ |
| 69 |
FS="[ ()]+"; |
| 70 |
printf("set key bottom\n"); |
| 71 |
printf("set title \"groups found by AutoClass\"\n"); |
| 72 |
printf("set parametric; set trange [0:6.28]\n"); |
| 73 |
printf("plot \\\n"); |
| 74 |
} |
| 75 |
/^[0-9][0-9]/{ |
| 76 |
if ($5~/latitude/) {latmean=$7; latsd=$8; ++data} |
| 77 |
if ($5~/longitude/) {lonmean=$7; lonsd=$8; ++data} |
| 78 |
if (data == 2) { |
| 79 |
if (group) printf(",\\\n"); |
| 80 |
printf("%s+2.45*%s*sin(t),%s+2.45*%s*cos(t) title \"group %d 95%% contour\",\\\n", |
| 81 |
lonmean, lonsd, latmean, latsd, group); |
| 82 |
printf(" \"group%d\" title \"group %d members\"", group, group); |
| 83 |
data=0; group++; |
| 84 |
} |
| 85 |
} |
| 86 |
END { printf("\n");}' | gnuplot -persist |
| 87 |
|
| 88 |
|
| 89 |
# execute autoclass against first test case |
| 90 |
# in case of failure, set the shell variable RESULT like this: |
| 91 |
RESULT=1 |
| 92 |
|
| 93 |
return $RESULT |
| 94 |
} |
| 95 |
|
| 96 |
test2(){ |
| 97 |
RESULT=0 |
| 98 |
|
| 99 |
# execute autoclass against second test case, |
| 100 |
# OR test for a different bug which has been reported in autoclass |
| 101 |
# OR test a different binary supplied by autoclass. |
| 102 |
# in case of failure, set the shell variable RESULT like this: |
| 103 |
RESULT=1 |
| 104 |
|
| 105 |
return $RESULT |
| 106 |
} |
| 107 |
|
| 108 |
runtest "first test case" test1 |
| 109 |
runtest "second test case" test2 |
| 110 |
# extend as necessary... |