From: <luc...@us...> - 2007-09-26 20:26:26
|
Revision: 6302 http://cctbx.svn.sourceforge.net/cctbx/?rev=6302&view=rev Author: luc_j_bourhis Date: 2007-09-26 13:26:22 -0700 (Wed, 26 Sep 2007) Log Message: ----------- normalise indentation Modified Paths: -------------- trunk/cctbx/cctbx/regression/tst_xray_minimization.py Modified: trunk/cctbx/cctbx/regression/tst_xray_minimization.py =================================================================== --- trunk/cctbx/cctbx/regression/tst_xray_minimization.py 2007-09-26 16:02:18 UTC (rev 6301) +++ trunk/cctbx/cctbx/regression/tst_xray_minimization.py 2007-09-26 20:26:22 UTC (rev 6302) @@ -6,17 +6,17 @@ from libtbx.test_utils import approx_equal def shift_u_iso(structure, shift): - for sc in structure.scatterers(): - if(sc.flags.use_u_iso() and sc.flags.grad_u_iso()): - sc.u_iso += (shift * random.random()) + for sc in structure.scatterers(): + if(sc.flags.use_u_iso() and sc.flags.grad_u_iso()): + sc.u_iso += (shift * random.random()) def shift_u_aniso(structure, shift): - for sc in structure.scatterers(): - if(sc.flags.use_u_aniso() and sc.flags.grad_u_aniso()): - u_star = list(sc.u_star) - for i in xrange(6): - u_star[i] += (shift * random.random()) - sc.u_star = u_star + for sc in structure.scatterers(): + if(sc.flags.use_u_aniso() and sc.flags.grad_u_aniso()): + u_star = list(sc.u_star) + for i in xrange(6): + u_star[i] += (shift * random.random()) + sc.u_star = u_star def exercise(target_functor, data_type, space_group_info, anomalous_flag, gradient_flags, occupancy_penalty, @@ -24,7 +24,7 @@ verbose=0,tan_u_iso=False, param = 0): assert data_type == 'F' or data_type == 'F^2' if (data_type == 'F^2' - and not target_functor == xray.unified_least_squares_residual): return + and not target_functor == xray.unified_least_squares_residual): return structure_ideal = random_structure.xray_structure( space_group_info, elements=(("O","N","C")*(n_elements))[:n_elements],#("Se",)*n_elements, @@ -34,9 +34,9 @@ random_occupancy=True, use_u_aniso = True) random_structure.random_modify_adp_and_adp_flags( - scatterers = structure_ideal.scatterers(), - random_u_iso_scale = 0.3, - random_u_iso_min = 0.0) + scatterers = structure_ideal.scatterers(), + random_u_iso_scale = 0.3, + random_u_iso_min = 0.0) xray.set_scatterer_grad_flags(scatterers = structure_ideal.scatterers(), site = gradient_flags.site, u_iso = gradient_flags.u_iso, @@ -58,12 +58,12 @@ algorithm="direct", cos_sin_table=True).f_calc() if data_type == "F": - y_obs = abs(rnd_f_calc) + y_obs = abs(rnd_f_calc) elif data_type == "F^2": - y_obs = rnd_f_calc.norm() - y_obs.set_observation_type_xray_intensity() + y_obs = rnd_f_calc.norm() + y_obs.set_observation_type_xray_intensity() else: - raise "Error: invalid data type: %s" % data_type + raise "Error: invalid data type: %s" % data_type if (0 or verbose): print "structure_ideal:" structure_ideal.show_summary().show_scatterers() @@ -85,7 +85,7 @@ if (gradient_flags.u_iso): shift_u_iso(structure_shake, 0.1) assert tuple(structure_ideal.special_position_indices()) \ - == tuple(structure_shake.special_position_indices()) + == tuple(structure_shake.special_position_indices()) if (0 or verbose): print "structure_shake:" structure_shake.show_summary().show_scatterers() @@ -96,9 +96,9 @@ occupancy_penalty=occupancy_penalty, structure_factor_algorithm="direct") if (0 or verbose): - print "first:", minimizer.first_target_value - print "final:", minimizer.final_target_value - print + print "first:", minimizer.first_target_value + print "final:", minimizer.final_target_value + print assert minimizer.final_target_value < minimizer.first_target_value if (0 or verbose): print "minimized structure_shake:" @@ -109,9 +109,9 @@ algorithm="direct", cos_sin_table=True).f_calc() if data_type == 'F': - f_final = abs(f_final) + f_final = abs(f_final) elif data_type == 'F^2': - f_final = f_final.norm() + f_final = f_final.norm() c = flex.linear_correlation(y_obs.data(), f_final.data()) assert c.is_well_defined() if (0 or verbose): @@ -122,7 +122,7 @@ print c_coefficient = c.coefficient() if(c_coefficient <= 0.999): - print c_coefficient + print c_coefficient if data_type == 'F': assert c_coefficient > 0.999 elif data_type == 'F^2': @@ -134,10 +134,10 @@ for target_functor in xray.target_functors.registry().values(): for (fsite, fu_iso, foccupancy, fu_aniso) in options: gradient_flags = xray.structure_factors.gradient_flags( - site = fsite, - u_iso = fu_iso, - u_aniso = fu_aniso, - occupancy = foccupancy) + site = fsite, + u_iso = fu_iso, + u_aniso = fu_aniso, + occupancy = foccupancy) for anomalous_flag in (False, True)[:]: #SWITCH u_penalty_types = [None] tan_u_isos = [False] @@ -149,30 +149,30 @@ xray.minimization.occupancy_penalty_exp()) for tan_u_iso in tan_u_isos: if(tan_u_iso): - param = 100 + param = 100 else: - param = 0 + param = 0 for occupancy_penalty in occupancy_penalty_types: if(0): - print fsite,fu_iso,foccupancy,fu_aniso,anomalous_flag,tan_u_iso + print fsite,fu_iso,foccupancy,fu_aniso,anomalous_flag,tan_u_iso do_exercise = lambda: exercise( - target_functor, - data_type, - space_group_info, - anomalous_flag, - gradient_flags, - occupancy_penalty=occupancy_penalty, - verbose=flags.Verbose, - tan_u_iso=tan_u_iso, - param = param, - d_min = 2.5) + target_functor, + data_type, + space_group_info, + anomalous_flag, + gradient_flags, + occupancy_penalty=occupancy_penalty, + verbose=flags.Verbose, + tan_u_iso=tan_u_iso, + param = param, + d_min = 2.5) try: - do_exercise() + do_exercise() except AssertionError: - print "Test did not pass: ruling out a random fluke..." - do_exercise() - do_exercise() - print "Ruled out!" + print "Test did not pass: ruling out a random fluke..." + do_exercise() + do_exercise() + print "Ruled out!" def run(): cmd_args = ['--F', '--F_sq', '--debugging'] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |