def test_intersection_with_stability_selection_multiple_thresholds(): """Tests whether intersection correctly performs an intersection with multiple thresholds. This test also covers the case when there are duplicates.""" coefs = np.array([ [[2, 1, -1, 0, 4], [4, 0, 2, -1, 5], [1, 2, 3, 4, 5]], [[2, 0, 0, 0, 0], [3, 1, 1, 0, 3], [6, 7, 8, 9, 10]], [[2, 0, 0, 0, 0], [2, -1, 3, 0, 2], [2, 4, 6, 8, 9]]]) true_intersection = np.array([ [True, False, False, False, False], [True, True, True, False, True], [True, True, True, True, True], [True, False, True, False, True]]) selection_thresholds = np.array([2, 3]) estimated_intersection = intersection( coefs=coefs, selection_thresholds=selection_thresholds) # we sort the supports since they might not be in the same order assert_array_equal( np.sort(true_intersection, axis=0), np.sort(estimated_intersection, axis=0))
def test_intersection_no_thresholds(): """Tests that the intersection method correctly calculates the intersection using the number of bootstraps as the default selection threshold.""" coefs = np.array([ [[2, 1, -1, 0, 4], [4, 0, 2, -1, 5], [1, 2, 3, 4, 5]], [[2, 0, 0, 0, 0], [3, 1, 1, 0, 3], [6, 7, 8, 9, 10]], [[2, 0, 0, 0, 0], [2, -1, 3, 0, 2], [2, 4, 6, 8, 9]]]) true_intersection = np.array([ [True, False, False, False, False], [True, True, True, True, True], [True, False, True, False, True]]) estimated_intersection = intersection( coefs=coefs, selection_thresholds=None) # we sort the supports since they might not be in the same order assert_array_equal( np.sort(true_intersection, axis=0), np.sort(estimated_intersection, axis=0))
def test_intersection(): """Tests whether intersection correctly performs a hard intersection.""" coefs = np.array([ [[2, 1, -1, 0, 4], [4, 0, 2, -1, 5], [1, 2, 3, 4, 5]], [[2, 0, 0, 0, 0], [3, 1, 1, 0, 3], [6, 7, 8, 9, 10]], [[2, 0, 0, 0, 0], [2, -1, 3, 0, 2], [2, 4, 6, 8, 9]]]) true_intersection = np.array([ [True, False, False, False, False], [True, False, True, False, True], [True, True, True, True, True]]) selection_thresholds = np.array([3]) estimated_intersection = intersection( coefs=coefs, selection_thresholds=selection_thresholds) # we sort the supports since they might not be in the same order assert_array_equal( np.sort(true_intersection, axis=0), np.sort(estimated_intersection, axis=0))