rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
file_name = self.under_build("dispatcher_include.sh") if (os.path.isfile(file_name)): try: lines = open(file_name).read().splitlines() except IOError, e: raise UserError(str(e)) lines.insert(0, " highlight_dispatcher_include_lines(lines) self._dispatcher_include = lines else: self._dispatcher_include = []
self._dispatcher_include = [] for file_name in os.listdir(self.build_path): if (not os.path.isfile(file_name)): continue if ( file_name.startswith("dispatcher_include") and file_name.endswith(".sh")): try: lines = open(file_name).read().splitlines() except IOError, e: raise UserError(str(e)) lines.insert(0, " highli...
def dispatcher_include(self): if (not hasattr(self, "_dispatcher_include")): file_name = self.under_build("dispatcher_include.sh") if (os.path.isfile(file_name)): try: lines = open(file_name).read().splitlines() except IOError, e: raise UserError(str(e)) lines.insert(0, "# included from %s" % file_name) highlight_dispa...
def write_dispatcher_include_sh(self): file_name = self.under_build("dispatcher_include.sh") if (not os.path.isfile(file_name)): f = open_info(file_name) print >> f, \ " f.close()
def write_dispatcher_in_bin(self, source_file, target_file): self.write_dispatcher( source_file=source_file, target_file=self.under_build("bin/"+target_file))
self.write_dispatcher_include_sh()
def write_setpath_files(self): print "Python:", sys.version.split()[0], sys.executable if (len(self.missing_for_build) == 0): self.build_options.report() print "Top-down list of all packages involved:" top_down_module_list = list(self.module_list) top_down_module_list.reverse() for module in top_down_module_list: print...
weights=weights), -10 )
weights=weights), -10, eps=1.e-4 )
def exercise_real_space_refinement(): unit_cell=130.45,130.245,288.405,90,90,120 unit_cell_gridding_n=144,144,360 grid_cell=uctbx.unit_cell((130.45/144,130.245/144,388.405/360,90,90,120)) grid_mat = grid_cell.fractionalization_matrix() map = test_map.deep_copy() map.resize(flex.grid((-1,-2,-1),(3,3,5))) sites_cart = fl...
maptbx.get_cartesian_crystallographic_interpolator(map,frac_mtx)]
maptbx.get_cartesian_crystallographic_interpolator(map,frac_mtx), maptbx.get_fractional_asu_interpolator(map,asu_mappings), maptbx.get_cartesian_asu_interpolator(map,asu_mappings)]
def exercise_abstract_interpolators(): unit_cell=130.45,130.245,288.405,90,90,120 unit_cell_gridding_n=144,144,360 grid_cell=uctbx.unit_cell((130.45/144,130.245/144,388.405/360,90,90,120)) grid_mat = grid_cell.fractionalization_matrix() map = test_map.deep_copy() map.resize(flex.grid((-1,-2,-1),(3,3,5))) interpolator =...
source_dir = libtbx.path.norm_join(libtbx.env.build_path, sub_dir)
source_dir = libtbx.env.under_build(sub_dir)
def run(target_root): cwd = os.getcwd() abs_target_root = os.path.normpath(os.path.abspath(target_root)) for sub_dir,visitor in (("lib", copy_lib_and_exe_files), ("exe", copy_lib_and_exe_files), ("python", copy_python_files)): source_dir = libtbx.path.norm_join(libtbx.env.build_path, sub_dir) if (os.path.isdir(source_d...
libtbx.bundle.utils.write_bundle_info(abs_target_root, write_build_options=True)
libtbx.bundle.utils.write_bundle_info( abs_target_root, write_build_options=True) file_name = "command_version_suffix" src = libtbx.env.under_build(file_name) if (os.path.isfile(src)): shutil.copy(src, libtbx.path.norm_join(abs_target_root, file_name))
def run(target_root): cwd = os.getcwd() abs_target_root = os.path.normpath(os.path.abspath(target_root)) for sub_dir,visitor in (("lib", copy_lib_and_exe_files), ("exe", copy_lib_and_exe_files), ("python", copy_python_files)): source_dir = libtbx.path.norm_join(libtbx.env.build_path, sub_dir) if (os.path.isdir(source_d...
mean_displacements = flex.sqrt( sh.structure_shifted.scatterers().extract_u_iso()) if (gradient_flags.u_iso):
if (anisotropic_flag): mean_displacements = None else: mean_displacements = flex.sqrt( sh.structure_shifted.scatterers().extract_u_iso()) if (gradient_flags.u_iso and not anisotropic_flag):
def exercise_packed(structure_ideal, f_obs, anomalous_flag, anisotropic_flag, verbose=0): sh, ls = shift_all(structure_ideal, f_obs, anomalous_flag, anisotropic_flag) flag = (random.random() > 0.5) gradient_flags = randomize_gradient_flags( xray.structure_factors.gradient_flags(site=flag, u=not flag), f_obs.anomalous_f...
if len(self.possible_solutions):
if len(self.possible_solutions)==0:
def __init__(self, xs_a, xs_b, max_delta=2.0, out=None, relative_length_tolerance=0.05, absolute_angle_tolerance=10.0, order=1):
self.normalized_calc_f.normalizer_for_miller_array/ self.normalized_obs_f.normalizer_for_miller_array)
self.normalized_obs_f.normalizer_for_miller_array/ self.normalized_calc_f.normalizer_for_miller_array)
def __init__(self, miller_obs, miller_calc, r_free_flags, width=None, number=100, auto_kernel=True, n_points=20, n_terms=13): self.n_terms=n_terms self.miller_obs = miller_obs.map_to_asu() self.miller_calc = abs(miller_calc.map_to_asu()) self.r_free_flags = r_free_flags.map_to_asu()
self.normalized_calc_f.normalizer_for_miller_array
self.normalized_obs_f.normalizer_for_miller_array
def __init__(self, miller_obs, miller_calc, r_free_flags, width=None, number=100, auto_kernel=True, n_points=20, n_terms=13): self.n_terms=n_terms self.miller_obs = miller_obs.map_to_asu() self.miller_calc = abs(miller_calc.map_to_asu()) self.r_free_flags = r_free_flags.map_to_asu()
install_script = bundle_name+"_install_script.csh"
def run(args): if (len(os.listdir(".")) != 0): print "Please use this command only in an empty directory." return if (len(args) != 2): print "usage: libtbx.start_binary_bundle bundle_name top_modules" return bundle_name, top_modules = args copy_all.run(bundle_name) install_script = bundle_name+"_install_script.csh" if ...
ave = orig.average_bijvoet_mates()
def exercise_array_2(space_group_info): xs = crystal.symmetry( unit_cell=space_group_info.any_compatible_unit_cell(60), space_group_info=space_group_info) for anomalous_flag in (False, True): st = miller.build_set(xs, anomalous_flag, d_min=1) for sigmas in (None, flex.double(xrange(1,st.indices().size()+1))): sg = mill...
assert vfy.correlation(ave).coefficient() > 1-1.e-5
assert vfy.correlation(ave).coefficient() > 1-1.e-6
def exercise_array_2(space_group_info): xs = crystal.symmetry( unit_cell=space_group_info.any_compatible_unit_cell(60), space_group_info=space_group_info) for anomalous_flag in (False, True): st = miller.build_set(xs, anomalous_flag, d_min=1) for sigmas in (None, flex.double(xrange(1,st.indices().size()+1))): sg = mill...
for i_site,site in zip(itertbx.count(),sites):
for i_site,site in enumerate(sites):
def finite_differences(sites, residual_obj, eps=1.e-6): sites_mod = sites[:] gradients = [] for i_site,site in zip(itertbx.count(),sites): grad = [] for i_x in xrange(3): t = [] for signed_eps in [eps, -eps]: add = [0]*3 add[i_x] = signed_eps sites_mod[i_site] = site + col(add) r = residual_obj(sites_mod) t.append(r) s...
for serial,site in zip(itertbx.count(1), sites_cart):
for serial,site in enumerate(sites_cart):
def dump_pdb(file_name, sites_cart): f = open(file_name, "w") for serial,site in zip(itertbx.count(1), sites_cart): print >> f, iotbx.pdb.format_atom_record(serial=serial, site=site) print >> f, "END" f.close()
for g in fg:
for g in flex.vec3_double(fg):
def exercise_chirality(verbose=0): # monomer library: CA N CB C sites = [col(site) for site in [ (27.660, 9.903, 2.078), (28.049, 9.675, 3.486), (28.183, 11.269, 1.625), (28.085, 8.759, 1.165)]] chir = geometry_restraints.chirality( sites=sites, volume_ideal=-2.48, both_signs=False, weight=1) assert approx_equal(chir.v...
for site,g in zip(sites_mod,fg):
for site,g in zip(sites_mod,flex.vec3_double(fg)):
def exercise_chirality(verbose=0): # monomer library: CA N CB C sites = [col(site) for site in [ (27.660, 9.903, 2.078), (28.049, 9.675, 3.486), (28.183, 11.269, 1.625), (28.085, 8.759, 1.165)]] chir = geometry_restraints.chirality( sites=sites, volume_ideal=-2.48, both_signs=False, weight=1) assert approx_equal(chir.v...
scale_l_and_s = True)
scale_l_and_s = True, use_trace_s_zero_constraint = True)
def __init__(self, fmodel, selections, tlsos): self.grad_T = [] self.grad_L = [] self.grad_S = [] d_target_d_uaniso = fmodel.gradient_wrt_u_aniso() for sel, tlso in zip(selections, tlsos): d_target_d_tls_manager = d_target_d_tls( sites = fmodel.xray_structure.sites_cart().select(sel), origin = tl...
for reflection_file in reflection_files: self.miller_arrays.extend(reflection_file.as_miller_arrays( crystal_symmetry=self.crystal_symmetry, force_symmetry=self.force_symmetry))
if (reflection_files is not None): for reflection_file in reflection_files: self.miller_arrays.extend(reflection_file.as_miller_arrays( crystal_symmetry=self.crystal_symmetry, force_symmetry=self.force_symmetry))
def __init__(self, crystal_symmetry=None, force_symmetry=None, reflection_files=None, err=None): self.crystal_symmetry = crystal_symmetry self.force_symmetry = force_symmetry if (err is None): self.err = sys.stderr else: self.err = err self.miller_arrays = [] for reflection_file in reflection_files: self.miller_arrays....
if (file_name == "python"): continue
if (file_name == "python" or file_name.startswith("python.")): continue
def create_show_path_duplicates(target_dir): package_names = {} for file_name in os.listdir(target_dir): if (file_name.startswith(".")): continue if (file_name.startswith("libtbx.")): continue if (file_name == "python"): continue package_names[file_name.split(".")[0]] = None package_names = package_names.keys() for com...
if (file_name_lower != "main.py"):
if (not file_name_lower.startswith("main.") or file_name_lower.count(".") != 1):
def write_dispatcher(self, source_dir, file_name, suppress_warning, target_file_name_infix=""): source_file = libtbx.path.norm_join(source_dir, file_name) if (not os.path.isfile(source_file)): return file_name_lower = file_name.lower() if (file_name_lower.startswith("__init__.py")): return if (file_name_lower.endswith(...
m = max([len(line) for line in lines]) lines.insert(0, " lines.append(lines[0])
highlight_dispatcher_include_lines(lines)
def dispatcher_include(self): if (not hasattr(self, "_dispatcher_include")): file_name = self.under_build("dispatcher_include.sh") if (os.path.isfile(file_name)): try: lines = open(file_name).read().splitlines() except IOError, e: raise UserError(str(e)) lines.insert(0, "# included from %s" % file_name) m = max([len(li...
echo "Installation aborted."
echo "$aborted"
def create_script( bundle, top_modules, test_py="`libtbx.show_dist_paths boost_adaptbx`/tst_rational.py", minimum_python_version="2.2"): return """\
set try_python_rtnpt=try_usr_local_bin_python_return goto def_try_python_exe try_usr_local_bin_python_return:
set try_python_rtnpt=try_ulb_python_return goto def_try_python_exe try_ulb_python_return:
def create_script( bundle, top_modules, test_py="`libtbx.show_dist_paths boost_adaptbx`/tst_rational.py", minimum_python_version="2.2"): return """\
set try_python_rtnpt=try_usr_bin_python_return goto def_try_python_exe try_usr_bin_python_return:
set try_python_rtnpt=try_ub_python_return goto def_try_python_exe try_ub_python_return:
def create_script( bundle, top_modules, test_py="`libtbx.show_dist_paths boost_adaptbx`/tst_rational.py", minimum_python_version="2.2"): return """\
set try_python_rtnpt=try_usr_bin_pythonv_return goto def_try_python_exe try_usr_bin_pythonv_return:
set try_python_rtnpt=try_ub_pythonv_return goto def_try_python_exe try_ub_pythonv_return:
def create_script( bundle, top_modules, test_py="`libtbx.show_dist_paths boost_adaptbx`/tst_rational.py", minimum_python_version="2.2"): return """\
def exercise(args): forever = False random_seed = None for arg in args: if (arg == "--forever"): forever = True elif (arg.startswith("--random_seed=")): random_seed = int(arg.split("=", 1)[1]) if (random_seed is None): random_seed = flex.get_random_seed() while True: print "random_seed:", random_seed random.seed(random...
def exercise_2(eps = 1.e-6):
exercise_2()
exercise(sys.argv[1:])
def exercise_2(eps = 1.e-6):
for file_name in ("libtbx.python", "python"):
python_dispatchers = ["libtbx.python"] for module in self.module_list: if (module.has_top_level_cvs_directory()): python_dispatchers.append("python") break for file_name in python_dispatchers:
def refresh(self): self.assemble_pythonpath() self.write_setpath_files() self.pickle() if (self.is_ready_for_build()): self.write_SConstruct() if (os.name != "nt"): self.write_run_tests_csh() self.clear_bin_directory() if (not os.path.isdir(self.bin_path)): os.makedirs(self.bin_path) for file_name in ("libtbx.python", ...
def set_b_iso_random(self, allow_mixed=False):
def set_b_iso_random(self, allow_mixed=False, b_min=10., b_max=35.):
def set_b_iso_random(self, allow_mixed=False): s = self._scatterers if (not allow_mixed and s.count_anisotropic() > 0): raise RuntimeError("set_b_iso_random: all scatterers must be isotropic.") b_iso_new = flex.double() for si in s: b_iso_new.append(random.randrange(10,35,1)) self.set_b_iso(values = b_iso_new)
b_iso_new.append(random.randrange(10,35,1))
b_iso_new.append(random.randrange(b_min,b_max,1))
def set_b_iso_random(self, allow_mixed=False): s = self._scatterers if (not allow_mixed and s.count_anisotropic() > 0): raise RuntimeError("set_b_iso_random: all scatterers must be isotropic.") b_iso_new = flex.double() for si in s: b_iso_new.append(random.randrange(10,35,1)) self.set_b_iso(values = b_iso_new)
self.params.scaling.input.xray_data.resolution = flex.min(miller_array.d_spacings().data())
self.params.scaling.input.xray_data.high_resolution = flex.min(self.miller_obs.d_spacings().data())
def __init__(self, miller_obs, miller_calc = None, miller_ref = None, parameters = None, text_out = None, plot_out = None): self.miller_obs = miller_obs # array of observed data, should be intensity or amplitude self.miller_calc = miller_calc # array if calculated data, need to be given self.miller_ref = m...
"Overmerging pseudo-symmetric or twinned data, intenisty to amplitude conversion problems"
"Overmerging pseudo-symmetric or twinned data, intensity to amplitude conversion problems"
def analyse_intensity_stats(self): if self.twin_results.maha_l >= self.maha_l_cut: if self.twin_results.l_mean < 0.5 : print >> self.twinning_verdict, \ "The results of the L-test indicate that the intensity statistics" print >> self.twinning_verdict, \ "are significantly different then is expected from good to reasona...
if (d_min is None): d_min = self.d_min()
if (d_min is None and grid_step is None): d_min = self.d_min()
def crystal_gridding(self, resolution_factor=1/3, d_min=None, grid_step=None, symmetry_flags=None, mandatory_factors=None, max_prime=5, assert_shannon_sampling=True): if (d_min is None): d_min = self.d_min() return maptbx.crystal_gridding( unit_cell=self.unit_cell(), d_min=d_min, resolution_factor=resolution_factor, st...
action = shutil.copyfile
action = create_python_execfile_dispatcher
def create_driver(target_dir, package_name, source_dir, file_name): source_file = norm(join(source_dir, file_name)) if (not isfile(source_file)): return if (file_name.lower().startswith("__init__.py")): return if (file_name.lower().endswith(".pyc")): return if (file_name[0] == "."): return target_file = norm(join(targe...
if (__name__ == "__main__"): import sys verbose = not "--quiet" in sys.argv[1:]
def compare_vectors(n, m, v_in, v_tr): for i in xrange(m): x = v_tr[i] / n assert abs(x - v_in[i]) < 1.e-6, "%d/%d %.6g %.6g" % (i, n, v_in[i], x) def test_comprehensive_cc_1d(max_transform_size): for n in xrange(1,max_transform_size+1): fft = fftbx.complex_to_complex(n) m = n * 2 v_in = shared.double() for i in xrang...
def test_real_to_complex_3d(verbose): fft = fftbx.real_to_complex_3d((3,4,5)) M = fft.Mreal() vd = shared.double(M[0] * M[1] * M[2]) vc = shared.complex_double(vd.size() / 2) for i in xrange(vd.size()): vd[i] = i for i in xrange(vc.size()): vc[i] = complex(2*i, 2*i+1) assert vd.size() == 2 * vc.size() fft.forward(vd) f...
test_complex_to_complex(verbose) test_real_to_complex(verbose) test_complex_to_complex_3d(verbose) test_real_to_complex_3d(verbose)
test_complex_to_complex(Flags.verbose) test_real_to_complex(Flags.verbose) test_complex_to_complex_3d(Flags.verbose) test_real_to_complex_3d(Flags.verbose) max_transform_size = 300 test_comprehensive_cc_1d(max_transform_size) test_comprehensive_rc_1d(max_transform_size) if (__name__ == "__main__"): run() t = os.times(...
def test_real_to_complex_3d(verbose): fft = fftbx.real_to_complex_3d((3,4,5)) M = fft.Mreal() vd = shared.double(M[0] * M[1] * M[2]) vc = shared.complex_double(vd.size() / 2) for i in xrange(vd.size()): vd[i] = i for i in xrange(vc.size()): vc[i] = complex(2*i, 2*i+1) assert vd.size() == 2 * vc.size() fft.forward(vd) f...
def print_structure_factors(SgInfo, adp=0, d_min=3.):
def print_structure_factors(SgInfo, adp=0, d_min=1.):
def print_structure_factors(SgInfo, adp=0, d_min=3.): elements = ("N", "C", "C", "O", "N", "C", "C", "O") xtal = debug_utils.random_structure( SgInfo, elements, volume_per_atom=50., min_distance=1.5, general_positions_only=0, anisotropic_displacement_parameters=adp) print xtal.UnitCell debug_utils.print_sites(xtal) max...
volume_per_atom=50.,
volume_per_atom=400.,
def print_structure_factors(SgInfo, adp=0, d_min=3.): elements = ("N", "C", "C", "O", "N", "C", "C", "O") xtal = debug_utils.random_structure( SgInfo, elements, volume_per_atom=50., min_distance=1.5, general_positions_only=0, anisotropic_displacement_parameters=adp) print xtal.UnitCell debug_utils.print_sites(xtal) max...
MillerIndices = xutils.build_miller_indices(xtal, d_min)
def print_structure_factors(SgInfo, adp=0, d_min=3.): elements = ("N", "C", "C", "O", "N", "C", "C", "O") xtal = debug_utils.random_structure( SgInfo, elements, volume_per_atom=50., min_distance=1.5, general_positions_only=0, anisotropic_displacement_parameters=adp) print xtal.UnitCell debug_utils.print_sites(xtal) max...
Fcalc = xutils.calculate_structure_factors(MillerIndices, xtal)
def print_structure_factors(SgInfo, adp=0, d_min=3.): elements = ("N", "C", "C", "O", "N", "C", "C", "O") xtal = debug_utils.random_structure( SgInfo, elements, volume_per_atom=50., min_distance=1.5, general_positions_only=0, anisotropic_displacement_parameters=adp) print xtal.UnitCell debug_utils.print_sites(xtal) max...
elif (sg_number < 15):
elif (sg_number < 16):
def any_compatible_unit_cell(self, volume): sg_number = self.type().number() if (sg_number < 3): params = (1., 1.3, 1.7, 83, 109, 129) elif (sg_number < 15): params = (1., 1.3, 1.7, 90, 109, 90) elif (sg_number < 75): params = (1., 1.3, 1.7, 90, 90, 90) elif (sg_number < 143): params = (1., 1., 1.7, 90, 90, 90) e...
if self.number > d_star_cubed_hkl.size():
if self.number >= d_star_cubed_hkl.size():
def __init__(self, miller_obs, miller_calc, r_free_flags, width=None, number=100, auto_kernel=True, n_points=20, n_terms=5): self.n_terms=n_terms self.miller_obs = miller_obs.map_to_asu() self.miller_calc = abs(miller_calc.map_to_asu()) self.r_free_flags = r_free_flags.map_to_asu()
class label_decorator(object):
class label_decorator(__builtins__["object"]):
def are_anomalous_labels(sign, labels): for label in labels: if (not is_anomalous_label(sign, label)): return False return True
legend=('R_calc','R_obs', 'Class', 'distance', 'choice')
legend=('R_obs','R_calc', 'Class', 'distance', 'choice')
def show(self): print >> self.out print >> self.out, "R vs R statistic:" print >> self.out, " Lebedev, Vagin, Murshudov. Acta Cryst. (2006). D62, 83-95" print >> self.out print >> self.out , " R_twin observed data : %4.3f"%(self.r_obs) if self.r_calc is not None: print >> self.out , " R_twin calculated data : %4.3...
== (4182529786L,2180050607L,3809380472L)
== (1791095845, 4282876139L, 3093770124L)
def exercise_random(): for i in xrange(3): for j in xrange(2): if (j == 0): mt = flex.mersenne_twister() else: mt.seed() assert tuple(mt.random_size_t(3)) \ == (4182529786L,2180050607L,3809380472L) assert approx_equal(mt.random_double(3), (0.68936349374460137, 0.94325460841489361, 0.92878638322669693)) if (j == 0): mt ...
(0.68936349374460137, 0.94325460841489361, 0.92878638322669693))
(0.93255736141757983, 0.00011438108051996238, 0.12812444780211069))
def exercise_random(): for i in xrange(3): for j in xrange(2): if (j == 0): mt = flex.mersenne_twister() else: mt.seed() assert tuple(mt.random_size_t(3)) \ == (4182529786L,2180050607L,3809380472L) assert approx_equal(mt.random_double(3), (0.68936349374460137, 0.94325460841489361, 0.92878638322669693)) if (j == 0): mt ...
== (1393419875, 3943084030L, 3680293049L)
== (2983900864L, 1547366158, 1775641839)
def exercise_random(): for i in xrange(3): for j in xrange(2): if (j == 0): mt = flex.mersenne_twister() else: mt.seed() assert tuple(mt.random_size_t(3)) \ == (4182529786L,2180050607L,3809380472L) assert approx_equal(mt.random_double(3), (0.68936349374460137, 0.94325460841489361, 0.92878638322669693)) if (j == 0): mt ...
(0.62126747463393661, 0.47816347295375622, 0.20067452178352385))
(0.10064729468446394, 0.76077030360716635, 0.89184217362009044))
def exercise_random(): for i in xrange(3): for j in xrange(2): if (j == 0): mt = flex.mersenne_twister() else: mt.seed() assert tuple(mt.random_size_t(3)) \ == (4182529786L,2180050607L,3809380472L) assert approx_equal(mt.random_double(3), (0.68936349374460137, 0.94325460841489361, 0.92878638322669693)) if (j == 0): mt ...
(0.68936349374460137, 0.94325460841489361, 0.92878638322669693)) assert list(flex.random_permutation(size=5)) == [0, 4, 1, 2, 3] assert list(flex.random_permutation(size=5)) == [2, 1, 3, 0, 4] assert list(flex.random_permutation(size=5)) == [2, 3, 1, 4, 0] assert list(flex.random_permutation(size=5)) == [1, 0, 3, 4, 2]
(0.93255736141757983, 0.00011438108051996238, 0.12812444780211069)) assert list(flex.random_permutation(size=5)) == [1, 0, 3, 2, 4] assert list(flex.random_permutation(size=5)) == [0, 1, 3, 2, 4] assert list(flex.random_permutation(size=5)) == [4, 3, 0, 1, 2] assert list(flex.random_permutation(size=5)) == [3, 2, 4, 0,...
def exercise_random(): for i in xrange(3): for j in xrange(2): if (j == 0): mt = flex.mersenne_twister() else: mt.seed() assert tuple(mt.random_size_t(3)) \ == (4182529786L,2180050607L,3809380472L) assert approx_equal(mt.random_double(3), (0.68936349374460137, 0.94325460841489361, 0.92878638322669693)) if (j == 0): mt ...
if (not hasattr(self, "_dispatcher_include_at_start")): self._dispatcher_include_at_start = [] self._dispatcher_include_before_command = [] for file_name in os.listdir(self.build_path): path = self.under_build(file_name) if (not os.path.isfile(path)): continue if ( file_name.startswith("dispatcher_include") and file...
assert hasattr(self, "_dispatcher_include_at_start")
def dispatcher_include(self, where): assert where in ["at_start", "before_command"] if (not hasattr(self, "_dispatcher_include_at_start")): self._dispatcher_include_at_start = [] self._dispatcher_include_before_command = [] for file_name in os.listdir(self.build_path): path = self.under_build(file_name) if (not os.path...
def write_lib_dispatcher_head(self, target_file="lib/dispatcher_head.sh"):
def write_lib_dispatcher_head(self, target_file="dispatcher_head.sh"):
def write_lib_dispatcher_head(self, target_file="lib/dispatcher_head.sh"): if (os.name == "nt"): return print " ", target_file self.write_bin_sh_dispatcher( source_file=None, target_file=self.under_build(target_file))
def write_setpath_files(self):
def show_build_options_and_module_listing(self):
def write_setpath_files(self): print 'Python: %s "%s"' % (sys.version.split()[0], sys.executable) if (self.is_ready_for_build()): self.build_options.report() print "command_version_suffix:", self.command_version_suffix self.show_module_listing() if (len(self.missing_for_use) > 0): raise Sorry("Missing modules: " + " "....
print 'Creating files in build directory:\n "%s"' % self.build_path
def write_setpath_files(self):
def write_setpath_files(self): print 'Python: %s "%s"' % (sys.version.split()[0], sys.executable) if (self.is_ready_for_build()): self.build_options.report() print "command_version_suffix:", self.command_version_suffix self.show_module_listing() if (len(self.missing_for_use) > 0): raise Sorry("Missing modules: " + " "....
self.write_lib_dispatcher_head()
def refresh(self): self.assemble_pythonpath() self.write_setpath_files() self.write_lib_dispatcher_head() self.pickle() if (self.is_ready_for_build()): self.write_SConstruct() if (os.name != "nt"): self.write_run_tests_csh() self.clear_bin_directory() if (not os.path.isdir(self.bin_path)): os.makedirs(self.bin_path) py...
assert out.getvalue() == """\
assert not show_diff(out.getvalue(), """\
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
"""
""")
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 0
Id: 1
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 1
Id: 2
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 2
Id: 3
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 3
Id: 4
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 4
Id: 5
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 5
Id: 6
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 6
Id: 7
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 7
Id: 8
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 8
Id: 9
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 9
Id: 10
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 10
Id: 11
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
Id: 11
Id: 12
def exercise_modifiers(verbose=0): if (verbose): out = sys.stdout mtz_object = mtz.object() mtz_object.set_title(title="012345678") assert mtz_object.title() == "012345678" mtz_object.set_title(title="012345678", append=True) assert mtz_object.title() == "012345678 012345678" mtz_object.set_title(title="0123456789"*10+...
+" abbreviated (e.g. -f=s).")
+" abbreviated (e.g. -f s).")
def run(args, command_name="iotbx.mtz.dump"): if (len(args) == 0): args = ["--help"] command_line = (option_parser( usage=command_name+" [options] file_name [...]") .option("-v", "--verbose", action="store_true", default=False, help="Enable CMTZ library messages.") .option("-c", "--show_column_data", action="store_true...
lib = (
lib = [
def dependencies(self):
)
]
def dependencies(self):
"eltbx": lib,
"eltbx": tuple(lib),
def dependencies(self):
sum_diff_cart = [0,0,0] for diff in self.calculate_shortest_diffs(): diff_cart = self.unit_cell.orthogonalize(diff) sum_diff_cart = python_utils.list_plus(sum_diff_cart, diff_cart) mean_diff_cart = [s / len(self.pairs) for s in sum_diff_cart] self.rms = math.sqrt(python_utils.list_dot_product(mean_diff_cart))
sum_dist2 = 0 for pair in self.pairs: sum_dist2 += self.unit_cell.Length2(self.calculate_shortest_diff(pair)) self.rms = math.sqrt(sum_dist2 / len(self.pairs))
def calculate_rms(self): sum_diff_cart = [0,0,0] for diff in self.calculate_shortest_diffs(): diff_cart = self.unit_cell.orthogonalize(diff) sum_diff_cart = python_utils.list_plus(sum_diff_cart, diff_cart) mean_diff_cart = [s / len(self.pairs) for s in sum_diff_cart] self.rms = math.sqrt(python_utils.list_dot_product(m...
print
print >> out
def show(self, out=None): if out is None: out = sys.stdout
print print
print >> out print >> out
def show(self, out=None): if out is None: out = sys.stdout
else: print "Space group is centric."
def ShowSgOpsGeneric(SgOps): print "Number of lattice translations:", SgOps.nLTr() if (SgOps.isCentric()): print "Space group is acentric." else: print "Space group is centric." if (SgOps.isChiral()): print "Space group is chiral." if (SgOps.isEnantiomorphic()): print "Space group is enantiomorphic." print "Number of r...
choices=("release", "quick", "debug"),
choices=("release", "quick", "debug", "debug_optimized"),
def process_args(self, args, default_repository=None): cold_start = default_repository is not None if (len(args) == 0): args = ["--help"] if (default_repository is None): command_name = "libtbx.configure" else: command_name = "libtbx/configure.py" parser = option_parser( usage="%s [options] module_name[=redirection_pat...
metavar="release|quick|debug")
metavar="release|quick|debug|debug_optimized")
def process_args(self, args, default_repository=None): cold_start = default_repository is not None if (len(args) == 0): args = ["--help"] if (default_repository is None): command_name = "libtbx.configure" else: command_name = "libtbx/configure.py" parser = option_parser( usage="%s [options] module_name[=redirection_pat...
assert self.mode in ["release", "quick", "debug"] self.optimization = (self.mode == "release") self.debug_symbols = (self.mode == "debug")
assert self.mode in ["release", "quick", "debug", "debug_optimized"] self.optimization = (self.mode in ["release", "debug_optimized"]) self.debug_symbols = (self.mode in ["debug", "debug_optimized"])
def __init__(self, compiler, mode, static_libraries, static_exe, scan_boost): introspection.adopt_init_args() assert self.mode in ["release", "quick", "debug"] self.optimization = (self.mode == "release") self.debug_symbols = (self.mode == "debug")
unknown_scattering_type_substitute = eltbx.xray_scattering.it1992( unknown_scattering_type_substitute, True).label()
unknown_scattering_type_substitute \ = eltbx.xray_scattering.get_standard_label( label=unknown_scattering_type_substitute)
def extract_xray_structure(self, special_position_settings=None, crystal_symmetry=None, force_symmetry=False, sites_cart=None, sites_frac=None, site_symmetry_table=None, scattering_types=None, infer_scattering_types_from_names=False, unknown_scattering_type_substitute=None): assert sites_cart is None or sites_frac is N...
scattering_type = eltbx.xray_scattering.it1992( scattering_type, exact_scattering_type).label()
scattering_type = eltbx.xray_scattering.get_standard_label( label=scattering_type, exact=exact_scattering_type)
def extract_xray_structure(self, special_position_settings=None, crystal_symmetry=None, force_symmetry=False, sites_cart=None, sites_frac=None, site_symmetry_table=None, scattering_types=None, infer_scattering_types_from_names=False, unknown_scattering_type_substitute=None): assert sites_cart is None or sites_frac is N...
fd_skip = {0:0, 1:0, 2:0}
fd_skip = {None:0, 0:0, 1:0, 2:0}
def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (POSIX version)"""
gtypename = '_TYPE_'.join(prefix.upper().rsplit('_',1))
gtypename = '_TYPE_'.join(prefix.upper().split('_',1))
stream.write ("typedef struct _%sClass %sClass;\n\n" % (classname,classname))
""" % {'classname':classname,'prefix':prefix, 'uprefix':prefix.upper(), 'gtypename':gtypename})
""" % {'classname':classname,'prefix':prefix, 'uprefix':prefix.upper()})
typedef struct _%(classname)sPrivate %(classname)sPrivate;
def _tick(self): self._ticks[1] -= 1 return True def _reset(self): if self._ticks != None: gobject.source_remove(self._ticks[0]) self._ticks = None def sleep(self, timeout): """ Sleeps for 'timeout' seconds without blocking the Mainloop. Blocking call. """ if self._callback == None: print 'Sleeping for %d seconds' % ...
self[nick+"_conn"]["StatusChanged"].listen() status = self[nick+"_conn"]["GetStatus"].call() while status != 0: if status == 2: raise Exception("Could not connect") status, reason = self[nick+"_conn"]["StatusChanged"].wait() return conn
def _tick(self): self._ticks[1] -= 1 return True
raise NotImplementedError() def __repr__(self): return str(self.__class__)
self.start_manager("client1") self.start_manager("client2")
def run(self): """ This method is called when the test must be run. Override it to implement your test script. Any exception thrown in this method will be reported as a test failure. """ raise NotImplementedError()
def run(cases): """ Call this method with a TestCase sub-class, or a list of TestCase sub-classes. Warning ! As the proxy objects and various signal connections aren't destroyed after a test, it is not a good idea to run more than one test after the other, better launch one process per test. The test case to run will ...
conn1 = self.connect("client1", "jabber", {"account": "telepathytest1@jabber.org", "password": "telepathy"}) conn2 = self.connect("client2", "jabber", { "account": "telepathytest2@jabber.org","password": "telepathy"})
def run(cases): """ Call this method with a TestCase sub-class, or a list of TestCase sub-classes. Warning ! As the proxy objects and various signal connections aren't destroyed after a test, it is not a good idea to run more than one test after the other, better launch one process per test. The test case to run will ...
cases = [case for case in cases if class_name(str(case)) in sys.argv] print 'Running the following test case:', [class_name(str(case)) for case in cases] results = [] def finish(): LOOP.quit() print 'Test Case ended.' for result in results: success, reason = result print '-------\nTestCase:\n%s\n--------' % (reason) i...
self["client1_conn"]["NewChannel"].listen() self["client2_chan"] = ( conn2, self["client2_conn"]["RequestChannel"].call( "org.freedesktop.Telepathy.Channel.Type.Text", 1, self["client2_conn"]["RequestHandles"].call (1, ["telepathytest1@jabber.org"])[0], False), {"text": "org.freedesktop.Telepathy.Channel.Type.Text...
def class_name(name): i = name.rfind(".") if i == -1: return name else: return name[i+1:]
class ClientSignalProxy: def __init__ (self, provider, proxy, name): self.provider = provider self.proxy = proxy self.name = name self.connected = False def _signal_emitted(self, *args): print "%s: Signal '%s' emitted with args:%s" % (self.provider, self.name, args) self.results.append(args) def listen(self): """ Sta...
run(BasicConnectTest)
def run_all_cases(): for case in cases: run_case(case) finish()
if s == 'v': return ("GValue *", "G_TYPE_VALUE", "BOXED", True) if s[:3] == 'a{s': return ("GHashTable *", "DBUS_TYPE_G_STRING_HASHTABLE", "BOXED", False)
def type_to_gtype(s): if s == 'y': #byte return ("guchar", "G_TYPE_UCHAR","UCHAR", False) if s == 'b': #boolean return ("gboolean", "G_TYPE_BOOLEAN","BOOLEAN", False) if s == 'n': #int16 return ("gint", "G_TYPE_INT","INT", False) if s == 'q': #uint16 return ("guint", "G_TYPE_UINT","UINT", False) if s == 'i': #int32 ret...
return ("gpointer", "G_TYPE_BOXED", "BOXED", True)
raise Exception, "don't know the GType for " + s
def type_to_gtype(s): if s == 'y': #byte return ("guchar", "G_TYPE_UCHAR","UCHAR", False) if s == 'b': #boolean return ("gboolean", "G_TYPE_BOOLEAN","BOOLEAN", False) if s == 'n': #int16 return ("gint", "G_TYPE_INT","INT", False) if s == 'q': #uint16 return ("guint", "G_TYPE_UINT","UINT", False) if s == 'i': #int32 ret...
exitstatus2, kernel_names = GLIUtility.spawn("ls -1 --color=no " + root + "/boot/kernel-*", return_output=True)
exitstatus2, kernel_names = GLIUtility.spawn("ls -1 --color=no " + root + "/boot/pentoo", return_output=True)
def _configure_grub(self): self.build_mode = self._install_profile.get_kernel_build_method() self._gather_grub_drive_info() root = self._chroot_dir exitstatus2, kernel_names = GLIUtility.spawn("ls -1 --color=no " + root + "/boot/kernel-*", return_output=True) self._logger.log("Output of Kernel Names:\n"+kernel_names) i...
exitstatus3, initrd_names = GLIUtility.spawn("ls -1 --color=no " + root + "/boot/init*", return_output=True)
exitstatus3, initrd_names = GLIUtility.spawn("ls -1 --color=no " + root + "/boot/pentoo.igz", return_output=True)
def _configure_grub(self): self.build_mode = self._install_profile.get_kernel_build_method() self._gather_grub_drive_info() root = self._chroot_dir exitstatus2, kernel_names = GLIUtility.spawn("ls -1 --color=no " + root + "/boot/kernel-*", return_output=True) self._logger.log("Output of Kernel Names:\n"+kernel_names) i...
if not options.simulate:
if not (options.simulate or options.listonly):
def main(): """ This program is used to generate the menu in enlightenment for the pentoo livecd Future version _might_ support other VM like gnome or others but kde :-) """ if options.listsupported: listdb() return 0 if options.simulate: print star + bold("Starting simulation") pkginstalled = [] pkginstalled = list...
print star + "Listing supported packages installed" print "Package\t\tIcon file\t\tMenu category"
def main(): """ This program is used to generate the menu in enlightenment for the pentoo livecd Future version _might_ support other VM like gnome or others but kde :-) """ if options.listsupported: listdb() return 0 if options.simulate: print star + bold("Starting simulation") pkginstalled = [] pkginstalled = list...
clean_menu() settermenv()
if not (options.listonly): clean_menu()
def main(): """ This program is used to generate the menu in enlightenment for the pentoo livecd Future version _might_ support other VM like gnome or others but kde :-) """ if options.listsupported: listdb() return 0 if options.simulate: print star + bold("Starting simulation") pkginstalled = [] pkginstalled = list...
MENUDIR = getHomeDir() + '/.e/e/applications/menu'
MENUDIR = getHomeDir() + '/.e/e/applications/menu/all/'
def getHomeDir(): ''' Try to find user's home directory, otherwise return current directory.''' try: path1=os.path.expanduser("~") except: path1="" try: path2=os.environ["HOME"] except: path2="" try: path3=os.environ["USERPROFILE"] except: path3="" if not os.path.exists(path1): if not os.path.exists(path2): if not os....
menu = os.path.join(MENUDIR, "all", all_menus[x])
menu = os.path.join(MENUDIR, all_menus[x])
def clean_menu(): """Function removing unused menu entries, usually called at the end""" all_menus = [] for y in range(db.__len__()): if not all_menus.__contains__(db[y][2]): all_menus.append(db[y][2]) # This will "save" submenus entries for x in range(menus_used.__len__()): # Preserve menu if only submenu inside for s...