Beispiel #1
0
def test_unmatricize():
    """
    Test implementation of unmatricize.
    """
    X = np.arange(2 * 3 * 4 * 5).reshape(3, 2, 4, 5)
    for i in range(X.ndim):
        X2 = matricize(X, i)
        assert_array_almost_equal(unmatricize(X2, i, X.shape), X)

    X2 = matricize(X, -2)
    assert_array_almost_equal(unmatricize(X2, -2, X.shape), X)

    X = np.arange(1, 9).reshape(2, 2, 2)
    for i in range(X.ndim):
        X2 = matricize(X, i)
        assert_array_almost_equal(unmatricize(X2, i, X.shape), X)
Beispiel #2
0
def test_matricize():
    """
    Test implementation of matricize.
    """
    X = np.arange(1, 9).reshape(2, 2, 2)
    matricize(X, 0)
    assert_array_almost_equal(matricize(X, 2), matricize(X, -1))
    assert_array_almost_equal(matricize(X, 1), matricize(X, -2))
Beispiel #3
0
def test_matricize():
    """
    Test implementation of matricize. Data from
    http://www.graphanalysis.org/SIAM-PP08/Dunlavy.pdf
    """
    X = np.arange(1, 9).reshape(2, 2, 2)
    matricize(X, 0)
    assert_array_almost_equal(matricize(X, 2), matricize(X, -1))
    assert_array_almost_equal(matricize(X, 1), matricize(X, -2))
Beispiel #4
0
def test_matricize():
    """
    Test implementation of matricize. Data from
    http://www.graphanalysis.org/SIAM-PP08/Dunlavy.pdf
    """
    X = np.arange(1, 9).reshape(2, 2, 2)
    matricize(X, 0)
    assert_array_almost_equal(matricize(X, 2), matricize(X, -1))
    assert_array_almost_equal(matricize(X, 1), matricize(X, -2))