The FACTOR command crashed if there were no cases
which had non-missing values for all variables.
This change emits a warning in this case and does
no analysis.
idata->cov = covariance_calculate (cov);
+ if (idata->cov == NULL)
+ {
+ msg (MW, _("The dataset contains no complete observations. No analysis will be performed."));
+ goto finish;
+ }
+
var_matrix = covariance_moments (cov, MOMENT_VARIANCE);
mean_matrix = covariance_moments (cov, MOMENT_MEAN);
idata->n = covariance_moments (cov, MOMENT_NONE);
const gsl_matrix *
covariance_calculate (struct covariance *cov)
{
- assert ( cov->state > 0 );
+ if ( cov->state <= 0 )
+ return NULL;
switch (cov->passes)
{
const gsl_matrix *
covariance_calculate_unnormalized (struct covariance *cov)
{
- assert ( cov->state > 0 );
+ if ( cov->state <= 0 )
+ return NULL;
switch (cov->passes)
{
socst,.222,.922
])
-AT_CLEANUP
\ No newline at end of file
+AT_CLEANUP
+
+
+
+AT_SETUP([FACTOR empty dataset])
+dnl Test that something sane happens when the dataset contains no complete observations
+
+AT_DATA([factor-empty.sps],
+ [data list notable list /x * y * z *.
+begin data.
+3.4 . 92.9
+. 32.09 34.2
+1.00 19.80 .
+2.00 . 3.6
+end data.
+
+factor /variables = ALL.
+])
+
+AT_CHECK([pspp -O format=csv factor-empty.sps], [0], [ignore])
+AT_CLEANUP