From 3e321285cf0c55004e5286db06a4630fe705c4ab Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 30 Apr 2017 20:35:55 +0200 Subject: [PATCH] MATRIX DATA: Rewrite to canonical rowtype values --- src/language/data-io/matrix-data.c | 12 ++++++++++++ tests/language/data-io/matrix-data.at | 28 +++++++++++++-------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/language/data-io/matrix-data.c b/src/language/data-io/matrix-data.c index 209ccb7af5..7855caf464 100644 --- a/src/language/data-io/matrix-data.c +++ b/src/language/data-io/matrix-data.c @@ -186,6 +186,18 @@ preprocess (struct casereader *casereader0, const struct dictionary *dict, void set_varname_column (outcase, mformat, " ", 8); } + /* Special case for SD and N_VECTOR: Rewrite as STDDEV and N respectively */ + if (0 == strncasecmp (val, "sd ", 8)) + { + value_copy_buf_rpad (case_data_rw (outcase, mformat->rowtype), 8, + (uint8_t *) "STDDEV", 6, ' '); + } + else if (0 == strncasecmp (val, "n_vector", 8)) + { + value_copy_buf_rpad (case_data_rw (outcase, mformat->rowtype), 8, + (uint8_t *) "N", 1, ' '); + } + casewriter_write (writer, outcase); } diff --git a/tests/language/data-io/matrix-data.at b/tests/language/data-io/matrix-data.at index 6cc1e67bb9..cba500ff10 100644 --- a/tests/language/data-io/matrix-data.at +++ b/tests/language/data-io/matrix-data.at @@ -32,7 +32,7 @@ AT_CHECK([pspp -O format=csv matrix-data.pspp], [0], [dnl Table: Data List ROWTYPE_,VARNAME_,var01,var02,var03,var04,var05,var06,var07,var08 mean ,,24.3000,5.4000,69.7000,20.1000,13.4000,2.7000,27.9000,3.7000 -sd ,,5.7000,1.5000,23.5000,5.8000,2.8000,4.5000,5.4000,1.5000 +STDDEV ,,5.7000,1.5000,23.5000,5.8000,2.8000,4.5000,5.4000,1.5000 n ,,92.0000,92.0000,92.0000,92.0000,92.0000,92.0000,92.0000,92.0000 corr ,var01,1.0000,.1800,-.2200,.3600,.2700,.3300,.5000,.1700 corr ,var02,.1800,1.0000,-.1700,.3100,.1600,.1500,.2900,.2900 @@ -55,13 +55,13 @@ matrix data /format = upper diagonal. begin data -mean 34 35 36 37 -sd 22 11 55 66 -n 100 101 102 103 -corr 1 9 8 7 -corr 1 6 5 -corr 1 4 -corr 1 +mean 34 35 36 37 +sd 22 11 55 66 +n_vector 100 101 102 103 +corr 1 9 8 7 +corr 1 6 5 +corr 1 4 +corr 1 end data. list. @@ -71,8 +71,8 @@ AT_CHECK([pspp -O format=csv matrix-data.pspp], [0], [dnl Table: Data List ROWTYPE_,VARNAME_,var01,var02,var03,var04 mean ,,34.0000,35.0000,36.0000,37.0000 -sd ,,22.0000,11.0000,55.0000,66.0000 -n ,,100.0000,101.0000,102.0000,103.0000 +STDDEV ,,22.0000,11.0000,55.0000,66.0000 +N ,,100.0000,101.0000,102.0000,103.0000 corr ,var01,1.0000,9.0000,8.0000,7.0000 corr ,var02,9.0000,1.0000,6.0000,5.0000 corr ,var03,8.0000,6.0000,1.0000,4.0000 @@ -107,7 +107,7 @@ AT_CHECK([pspp -O format=csv matrix-data.pspp], [0], [dnl Table: Data List ROWTYPE_,VARNAME_,var01,var02,var03,var04 MEAN ,,34.0000,35.0000,36.0000,37.0000 -SD ,,22.0000,11.0000,55.0000,66.0000 +STDDEV ,,22.0000,11.0000,55.0000,66.0000 N ,,100.0000,101.0000,102.0000,103.0000 CORR ,var01,1.0000,9.0000,8.0000,7.0000 CORR ,var02,9.0000,1.0000,6.0000,5.0000 @@ -141,7 +141,7 @@ AT_CHECK([pspp -O format=csv matrix-data.pspp], [0], [dnl Table: Data List ROWTYPE_,VARNAME_,var01,var02,var03,var04 mean ,,34.0000,35.0000,36.0000,37.0000 -sd ,,22.0000,11.0000,55.0000,66.0000 +STDDEV ,,22.0000,11.0000,55.0000,66.0000 n ,,100.0000,101.0000,102.0000,103.0000 corr ,var01,1.0000,9.0000,8.0000,7.0000 corr ,var02,9.0000,1.0000,6.0000,5.0000 @@ -175,7 +175,7 @@ AT_CHECK([pspp -O format=csv matrix-data.pspp], [0], [dnl Table: Data List ROWTYPE_,VARNAME_,var01,var02,var03,var04 mean ,,34.0000,35.0000,36.0000,37.0000 -sd ,,22.0000,11.0000,55.0000,66.0000 +STDDEV ,,22.0000,11.0000,55.0000,66.0000 n ,,100.0000,101.0000,102.0000,103.0000 corr ,var01,1.0000,9.0000,8.0000,7.0000 corr ,var02,9.0000,1.0000,6.0000,5.0000 @@ -223,7 +223,7 @@ var04,Format: F10.4,8 Table: Data List s1,s2,ROWTYPE_,VARNAME_,var01,var02,var03,var04 1,1,mean ,,34.0000,35.0000,36.0000,37.0000 -1,1,sd ,,22.0000,11.0000,55.0000,66.0000 +1,1,STDDEV ,,22.0000,11.0000,55.0000,66.0000 1,0,n ,,100.0000,101.0000,102.0000,103.0000 1,0,corr ,var01,1.0000,9.0000,8.0000,7.0000 0,1,corr ,var02,9.0000,1.0000,6.0000,5.0000 -- 2.30.2