Beispiel #1
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)
Beispiel #2
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)
Beispiel #3
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)
Beispiel #4
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
Beispiel #5
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)
Beispiel #6
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)
Beispiel #7
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
Beispiel #8
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
Beispiel #9
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))
Beispiel #10
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)
Beispiel #11
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)
Beispiel #12
0
def test_get_hori_recur_2():
    ps = ParameterSet.create_from_parm_and_value_sizes(5, 2)
    g = IpoGenerator(ps, 4)
    g.first_parameters()

    tva = InteractionElement({2: 1, 4: 2})

    pi = set()
    g.get_hori_recur(4, 2, pi, tva)

    ie1 = InteractionElement({1: 1, 2: 1, 3: 1, 4: 2})
    ie2 = InteractionElement({1: 1, 2: 1, 3: 2, 4: 2})
    ie3 = InteractionElement({1: 2, 2: 1, 3: 1, 4: 2})
    ie4 = InteractionElement({1: 2, 2: 1, 3: 2, 4: 2})
    ie5 = InteractionElement({0: 1, 1: 1, 2: 1, 4: 2})
    ie6 = InteractionElement({0: 1, 1: 2, 2: 1, 4: 2})
    ie7 = InteractionElement({0: 2, 1: 1, 2: 1, 4: 2})
    ie8 = InteractionElement({0: 2, 1: 2, 2: 1, 4: 2})
    ie9 = InteractionElement({0: 1, 2: 1, 3: 1, 4: 2})
    ie10 = InteractionElement({0: 1, 2: 1, 3: 2, 4: 2})
    ie11 = InteractionElement({0: 2, 2: 1, 3: 1, 4: 2})
    ie12 = InteractionElement({0: 2, 2: 1, 3: 2, 4: 2})

    assert len(pi) == 12
    assert ie1 in pi
    assert ie2 in pi
    assert ie3 in pi
    assert ie4 in pi
    assert ie5 in pi
    assert ie6 in pi
    assert ie7 in pi
    assert ie8 in pi
    assert ie9 in pi
    assert ie10 in pi
    assert ie11 in pi
    assert ie12 in pi
Beispiel #13
0
def test_parmset_jsonify():
    ps = ParameterSet.create_from_parm_and_value_sizes(3, 4)
    j = ps.to_json()
    x = ParameterSet.from_json(j)
    assert x == ps