Changeset 1232
- Timestamp:
- Mar 15, 2008, 4:06:01 AM (14 years ago)
- Location:
- trunk/test
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/Suite.cc
r1228 r1232 60 60 61 61 62 void Suite::add(bool ok) 63 { 64 ok_ = ok_ && ok; 65 } 66 67 62 68 std::ostream& Suite::err(void) const 63 69 { … … 79 85 { 80 86 return ok_; 81 }82 83 84 void Suite::ok(bool ok)85 {86 ok_ = ok;87 87 } 88 88 -
trunk/test/Suite.h
r1228 r1232 44 44 45 45 /** 46 set ok to 'b && ok' 47 */ 48 void add(bool b); 49 50 /** 46 51 \return In verbose mode std::cerr, else a ofstream to "/dev/null". 47 52 */ … … 52 57 */ 53 58 bool ok(void) const; 54 55 /**56 \brief set ok57 */58 void ok(bool);59 59 60 60 /** -
trunk/test/alignment_test.cc
r1231 r1232 115 115 double score=utility::SmithWaterman(m, 100, 100); 116 116 if (score!=21) 117 suite. ok(false);117 suite.add(false); 118 118 119 119 // testing ssearch … … 122 122 << utility::ssearch("Hello", "Hll", 0.0, 1.0) 123 123 << " expected " << 2 << std::endl; 124 suite. ok(false);124 suite.add(false); 125 125 } 126 126 if (utility::ssearch("Hello", "Peter said you can't say 'allo", 1, 1)!=3) 127 suite. ok(false);127 suite.add(false); 128 128 129 129 return suite.return_value(); -
trunk/test/averager_test.cc
r1224 r1232 67 67 a.add(5); 68 68 if (a.n()!=3 || a.mean()!=3 || a.sum_xx()!=35){ 69 suite. ok(false);69 suite.add(false); 70 70 suite.err() << "error: add\n"; 71 71 } … … 75 75 u_int tol = 10; 76 76 if (!equal(a,*a1, tol, suite)){ 77 suite. ok(false);77 suite.add(false); 78 78 suite.err().precision(25); 79 79 suite.err() << a.sum_x() << '\t' << a1->sum_x() << std::endl; … … 90 90 a1 = new Averager(a); 91 91 if (!equal(a,*a1, tol, suite)){ 92 suite. ok(false);92 suite.add(false); 93 93 suite.err() << "error: Copy constructor\n"; 94 94 } … … 98 98 if (std::abs(a.standard_error()-sqrt(a.variance()/a.n()))> 99 99 std::numeric_limits<double>().round_error() ){ 100 suite. ok(false);100 suite.add(false); 101 101 suite.err() << "error: standard_error\n"; 102 102 } … … 105 105 if ( std::abs(a.variance() - a.std()*a.std())> 106 106 std::numeric_limits<double>().round_error() ){ 107 suite. ok(false);107 suite.add(false); 108 108 suite.err() << "error: std squared should be variance" << std::endl; 109 109 suite.err() << "std2: " << a.std()*a.std() << std::endl; … … 113 113 114 114 if ( a.variance() != a.variance(a.mean()) ){ 115 suite. ok(false);115 suite.add(false); 116 116 suite.err() << "error: variance incorrect\n" << std::endl; 117 117 suite.err() << "variance: " << a.variance() << std::endl; … … 143 143 suite.err() << "error: AveragerWeighted with unitary weights should " 144 144 << "be equal to Averager" << std::endl; 145 suite. ok(false);145 suite.add(false); 146 146 } 147 147 … … 149 149 if (!equal(aw,*aw2,tol,suite)){ 150 150 suite.err() << "error: AveragerWeighted copy constructor " << std::endl; 151 suite. ok(false);151 suite.add(false); 152 152 } 153 153 … … 156 156 suite.err() << "error: AveragerWeighted adding a data point with weight=0 " 157 157 << "should make no change " << std::endl; 158 suite. ok(false);158 suite.add(false); 159 159 } 160 160 … … 165 165 suite.err() << "error: AveragerWeighted rescaling weights " 166 166 << "should make no change " << std::endl; 167 suite. ok(false);167 suite.add(false); 168 168 } 169 169 delete aw2; … … 185 185 ap.add(static_cast<double>(i),i); 186 186 if (std::abs(ap.correlation()-1)>tol){ 187 suite. ok(false);187 suite.add(false); 188 188 suite.err() << "correlation: " << ap.correlation() << std::endl; 189 189 suite.err() << "error: correlation between identical vectors should be unity" … … 191 191 } 192 192 if (ap.x_averager().variance()!=ap.covariance()){ 193 suite. ok(false);193 suite.add(false); 194 194 suite.err() << "error: covariance of identical vectors should equal to variance" 195 195 << std::endl; … … 209 209 suite.err() << "error: AveragerPairWeighted with unitary weights should " 210 210 << "be equal to AveragerPair" << std::endl; 211 suite. ok(false);211 suite.add(false); 212 212 } 213 213 … … 215 215 if (!equal(apw,*apw2,tol,suite)){ 216 216 suite.err() << "error: AveragerPairWeighted copy constructor " << std::endl; 217 suite. ok(false);217 suite.add(false); 218 218 } 219 219 … … 222 222 suite.err() << "error: AveragerWeighted adding a data point with weight=0 " 223 223 << "should make no change " << std::endl; 224 suite. ok(false);224 suite.add(false); 225 225 } 226 226 … … 231 231 suite.err() << "error: AveragerWeighted rescaling weights " 232 232 << "should make no change " << std::endl; 233 suite. ok(false);233 suite.add(false); 234 234 } 235 235 delete apw2; … … 294 294 bool ok = true; 295 295 if ( std::abs(a.covariance()-b.covariance())>tol){ 296 suite. ok(false);296 suite.add(false); 297 297 suite.err() << "error covariance: " << a.covariance() << "\t" 298 298 << b.covariance() << std::endl; 299 299 } 300 300 if ( std::abs(a.correlation()-b.correlation())>tol ) { 301 suite. ok(false);301 suite.add(false); 302 302 suite.err() << "error correlation" << std::endl; 303 303 } … … 310 310 bool ok = true; 311 311 if ( std::abs(a.covariance()-b.covariance())>tol){ 312 suite. ok(false);312 suite.add(false); 313 313 suite.err() << "error covariance: " << a.covariance() << "\t" 314 314 << b.covariance() << std::endl; 315 315 } 316 316 if ( std::abs(a.correlation()-b.correlation())>tol ) { 317 suite. ok(false);317 suite.add(false); 318 318 suite.err() << "error correlation" << std::endl; 319 319 suite.err() << "unweighted:" << a.correlation() << std::endl; … … 333 333 bool ok = true; 334 334 if ( !test::equal(a.covariance(),b.covariance(),tol) ){ 335 suite. ok(false);335 suite.add(false); 336 336 suite.err() << "error covariance: " << a.covariance() << "\t" 337 337 << b.covariance() << std::endl; 338 338 } 339 339 if ( !test::equal(a.correlation(), b.correlation(), tol) ) { 340 suite. ok(false);340 suite.add(false); 341 341 suite.err() << "error correlation" << std::endl; 342 342 suite.err() << "a:" << a.correlation() << std::endl; -
trunk/test/commandline_test.cc
r1178 r1232 2 2 3 3 /* 4 Copyright (C) 2007 Peter Johansson4 Copyright (C) 2007 2008 Peter Johansson 5 5 6 6 This file is part of the yat library, http://trac.thep.lu.se/yat … … 22 22 */ 23 23 24 #include "Suite.h" 25 24 26 #include "yat/utility/CommandLine.h" 25 27 #include "yat/utility/OptionArg.h" … … 31 33 #include <stdexcept> 32 34 33 using namespace theplu::yat::utility; 34 bool cmd_help(std::ostream& error); 35 bool test_switch(std::ostream& error); 36 bool test_arg(std::ostream& error); 37 bool test_file(std::ostream& error); 38 bool test_failures(std::ostream& error); 39 40 int main(const int argc,const char* argv[]) 35 using namespace theplu; 36 using namespace yat::utility; 37 bool cmd_help(yat::test::Suite& error); 38 bool test_switch(yat::test::Suite& error); 39 bool test_arg(yat::test::Suite& error); 40 bool test_file(yat::test::Suite& error); 41 bool test_failures(yat::test::Suite& error); 42 43 int main(int argc, char* argv[]) 41 44 { 42 45 43 std::ostream* error; 44 if (argc>1 && argv[1]==std::string("-v")) 45 error = &std::cerr; 46 else { 47 error = new std::ofstream("/dev/null"); 48 if (argc>1) 49 std::cout << "commandline_test -v : for printing extra " 50 << "information\n"; 51 } 52 *error << "testing commandline" << std::endl; 53 bool ok = true; 46 yat::test::Suite suite(argc, argv); 47 48 suite.err() << "testing commandline" << std::endl; 54 49 55 50 try { 56 ok &= cmd_help(*error); 57 58 ok &= test_switch(*error); 59 ok &= test_arg(*error); 60 ok &= test_file(*error); 61 ok &= test_failures(*error); 51 suite.add(cmd_help(suite)); 52 suite.add(test_switch(suite)); 53 suite.add(test_arg(suite)); 54 suite.add(test_file(suite)); 55 suite.add(test_failures(suite)); 62 56 } 63 57 catch (std::runtime_error& e) { 64 *error<< "exception thrown\n" << e.what() << std::endl;58 suite.err() << "exception thrown\n" << e.what() << std::endl; 65 59 } 66 60 … … 68 62 OptionFile file(cmd, "f,file", "description"); 69 63 70 if (!ok) 71 *error << "commandline test failed" << std::endl; 72 else 73 *error << "All tests are OK." << std::endl; 74 75 if (error!=&std::cerr) 76 delete error; 77 78 return (ok ? 0 : -1); 79 } 80 81 82 bool cmd_help(std::ostream& error) 64 return suite.return_value(); 65 } 66 67 68 bool cmd_help(yat::test::Suite& suite) 83 69 { 84 70 using namespace theplu::yat::utility; … … 90 76 OptionSwitch version(cmd, "version", "output version and exit"); 91 77 92 error<< cmd;78 suite.err() << cmd; 93 79 return true; 94 80 } 95 81 96 bool test_switch( std::ostream& error)82 bool test_switch(yat::test::Suite& suite) 97 83 { 98 84 bool ok=true; … … 101 87 OptionSwitch verbose(cmd, "v,verbose", "explain what is being done", true); 102 88 103 error<< "Testing OptionSwitch -T...";89 suite.err() << "Testing OptionSwitch -T..."; 104 90 { 105 91 int ac = 2; … … 107 93 cmd.parse(ac,av); 108 94 if (target.present() && !verbose.present()) 109 error<< "ok\n";110 else { 111 error<< "failed\n";112 ok =false; 113 } 114 } 115 116 117 error<< "Testing OptionSwitch --target...";95 suite.err() << "ok\n"; 96 else { 97 suite.err() << "failed\n"; 98 ok =false; 99 } 100 } 101 102 103 suite.err() << "Testing OptionSwitch --target..."; 118 104 { 119 105 int ac = 2; … … 121 107 cmd.parse(ac,av); 122 108 if (target.present() && !verbose.present()) 123 error<< "ok\n";124 else { 125 error<< "failed\n";126 ok =false; 127 } 128 } 129 130 error<< "Testing OptionSwitch -T -v...";109 suite.err() << "ok\n"; 110 else { 111 suite.err() << "failed\n"; 112 ok =false; 113 } 114 } 115 116 suite.err() << "Testing OptionSwitch -T -v..."; 131 117 { 132 118 int ac = 3; … … 134 120 cmd.parse(ac,av); 135 121 if (target.present() && verbose.present()) 136 error<< "ok\n";137 else { 138 error<< "failed\n";139 ok =false; 140 } 141 } 142 143 error<< "Testing OptionSwitch -vT...";122 suite.err() << "ok\n"; 123 else { 124 suite.err() << "failed\n"; 125 ok =false; 126 } 127 } 128 129 suite.err() << "Testing OptionSwitch -vT..."; 144 130 { 145 131 int ac = 2; … … 147 133 cmd.parse(ac,av); 148 134 if (target.present() && verbose.present()) 149 error<< "ok\n";150 else { 151 error<< "failed\n";135 suite.err() << "ok\n"; 136 else { 137 suite.err() << "failed\n"; 152 138 ok =false; 153 139 } … … 157 143 158 144 159 bool test_arg( std::ostream& error)145 bool test_arg(yat::test::Suite& suite) 160 146 { 161 147 bool ok=true; … … 164 150 OptionArg<u_int> n(cmd, "n", "number of lines"); 165 151 166 error<< "Testing OptionArg existence -i file...";152 suite.err() << "Testing OptionArg existence -i file..."; 167 153 { 168 154 int ac = 3; … … 170 156 cmd.parse(ac,av); 171 157 if (input.present()) 172 error<< "ok\n";173 else { 174 error<< "failed\n";175 ok =false; 176 } 177 } 178 179 error<< "Testing OptionArg value -i file...";158 suite.err() << "ok\n"; 159 else { 160 suite.err() << "failed\n"; 161 ok =false; 162 } 163 } 164 165 suite.err() << "Testing OptionArg value -i file..."; 180 166 { 181 167 int ac = 3; … … 183 169 cmd.parse(ac,av); 184 170 if (input.value()=="file") 185 error<< "ok\n";186 else { 187 error<< "failed\n";188 ok =false; 189 } 190 } 191 192 error<< "Testing OptionArg existence --input file...";171 suite.err() << "ok\n"; 172 else { 173 suite.err() << "failed\n"; 174 ok =false; 175 } 176 } 177 178 suite.err() << "Testing OptionArg existence --input file..."; 193 179 { 194 180 int ac = 3; … … 196 182 cmd.parse(ac,av); 197 183 if (input.present()) 198 error<< "ok\n";199 else { 200 error<< "failed\n";201 ok =false; 202 } 203 } 204 205 error<< "Testing OptionArg value --input=file...";184 suite.err() << "ok\n"; 185 else { 186 suite.err() << "failed\n"; 187 ok =false; 188 } 189 } 190 191 suite.err() << "Testing OptionArg value --input=file..."; 206 192 { 207 193 int ac = 2; … … 209 195 cmd.parse(ac,av); 210 196 if (input.value()=="file") 211 error<< "ok\n";212 else { 213 error<< "failed\n";214 ok =false; 215 } 216 } 217 218 error<< "Testing OptionArg value --input=\"file called something\"...";197 suite.err() << "ok\n"; 198 else { 199 suite.err() << "failed\n"; 200 ok =false; 201 } 202 } 203 204 suite.err() << "Testing OptionArg value --input=\"file called something\"..."; 219 205 { 220 206 int ac = 2; … … 222 208 cmd.parse(ac,av); 223 209 if (input.value()=="file called something") 224 error<< "ok\n";225 else { 226 error<< "failed\n";227 error<< "value is `" << input.value() << "'\n"210 suite.err() << "ok\n"; 211 else { 212 suite.err() << "failed\n"; 213 suite.err() << "value is `" << input.value() << "'\n" 228 214 << "expected `file called something'\n"; 229 215 ok =false; … … 231 217 } 232 218 233 error<< "Testing OptionArg u_int value -n 3...";219 suite.err() << "Testing OptionArg u_int value -n 3..."; 234 220 { 235 221 int ac = 3; … … 237 223 cmd.parse(ac,av); 238 224 if (n.value()==3) 239 error<< "ok\n";240 else { 241 error<< "failed\n";242 ok =false; 243 } 244 } 245 246 247 error<< "Testing OptionArg 2 value --input file -n 3...";225 suite.err() << "ok\n"; 226 else { 227 suite.err() << "failed\n"; 228 ok =false; 229 } 230 } 231 232 233 suite.err() << "Testing OptionArg 2 value --input file -n 3..."; 248 234 { 249 235 int ac = 5; … … 251 237 cmd.parse(ac,av); 252 238 if (input.value()=="file") 253 error<< "ok\n";254 else { 255 error<< "failed\n";239 suite.err() << "ok\n"; 240 else { 241 suite.err() << "failed\n"; 256 242 ok =false; 257 243 } … … 262 248 } 263 249 264 bool test_failures( std::ostream& error)250 bool test_failures(yat::test::Suite& suite) 265 251 { 266 252 bool ok=true; … … 270 256 OptionArg<u_int> n(cmd, "n", "number of lines"); 271 257 272 error<< "Testing unknown option --peter...";258 suite.err() << "Testing unknown option --peter..."; 273 259 { 274 260 int ac = 2; … … 276 262 try{ 277 263 cmd.parse(ac,av); 278 error<< "failed\n";279 ok =false; 280 } 281 catch (...) { 282 error<< "ok\n";283 } 284 } 285 286 error<< "Testing unknown option -jvjhsgad...";264 suite.err() << "failed\n"; 265 ok =false; 266 } 267 catch (...) { 268 suite.err() << "ok\n"; 269 } 270 } 271 272 suite.err() << "Testing unknown option -jvjhsgad..."; 287 273 { 288 274 int ac = 2; … … 290 276 try{ 291 277 cmd.parse(ac,av); 292 error<< "failed\n";293 ok =false; 294 } 295 catch (...) { 296 error<< "ok\n";297 } 298 } 299 300 301 error<< "Testing invalid option -nv 3...";278 suite.err() << "failed\n"; 279 ok =false; 280 } 281 catch (...) { 282 suite.err() << "ok\n"; 283 } 284 } 285 286 287 suite.err() << "Testing invalid option -nv 3..."; 302 288 { 303 289 int ac = 3; … … 305 291 try{ 306 292 cmd.parse(ac,av); 307 error<< "failed\n";308 ok =false; 309 } 310 catch (...) { 311 error<< "ok\n";312 } 313 } 314 315 316 error<< "Testing 23.12 is not u_int...";293 suite.err() << "failed\n"; 294 ok =false; 295 } 296 catch (...) { 297 suite.err() << "ok\n"; 298 } 299 } 300 301 302 suite.err() << "Testing 23.12 is not u_int..."; 317 303 { 318 304 int ac = 3; … … 320 306 try{ 321 307 cmd.parse(ac,av); 322 error<< "failed\n";308 suite.err() << "failed\n"; 323 309 ok =false; 324 310 } 325 311 catch (std::runtime_error& e) { 326 error<< "ok\n";327 } 328 } 329 330 error<< "Testing -1 is not u_int...";312 suite.err() << "ok\n"; 313 } 314 } 315 316 suite.err() << "Testing -1 is not u_int..."; 331 317 { 332 318 int ac = 3; … … 334 320 try{ 335 321 cmd.parse(ac,av); 336 error<< "failed\n";337 ok =false; 338 } 339 catch (...) { 340 error<< "ok\n";341 } 342 } 343 344 345 error<< "Testing OptionArg required ...";322 suite.err() << "failed\n"; 323 ok =false; 324 } 325 catch (...) { 326 suite.err() << "ok\n"; 327 } 328 } 329 330 331 suite.err() << "Testing OptionArg required ..."; 346 332 { 347 333 OptionArg<std::string> required(cmd, "required", "required", true); … … 350 336 try{ 351 337 cmd.parse(ac,av); 352 error<< "failed\n";353 ok =false; 354 } 355 catch (...) { 356 error<< "ok\n";338 suite.err() << "failed\n"; 339 ok =false; 340 } 341 catch (...) { 342 suite.err() << "ok\n"; 357 343 } 358 344 } … … 363 349 364 350 365 bool test_file( std::ostream& error)351 bool test_file(yat::test::Suite& suite) 366 352 { 367 353 bool ok=true; … … 372 358 OptionSwitch help(cmd, "h,help", "display this help and exit"); 373 359 374 error<< "Testing OptionFile... ";360 suite.err() << "Testing OptionFile... "; 375 361 { 376 362 int ac = 2; … … 379 365 "commandline_test.cc"}; 380 366 cmd.parse(ac,av); 381 error<< "ok\n";367 suite.err() << "ok\n"; 382 368 } 383 369 return ok; -
trunk/test/consensus_inputranker_test.cc
r1121 r1232 4 4 Copyright (C) 2004, 2005 Peter Johansson 5 5 Copyright (C) 2006 Jari Häkkinen, Peter Johansson 6 Copyright (C) 2007 Peter Johansson6 Copyright (C) 2007 2008 Peter Johansson 7 7 8 8 This file is part of the yat library, http://trac.thep.lu.se/yat … … 24 24 */ 25 25 26 #include "Suite.h" 27 26 28 #include "yat/classifier/ConsensusInputRanker.h" 27 29 #include "yat/statistics/AUC.h" … … 38 40 using namespace std; 39 41 40 int main( const int argc,constchar* argv[])42 int main(int argc, char* argv[]) 41 43 { 42 std::ostream* error; 43 if (argc>1 && argv[1]==std::string("-v")) 44 error = &std::cerr; 45 else { 46 error = new std::ofstream("/dev/null"); 47 if (argc>1) 48 std::cout << "consensus_inputranker_test -v : for printing extra " 49 << "information\n"; 50 } 51 *error << "testing consensus_inputranker" << std::endl; 52 bool ok = true; 44 theplu::yat::test::Suite suite(argc, argv); 45 suite.err() << "testing consensus_inputranker" << std::endl; 53 46 54 47 ifstream is("data/rank_data.txt"); … … 64 57 theplu::yat::statistics::AUC roc; 65 58 theplu::yat::classifier::CrossValidationSampler sampler(target,30,3); 66 *error<< "Building Consensus_Inputranker" << std::endl;59 suite.err() << "Building Consensus_Inputranker" << std::endl; 67 60 theplu::yat::classifier::IRRank retrieve; 68 61 theplu::yat::statistics::Median median; … … 70 63 cir.add(sampler,data,roc); 71 64 72 *error<< "test ids... ";65 suite.err() << "test ids... "; 73 66 if (cir.id(0)!=2 || cir.id(1)!=0 || cir.id(2)!=1){ 74 *error<< "\nincorrect id for weighted" << endl;75 ok=false;67 suite.err() << "\nincorrect id for weighted" << endl; 68 suite.add(false); 76 69 } 77 70 else 78 *error<< "ok." << std::endl;71 suite.err() << "ok." << std::endl; 79 72 80 *error<< "test ranks... ";73 suite.err() << "test ranks... "; 81 74 if (cir.rank(0)!=1 || cir.rank(1)!=2 || cir.rank(2)!=0){ 82 *error<< "\nincorrect rank for weighted" << endl;83 ok=false;75 suite.err() << "\nincorrect rank for weighted" << endl; 76 suite.add(false); 84 77 } 85 78 else 86 *error<< "ok." << std::endl;79 suite.err() << "ok." << std::endl; 87 80 88 81 theplu::yat::utility::Matrix flag(data.rows(),data.columns(),1); … … 91 84 cir2.add(sampler,data,roc); 92 85 93 *error<< "test ids... ";86 suite.err() << "test ids... "; 94 87 if (cir2.id(0)!=2 || cir2.id(1)!=0 || cir2.id(2)!=1){ 95 *error<< "\nincorrect id for weighted" << endl;96 ok=false;88 suite.err() << "\nincorrect id for weighted" << endl; 89 suite.add(false); 97 90 } 98 91 else 99 *error<< "ok." << std::endl;92 suite.err() << "ok." << std::endl; 100 93 101 *error<< "test ranks... ";94 suite.err() << "test ranks... "; 102 95 if (cir2.rank(0)!=1 || cir2.rank(1)!=2 || cir2.rank(2)!=0){ 103 *error<< "\nincorrect rank for weighted" << endl;104 ok=false;96 suite.err() << "\nincorrect rank for weighted" << endl; 97 suite.add(false); 105 98 } 106 99 else 107 *error<< "ok." << std::endl;100 suite.err() << "ok." << std::endl; 108 101 109 if (error!=&std::cerr) 110 delete error; 111 112 if(ok) 113 return 0; 114 return -1; 102 return suite.return_value(); 115 103 } -
trunk/test/regression_test.cc
r1230 r1232 86 86 suite.err() << " fit_parameters(1) = " 87 87 << polynomial.fit_parameters()(1) << std::endl; 88 suite. ok(false);88 suite.add(false); 89 89 } 90 90 if (test::equal(polynomial.fit_parameters()(0), … … 94 94 suite.err() << "error: alpha-beta*m_x = " 95 95 << linear.alpha()-linear.beta()*1985 << std::endl; 96 suite. ok(false);96 suite.add(false); 97 97 } 98 98 if ( std::abs(polynomial.chisq()-linear.chisq())>0.0001){ 99 99 suite.err() << "error: chisq not same in linear and polynomial(1)" 100 100 << std::endl; 101 suite. ok(false);101 suite.add(false); 102 102 } 103 103 if ( std::abs(polynomial.predict(1.0)-linear.predict(1.0))>0.0001){ 104 104 suite.err() << "error: predict not same in linear and polynomial(1)" 105 105 << std::endl; 106 suite. ok(false);106 suite.add(false); 107 107 } 108 108 if ( std::abs(polynomial.standard_error2(1985)-linear.standard_error2(1985)) … … 112 112 << "\n linear: " << linear.standard_error2(1985) 113 113 << std::endl; 114 suite. ok(false);114 suite.add(false); 115 115 } 116 116 … … 125 125 suite.err() << "predicted value: " << y_predicted << " expected 12.8" 126 126 << std::endl; 127 suite. ok(false);127 suite.add(false); 128 128 } 129 129 … … 139 139 suite.err() << " fit_parameters(1) = " 140 140 << polynomial_w.fit_parameters()(1) << std::endl; 141 suite. ok(false);141 suite.add(false); 142 142 } 143 143 if ( std::abs(polynomial_w.fit_parameters()(0)-linear_w.alpha()+ … … 147 147 suite.err() << "error: alpha-beta*m_x = " 148 148 << linear.alpha()-linear.beta()*1990 << std::endl; 149 suite. ok(false);149 suite.add(false); 150 150 } 151 151 if ( std::abs(polynomial_w.s2()-linear_w.s2())>0.0001){ 152 152 suite.err() << "error: chisq not same in linear and polynomial(1)" 153 153 << std::endl; 154 suite. ok(false);154 suite.add(false); 155 155 } 156 156 if ( std::abs(polynomial_w.predict(1.0)-linear_w.predict(1.0))>0.0001){ 157 157 suite.err() << "error: predict not same in linear and polynomial(1)" 158 158 << std::endl; 159 suite. ok(false);159 suite.add(false); 160 160 } 161 161 if ( std::abs(polynomial_w.standard_error2(1985)-linear_w.standard_error2(1985)) … … 165 165 << "\n linear: " << linear.standard_error2(1985) 166 166 << std::endl; 167 suite. ok(false);167 suite.add(false); 168 168 } 169 169 … … 181 181 suite.err() << "returned value: " << y_predicted << std::endl; 182 182 suite.err() << "expected: " << 0.1*12+0.2*11+0.3*14+0.4*13 << std::endl; 183 suite. ok(false);183 suite.add(false); 184 184 } 185 185 … … 190 190 if (!Local_test(rl,kb)) { 191 191 suite.err() << "regression_Local: Linear cannot reproduce fit." << std::endl; 192 suite. ok(false);192 suite.add(false); 193 193 } 194 194 regression::NaiveWeighted rn; 195 195 if (!Local_test(rn,kb)) { 196 196 suite.err() << "regression_Local: Naive cannot reproduce fit." << std::endl; 197 suite. ok(false);197 suite.add(false); 198 198 } 199 199 … … 216 216 fit(2)+1.159674470130)>1e-11) { 217 217 suite.err() << "regression_Polynomial: cannot reproduce fit." << std::endl; 218 suite. ok(false);218 suite.add(false); 219 219 } 220 220 } … … 254 254 rw.fit(x,y,w); 255 255 if (std::abs(r.predict(2000) - rw.predict(2000))>1e-15) { 256 suite. ok(false);256 suite.add(false); 257 257 suite.err() << "Error: predict not equal\n" 258 258 << " weighted: " << rw.predict(2000) << "\n" … … 261 261 } 262 262 if (std::abs(r.s2()-rw.s2(1.0))>10E-7){ 263 suite. ok(false);263 suite.add(false); 264 264 suite.err() << "Error: s2 not equal non-weighted version." << std::endl; 265 265 suite.err() << "weighted s2 = " << rw.s2(1.0) << std::endl; … … 267 267 } 268 268 if (std::abs(r.standard_error2(2000)-rw.standard_error2(2000))>10e-7){ 269 suite. ok(false);269 suite.add(false); 270 270 suite.err() << "Error: standard_error not equal non-weighted version." 271 271 << std::endl; 272 272 } 273 273 if (std::abs(r.r2()-rw.r2())>10E-7){ 274 suite. ok(false);274 suite.add(false); 275 275 suite.err() << "Error: r2 not equal non-weighted version." << std::endl; 276 276 suite.err() << "weighted r2 = " << rw.r2() << std::endl; … … 278 278 } 279 279 if (std::abs(r.prediction_error2(2000)-rw.prediction_error2(2000,1))>10e-7){ 280 suite. ok(false);280 suite.add(false); 281 281 suite.err() << "Error: prediction_error2 not equal non-weighted version.\n" 282 282 << " weighted: " << rw.prediction_error2(2000,1) << "\n" … … 303 303 wr.fit(x,y,w); 304 304 if (std::abs(wr.predict(2000)-predict)>10e-11){ 305 suite. ok(false);305 suite.add(false); 306 306 suite.err() << "Error: predict not equal after rescaling.\n"; 307 307 suite.err() << " predict = " << predict … … 310 310 } 311 311 if (std::abs(wr.s2(2)-s2)>10e-11){ 312 suite. ok(false);312 suite.add(false); 313 313 suite.err() << "Error: s2 not equal after rescaling.\n"; 314 314 suite.err() << " s2 = " << s2 << " and after doubling weights.\n"; … … 317 317 } 318 318 if (std::abs(wr.standard_error2(2000)-standard_error2)>10e-6){ 319 suite. ok(false);319 suite.add(false); 320 320 suite.err() << "Error: standard_error2 not equal after rescaling.\n"; 321 321 suite.err() << " standard_error2 = " << standard_error2 … … 327 327 } 328 328 if (std::abs(wr.r2()-r2)>10e-6){ 329 suite. ok(false);329 suite.add(false); 330 330 suite.err() << "Error: r2 not equal after rescaling.\n"; 331 331 } 332 332 if (std::abs(wr.prediction_error2(2000,2)-prediction_error2)>10e-6){ 333 suite. ok(false);333 suite.add(false); 334 334 suite.err() << "Error: prediction_error2 not equal after rescaling.\n"; 335 335 suite.err() << " prediction_error2 = " << prediction_error2 … … 365 365 wr.fit(x2,y2,w2); 366 366 if (std::abs(wr.predict(2000) - predict)>1e-10) { 367 suite. ok(false);367 suite.add(false); 368 368 suite.err() << "Error: predict not equal.\n"; 369 369 suite.err() << " weighted predict: " << wr.predict(2000) << "\n"; … … 373 373 } 374 374 if (std::abs(wr.prediction_error2(2000) - prediction_error2)>1e-13) { 375 suite. ok(false);375 suite.add(false); 376 376 suite.err() << "Error: prediction_error2 not equal.\n"; 377 377 } 378 378 if (std::abs(wr.r2() - r2)>1e-15) { 379 suite. ok(false);379 suite.add(false); 380 380 suite.err() << "Error: r2 not equal.\n"; 381 381 suite.err() << " r2: " << r2 << "\n"; … … 383 383 } 384 384 if (std::abs(wr.s2() - s2)>1e-15) { 385 suite. ok(false);385 suite.add(false); 386 386 suite.err() << "Error: s2 not equal.\n"; 387 387 } 388 388 if (std::abs(wr.standard_error2(2000) - standard_error2)>1e-15) { 389 suite. ok(false);389 suite.add(false); 390 390 suite.err() << "Error: standard_error2 not equal.\n"; 391 391 } … … 414 414 z(2)=2000*2000; 415 415 if (!test::equal(md.predict(z), mdw.predict(z))){ 416 suite. ok(false);416 suite.add(false); 417 417 suite.err() << "Error: predict not equal\n" 418 418 << " weighted: " << mdw.predict(z) << "\n" … … 422 422 423 423 if (std::abs(md.standard_error2(z)-mdw.standard_error2(z))>10e-6){ 424 suite. ok(false);424 suite.add(false); 425 425 suite.err() << "Error: standard_error2 not equal\n" 426 426 << " weighted: " << mdw.standard_error2(z) << "\n" … … 429 429 } 430 430 if (std::abs(md.prediction_error2(z)-mdw.prediction_error2(z,1.0))>10e-7){ 431 suite. ok(false);431 suite.add(false); 432 432 suite.err() << "Error: prediction_error2 not equal\n" 433 433 << " weighted: " << mdw.prediction_error2(z,1.0) << "\n" … … 446 446 mdw.fit(data,y,w); 447 447 if (std::abs(mdw.predict(z)-predict)>10e-10){ 448 suite. ok(false);448 suite.add(false); 449 449 suite.err() << "Error: predict not equal after rescaling.\n"; 450 450 suite.err() << " predict = " << predict << " and after doubling weights.\n"; … … 452 452 } 453 453 if (std::abs(mdw.prediction_error2(z,2)-prediction_error2)>10e-7){ 454 suite. ok(false);454 suite.add(false); 455 455 suite.err() << "Error: prediction_error2 not equal after rescaling.\n"; 456 456 suite.err() << " predict_error2 = " << prediction_error2 … … 459 459 } 460 460 if (std::abs(mdw.s2(2)-s2)>10e-10){ 461 suite. ok(false);461 suite.add(false); 462 462 suite.err() << "Error: s2 not equal after rescaling.\n"; 463 463 suite.err() << " s2 = " << s2 << " and after doubling weights.\n"; … … 465 465 } 466 466 if (std::abs(mdw.standard_error2(z)-standard_error2)>10e-7){ 467 suite. ok(false);467 suite.add(false); 468 468 suite.err() << "Error: standard_error2 not equal after rescaling.\n"; 469 469 suite.err() << " standard_error2 = " << standard_error2
Note: See TracChangeset
for help on using the changeset viewer.