def METHOD_NAME(space_group_info, n_scatterers=8, d_min=2, verbose=0,
             e_min=1.5):
  structure = random_structure.xray_structure(
    space_group_info,
    elements=["const"]*n_scatterers,
    volume_per_atom=200,
    min_distance=3.,
    general_positions_only=True,
    u_iso=0.0)
  if (0 or verbose):
    structure.show_summary().show_scatterers()
  f_calc = structure.structure_factors(
    d_min=d_min, anomalous_flag=False).f_calc()
  f_obs = abs(f_calc)
  q_obs = miller.array(
    miller_set=f_obs,
    data=f_obs.data()
        / math.sqrt(f_obs.space_group().order_p() * n_scatterers)
        / f_obs.space_group().n_ltr())
  q_obs = q_obs.sort(by_value="abs")
  q_obs.setup_binner(auto_binning=True)
  n_obs = q_obs.quasi_normalize_structure_factors()
  r = flex.linear_regression(q_obs.data(), n_obs.data())
  if (0 or verbose):
    r.show_summary()
  assert r.is_well_defined()
  assert abs(r.y_intercept()) < 0.1
  assert abs(r.slope() - 1) < 0.2
  q_large = q_obs.select(
    q_obs.quasi_normalized_as_normalized().data() > e_min)
  if (0 or verbose):
    print("Number of e-values > %.6g: %d" % (e_min, q_large.size()))
  other_structure = random_structure.xray_structure(
    space_group_info,
    elements=["const"]*n_scatterers,
    volume_per_atom=200,
    min_distance=3.,
    general_positions_only=True,
    u_iso=0.0)
  assert other_structure.unit_cell().is_similar_to(structure.unit_cell())
  q_calc = q_large.structure_factors_from_scatterers(
    other_structure, algorithm="direct").f_calc()
  start = q_large.phase_transfer(q_calc.data())
  for selection_fixed in (
        None,
        flex.double([random.random() for i in range(start.size())]) < 0.4):
    from_map_data = direct_space_squaring(start, selection_fixed)
    direct_space_result = start.phase_transfer(phase_source=from_map_data)
    new_phases = reciprocal_space_squaring(start, selection_fixed, verbose)
    reciprocal_space_result = start.phase_transfer(
      phase_source=flex.polar(1,new_phases))
    mwpe = direct_space_result.mean_weighted_phase_error(
      reciprocal_space_result)
    if (0 or verbose):
      print("mwpe: %.2f" % mwpe, start.space_group_info())
    for i,h in enumerate(direct_space_result.indices()):
      amp_d,phi_d = complex_math.abs_arg(
        direct_space_result.data()[i], deg=True)
      amp_r,phi_r = complex_math.abs_arg(
        reciprocal_space_result.data()[i],deg=True)
      phase_err = scitbx.math.phase_error(phi_d, phi_r, deg=True)
      assert phase_err < 1.0 or abs(from_map_data[i]) < 1.e-6
  exercise_truncate(q_large)