#include <testutil.h>
Static Public Member Functions | |
static int | get_debug_int (int i) |
static float | get_debug_float (int i) |
static string | get_debug_string (int i) |
static string | get_debug_image (const string &imagename) |
static string | get_golden_image (const string &imagename) |
static void | to_emobject (const Dict &d) |
static EMObject | emobject_to_py (bool b) |
static EMObject | emobject_to_py (unsigned int n) |
static EMObject | emobject_to_py (int n) |
static EMObject | emobject_to_py (float f) |
static EMObject | emobject_to_py (double f) |
static EMObject | emobject_to_py (const string &str) |
static EMObject | emobject_to_py (EMData *emdata) |
static EMObject | emobject_to_py (XYData *xydata) |
static EMObject | emobject_farray_to_py () |
static EMObject | emobject_strarray_to_py () |
static EMObject | emobject_to_py (Transform *t) |
static EMObject | emobject_to_py (Ctf *ctf_) |
static IntPoint | test_IntPoint (const IntPoint &p) |
static FloatPoint | test_FloatPoint (const FloatPoint &p) |
static IntSize | test_IntSize (const IntSize &p) |
static FloatSize | test_FloatSize (const FloatSize &p) |
static Vec3i | test_Vec3i (const Vec3i &p) |
static Vec3f | test_Vec3f (const Vec3f &p) |
static vector< int > | test_vector_int (const vector< int > &v) |
static vector< float > | test_vector_float (const vector< float > &v) |
static vector< long > | test_vector_long (const vector< long > &v) |
static vector< string > | test_vector_string (const vector< string > &v) |
static vector< EMData * > | test_vector_emdata (const vector< EMData * > &v) |
static vector< Pixel > | test_vector_pixel (const vector< Pixel > &v) |
static map< string, int > | test_map_int (const map< string, int > &d) |
static map< string, long > | test_map_long (const map< string, long > &d) |
static map< string, float > | test_map_float (const map< string, float > &d) |
static map< string, string > | test_map_string (const map< string, string > &d) |
static map< string, EMObject > | test_map_emobject (const map< string, EMObject > &d) |
static map< string, vector< string > > | test_map_vecstring (const map< string, vector< string > > &d) |
static Dict | test_dict (const Dict &d) |
static void | dump_image_from_file (const string &filename) |
static void | dump_emdata (EMData *image, const string &filename) |
static int | check_image (const string &imagefile, EMData *image=0) |
static void | set_progname (const string &cur_progname) |
static void | make_image_file (const string &filename, EMUtil::ImageType image_type, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1) |
static int | verify_image_file (const string &filename, EMUtil::ImageType image_type, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1) |
static void | make_image_file2 (const string &filename, EMUtil::ImageType image_type, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1) |
static int | verify_image_file2 (const string &filename, EMUtil::ImageType image_type, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1) |
Static Public Attributes | |
static const char * | EMDATA_HEADER_EXT = ".head" |
static const char * | EMDATA_DATA_EXT = ".data" |
Static Private Member Functions | |
static void | make_image_file_by_mode (const string &filename, EMUtil::ImageType image_type, int mode, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1) |
static int | verify_image_file_by_mode (const string &filename, EMUtil::ImageType image_type, int mode, EMUtil::EMDataType datatype=EMUtil::EM_FLOAT, int nx=16, int ny=16, int nz=1) |
static float | get_pixel_value_by_dist1 (int nx, int ny, int nz, int x, int y, int z) |
static float | get_pixel_value_by_dist2 (int nx, int ny, int nz, int x, int y, int z) |
Static Private Attributes | |
static float | tf [10] = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5} |
static int | ti [10] = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100} |
static string | progname = "" |
Definition at line 52 of file testutil.h.
|
Definition at line 393 of file testutil.cpp. References dump_emdata(), dump_image_from_file(), EMDATA_DATA_EXT, EMDATA_HEADER_EXT, EMAN::Util::is_file_exist(), LOGERR, progname, and EMAN::Util::sbasename(). 00394 { 00395 #if DEBUG 00396 string headerfile1 = Util::sbasename(imagefile) + EMDATA_HEADER_EXT; 00397 string datafile1 = Util::sbasename(imagefile) + EMDATA_DATA_EXT; 00398 00399 char imgpath[MAXPATHLEN]; 00400 char * path_env = getenv("DEBUG_IMAGE_PATH"); 00401 if (path_env) { 00402 sprintf(imgpath, "%s/testdata/%s/", path_env, progname.c_str()); 00403 } 00404 else { 00405 sprintf(imgpath, "%s/images/testdata/%s/", getenv("HOME"), progname.c_str()); 00406 } 00407 00408 string headerfile2 = string(imgpath) + headerfile1; 00409 string datafile2 = string(imgpath) + datafile1; 00410 00411 00412 if (image) { 00413 dump_emdata(image, imagefile); 00414 } 00415 else { 00416 dump_image_from_file(imagefile); 00417 } 00418 00419 if (!Util::is_file_exist(headerfile2) || 00420 !Util::is_file_exist(datafile2)) { 00421 return 0; 00422 } 00423 00424 string diffcmd1 = "diff " + headerfile1 + " " + headerfile2; 00425 00426 int err = system(diffcmd1.c_str()); 00427 if (!err) { 00428 string diffcmd2 = "diff " + datafile1 + " " + datafile2; 00429 err = system(diffcmd2.c_str()); 00430 } 00431 if (err) { 00432 LOGERR("check_image on %s FAILED\n", imagefile.c_str()); 00433 } 00434 00435 return err; 00436 #endif 00437 return 0; 00438 }
|
|
Definition at line 452 of file testutil.cpp. References EMDATA_DATA_EXT, EMDATA_HEADER_EXT, FileAccessException, EMAN::EMData::get_attr_dict(), EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::keys(), nx, ny, rdata, EMAN::Util::sbasename(), EMAN::Util::sstrncmp(), and EMAN::Gatan::to_str(). Referenced by check_image(), and dump_image_from_file(). 00453 { 00454 string filebase = Util::sbasename(filename); 00455 string headerfile = filebase + EMDATA_HEADER_EXT; 00456 string datafile = filebase + EMDATA_DATA_EXT; 00457 00458 FILE *hfile = fopen(headerfile.c_str(), "wb"); 00459 if (!hfile) { 00460 throw FileAccessException(headerfile); 00461 } 00462 #if 0 00463 vector<string> excl_keys; 00464 excl_keys.push_back("MRC.label"); 00465 excl_keys.push_back("IMAGIC.minute"); 00466 excl_keys.push_back("IMAGIC.sec"); 00467 00468 Dict attr_dict = image->get_attr_dict(); 00469 vector < string > keys = attr_dict.keys(); 00470 00471 00472 00473 for (size_t i = 0; i < keys.size(); i++) { 00474 00475 bool is_exclude = false; 00476 for (size_t j = 0; j < excl_keys.size(); j++) { 00477 if (Util::sstrncmp(keys[i].c_str(), excl_keys[j].c_str())) { 00478 is_exclude = true; 00479 break; 00480 } 00481 } 00482 if (!is_exclude) { 00483 fprintf(hfile, "%s = %s\n", keys[i].c_str(), 00484 attr_dict[keys[i]].to_str().c_str()); 00485 } 00486 } 00487 #endif 00488 00489 fprintf(hfile, "nx = %d\n", image->get_xsize()); 00490 fprintf(hfile, "ny = %d\n", image->get_ysize()); 00491 fprintf(hfile, "nz = %d\n", image->get_zsize()); 00492 00493 fclose(hfile); 00494 hfile = 0; 00495 00496 FILE *dfile = fopen(datafile.c_str(), "wb"); 00497 if (!dfile) { 00498 throw FileAccessException(datafile); 00499 } 00500 00501 int nx = image->get_xsize(); 00502 int ny = image->get_ysize(); 00503 int nz = image->get_zsize(); 00504 00505 size_t row_size = nx * sizeof(float); 00506 size_t nxy = nx * ny; 00507 float * rdata = image->get_data(); 00508 00509 for (int i = 0; i < nz; i++) { 00510 for (int j = 0; j < ny; j++) { 00511 fwrite(&rdata[i * nxy + j * nx], row_size, 1, dfile); 00512 } 00513 } 00514 fclose(dfile); 00515 dfile = 0; 00516 }
|
|
Definition at line 440 of file testutil.cpp. References dump_emdata(), and EMAN::EMData::read_image(). Referenced by check_image(). 00441 { 00442 EMData * e = new EMData(); 00443 e->read_image(filename); 00444 dump_emdata(e, filename); 00445 if( e ) 00446 { 00447 delete e; 00448 e = 0; 00449 } 00450 }
|
|
Definition at line 690 of file testutil.cpp. 00691 { 00692 vector<float> v(3); 00693 for (int i = 0; i < 3; i++) { 00694 v[i] = tf[i]; 00695 } 00696 return EMObject(v); 00697 }
|
|
Definition at line 700 of file testutil.cpp. References get_debug_string(), and v. 00701 { 00702 vector<string> v(3); 00703 for (int i = 0; i < 3; i++) { 00704 v[i] = get_debug_string(i); 00705 } 00706 return EMObject(v); 00707 }
|
|
Definition at line 714 of file testutil.cpp. 00715 { 00716 return EMObject(ctf_); 00717 }
|
|
Definition at line 709 of file testutil.cpp. 00710 { 00711 return EMObject(t); 00712 }
|
|
Definition at line 684 of file testutil.cpp. 00685 { 00686 return EMObject(xydata); 00687 }
|
|
Definition at line 678 of file testutil.cpp. 00679 { 00680 return EMObject(emdata); 00681 }
|
|
Definition at line 672 of file testutil.cpp. 00673 { 00674 return EMObject(str); 00675 }
|
|
Definition at line 667 of file testutil.cpp. 00668 { 00669 return EMObject(f); 00670 }
|
|
Definition at line 662 of file testutil.cpp. 00663 { 00664 return EMObject(f); 00665 }
|
|
Definition at line 657 of file testutil.cpp. 00658 { 00659 return EMObject(n); 00660 }
|
|
Definition at line 652 of file testutil.cpp. 00653 { 00654 return EMObject(un); 00655 }
|
|
Definition at line 647 of file testutil.cpp.
|
|
Definition at line 69 of file testutil.cpp. References tf. 00070 { 00071 return tf[i]; 00072 }
|
|
Definition at line 81 of file testutil.cpp. 00082 { 00083 char imgpath[MAXPATHLEN]; 00084 char * path_env = getenv("DEBUG_IMAGE_PATH"); 00085 if (path_env) { 00086 sprintf(imgpath, "%s/%s", path_env, imagename.c_str()); 00087 } 00088 else { 00089 sprintf(imgpath, "%s/images/%s", getenv("HOME"), imagename.c_str()); 00090 } 00091 return string(imgpath); 00092 }
|
|
Definition at line 64 of file testutil.cpp. References ti. 00065 { 00066 return ti[i]; 00067 }
|
|
Definition at line 74 of file testutil.cpp. Referenced by emobject_strarray_to_py(), test_dict(), and to_emobject().
|
|
Definition at line 94 of file testutil.cpp. 00095 { 00096 char imgpath[MAXPATHLEN]; 00097 char * path_env = getenv("DEBUG_IMAGE_PATH"); 00098 if (path_env) { 00099 sprintf(imgpath, "%s/testdata/%s", path_env, imagename.c_str()); 00100 } 00101 else { 00102 sprintf(imgpath, "%s/images/testdata/%s", getenv("HOME"), imagename.c_str()); 00103 } 00104 return string(imgpath); 00105 }
|
|
Definition at line 161 of file testutil.h. References abs. Referenced by make_image_file_by_mode(), and verify_image_file_by_mode(). 00162 { 00163 int x2 = x; 00164 int y2 = y; 00165 int z2 = z; 00166 00167 x2 = abs(nx/2-x); 00168 y2 = abs(ny/2-y); 00169 00170 if (z > nz/2) { 00171 z2 = nz-z; 00172 } 00173 00174 if (nz == 1) { 00175 return (float)(x2*x2 + y2*y2); 00176 } 00177 else { 00178 int areax = (int)((float)nx * z2 / nz); 00179 int areay = (int)((float)ny * z2 / nz); 00180 if ((abs(x-nx/2) <= areax) && (abs(y-ny/2) <= areay)) { 00181 return (float)(x2*x2 + y2*y2); 00182 } 00183 else { 00184 return 0; 00185 } 00186 } 00187 }
|
|
Definition at line 189 of file testutil.h. References abs. Referenced by make_image_file_by_mode(), and verify_image_file_by_mode(). 00190 { 00191 int x2 = x; 00192 int y2 = y; 00193 int z2 = z; 00194 00195 00196 if (x > nx/2) { 00197 x2 = nx-x; 00198 } 00199 if (y > ny/2) { 00200 y2 = ny-y; 00201 } 00202 00203 if (z > nz/2) { 00204 z2 = nz-z; 00205 } 00206 00207 if (nz == 1) { 00208 return (float)(x2*x2 + y2*y2); 00209 } 00210 else { 00211 int areax = (int)((float)nx * z2 / nz); 00212 int areay = (int)((float)ny * z2 / nz); 00213 if ((abs(x-nx/2) <= areax) && (abs(y-ny/2) <= areay)) { 00214 return (float)(x2*x2 + y2*y2); 00215 } 00216 else { 00217 return 0; 00218 } 00219 } 00220 }
|
|
Definition at line 109 of file testutil.h. References make_image_file_by_mode(), nx, and ny. 00113 { 00114 make_image_file_by_mode(filename, image_type, 1, datatype, nx, ny, nz); 00115 }
|
|
Definition at line 125 of file testutil.h. References make_image_file_by_mode(), nx, and ny. 00129 { 00130 make_image_file_by_mode(filename, image_type, 2, datatype,nx, ny, nz); 00131 }
|
|
Definition at line 524 of file testutil.cpp. References data, EMAN::EMData::do_fft(), EMAN::EMData::get_data(), get_pixel_value_by_dist1(), get_pixel_value_by_dist2(), is_complex(), EMAN::EMUtil::is_complex_type(), EMAN::EMData::set_attr(), EMAN::EMData::set_size(), EMAN::EMData::update(), and EMAN::EMData::write_image(). Referenced by make_image_file(), and make_image_file2(). 00528 { 00529 EMData * e = new EMData(); 00530 e->set_size(nx, ny, nz); 00531 bool is_complex = EMUtil::is_complex_type(datatype); 00532 00533 e->set_attr("is_complex", (int)is_complex); 00534 e->set_attr("datatype", (int)datatype); 00535 float * data = e->get_data(); 00536 00537 size_t l = 0; 00538 for (int i = 0; i < nz; i++) { 00539 for (int j = 0; j < ny; j++) { 00540 for (int k = 0; k < nx; k++) { 00541 if (mode == 1) { 00542 data[l] = get_pixel_value_by_dist1(nx, ny, nz, k, j, i); 00543 } 00544 else if (mode == 2) { 00545 data[l] = get_pixel_value_by_dist2(nx, ny, nz, k, j, i); 00546 } 00547 l++; 00548 } 00549 } 00550 } 00551 00552 if (!is_complex) { 00553 e->write_image(filename, 0, image_type, false, 0, datatype, true); 00554 } 00555 else { 00556 e->update(); 00557 e->set_attr("is_complex", false); 00558 EMData * fft = e->do_fft(); 00559 fft->write_image(filename, 0, image_type, false, 0, datatype, true); 00560 if( fft ) 00561 { 00562 delete fft; 00563 fft = 0; 00564 } 00565 } 00566 00567 if( e ) 00568 { 00569 delete e; 00570 e = 0; 00571 } 00572 }
|
|
Definition at line 518 of file testutil.cpp. References progname, and EMAN::Util::sbasename(). 00519 { 00520 progname = Util::sbasename(cur_progname); 00521 }
|
|
Definition at line 375 of file testutil.cpp. References Assert, get_debug_string(), EMAN::Dict::keys(), LOGDEBUG, and tf. 00376 { 00377 Dict r; 00378 00379 vector<string> keys = d.keys(); 00380 sort(keys.begin(), keys.end()); 00381 00382 for (size_t i = 0; i < keys.size(); i++) { 00383 LOGDEBUG("keys[%s] = %f\n", keys[i].c_str(), (float)d[keys[i]]); 00384 Assert(keys[i] == get_debug_string(i)); 00385 Assert(((float)d[keys[i]]) == tf[i]); 00386 r[keys[i]] = d[keys[i]]; 00387 } 00388 00389 return r; 00390 }
|
|
Definition at line 186 of file testutil.cpp. References Assert, LOGDEBUG, and tf. 00187 { 00188 Assert(p[0] == tf[0]); 00189 Assert(p[1] == tf[1]); 00190 Assert(p[2] == tf[2]); 00191 LOGDEBUG("FloatPoint p = (%f, %f, %f)\n", p[0], p[1], p[2]); 00192 return FloatPoint(tf[0], tf[1], tf[2]); 00193 }
|
|
Definition at line 206 of file testutil.cpp. References Assert, LOGDEBUG, and tf. 00207 { 00208 Assert(p[0] == tf[0]); 00209 Assert(p[1] == tf[1]); 00210 Assert(p[2] == tf[2]); 00211 LOGDEBUG("FloatSize p = (%f, %f, %f)\n", p[0], p[1], p[2]); 00212 return FloatSize(tf[0], tf[1], tf[2]); 00213 }
|
|
Definition at line 177 of file testutil.cpp. References Assert, LOGDEBUG, and ti. 00178 { 00179 Assert(p[0] == ti[0]); 00180 Assert(p[1] == ti[1]); 00181 Assert(p[2] == ti[2]); 00182 LOGDEBUG("IntPoint p = (%d, %d, %d)\n", p[0], p[1], p[2]); 00183 return IntPoint(ti[0], ti[1], ti[2]); 00184 }
|
|
Definition at line 196 of file testutil.cpp. References Assert, LOGDEBUG, and ti. 00197 { 00198 Assert(p[0] == ti[0]); 00199 Assert(p[1] == ti[1]); 00200 Assert(p[2] == ti[2]); 00201 LOGDEBUG("IntSize p = (%d, %d, %d)\n", p[0], p[1], p[2]); 00202 return IntSize(ti[0], ti[1], ti[2]); 00203 }
|
|
Definition at line 283 of file testutil.cpp. References LOGDEBUG. 00284 { 00285 map<string, EMObject> r; 00286 map<string, EMObject>::const_iterator p; 00287 for (p = d.begin(); p != d.end(); p++) { 00288 LOGDEBUG("map[\"%s\"] = %f; ", p->first.c_str(), (float)(p->second)); 00289 r[p->first] = EMObject(p->second); 00290 } 00291 LOGDEBUG("\n"); 00292 return r; 00293 }
|
|
Definition at line 259 of file testutil.cpp. References LOGDEBUG. 00260 { 00261 map<string, float> r; 00262 map<string, float>::const_iterator p; 00263 for (p = d.begin(); p != d.end(); p++) { 00264 LOGDEBUG("map[\"%s\"] = %f; ", p->first.c_str(), p->second); 00265 r[p->first] = p->second; 00266 } 00267 LOGDEBUG("\n"); 00268 return r; 00269 }
|
|
Definition at line 235 of file testutil.cpp. References LOGDEBUG. 00236 { 00237 map<string, int> r; 00238 map<string, int>::const_iterator p; 00239 for (p = d.begin(); p != d.end(); p++) { 00240 LOGDEBUG("map[\"%s\"] = %d; ", p->first.c_str(), p->second); 00241 r[p->first] = p->second; 00242 } 00243 LOGDEBUG("\n"); 00244 return r; 00245 }
|
|
Definition at line 247 of file testutil.cpp. References LOGDEBUG. 00248 { 00249 map<string, long> r; 00250 map<string, long>::const_iterator p; 00251 for (p = d.begin(); p != d.end(); p++) { 00252 LOGDEBUG("map[\"%s\"] = %d; ", p->first.c_str(), p->second); 00253 r[p->first] = p->second; 00254 } 00255 LOGDEBUG("\n"); 00256 return r; 00257 }
|
|
Definition at line 271 of file testutil.cpp. References LOGDEBUG. 00272 { 00273 map<string, string> r; 00274 map<string, string>::const_iterator p; 00275 for (p = d.begin(); p != d.end(); p++) { 00276 LOGDEBUG("map[\"%s\"] = %s; ", p->first.c_str(), p->second.c_str()); 00277 r[p->first] = p->second; 00278 } 00279 LOGDEBUG("\n"); 00280 return r; 00281 }
|
|
Definition at line 295 of file testutil.cpp.
|
|
Definition at line 225 of file testutil.cpp. References Assert, LOGDEBUG, and tf. 00226 { 00227 Assert(p[0] == tf[0]); 00228 Assert(p[1] == tf[1]); 00229 Assert(p[2] == tf[2]); 00230 LOGDEBUG("Vec3f p = (%f, %f, %f)\n", p[0], p[1], p[2]); 00231 return Vec3f(tf[0], tf[1], tf[2]); 00232 }
|
|
Definition at line 216 of file testutil.cpp. References Assert, LOGDEBUG, and ti. 00217 { 00218 Assert(p[0] == ti[0]); 00219 Assert(p[1] == ti[1]); 00220 Assert(p[2] == ti[2]); 00221 LOGDEBUG("Vec3i p = (%d, %d, %d)\n", p[0], p[1], p[2]); 00222 return Vec3i(ti[0], ti[1], ti[2]); 00223 }
|
|
Definition at line 350 of file testutil.cpp. References EMAN::EMData::get_xsize(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), and LOGDEBUG. 00351 { 00352 vector<EMData*> r; 00353 for (size_t i = 0; i < v.size(); i++) { 00354 EMData * e = v[i]; 00355 LOGDEBUG("Image(%d,%d,%d); ", e->get_xsize(), e->get_ysize(), e->get_zsize()); 00356 r.push_back(v[i]); 00357 } 00358 LOGDEBUG("\n"); 00359 return r; 00360 }
|
|
Definition at line 315 of file testutil.cpp. References Assert, LOGDEBUG, and tf. 00316 { 00317 vector<float> r; 00318 for (size_t i = 0; i < v.size(); i++) { 00319 LOGDEBUG("v[%d]=%f; ", i, v[i]); 00320 Assert(v[i] == tf[i]); 00321 r.push_back(v[i]); 00322 } 00323 LOGDEBUG("\n"); 00324 return r; 00325 }
|
|
Definition at line 303 of file testutil.cpp. References Assert, LOGDEBUG, and ti. 00304 { 00305 vector<int> r; 00306 for (size_t i = 0; i < v.size(); i++) { 00307 LOGDEBUG("v[%d]=%d; ", i, v[i]); 00308 Assert(v[i] == ti[i]); 00309 r.push_back(v[i]); 00310 } 00311 LOGDEBUG("\n"); 00312 return r; 00313 }
|
|
Definition at line 327 of file testutil.cpp. References Assert, LOGDEBUG, and ti. 00328 { 00329 vector<long> r; 00330 for (size_t i = 0; i < v.size(); i++) { 00331 LOGDEBUG("v[%d]=%d; ", i, (int)v[i]); 00332 Assert((int)v[i] == ti[i]); 00333 r.push_back(v[i]); 00334 } 00335 LOGDEBUG("\n"); 00336 return r; 00337 }
|
|
Definition at line 362 of file testutil.cpp. References LOGDEBUG, EMAN::Pixel::value, EMAN::Pixel::x, EMAN::Pixel::y, and EMAN::Pixel::z. 00363 { 00364 vector<Pixel> r; 00365 for (size_t i = 0; i < v.size(); i++) { 00366 Pixel p = v[i]; 00367 LOGDEBUG("Pixel(%d,%d,%d)=%4.2f; ", p.x, p.y, p.z, p.value); 00368 Pixel p2(p.x, p.y, p.z, p.value); 00369 r.push_back(p2); 00370 } 00371 00372 return r; 00373 }
|
|
Definition at line 339 of file testutil.cpp. References LOGDEBUG. 00340 { 00341 vector<string> r; 00342 for (size_t i = 0; i < v.size(); i++) { 00343 LOGDEBUG("v[%d]=%s; ", i, v[i].c_str()); 00344 r.push_back(v[i]); 00345 } 00346 LOGDEBUG("\n"); 00347 return r; 00348 }
|
|
Definition at line 107 of file testutil.cpp. References Assert, get_debug_string(), EMAN::XYData::get_size(), EMAN::XYData::get_x(), EMAN::EMData::get_xsize(), EMAN::XYData::get_y(), EMAN::EMData::get_ysize(), EMAN::EMData::get_zsize(), EMAN::Dict::has_key(), LOGDEBUG, nx, ny, tf, and ti. 00108 { 00109 if (d.has_key("floatarray")) { 00110 vector<float> array = d["floatarray"]; 00111 for (size_t i = 0; i < array.size(); i++) { 00112 Assert(array[i] == tf[i]); 00113 LOGDEBUG("floatarray[%d] = %f\n", i, array[i]); 00114 } 00115 } 00116 00117 if (d.has_key("emdata")) { 00118 EMData * img = d["emdata"]; 00119 if (img) { 00120 int nx = img->get_xsize(); 00121 int ny = img->get_ysize(); 00122 int nz = img->get_zsize(); 00123 Assert(nx == ti[0]); 00124 Assert(ny == ti[1]); 00125 Assert(nz == ti[2]); 00126 LOGDEBUG("image size = (%d, %d, %d)\n", nx, ny, nz); 00127 } 00128 } 00129 00130 if (d.has_key("int")) { 00131 int n = d["int"]; 00132 Assert(n == ti[0]); 00133 LOGDEBUG("int n = %d\n", n); 00134 } 00135 00136 if (d.has_key("float")) { 00137 float f = d["float"]; 00138 Assert(f == tf[0]); 00139 LOGDEBUG("float f = %f\n", f); 00140 } 00141 00142 if (d.has_key("long")) { 00143 int l = (int)d["long"]; 00144 Assert(l == ti[0]); 00145 LOGDEBUG("long l = %d\n", l); 00146 } 00147 00148 if (d.has_key("string")) { 00149 string s = (const char*)d["string"]; 00150 string s2 = get_debug_string(0); 00151 Assert(s == s2); 00152 } 00153 00154 00155 if (d.has_key("xydata")) { 00156 XYData *xyd = d["xydata"]; 00157 size_t nitems = xyd->get_size(); 00158 for (size_t i = 0; i < nitems; i++) { 00159 float xi = xyd->get_x(i); 00160 float yi = xyd->get_y(i); 00161 LOGDEBUG("xydata[%d] = (%f,%f)\n", i, xi, yi); 00162 Assert(xi == tf[i]); 00163 Assert(yi == tf[i]); 00164 } 00165 } 00166 00167 if (d.has_key("stringarray")) { 00168 vector<string> array = d["stringarray"]; 00169 for (size_t i = 0; i < array.size(); i++) { 00170 Assert(array[i] == get_debug_string(i)); 00171 LOGDEBUG("stringarray[%d] = %s\n", i, array[i].c_str()); 00172 } 00173 } 00174 }
|
|
Definition at line 117 of file testutil.h. References nx, ny, and verify_image_file_by_mode(). 00121 { 00122 return verify_image_file_by_mode(filename, image_type, 1, datatype, nx, ny, nz); 00123 }
|
|
Definition at line 133 of file testutil.h. References nx, ny, and verify_image_file_by_mode(). 00137 { 00138 return verify_image_file_by_mode(filename, image_type, 2, 00139 datatype, nx, ny, nz); 00140 }
|
|
Definition at line 574 of file testutil.cpp. References data, EMAN::EMData::get_attr_dict(), EMAN::EMData::get_data(), get_pixel_value_by_dist1(), get_pixel_value_by_dist2(), is_complex(), EMAN::EMUtil::is_complex_type(), LOGERR, and EMAN::EMData::read_image(). Referenced by verify_image_file(), and verify_image_file2(). 00578 { 00579 int err = 0; 00580 00581 EMData * e = new EMData(); 00582 e->read_image(filename); 00583 00584 Dict attr_dict = e->get_attr_dict(); 00585 bool is_complex = EMUtil::is_complex_type(datatype); 00586 00587 if (is_complex) { 00588 nx = (nx+2); 00589 } 00590 00591 if (nx != (int) attr_dict["nx"]) { 00592 LOGERR("nx: %d != %d\n", nx, (int) attr_dict["nx"]); 00593 return 1; 00594 } 00595 00596 if (ny != (int) attr_dict["ny"]) { 00597 LOGERR("ny: %d != %d\n", ny, (int) attr_dict["ny"]); 00598 return 1; 00599 } 00600 00601 if (nz != (int) attr_dict["nz"]) { 00602 LOGERR("nz: %d != %d\n", nz, (int) attr_dict["nz"]); 00603 return 1; 00604 } 00605 00606 if (datatype != (int) attr_dict["datatype"]) { 00607 LOGERR("datatype: %d != %d\n", datatype, (int) attr_dict["datatype"]); 00608 return 1; 00609 } 00610 00611 00612 if ((int)is_complex != (int) attr_dict["is_complex"]) { 00613 LOGERR("is_complex: %d != %d\n", is_complex, (int) attr_dict["is_complex"]); 00614 return 1; 00615 } 00616 00617 00618 if (!is_complex) { 00619 float * data = e->get_data(); 00620 size_t l = 0; 00621 for (int i = 0; i < nz; i++) { 00622 for (int j = 0; j < ny; j++) { 00623 for (int k = 0; k < nx; k++) { 00624 00625 int d2 = 0; 00626 if (mode == 1) { 00627 d2 = (int)get_pixel_value_by_dist1(nx,ny,nz,k,j,i); 00628 } 00629 else if (mode == 2) { 00630 d2 = (int)get_pixel_value_by_dist2(nx,ny,nz,k,j,i); 00631 } 00632 00633 if ((int)data[l] != d2) { 00634 LOGERR("(%d,%d,%d): %d != %d\n", i,j,k,(int)data[l], d2); 00635 break; 00636 err = 1; 00637 } 00638 l++; 00639 } 00640 } 00641 } 00642 } 00643 00644 return err; 00645 }
|
|
Definition at line 56 of file testutil.h. Referenced by check_image(), and dump_emdata(). |
|
Definition at line 55 of file testutil.h. Referenced by check_image(), and dump_emdata(). |
|
Definition at line 148 of file testutil.h. Referenced by check_image(), and set_progname(). |
|
Definition at line 146 of file testutil.h. Referenced by emobject_farray_to_py(), get_debug_float(), test_dict(), test_FloatPoint(), test_FloatSize(), test_Vec3f(), test_vector_float(), and to_emobject(). |
|
Definition at line 147 of file testutil.h. Referenced by get_debug_int(), test_IntPoint(), test_IntSize(), test_Vec3i(), test_vector_int(), test_vector_long(), and to_emobject(). |