def test_unary_potentials():
    g = NodeTypeEdgeFeatureGraphCRF(1, [4], [3], np.array([[3]]))
    node_f = [np.array([[1, 1, 1], [2, 2, 2]])]
    edges = [np.array([[0, 1]])]
    edge_f = [np.array([[3, 3, 3]])]
    x = (node_f, edges, edge_f)
    y = np.hstack([np.array([1, 2])])
    g.initialize(x, y)
    gref = EdgeFeatureGraphCRF(4, 3, 3)
    xref = (node_f[0], edges[0], edge_f[0])
    wref = np.arange(gref.size_joint_feature)
    potref = gref._get_unary_potentials(xref, wref)
    w = np.arange(g.size_joint_feature)
    pot = g._get_unary_potentials(x, w)
    assert_array_equal(pot, [potref])
    pwpotref = gref._get_pairwise_potentials(xref, wref)
    pwpot = g._get_pairwise_potentials(x, w)
    assert_array_equal(pwpot, [pwpotref])
def test_unary_potentials():
    g = NodeTypeEdgeFeatureGraphCRF(1, [4], [3], np.array([[3]]))
    node_f = [np.array([[1, 1, 1], [2, 2, 2]])]
    edges = [np.array([[0, 1]])]
    edge_f = [np.array([[3, 3, 3]])]
    x = (node_f, edges, edge_f)
    y = np.hstack([np.array([1, 2])])
    g.initialize(x, y)
    gref = EdgeFeatureGraphCRF(4, 3, 3)
    xref = (node_f[0], edges[0], edge_f[0])
    wref = np.arange(gref.size_joint_feature)
    potref = gref._get_unary_potentials(xref, wref)
    w = np.arange(g.size_joint_feature)
    pot = g._get_unary_potentials(x, w)
    assert_array_equal(pot, [potref])
    pwpotref = gref._get_pairwise_potentials(xref, wref)
    pwpot = g._get_pairwise_potentials(x, w)
    assert_array_equal(pwpot, [pwpotref])