示例#1
0
def test_generate_nodes(s):
    nodes = generate_nodes(s.tpm, s.cm, s.state, s.node_indices, s.node_labels)

    node0_tpm = np.array([
        [[[1, 0],
          [0, 1]],
         [[0, 1],
          [0, 1]]]
    ])
    assert np.array_equal(nodes[0].tpm, node0_tpm)
    assert nodes[0].inputs == set([1, 2])
    assert nodes[0].outputs == set([2])
    assert nodes[0].label == 'A'

    node1_tpm = np.array([
        [[[1, 0],
          [0, 1]]]
    ])
    assert np.array_equal(nodes[1].tpm, node1_tpm)
    assert nodes[1].inputs == set([2])
    assert nodes[1].outputs == set([0, 2])
    assert nodes[1].label == 'B'

    node2_tpm = np.array([
        [[[1, 0]],
         [[0, 1]]],
        [[[0, 1]],
         [[1, 0]]]
    ])
    assert np.array_equal(nodes[2].tpm, node2_tpm)
    assert nodes[2].inputs == set([0, 1])
    assert nodes[2].outputs == set([0, 1])
    assert nodes[2].label == 'C'
示例#2
0
def test_generate_nodes(s):
    nodes = generate_nodes(s.tpm, s.cm, s.state, s.node_indices, s.node_labels)

    # fmt: off
    node0_tpm = np.array([
        [[[1, 0], [0, 1]], [[0, 1], [0, 1]]],
    ])
    # fmt: on
    assert np.array_equal(nodes[0].tpm, node0_tpm)
    assert nodes[0].inputs == set([1, 2])
    assert nodes[0].outputs == set([2])
    assert nodes[0].label == "A"

    # fmt: off
    node1_tpm = np.array([
        [[[1, 0], [0, 1]]],
    ])
    # fmt: on
    assert np.array_equal(nodes[1].tpm, node1_tpm)
    assert nodes[1].inputs == set([2])
    assert nodes[1].outputs == set([0, 2])
    assert nodes[1].label == "B"

    # fmt: off
    node2_tpm = np.array([[[[1, 0]], [[0, 1]]], [[[0, 1]], [[1, 0]]]])
    # fmt: on
    assert np.array_equal(nodes[2].tpm, node2_tpm)
    assert nodes[2].inputs == set([0, 1])
    assert nodes[2].outputs == set([0, 1])
    assert nodes[2].label == "C"
示例#3
0
def test_generate_nodes(s):
    nodes = generate_nodes(s.tpm, s.cm, s.state, s.node_indices)

    node0_tpm = np.array([[[[1, 0], [0, 1]], [[0, 1], [0, 1]]]])
    assert np.array_equal(nodes[0].tpm, node0_tpm)
    assert nodes[0].inputs == set([1, 2])
    assert nodes[0].outputs == set([2])
    assert nodes[0].label == 'n0'

    node1_tpm = np.array([[[[1, 0], [0, 1]]]])
    assert np.array_equal(nodes[1].tpm, node1_tpm)
    assert nodes[1].inputs == set([2])
    assert nodes[1].outputs == set([0, 2])
    assert nodes[1].label == 'n1'

    node2_tpm = np.array([[[[1, 0]], [[0, 1]]], [[[0, 1]], [[1, 0]]]])
    assert np.array_equal(nodes[2].tpm, node2_tpm)
    assert nodes[2].inputs == set([0, 1])
    assert nodes[2].outputs == set([0, 1])
    assert nodes[2].label == 'n2'
示例#4
0
def test_generate_nodes_default_labels(s):
    nodes = generate_nodes(s.tpm, s.cm, s.state, s.node_indices)
    assert [n.label for n in nodes] == ['n0', 'n1', 'n2']
示例#5
0
def test_generate_nodes_default_labels(s):
    nodes = generate_nodes(s.tpm, s.cm, s.state, s.node_indices)
    assert [n.label for n in nodes] == ['n0', 'n1', 'n2']
示例#6
0
def test_generate_nodes_default_labels(s):
    nodes = generate_nodes(s.tpm, s.cm, s.state, s.node_indices)
    assert [n.label for n in nodes] == ["n0", "n1", "n2"]