def test_simple_outlier_rejection(generated_Ih_table): """Test the simple outlier rejection algorithm.""" zmax = 6.0 outlier_rej = SimpleNormDevOutlierRejection(generated_Ih_table, zmax) outlier_rej.run() outliers = outlier_rej.final_outlier_arrays assert len(outliers) == 1 assert list(outliers[0]) == [4, 5, 6, 7, 8, 9]
def test_multi_dataset_outlier_rejection(test_sg): """Test outlier rejection with two datasets.""" rt1 = flex.reflection_table() rt1["intensity"] = flex.double( [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 20.0, 400.0, 10.0]) rt1["variance"] = flex.double(9, 1.0) rt1["inverse_scale_factor"] = flex.double(9, 1.0) rt1["miller_index"] = flex.miller_index([ (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 2), (0, 0, 2), (0, 0, 2), (0, 0, 2), (0, 0, 3), ]) rt1.set_flags( flex.bool( [True, False, False, False, False, False, False, False, False]), rt1.flags.excluded_for_scaling, ) rt1.set_flags(flex.bool(9, False), rt1.flags.user_excluded_in_scaling) rt2 = flex.reflection_table() rt2["intensity"] = flex.double([10.0, 20.0, 500.0]) rt2["variance"] = flex.double(3, 1.0) rt2["inverse_scale_factor"] = flex.double(3, 1.0) rt2["miller_index"] = flex.miller_index([(0, 0, 23), (0, 0, 1), (0, 0, 2)]) rt2.set_flags(flex.bool([False, False, False]), rt1.flags.excluded_for_scaling) rt2.set_flags(flex.bool(3, False), rt2.flags.user_excluded_in_scaling) Ih_table = IhTable([rt1, rt2], test_sg, nblocks=1) zmax = 6.0 outlier_rej = SimpleNormDevOutlierRejection(Ih_table, zmax) outlier_rej.run() outliers = outlier_rej.final_outlier_arrays assert len(outliers) == 2 assert list(outliers[0]) == [4, 5, 6, 7] assert list(outliers[1]) == [1, 2] outlier_rej = NormDevOutlierRejection(Ih_table, zmax) outlier_rej.run() outliers = outlier_rej.final_outlier_arrays assert len(outliers) == 2 assert list(outliers[0]) == [7, 6] assert list(outliers[1]) == [1, 2]