tests: Tag all the tests that take more than about 1s as "slow".
[pspp] / tests / language / stats / quick-cluster.at
index 75dd52cb19f89a0a584ab3281bc9c24334ae7953..ee790ac8565d707bf1867328a90267182f5748aa 100644 (file)
@@ -1,3 +1,19 @@
+dnl PSPP - a program for statistical analysis.
+dnl Copyright (C) 2017 Free Software Foundation, Inc.
+dnl 
+dnl This program is free software: you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation, either version 3 of the License, or
+dnl (at your option) any later version.
+dnl 
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl 
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program.  If not, see <http://www.gnu.org/licenses/>.
+dnl
 AT_BANNER([QUICK CLUSTER])
 
 AT_SETUP([QUICK CLUSTER with small data set])
@@ -44,15 +60,16 @@ Valid,,11
 AT_CLEANUP
 
 AT_SETUP([QUICK CLUSTER with large data set])
+AT_KEYWORDS([slow])
 AT_DATA([quick-cluster.sps], [dnl
 input program.
-loop #i = 1 to 500000.
+loop #i = 1 to 50000.
 compute x = 3.
 end case.
 end loop.
 end file.
 end input program.
-QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
+QUICK CLUSTER x /CRITERIA = CLUSTER(4) NOINITIAL.
 ])
 AT_CHECK([pspp -o pspp.csv quick-cluster.sps])
 AT_CHECK([cat pspp.csv], [0], [dnl
@@ -61,14 +78,14 @@ Table: Final Cluster Centers
 ,,,,
 ,1,2,3,4
 ,,,,
-x,.00,.00,.00,3.00
+x,NaN,NaN,NaN,3.00
 
 Table: Number of Cases in each Cluster
 Cluster,1,0
 ,2,0
 ,3,0
-,4,500000
-Valid,,500000
+,4,50000
+Valid,,50000
 ])
 AT_CLEANUP
 
@@ -91,7 +108,7 @@ end input program.
 
 weight by w.
 
-QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
+QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (10).
 ])
 
 AT_CHECK([pspp -o pspp-w.csv qc-weighted.sps])
@@ -106,7 +123,7 @@ end loop.
 end file.
 end input program.
 
-QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
+QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (10).
 ])
 
 AT_CHECK([pspp -o pspp-unw.csv qc-unweighted.sps])
@@ -128,7 +145,7 @@ begin data.
 2
 end data.
 
-QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
+QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (10).
 ])
 
 AT_CHECK([pspp -o pspp-m.csv quick-miss.sps])
@@ -144,7 +161,7 @@ begin data.
 2
 end data.
 
-QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (100).
+QUICK CLUSTER x /CRITERIA = CLUSTER(4) MXITER (10).
 ])
 
 AT_CHECK([pspp -o pspp-nm.csv quick-nmiss.sps])
@@ -155,6 +172,12 @@ AT_CLEANUP
 
 
 AT_SETUP([QUICK CLUSTER with pairwise missing])
+
+dnl This test runs two programs, which are identical except that one
+dnl has an extra case with one missing value. Because the syntax uses
+dnl NOINITIAL and NOUPDATE, the results should be identical except for
+dnl the final classification.
+
 AT_DATA([quick-s.sps], [dnl
 data list notable list /x * y *.
 begin data.
@@ -169,16 +192,15 @@ begin data.
 3.4 3
 3.5 2.5
 3.1 2.0
-3.9 2.5
-3.8 2.0
 end data.
 
 QUICK CLUSTER x y 
-       /CRITERIA = CLUSTER(3) MXITER (100)
+       /PRINT = INITIAL
+       /CRITERIA = CLUSTER(3) NOINITIAL NOUPDATE
        .
 ])
 
-AT_CHECK([pspp -O format=csv quick-s.sps | tail -5 > pspp-s.csv])
+AT_CHECK([pspp -O format=csv quick-s.sps  > pspp-s.csv])
 
 AT_DATA([quick-pw.sps], [dnl
 data list notable list /x * y *.
@@ -194,19 +216,28 @@ begin data.
 3.4 3
 3.5 2.5
 3.1 2.0
-3.9 .
-3.8 .
+.   2.3
 end data.
 
 QUICK CLUSTER x y 
-       /CRITERIA = CLUSTER(3) MXITER (100)
+       /CRITERIA = CLUSTER(3) NOINITIAL NOUPDATE
+       /PRINT = INITIAL
        /MISSING = PAIRWISE
        .
 ])
 
-AT_CHECK([pspp -O format=csv quick-pw.sps | tail -5 > pspp-pw.csv])
+AT_CHECK([pspp -O format=csv quick-pw.sps  > pspp-pw.csv])
+
+AT_CHECK([head -n 18  pspp-s.csv > top-s.csv])
+AT_CHECK([head -n 18  pspp-pw.csv > top-pw.csv])
+AT_CHECK([diff top-s.csv top-pw.csv])
+
+
+AT_CHECK([grep Valid pspp-s.csv], [0], [Valid,,11
+])
 
-AT_CHECK([diff pspp-s.csv pspp-pw.csv], [0])
+AT_CHECK([grep Valid pspp-pw.csv], [0], [Valid,,12
+])
 
 
 AT_CLEANUP
@@ -321,8 +352,8 @@ Table: Initial Cluster Centers
 ,,,
 ,1,2,3
 ,,,
-x,0,0,1
-y,0,1,0
+x,-11,-12,11
+y,-12,11,11
 
 Table: Final Cluster Centers
 ,Cluster,,
@@ -400,3 +431,24 @@ Case Number,Cluster
 ])
 
 AT_CLEANUP
+
+
+dnl Test for a crash which happened on bad input syntax
+AT_SETUP([QUICK CLUSTER -- Empty Parentheses])
+
+AT_DATA([empty-parens.sps], [dnl
+data list notable list /x * y *.
+begin data.
+1   2
+1   2.2
+end data.
+
+QUICK CLUSTER x y
+       /CRITERIA = CONVERGE()
+       .
+])
+
+AT_CHECK([pspp -o pspp.csv empty-parens.sps], [1], [ignore])
+
+AT_CLEANUP
+