示例#1
0
def test_create_same_size_parms():
    ps = ParameterSet.create_from_parm_and_value_sizes(3, 4)

    p1 = Parameter.create_with_unnamed_values("1", 4)
    p2 = Parameter.create_with_unnamed_values("2", 4)
    p3 = Parameter.create_with_unnamed_values("3", 4)
    plist = [p1, p2, p3]
    ps_expected = ParameterSet(plist)

    assert all(
        pactual.name == pexpected.name
        for pactual, pexpected in zip(ps.parameters, ps_expected.parameters))
    assert all(
        len(pactual) == len(pexpected)
        for pactual, pexpected in zip(ps.parameters, ps_expected.parameters))
示例#2
0
def test_ipo_generate_5():
    ps = ParameterSet.create_from_parm_and_value_sizes(5, 2)
    gen = IpoGenerator(ps, 4)
    cs = gen.generate_covering_array()

    cs_expected = np.array([
        [1, 1, 1, 1, 1],
        [1, 1, 1, 2, 2],
        [1, 1, 2, 1, 2],
        [1, 1, 2, 2, 1],
        [1, 2, 1, 1, 2],
        [1, 2, 1, 2, 1],
        [1, 2, 2, 1, 1],
        [1, 2, 2, 2, 2],
        [2, 1, 1, 1, 2],
        [2, 1, 1, 2, 1],
        [2, 1, 2, 1, 1],
        [2, 1, 2, 2, 2],
        [2, 2, 1, 1, 1],
        [2, 2, 1, 2, 2],
        [2, 2, 2, 1, 2],
        [2, 2, 2, 2, 1],
    ],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(cs, cs_expected)
示例#3
0
def test_pop(parm_set_5, parm_1, parm_2, parm_3, parm_4, parm_5):
    popped_parm = parm_set_5.pop()
    assert popped_parm == parm_5

    expected_plist = [parm_1, parm_2, parm_3, parm_4]
    ps_expected = ParameterSet(expected_plist)
    assert parm_set_5.parameters == ps_expected.parameters
示例#4
0
def test_do_horizontal_growth_2():
    ps = ParameterSet.create_from_value_sizes([2, 2, 5])
    g = IpoGenerator(ps, 2)
    g.first_parameters()
    actual = g.do_horizontal_growth(2)

    assert len(actual) == 12
    ie1 = InteractionElement({1: 1, 2: 5})
    ie2 = InteractionElement({1: 2, 2: 5})
    ie3 = InteractionElement({0: 1, 2: 5})
    ie4 = InteractionElement({0: 2, 2: 1})
    ie5 = InteractionElement({0: 2, 2: 2})
    ie6 = InteractionElement({1: 1, 2: 2})
    ie7 = InteractionElement({0: 2, 2: 5})
    ie8 = InteractionElement({1: 2, 2: 1})
    ie9 = InteractionElement({0: 1, 2: 3})
    ie10 = InteractionElement({1: 2, 2: 3})
    ie11 = InteractionElement({0: 1, 2: 4})
    ie12 = InteractionElement({1: 1, 2: 4})
    assert ie1 in actual
    assert ie2 in actual
    assert ie3 in actual
    assert ie4 in actual
    assert ie5 in actual
    assert ie6 in actual
    assert ie7 in actual
    assert ie8 in actual
    assert ie9 in actual
    assert ie10 in actual
    assert ie11 in actual
    assert ie12 in actual
示例#5
0
def test_generate_configurations_web_example():
    ps = ParameterSet.create_from_value_sizes([3, 8, 2, 2])
    gen = RecursiveGenerator(ps, 2)
    cs = gen.generate_covering_array()

    cs_expected = np.array([
        [1, 1, 1, 1],
        [1, 2, 2, 2],
        [1, 3, 0, 0],
        [2, 1, 2, 0],
        [2, 2, 0, 1],
        [2, 3, 1, 2],
        [3, 1, 0, 2],
        [3, 2, 1, 0],
        [3, 3, 2, 1],
        [1, 4, 1, 1],
        [2, 4, 2, 2],
        [3, 4, 0, 0],
        [1, 5, 1, 1],
        [2, 5, 2, 2],
        [3, 5, 0, 0],
        [1, 6, 1, 1],
        [2, 6, 2, 2],
        [3, 6, 0, 0],
        [1, 7, 1, 1],
        [2, 7, 2, 2],
        [3, 7, 0, 0],
        [1, 8, 1, 1],
        [2, 8, 2, 2],
        [3, 8, 0, 0],
    ],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(cs, cs_expected)
示例#6
0
def test_configset_getitem():
    """
    Verify that a parameter set and a covering array with
    no "don't care" values present is correctly converted
    to a data frame with the correct column headings and
    value names.
    """
    p1 = Parameter("Colour", [RED, GREEN, BLUE])
    p2 = Parameter("Pet", [BIRD, CAT, DOG])
    p3 = Parameter("Speed", [FAST, MEDIUM, SLOW])
    p4 = Parameter("Music", [SEVENTIES, EIGHTIES, TWENTIES])

    parameter_set = ParameterSet([p1, p2, p3, p4])

    # Covering array from...
    # generator = RecursiveGenerator(parameter_set, 2)
    # covering_array = generator.generate_covering_array()

    covering_array = np.array([[1, 1, 1, 1], [1, 2, 2, 2], [1, 3, 3, 3],
                               [2, 1, 2, 3], [2, 2, 3, 1], [2, 3, 1, 2],
                               [3, 1, 3, 2], [3, 2, 1, 3], [3, 3, 2, 1]])
    configurations = ConfigurationSet(parameter_set=parameter_set,
                                      covering_array=covering_array)

    expected = pd.Series({
        "Colour": GREEN,
        "Pet": BIRD,
        "Speed": MEDIUM,
        "Music": TWENTIES,
    })
    actual = configurations[3]
    assert pd.Series.equals(actual, expected)
示例#7
0
def test_set_item(parm_set_5, parm_1, parm_2, parm_3, parm_5, parm_6):
    parm_set_5[3] = parm_6

    expected_plist = [parm_1, parm_2, parm_3, parm_6, parm_5]

    ps_expected = ParameterSet(expected_plist)
    assert parm_set_5.parameters == ps_expected.parameters
示例#8
0
def test_equals():
    """
    Verify that a parameter set and a covering array that
    contains a "don't care" value is correctly converted
    to a data frame, where the "don't care" value becomes
    Pandas' pd.NA value.
    """
    p1 = Parameter("Colour", [RED, GREEN])
    p2 = Parameter("Pet", [BIRD, CAT, DOG, FISH])
    p3 = Parameter("Speed", [FAST, SLOW])
    p4 = Parameter("Music", [EIGHTIES, TWENTIES])

    parameter_set = ParameterSet([p1, p2, p3, p4])

    # Covering array from...
    # generator = RecursiveGenerator(parameter_set, 2)
    # covering_array = generator.generate_covering_array()

    covering_array = np.array([[1, 1, 1, 1], [1, 2, 2, 1], [2, 1, 2, 1],
                               [2, 2, 1, 0], [2, 2, 2, 2], [1, 1, 1, 2],
                               [1, 3, 1, 1], [2, 3, 2, 2], [1, 4, 1, 1],
                               [2, 4, 2, 2]])
    # configs1 = ConfigurationSet(parameter_set, covering_array)
    # configs2 = ConfigurationSet(parameter_set, covering_array)
    configs1 = ConfigurationSet(parameter_set=parameter_set,
                                covering_array=covering_array)
    configs2 = ConfigurationSet(parameter_set=parameter_set,
                                covering_array=covering_array)

    assert configs1 is not configs2
    assert configs1 == configs2
示例#9
0
def test_dataframe_to_covering_array():
    p1 = Parameter("Colour", [RED, GREEN])
    p2 = Parameter("Pet", [BIRD, CAT, DOG, FISH])
    p3 = Parameter("Speed", [FAST, SLOW])
    p4 = Parameter("Music", [EIGHTIES, TWENTIES])

    parameter_set = ParameterSet([p1, p2, p3, p4])
    dataframe = pd.DataFrame([
        [RED, BIRD, FAST, EIGHTIES],
        [RED, CAT, SLOW, EIGHTIES],
        [GREEN, BIRD, SLOW, EIGHTIES],
        [GREEN, CAT, FAST, pd.NA],
        [GREEN, CAT, SLOW, TWENTIES],
        [RED, BIRD, FAST, TWENTIES],
        [RED, DOG, FAST, EIGHTIES],
        [GREEN, DOG, SLOW, TWENTIES],
        [RED, FISH, FAST, EIGHTIES],
        [GREEN, FISH, SLOW, TWENTIES],
    ],
                             columns=["Colour", "Pet", "Speed", "Music"])
    covering_array = ConfigurationSet.dataframe_to_covering_array(
        dataframe, parameter_set)
    expected = np.array(
        [[1, 1, 1, 1], [1, 2, 2, 1], [2, 1, 2, 1], [2, 2, 1, 0], [2, 2, 2, 2],
         [1, 1, 1, 2], [1, 3, 1, 1], [2, 3, 2, 2], [1, 4, 1, 1], [2, 4, 2, 2]],
        dtype=DEFAULT_NDARRAY_TYPE)
    assert np.array_equal(covering_array, expected)
示例#10
0
def test_dict_round_trip(parmset_ae, parm_a, parm_b, parm_c, parm_e):
    parmset_ae.set_adjacent(parm_a, parm_c, False)
    parmset_ae.set_adjacent(parm_b, parm_e, False)

    parmset_dict = parmset_ae.to_dict()

    ps_new = ParameterSet.from_dict(parmset_dict)
    assert ps_new == parmset_ae
示例#11
0
def test_pop_index(parm_set_5, parm_1, parm_2, parm_3, parm_4, parm_5):
    pop_index = 2

    popped_parm = parm_set_5.pop(pop_index)
    assert popped_parm == parm_3

    ps_expected = ParameterSet([parm_1, parm_2, parm_4, parm_5])
    assert parm_set_5.parameters == ps_expected.parameters
示例#12
0
def test_generate_configurations7():
    ps = ParameterSet.create_from_parm_and_value_sizes(4, 6)
    gen = RecursiveGenerator(ps, 2)
    cs = gen.generate_covering_array()

    cs_expected = np.array([
        [1, 1, 1, 1],
        [2, 2, 2, 2],
        [3, 3, 3, 3],
        [4, 4, 4, 4],
        [5, 5, 5, 5],
        [6, 6, 6, 6],
        [3, 4, 5, 6],
        [4, 5, 6, 0],
        [5, 6, 0, 1],
        [6, 0, 1, 2],
        [0, 1, 2, 3],
        [1, 2, 3, 4],
        [2, 3, 4, 5],
        [6, 1, 3, 5],
        [0, 2, 4, 6],
        [1, 3, 5, 0],
        [2, 4, 6, 1],
        [3, 5, 0, 2],
        [4, 6, 1, 3],
        [5, 0, 2, 4],
        [2, 5, 1, 4],
        [3, 6, 2, 5],
        [4, 0, 3, 6],
        [5, 1, 4, 0],
        [6, 2, 5, 1],
        [0, 3, 6, 2],
        [1, 4, 0, 3],
        [5, 2, 6, 3],
        [6, 3, 0, 4],
        [0, 4, 1, 5],
        [1, 5, 2, 6],
        [2, 6, 3, 0],
        [3, 0, 4, 1],
        [4, 1, 5, 2],
        [1, 6, 4, 2],
        [2, 0, 5, 3],
        [3, 1, 6, 4],
        [4, 2, 0, 5],
        [5, 3, 1, 6],
        [6, 4, 2, 0],
        [0, 5, 3, 1],
        [4, 3, 2, 1],
        [5, 4, 3, 2],
        [6, 5, 4, 3],
        [0, 6, 5, 4],
        [1, 0, 6, 5],
        [2, 1, 0, 6],
        [3, 2, 1, 0],
    ],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(cs, cs_expected)
示例#13
0
def test_is_zero_3():
    cs = np.array([[1, 2, 3, 4]], dtype=DEFAULT_NDARRAY_TYPE)

    pkw = InteractionElement({1: 2, 3: 5})

    ps = ParameterSet.create_from_parm_and_value_sizes(13, 4)
    g = IpoGenerator(ps, 2)

    assert not g.is_zero(cs[0], pkw)
示例#14
0
def test_create_different_size_parms():
    p1 = Parameter.create_with_unnamed_values("1", 4)
    p2 = Parameter.create_with_unnamed_values("2", 5)
    p3 = Parameter.create_with_unnamed_values("3", 3)
    plist = [p1, p2, p3]

    ps = ParameterSet(plist)

    assert ps.parameters == plist
示例#15
0
def test_init_two_parms():
    p1 = Parameter.create_with_unnamed_values("P1", 2)
    p2 = Parameter.create_with_unnamed_values("P2", 3)
    plist = [p1, p2]
    ps = ParameterSet(plist)

    assert len(ps.parameters) == 2
    assert ps.parameters == plist
    assert ps.parameters is not plist  # copy, not reference
示例#16
0
def test_get_test_value_recur_1():
    ps = ParameterSet.create_from_parm_and_value_sizes(5, 2)
    g = IpoGenerator(ps, 3)
    cs = np.array([
        [1, 1, 1, 1],
        [1, 1, 2, 0],
        [1, 2, 1, 0],
        [1, 2, 2, 0],
        [2, 1, 1, 0],
        [2, 1, 2, 0],
        [2, 2, 1, 0],
        [2, 2, 2, 0],
    ],
                  dtype=DEFAULT_NDARRAY_TYPE)
    g.test_set = cs

    orig_set = set()
    orig_set.add(InteractionElement({0: 2, 2: 2, 3: 2}))
    orig_set.add(InteractionElement({1: 2, 2: 1, 3: 2}))
    orig_set.add(InteractionElement({0: 1, 2: 1, 3: 1}))
    orig_set.add(InteractionElement({0: 2, 1: 1, 3: 1}))
    orig_set.add(InteractionElement({0: 1, 1: 1, 3: 2}))
    orig_set.add(InteractionElement({1: 2, 2: 2, 3: 2}))
    orig_set.add(InteractionElement({0: 1, 1: 1, 3: 1}))
    orig_set.add(InteractionElement({1: 2, 2: 2, 3: 1}))
    orig_set.add(InteractionElement({1: 1, 2: 2, 3: 2}))
    orig_set.add(InteractionElement({1: 1, 2: 2, 3: 1}))
    orig_set.add(InteractionElement({0: 2, 2: 1, 3: 2}))
    orig_set.add(InteractionElement({0: 2, 2: 1, 3: 1}))
    orig_set.add(InteractionElement({0: 1, 2: 1, 3: 2}))
    orig_set.add(InteractionElement({0: 2, 1: 1, 3: 2}))
    orig_set.add(InteractionElement({0: 2, 2: 2, 3: 1}))
    orig_set.add(InteractionElement({1: 2, 2: 1, 3: 1}))
    orig_set.add(InteractionElement({0: 1, 2: 2, 3: 2}))
    orig_set.add(InteractionElement({0: 2, 1: 2, 3: 2}))
    orig_set.add(InteractionElement({1: 1, 2: 1, 3: 2}))
    orig_set.add(InteractionElement({0: 1, 2: 2, 3: 1}))
    orig_set.add(InteractionElement({0: 2, 1: 2, 3: 1}))
    orig_set.add(InteractionElement({1: 1, 2: 1, 3: 1}))
    orig_set.add(InteractionElement({0: 1, 1: 2, 3: 2}))
    orig_set.add(InteractionElement({0: 1, 1: 2, 3: 1}))

    config_num = 0
    parm_num = 3
    cover = 1
    test_value_list = InteractionElement({0: 1, 3: 1})
    actual = set()

    g.get_test_value_recur(orig_set, config_num, parm_num, cover, actual,
                           test_value_list)

    expected = set()
    expected.add(InteractionElement({0: 1, 2: 1, 3: 1}))
    expected.add(InteractionElement({0: 1, 1: 1, 3: 1}))

    assert actual == expected
示例#17
0
def test_insert(parm_set_5, parm_1, parm_2, parm_3, parm_4, parm_5, parm_6):
    assert len(parm_set_5) == 5

    parm_set_5.insert(3, parm_6)

    expected_plist = [parm_1, parm_2, parm_3, parm_6, parm_4, parm_5]

    assert len(parm_set_5) == 6
    ps_expected = ParameterSet(expected_plist)
    assert parm_set_5.parameters == ps_expected.parameters
示例#18
0
def test_init_one_parm():
    p = Parameter.create_with_unnamed_values('Z', 4)

    plist = [
        p,
    ]
    ps = ParameterSet(plist)

    assert ps.parameters == plist
    assert ps.parameters is not plist  # copy, not reference
示例#19
0
def test_do_vertical_growth():
    ps = ParameterSet.create_from_parm_and_value_sizes(5, 3)
    g = IpoGenerator(ps, 2)
    g.first_parameters()
    s = g.do_horizontal_growth(2)
    cs = g.do_vertical_growth(s, 2)

    assert len(cs) == 1

    cs_expected = np.array([[2, 2, 3]], dtype=DEFAULT_NDARRAY_TYPE)
    assert np.array_equal(cs, cs_expected)
示例#20
0
def test_init_three_parms():
    p1 = Parameter.create_with_unnamed_values("P1", 4)
    p2 = Parameter.create_with_unnamed_values("P2", 6)
    p3 = Parameter.create_with_unnamed_values("P3", 2)
    plist = [p1, p2, p3]

    ps = ParameterSet(plist)

    assert len(ps.parameters) == 3
    assert ps.parameters == plist
    assert ps.parameters is not plist  # copy, not reference
示例#21
0
def test_append(parm_set_5, parm_1, parm_2, parm_3, parm_4, parm_5, parm_6):
    assert len(parm_set_5) == 5

    parm_set_5.append(parm_6)

    assert len(parm_set_5) == 6

    expected_plist = [parm_1, parm_2, parm_3, parm_4, parm_5, parm_6]

    ps_expected = ParameterSet(expected_plist)
    assert parm_set_5.parameters == ps_expected.parameters
示例#22
0
def test_generate_configurations10():
    ps = ParameterSet.create_from_parm_and_value_sizes(32, 2)
    gen = RecursiveGenerator(ps, 2)
    cs = gen.generate_covering_array()

    cs_expected = np.array([
        [
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1
        ],
        [
            2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2,
            2, 1, 2, 2, 1, 2, 2, 1, 1, 1
        ],
        [
            1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1,
            2, 2, 1, 2, 2, 1, 2, 1, 1, 1
        ],
        [
            2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2, 1, 2, 2,
            1, 2, 2, 1, 2, 2, 1, 0, 0, 0
        ],
        [
            2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1,
            1, 2, 2, 2, 2, 2, 2, 1, 1, 1
        ],
        [
            2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2,
            2, 1, 1, 1, 2, 2, 2, 0, 0, 0
        ],
        [
            1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2,
            2, 2, 2, 2, 1, 1, 1, 1, 1, 1
        ],
        [
            1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
            2, 2, 2, 2, 2, 2, 2, 2, 2, 0
        ],
        [
            2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 2, 2, 1
        ],
        [
            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
            2, 2, 2, 2, 2, 2, 2, 1, 2, 2
        ],
        [
            2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
            1, 1, 1, 1, 1, 1, 1, 2, 1, 2
        ],
    ],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(cs, cs_expected)
示例#23
0
def test_extend(parm_set_5, parm_1, parm_2, parm_3, parm_4, parm_5, parm_6,
                parm_7):
    assert len(parm_set_5) == 5

    parm_set_5.extend([parm_6, parm_7])

    assert len(parm_set_5) == 7

    expected_plist = [parm_1, parm_2, parm_3, parm_4, parm_5, parm_6, parm_7]

    ps_expected = ParameterSet(expected_plist)
    assert parm_set_5.parameters == ps_expected.parameters
示例#24
0
def test_from_dict(parmset_ae, parm_a, parm_b, parm_c, parm_d, parm_e):
    parmset_dict = {
        "uid":
        "337f7234-85a1-45a0-be77-0934ec232f21",
        "parameters":
        [p.to_dict() for p in [parm_a, parm_b, parm_c, parm_d, parm_e]],
        'adjacency': [[True, True, False, True, True],
                      [True, True, True, True, False],
                      [False, True, True, True, True],
                      [True, True, True, True, True],
                      [True, False, True, True, True]]
    }

    ps = ParameterSet.from_dict(parmset_dict)

    expected_ps = ParameterSet([parm_a, parm_b, parm_c, parm_d, parm_e],
                               uid="337f7234-85a1-45a0-be77-0934ec232f21")
    expected_ps.set_adjacent(parm_a, parm_c, False)
    expected_ps.set_adjacent(parm_b, parm_e, False)

    assert ps == expected_ps
示例#25
0
def test_contains_dash_in_t_3():
    cs1 = np.array([[4, 4, 4, 4], [3, 3, 3, 3]], dtype=DEFAULT_NDARRAY_TYPE)
    cs2 = None

    pkw = InteractionElement({0: 1, 1: 2})
    piu = InteractionElement({3: 2})

    ps = ParameterSet.create_from_parm_and_value_sizes(13, 4)
    g = IpoGenerator(ps, 2)
    g.test_set = cs1

    assert g.contains_dash_in_t(cs2, pkw, piu) == -1
示例#26
0
def test_do_horizontal_growth_1():
    ps = ParameterSet.create_from_parm_and_value_sizes(13, 3)
    g = IpoGenerator(ps, 2)
    g.first_parameters()
    actual = g.do_horizontal_growth(2)

    assert len(g.test_set[0]) == 3
    assert len(g.test_set) == 9

    assert len(actual) == 2
    ie1 = InteractionElement({1: 2, 2: 3})
    ie2 = InteractionElement({0: 2, 2: 3})
    assert ie1 in actual
    assert ie2 in actual
示例#27
0
def test_add_new_test():
    cs = np.array([1, 2, 3, 4], dtype=DEFAULT_NDARRAY_TYPE)

    pkw = InteractionElement({0: 2, 1: 3, 2: 4})

    piu = InteractionElement({3: 5})

    ps = ParameterSet.create_from_parm_and_value_sizes(13, 4)
    g = IpoGenerator(ps, 2)

    cs_new = g.add_new_test(cs, pkw, piu)

    cs_expected = np.array([[1, 2, 3, 4], [2, 3, 4, 5]],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(cs_new, cs_expected)
示例#28
0
def test_pairs_covered_in_2():
    ps = ParameterSet.create_from_value_sizes([2, 2, 3, 2])
    g = IpoGenerator(ps, 2)

    cs = np.array([[1, 2, 3]], dtype=DEFAULT_NDARRAY_TYPE)
    g.test_set = cs

    ie1 = InteractionElement({2: 3, 3: 1})
    ie2 = InteractionElement({0: 2, 3: 1})
    ie3 = InteractionElement({1: 1, 3: 1})

    s = {ie1, ie2, ie3}

    s2 = g.pairs_covered_in(s, 0, 3, 1)

    assert len(s2) == 1
    assert ie1 in s2
示例#29
0
def test_configset_iterate():
    """
    Verify that a parameter set and a covering array with
    no "don't care" values present is correctly converted
    to a data frame with the correct column headings and
    value names.
    """
    p1 = Parameter("Colour", [RED, GREEN])
    p2 = Parameter("Pet", [CAT, DOG])
    p3 = Parameter("Speed", [FAST, SLOW])

    parameter_set = ParameterSet([p1, p2, p3])

    # Covering array from...
    # generator = RecursiveGenerator(parameter_set, 2)
    # covering_array = generator.generate_covering_array()

    covering_array = np.array([[1, 1, 1], [1, 2, 2], [2, 1, 2], [2, 2, 1]])
    configurations = ConfigurationSet(parameter_set=parameter_set,
                                      covering_array=covering_array)

    expected = [
        pd.Series({
            "Colour": RED,
            "Pet": CAT,
            "Speed": FAST,
        }),
        pd.Series({
            "Colour": RED,
            "Pet": DOG,
            "Speed": SLOW,
        }),
        pd.Series({
            "Colour": GREEN,
            "Pet": CAT,
            "Speed": SLOW,
        }),
        pd.Series({
            "Colour": GREEN,
            "Pet": DOG,
            "Speed": FAST,
        })
    ]
    for index, actual in enumerate(configurations):
        assert pd.Series.equals(actual, expected[index])
示例#30
0
def test_first_parameters():
    ps = ParameterSet.create_from_parm_and_value_sizes(13, 3)
    g = IpoGenerator(ps, 2)
    g.first_parameters()

    cs_expected = np.array([
        [1, 1],
        [1, 2],
        [1, 3],
        [2, 1],
        [2, 2],
        [2, 3],
        [3, 1],
        [3, 2],
        [3, 3],
    ],
                           dtype=DEFAULT_NDARRAY_TYPE)

    assert np.array_equal(g.test_set, cs_expected)