#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 Transform | get_debug_transform (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_transformarray_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.
int TestUtil::check_image | ( | const string & | imagefile, | |
EMData * | image = 0 | |||
) | [static] |
Definition at line 413 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().
00414 { 00415 #if DEBUG 00416 string headerfile1 = Util::sbasename(imagefile) + EMDATA_HEADER_EXT; 00417 string datafile1 = Util::sbasename(imagefile) + EMDATA_DATA_EXT; 00418 00419 char imgpath[MAXPATHLEN]; 00420 char * path_env = getenv("DEBUG_IMAGE_PATH"); 00421 if (path_env) { 00422 sprintf(imgpath, "%s/testdata/%s/", path_env, progname.c_str()); 00423 } 00424 else { 00425 sprintf(imgpath, "%s/images/testdata/%s/", getenv("HOME"), progname.c_str()); 00426 } 00427 00428 string headerfile2 = string(imgpath) + headerfile1; 00429 string datafile2 = string(imgpath) + datafile1; 00430 00431 00432 if (image) { 00433 dump_emdata(image, imagefile); 00434 } 00435 else { 00436 dump_image_from_file(imagefile); 00437 } 00438 00439 if (!Util::is_file_exist(headerfile2) || 00440 !Util::is_file_exist(datafile2)) { 00441 return 0; 00442 } 00443 00444 string diffcmd1 = "diff " + headerfile1 + " " + headerfile2; 00445 00446 int err = system(diffcmd1.c_str()); 00447 if (!err) { 00448 string diffcmd2 = "diff " + datafile1 + " " + datafile2; 00449 err = system(diffcmd2.c_str()); 00450 } 00451 if (err) { 00452 LOGERR("check_image on %s FAILED\n", imagefile.c_str()); 00453 } 00454 00455 return err; 00456 #endif 00457 return 0; 00458 }
void TestUtil::dump_emdata | ( | EMData * | image, | |
const string & | filename | |||
) | [static] |
Definition at line 472 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().
00473 { 00474 string filebase = Util::sbasename(filename); 00475 string headerfile = filebase + EMDATA_HEADER_EXT; 00476 string datafile = filebase + EMDATA_DATA_EXT; 00477 00478 FILE *hfile = fopen(headerfile.c_str(), "wb"); 00479 if (!hfile) { 00480 throw FileAccessException(headerfile); 00481 } 00482 #if 0 00483 vector<string> excl_keys; 00484 excl_keys.push_back("MRC.label"); 00485 excl_keys.push_back("IMAGIC.minute"); 00486 excl_keys.push_back("IMAGIC.sec"); 00487 00488 Dict attr_dict = image->get_attr_dict(); 00489 vector < string > keys = attr_dict.keys(); 00490 00491 00492 00493 for (size_t i = 0; i < keys.size(); i++) { 00494 00495 bool is_exclude = false; 00496 for (size_t j = 0; j < excl_keys.size(); j++) { 00497 if (Util::sstrncmp(keys[i].c_str(), excl_keys[j].c_str())) { 00498 is_exclude = true; 00499 break; 00500 } 00501 } 00502 if (!is_exclude) { 00503 fprintf(hfile, "%s = %s\n", keys[i].c_str(), 00504 attr_dict[keys[i]].to_str().c_str()); 00505 } 00506 } 00507 #endif 00508 00509 fprintf(hfile, "nx = %d\n", image->get_xsize()); 00510 fprintf(hfile, "ny = %d\n", image->get_ysize()); 00511 fprintf(hfile, "nz = %d\n", image->get_zsize()); 00512 00513 fclose(hfile); 00514 hfile = 0; 00515 00516 FILE *dfile = fopen(datafile.c_str(), "wb"); 00517 if (!dfile) { 00518 throw FileAccessException(datafile); 00519 } 00520 00521 int nx = image->get_xsize(); 00522 int ny = image->get_ysize(); 00523 int nz = image->get_zsize(); 00524 00525 size_t row_size = nx * sizeof(float); 00526 size_t nxy = nx * ny; 00527 float * rdata = image->get_data(); 00528 00529 for (int i = 0; i < nz; i++) { 00530 for (int j = 0; j < ny; j++) { 00531 fwrite(&rdata[i * nxy + j * nx], row_size, 1, dfile); 00532 } 00533 } 00534 fclose(dfile); 00535 dfile = 0; 00536 }
void TestUtil::dump_image_from_file | ( | const string & | filename | ) | [static] |
Definition at line 460 of file testutil.cpp.
References dump_emdata(), and EMAN::EMData::read_image().
Referenced by check_image().
00461 { 00462 EMData * e = new EMData(); 00463 e->read_image(filename); 00464 dump_emdata(e, filename); 00465 if( e ) 00466 { 00467 delete e; 00468 e = 0; 00469 } 00470 }
EMObject TestUtil::emobject_farray_to_py | ( | ) | [static] |
EMObject TestUtil::emobject_strarray_to_py | ( | ) | [static] |
Definition at line 720 of file testutil.cpp.
References get_debug_string(), and v.
00721 { 00722 vector<string> v(3); 00723 for (int i = 0; i < 3; i++) { 00724 v[i] = get_debug_string(i); 00725 } 00726 return EMObject(v); 00727 }
EMObject TestUtil::emobject_to_py | ( | const string & | str | ) | [static] |
EMObject TestUtil::emobject_to_py | ( | double | f | ) | [static] |
EMObject TestUtil::emobject_to_py | ( | float | f | ) | [static] |
EMObject TestUtil::emobject_to_py | ( | int | n | ) | [static] |
EMObject TestUtil::emobject_to_py | ( | unsigned int | n | ) | [static] |
EMObject TestUtil::emobject_to_py | ( | bool | b | ) | [static] |
EMObject TestUtil::emobject_transformarray_to_py | ( | ) | [static] |
float TestUtil::get_debug_float | ( | int | i | ) | [static] |
string TestUtil::get_debug_image | ( | const string & | imagename | ) | [static] |
Definition at line 92 of file testutil.cpp.
00093 { 00094 char imgpath[MAXPATHLEN]; 00095 char * path_env = getenv("DEBUG_IMAGE_PATH"); 00096 if (path_env) { 00097 sprintf(imgpath, "%s/%s", path_env, imagename.c_str()); 00098 } 00099 else { 00100 sprintf(imgpath, "%s/images/%s", getenv("HOME"), imagename.c_str()); 00101 } 00102 return string(imgpath); 00103 }
int TestUtil::get_debug_int | ( | int | i | ) | [static] |
string TestUtil::get_debug_string | ( | int | i | ) | [static] |
Definition at line 74 of file testutil.cpp.
Referenced by emobject_strarray_to_py(), test_dict(), and to_emobject().
Transform TestUtil::get_debug_transform | ( | int | i | ) | [static] |
string TestUtil::get_golden_image | ( | const string & | imagename | ) | [static] |
Definition at line 105 of file testutil.cpp.
00106 { 00107 char imgpath[MAXPATHLEN]; 00108 char * path_env = getenv("DEBUG_IMAGE_PATH"); 00109 if (path_env) { 00110 sprintf(imgpath, "%s/testdata/%s", path_env, imagename.c_str()); 00111 } 00112 else { 00113 sprintf(imgpath, "%s/images/testdata/%s", getenv("HOME"), imagename.c_str()); 00114 } 00115 return string(imgpath); 00116 }
static float EMAN::TestUtil::get_pixel_value_by_dist1 | ( | int | nx, | |
int | ny, | |||
int | nz, | |||
int | x, | |||
int | y, | |||
int | z | |||
) | [inline, static, private] |
Definition at line 163 of file testutil.h.
References abs.
Referenced by make_image_file_by_mode(), and verify_image_file_by_mode().
00164 { 00165 int x2 = x; 00166 int y2 = y; 00167 int z2 = z; 00168 00169 x2 = abs(nx/2-x); 00170 y2 = abs(ny/2-y); 00171 00172 if (z > nz/2) { 00173 z2 = nz-z; 00174 } 00175 00176 if (nz == 1) { 00177 return (float)(x2*x2 + y2*y2); 00178 } 00179 else { 00180 int areax = (int)((float)nx * z2 / nz); 00181 int areay = (int)((float)ny * z2 / nz); 00182 if ((abs(x-nx/2) <= areax) && (abs(y-ny/2) <= areay)) { 00183 return (float)(x2*x2 + y2*y2); 00184 } 00185 else { 00186 return 0; 00187 } 00188 } 00189 }
static float EMAN::TestUtil::get_pixel_value_by_dist2 | ( | int | nx, | |
int | ny, | |||
int | nz, | |||
int | x, | |||
int | y, | |||
int | z | |||
) | [inline, static, private] |
Definition at line 191 of file testutil.h.
References abs.
Referenced by make_image_file_by_mode(), and verify_image_file_by_mode().
00192 { 00193 int x2 = x; 00194 int y2 = y; 00195 int z2 = z; 00196 00197 00198 if (x > nx/2) { 00199 x2 = nx-x; 00200 } 00201 if (y > ny/2) { 00202 y2 = ny-y; 00203 } 00204 00205 if (z > nz/2) { 00206 z2 = nz-z; 00207 } 00208 00209 if (nz == 1) { 00210 return (float)(x2*x2 + y2*y2); 00211 } 00212 else { 00213 int areax = (int)((float)nx * z2 / nz); 00214 int areay = (int)((float)ny * z2 / nz); 00215 if ((abs(x-nx/2) <= areax) && (abs(y-ny/2) <= areay)) { 00216 return (float)(x2*x2 + y2*y2); 00217 } 00218 else { 00219 return 0; 00220 } 00221 } 00222 }
static void EMAN::TestUtil::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 | |||
) | [inline, static] |
Definition at line 111 of file testutil.h.
References make_image_file_by_mode(), nx, and ny.
00115 { 00116 make_image_file_by_mode(filename, image_type, 1, datatype, nx, ny, nz); 00117 }
static void EMAN::TestUtil::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 | |||
) | [inline, static] |
Definition at line 127 of file testutil.h.
References make_image_file_by_mode(), nx, and ny.
00131 { 00132 make_image_file_by_mode(filename, image_type, 2, datatype,nx, ny, nz); 00133 }
void TestUtil::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, private] |
Definition at line 544 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().
00548 { 00549 EMData * e = new EMData(); 00550 e->set_size(nx, ny, nz); 00551 bool is_complex = EMUtil::is_complex_type(datatype); 00552 00553 e->set_attr("is_complex", (int)is_complex); 00554 e->set_attr("datatype", (int)datatype); 00555 float * data = e->get_data(); 00556 00557 size_t l = 0; 00558 for (int i = 0; i < nz; i++) { 00559 for (int j = 0; j < ny; j++) { 00560 for (int k = 0; k < nx; k++) { 00561 if (mode == 1) { 00562 data[l] = get_pixel_value_by_dist1(nx, ny, nz, k, j, i); 00563 } 00564 else if (mode == 2) { 00565 data[l] = get_pixel_value_by_dist2(nx, ny, nz, k, j, i); 00566 } 00567 l++; 00568 } 00569 } 00570 } 00571 00572 if (!is_complex) { 00573 e->write_image(filename, 0, image_type, false, 0, datatype, true); 00574 } 00575 else { 00576 e->update(); 00577 e->set_attr("is_complex", false); 00578 EMData * fft = e->do_fft(); 00579 fft->write_image(filename, 0, image_type, false, 0, datatype, true); 00580 if( fft ) 00581 { 00582 delete fft; 00583 fft = 0; 00584 } 00585 } 00586 00587 if( e ) 00588 { 00589 delete e; 00590 e = 0; 00591 } 00592 }
void TestUtil::set_progname | ( | const string & | cur_progname | ) | [static] |
Definition at line 538 of file testutil.cpp.
References progname, and EMAN::Util::sbasename().
00539 { 00540 progname = Util::sbasename(cur_progname); 00541 }
Definition at line 395 of file testutil.cpp.
References Assert, get_debug_string(), EMAN::Dict::keys(), LOGDEBUG, and tf.
00396 { 00397 Dict r; 00398 00399 vector<string> keys = d.keys(); 00400 sort(keys.begin(), keys.end()); 00401 00402 for (size_t i = 0; i < keys.size(); i++) { 00403 LOGDEBUG("keys[%s] = %f\n", keys[i].c_str(), (float)d[keys[i]]); 00404 Assert(keys[i] == get_debug_string(i)); 00405 Assert(((float)d[keys[i]]) == tf[i]); 00406 r[keys[i]] = d[keys[i]]; 00407 } 00408 00409 return r; 00410 }
FloatPoint TestUtil::test_FloatPoint | ( | const FloatPoint & | p | ) | [static] |
Definition at line 303 of file testutil.cpp.
References LOGDEBUG.
00304 { 00305 map<string, EMObject> r; 00306 map<string, EMObject>::const_iterator p; 00307 for (p = d.begin(); p != d.end(); p++) { 00308 LOGDEBUG("map[\"%s\"] = %f; ", p->first.c_str(), (float)(p->second)); 00309 r[p->first] = EMObject(p->second); 00310 } 00311 LOGDEBUG("\n"); 00312 return r; 00313 }
map< string, float > TestUtil::test_map_float | ( | const map< string, float > & | d | ) | [static] |
Definition at line 279 of file testutil.cpp.
References LOGDEBUG.
00280 { 00281 map<string, float> r; 00282 map<string, float>::const_iterator p; 00283 for (p = d.begin(); p != d.end(); p++) { 00284 LOGDEBUG("map[\"%s\"] = %f; ", p->first.c_str(), p->second); 00285 r[p->first] = p->second; 00286 } 00287 LOGDEBUG("\n"); 00288 return r; 00289 }
map< string, int > TestUtil::test_map_int | ( | const map< string, int > & | d | ) | [static] |
Definition at line 255 of file testutil.cpp.
References LOGDEBUG.
00256 { 00257 map<string, int> r; 00258 map<string, int>::const_iterator p; 00259 for (p = d.begin(); p != d.end(); p++) { 00260 LOGDEBUG("map[\"%s\"] = %d; ", p->first.c_str(), p->second); 00261 r[p->first] = p->second; 00262 } 00263 LOGDEBUG("\n"); 00264 return r; 00265 }
map< string, long > TestUtil::test_map_long | ( | const map< string, long > & | d | ) | [static] |
Definition at line 267 of file testutil.cpp.
References LOGDEBUG.
00268 { 00269 map<string, long> r; 00270 map<string, long>::const_iterator p; 00271 for (p = d.begin(); p != d.end(); p++) { 00272 LOGDEBUG("map[\"%s\"] = %d; ", p->first.c_str(), p->second); 00273 r[p->first] = p->second; 00274 } 00275 LOGDEBUG("\n"); 00276 return r; 00277 }
map< string, string > TestUtil::test_map_string | ( | const map< string, string > & | d | ) | [static] |
Definition at line 291 of file testutil.cpp.
References LOGDEBUG.
00292 { 00293 map<string, string> r; 00294 map<string, string>::const_iterator p; 00295 for (p = d.begin(); p != d.end(); p++) { 00296 LOGDEBUG("map[\"%s\"] = %s; ", p->first.c_str(), p->second.c_str()); 00297 r[p->first] = p->second; 00298 } 00299 LOGDEBUG("\n"); 00300 return r; 00301 }
map< string, vector< string > > TestUtil::test_map_vecstring | ( | const map< string, vector< string > > & | d | ) | [static] |
Definition at line 370 of file testutil.cpp.
References LOGDEBUG.
00371 { 00372 vector<EMData*> r; 00373 for (size_t i = 0; i < v.size(); i++) { 00374 EMData * e = v[i]; 00375 LOGDEBUG("Image(%d,%d,%d); ", e->get_xsize(), e->get_ysize(), e->get_zsize()); 00376 r.push_back(v[i]); 00377 } 00378 LOGDEBUG("\n"); 00379 return r; 00380 }
vector< float > TestUtil::test_vector_float | ( | const vector< float > & | v | ) | [static] |
Definition at line 335 of file testutil.cpp.
References Assert, LOGDEBUG, and tf.
00336 { 00337 vector<float> r; 00338 for (size_t i = 0; i < v.size(); i++) { 00339 LOGDEBUG("v[%d]=%f; ", i, v[i]); 00340 Assert(v[i] == tf[i]); 00341 r.push_back(v[i]); 00342 } 00343 LOGDEBUG("\n"); 00344 return r; 00345 }
vector< int > TestUtil::test_vector_int | ( | const vector< int > & | v | ) | [static] |
Definition at line 323 of file testutil.cpp.
References Assert, LOGDEBUG, and ti.
00324 { 00325 vector<int> r; 00326 for (size_t i = 0; i < v.size(); i++) { 00327 LOGDEBUG("v[%d]=%d; ", i, v[i]); 00328 Assert(v[i] == ti[i]); 00329 r.push_back(v[i]); 00330 } 00331 LOGDEBUG("\n"); 00332 return r; 00333 }
vector< long > TestUtil::test_vector_long | ( | const vector< long > & | v | ) | [static] |
Definition at line 347 of file testutil.cpp.
References Assert, LOGDEBUG, and ti.
00348 { 00349 vector<long> r; 00350 for (size_t i = 0; i < v.size(); i++) { 00351 LOGDEBUG("v[%d]=%d; ", i, (int)v[i]); 00352 Assert((int)v[i] == ti[i]); 00353 r.push_back(v[i]); 00354 } 00355 LOGDEBUG("\n"); 00356 return r; 00357 }
Definition at line 382 of file testutil.cpp.
References LOGDEBUG.
00383 { 00384 vector<Pixel> r; 00385 for (size_t i = 0; i < v.size(); i++) { 00386 Pixel p = v[i]; 00387 LOGDEBUG("Pixel(%d,%d,%d)=%4.2f; ", p.x, p.y, p.z, p.value); 00388 Pixel p2(p.x, p.y, p.z, p.value); 00389 r.push_back(p2); 00390 } 00391 00392 return r; 00393 }
vector< string > TestUtil::test_vector_string | ( | const vector< string > & | v | ) | [static] |
void TestUtil::to_emobject | ( | const Dict & | d | ) | [static] |
Definition at line 118 of file testutil.cpp.
References Assert, get_debug_string(), get_debug_transform(), EMAN::Dict::has_key(), LOGDEBUG, nx, ny, tf, and ti.
00119 { 00120 if (d.has_key("floatarray")) { 00121 vector<float> array = d["floatarray"]; 00122 for (size_t i = 0; i < array.size(); i++) { 00123 Assert(array[i] == tf[i]); 00124 LOGDEBUG("floatarray[%d] = %f\n", i, array[i]); 00125 } 00126 } 00127 00128 if (d.has_key("emdata")) { 00129 EMData * img = d["emdata"]; 00130 if (img) { 00131 int nx = img->get_xsize(); 00132 int ny = img->get_ysize(); 00133 int nz = img->get_zsize(); 00134 Assert(nx == ti[0]); 00135 Assert(ny == ti[1]); 00136 Assert(nz == ti[2]); 00137 LOGDEBUG("image size = (%d, %d, %d)\n", nx, ny, nz); 00138 } 00139 } 00140 00141 if (d.has_key("int")) { 00142 int n = d["int"]; 00143 Assert(n == ti[0]); 00144 LOGDEBUG("int n = %d\n", n); 00145 } 00146 00147 if (d.has_key("float")) { 00148 float f = d["float"]; 00149 Assert(f == tf[0]); 00150 LOGDEBUG("float f = %f\n", f); 00151 } 00152 00153 if (d.has_key("long")) { 00154 int l = (int)d["long"]; 00155 Assert(l == ti[0]); 00156 LOGDEBUG("long l = %d\n", l); 00157 } 00158 00159 if (d.has_key("string")) { 00160 string s = (const char*)d["string"]; 00161 string s2 = get_debug_string(0); 00162 Assert(s == s2); 00163 } 00164 00165 00166 if (d.has_key("xydata")) { 00167 XYData *xyd = d["xydata"]; 00168 size_t nitems = xyd->get_size(); 00169 for (size_t i = 0; i < nitems; i++) { 00170 float xi = xyd->get_x(i); 00171 float yi = xyd->get_y(i); 00172 LOGDEBUG("xydata[%d] = (%f,%f)\n", i, xi, yi); 00173 Assert(xi == tf[i]); 00174 Assert(yi == tf[i]); 00175 } 00176 } 00177 00178 if (d.has_key("stringarray")) { 00179 vector<string> array = d["stringarray"]; 00180 for (size_t i = 0; i < array.size(); i++) { 00181 Assert(array[i] == get_debug_string(i)); 00182 LOGDEBUG("stringarray[%d] = %s\n", i, array[i].c_str()); 00183 } 00184 } 00185 00186 if (d.has_key("transformarray")) { 00187 vector<Transform> array = d["transformarray"]; 00188 for (size_t i = 0; i < array.size(); i++) { 00189 // array[i].printme(); 00190 Assert(array[i] == get_debug_transform(i)); 00191 // LOGDEBUG("transformarray[%d] = %s\n", i, array[i].to_str()); 00192 } 00193 } 00194 }
static int EMAN::TestUtil::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 | |||
) | [inline, static] |
Definition at line 119 of file testutil.h.
References nx, ny, and verify_image_file_by_mode().
00123 { 00124 return verify_image_file_by_mode(filename, image_type, 1, datatype, nx, ny, nz); 00125 }
static int EMAN::TestUtil::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 | |||
) | [inline, static] |
Definition at line 135 of file testutil.h.
References nx, ny, and verify_image_file_by_mode().
00139 { 00140 return verify_image_file_by_mode(filename, image_type, 2, 00141 datatype, nx, ny, nz); 00142 }
int TestUtil::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, private] |
Definition at line 594 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().
00598 { 00599 int err = 0; 00600 00601 EMData * e = new EMData(); 00602 e->read_image(filename); 00603 00604 Dict attr_dict = e->get_attr_dict(); 00605 bool is_complex = EMUtil::is_complex_type(datatype); 00606 00607 if (is_complex) { 00608 nx = (nx+2); 00609 } 00610 00611 if (nx != (int) attr_dict["nx"]) { 00612 LOGERR("nx: %d != %d\n", nx, (int) attr_dict["nx"]); 00613 return 1; 00614 } 00615 00616 if (ny != (int) attr_dict["ny"]) { 00617 LOGERR("ny: %d != %d\n", ny, (int) attr_dict["ny"]); 00618 return 1; 00619 } 00620 00621 if (nz != (int) attr_dict["nz"]) { 00622 LOGERR("nz: %d != %d\n", nz, (int) attr_dict["nz"]); 00623 return 1; 00624 } 00625 00626 if (datatype != (int) attr_dict["datatype"]) { 00627 LOGERR("datatype: %d != %d\n", datatype, (int) attr_dict["datatype"]); 00628 return 1; 00629 } 00630 00631 00632 if ((int)is_complex != (int) attr_dict["is_complex"]) { 00633 LOGERR("is_complex: %d != %d\n", is_complex, (int) attr_dict["is_complex"]); 00634 return 1; 00635 } 00636 00637 00638 if (!is_complex) { 00639 float * data = e->get_data(); 00640 size_t l = 0; 00641 for (int i = 0; i < nz; i++) { 00642 for (int j = 0; j < ny; j++) { 00643 for (int k = 0; k < nx; k++) { 00644 00645 int d2 = 0; 00646 if (mode == 1) { 00647 d2 = (int)get_pixel_value_by_dist1(nx,ny,nz,k,j,i); 00648 } 00649 else if (mode == 2) { 00650 d2 = (int)get_pixel_value_by_dist2(nx,ny,nz,k,j,i); 00651 } 00652 00653 if ((int)data[l] != d2) { 00654 LOGERR("(%d,%d,%d): %d != %d\n", i,j,k,(int)data[l], d2); 00655 break; 00656 err = 1; 00657 } 00658 l++; 00659 } 00660 } 00661 } 00662 } 00663 00664 return err; 00665 }
const char * TestUtil::EMDATA_DATA_EXT = ".data" [static] |
const char * TestUtil::EMDATA_HEADER_EXT = ".head" [static] |
string TestUtil::progname = "" [static, private] |
float TestUtil::tf = {1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5} [static, private] |
Definition at line 148 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().
int TestUtil::ti = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100} [static, private] |
Definition at line 149 of file testutil.h.
Referenced by get_debug_int(), test_IntPoint(), test_IntSize(), test_Vec3i(), test_vector_int(), test_vector_long(), and to_emobject().