def test_write_center(self): dpath = os.path.join('test', 'tmp') cen_range = (5, 7, 0.5) cen = np.arange(*cen_range) write_center( read_file('proj.npy'), read_file('angle.npy'), dpath, cen_range=cen_range, algorithm='gridrec', filter_name='shepp') for m in range(cen.size): assert_equals( os.path.isfile( os.path.join( os.path.join('test', 'tmp'), str('{0:.2f}'.format(cen[m]) + '.tiff'))), True) shutil.rmtree(dpath)
def check_rpc_consistency(n, q): """Check if q expanding and then contracting a ring polymer is a no-op. Args: n: The number of beads in the scaled ring polymer. q: The original position array. """ rescale1 = nmtransform.nm_rescale(q.shape[0], n) rescale2 = nmtransform.nm_rescale(n, q.shape[0]) beads_n = rescale1.b1tob2(q) beads_1 = rescale1.b2tob1(beads_n) beads_2 = rescale2.b1tob2(beads_n) assert_equals(beads_1, beads_2)
def test_write_center(self): dpath = os.path.join('test', 'tmp') cen_range = (5, 7, 0.5) cen = np.arange(*cen_range) write_center(read_file('proj.npy'), read_file('angle.npy'), dpath, cen_range=cen_range, algorithm='gridrec', filter_name='shepp') for m in range(cen.size): assert_equals( os.path.isfile( os.path.join(os.path.join('test', 'tmp'), str('{0:.2f}'.format(cen[m]) + '.tiff'))), True) shutil.rmtree(dpath)
def check_centroid_pos(n, q): """Check if expanding and then contracting a ring polymer maintains the centroid. Args: n: The number of beads in the scaled ring polymer. q: The original position array. """ beads_big = check_up_and_down_scaling(n, q) rescale_big = nmtransform.mk_rs_matrix(n, 1) rescale_q = nmtransform.mk_rs_matrix(q.shape[0], 1) centroid_big = np.dot(rescale_big, beads_big) centroid_q = np.dot(rescale_q, q) assert_equals(centroid_q, centroid_big)
def check_up_and_down_scaling(n, q): """Check if q expanding and then contracting a ring polymer is a no-op. Args: n: The number of beads in the scaled ring polymer. q: The original position array. """ rescale = nmtransform.nm_rescale(q.shape[0], n) print "Initial position of the beads:" print q, q.shape, (q.shape[0], n) # rescale up to the n beads beads_n = rescale.b1tob2(q) print "Upscaled to %d beads:" % n print beads_n, beads_n.shape beads_final = rescale.b2tob1(beads_n) print "Final position of the beads:" print beads_final assert_equals(q, beads_final) return beads_n
def test_shepp2d(self): assert_equals(shepp2d().dtype, 'float32') assert_equals(shepp2d().shape, (1, 512, 512)) assert_equals(shepp2d(size=(128, 256)).shape, (1, 128, 256)) assert_equals(shepp2d(size=64).shape, (1, 64, 64))
def test_checkerboard(self): assert_equals(checkerboard().dtype, 'float32') assert_equals(checkerboard().shape, (1, 512, 512)) assert_equals(checkerboard(size=(128, 256)).shape, (1, 128, 256)) assert_equals(checkerboard(size=64).shape, (1, 64, 64))
def test_cameraman(self): assert_equals(cameraman().dtype, 'float32') assert_equals(cameraman().shape, (1, 512, 512)) assert_equals(cameraman(size=(128, 256)).shape, (1, 128, 256)) assert_equals(cameraman(size=64).shape, (1, 64, 64))
def test_barbara(self): assert_equals(barbara().dtype, 'float32') assert_equals(barbara().shape, (1, 512, 512)) assert_equals(barbara(size=(128, 256)).shape, (1, 128, 256)) assert_equals(barbara(size=64).shape, (1, 64, 64))
def test_shepp3d(self): assert_equals(shepp3d(size=(6, 8, 10)).dtype, 'float32') assert_equals(shepp3d(size=(6, 8, 10)).shape, (6, 8, 10)) assert_equals(shepp3d(size=(6, 8, 10)).min(), 0) assert_equals(shepp3d(size=6).shape, (6, 6, 6))