def test_getters(): from dials.algorithms.profile_model.modeller import GridSampler width = 1000 height = 1000 scan_range = (2, 12) depth = scan_range[1] - scan_range[0] nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) image_size = sampler.image_size() scan_range = sampler.scan_range() grid_size = sampler.grid_size() step_size = sampler.step_size() size = len(sampler) assert width == image_size[0] assert height == image_size[1] assert scan_range[0] == scan_range[0] assert scan_range[1] == scan_range[1] assert nx == grid_size[0] assert ny == grid_size[1] assert nz == grid_size[2] assert step_size[0] == width / nx assert step_size[1] == height / ny assert step_size[2] == depth / nz assert nx * ny * nz == size
def tst_getters(self): from dials.algorithms.profile_model.modeller import GridSampler width = 1000 height = 1000 scan_range = (2, 12) depth = scan_range[1] - scan_range[0] nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) image_size = sampler.image_size() scan_range = sampler.scan_range() grid_size = sampler.grid_size() step_size = sampler.step_size() size = len(sampler) assert(width == image_size[0]) assert(height == image_size[1]) assert(scan_range[0] == scan_range[0]) assert(scan_range[1] == scan_range[1]) assert(nx == grid_size[0]) assert(ny == grid_size[1]) assert(nz == grid_size[2]) assert(step_size[0] == width / nx) assert(step_size[1] == height / ny) assert(step_size[2] == depth / nz) assert(nx * ny * nz == size) print 'OK'
def test_pickle(): from dials.algorithms.profile_model.modeller import GridSampler width = 1000 height = 1000 scan_range = (2, 12) nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) sampler2 = pickle.loads(pickle.dumps(sampler)) assert sampler.image_size() == sampler2.image_size() assert sampler.grid_size() == sampler2.grid_size()
def tst_pickle(self): from dials.algorithms.profile_model.modeller import GridSampler import tempfile import cPickle as pickle width = 1000 height = 1000 scan_range = (2, 12) depth = scan_range[1] - scan_range[0] nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) tf = tempfile.TemporaryFile() pickle.dump(sampler, tf) tf.flush() tf.seek(0) sampler2 = pickle.load(tf) assert (sampler.image_size() == sampler2.image_size()) assert (sampler.grid_size() == sampler2.grid_size()) print 'OK'
def tst_pickle(self): from dials.algorithms.profile_model.modeller import GridSampler import tempfile import cPickle as pickle width = 1000 height = 1000 scan_range = (2, 12) depth = scan_range[1] - scan_range[0] nx = 10 ny = 10 nz = 2 sampler = GridSampler((width, height), scan_range, (nx, ny, nz)) tf = tempfile.TemporaryFile() pickle.dump(sampler, tf) tf.flush() tf.seek(0) sampler2 = pickle.load(tf) assert(sampler.image_size() == sampler2.image_size()) assert(sampler.grid_size() == sampler2.grid_size()) print 'OK'