Example #1
0
def test_matrix_of_pairs():
    dic = {(2, 2): 0.22, (3, 2): 0.10, (2, 3): .03}
    mat = matrix_of_pairs(dic)
    mat_actual = np.array([
        [.22, 0.03],
        [0.1, 0]
    ])
    assert np.array_equal(mat, mat_actual)
Example #2
0
def test_compute_correlations():

    n = 1000
    nspikes = 3 * n
    clusters = np.repeat([0, 1, 2],  n)
    features = np.zeros((nspikes, 2))
    masks = np.ones((nspikes, 2))

    # clusters 0 and 1 are close, 2 is far away from 0 and 1
    features[:n, :] = np.random.randn(n, 2)
    features[n:2*n, :] = np.random.randn(n, 2)
    features[2*n:, :] = np.array([[10, 10]]) + np.random.randn(n, 2)

    # compute the correlation matrix
    correlations = compute_correlations(features, clusters, masks)
    matrix = matrix_of_pairs(correlations)

    # check that correlation between 0 and 1 is much higher than the
    # correlation between 2 and 0/1
    assert matrix[0,1] > 100 * matrix[0, 2]
    assert matrix[0,1] > 100 * matrix[1, 2]
Example #3
0
def test_compute_correlations():

    n = 1000
    nspikes = 3 * n
    clusters = np.repeat([0, 1, 2], n)
    features = np.zeros((nspikes, 2))
    masks = np.ones((nspikes, 2))

    # clusters 0 and 1 are close, 2 is far away from 0 and 1
    features[:n, :] = np.random.randn(n, 2)
    features[n:2 * n, :] = np.random.randn(n, 2)
    features[2 * n:, :] = np.array([[10, 10]]) + np.random.randn(n, 2)

    # compute the correlation matrix
    correlations = compute_correlations(features, clusters, masks)
    matrix = matrix_of_pairs(correlations)

    # check that correlation between 0 and 1 is much higher than the
    # correlation between 2 and 0/1
    assert matrix[0, 1] > 100 * matrix[0, 2]
    assert matrix[0, 1] > 100 * matrix[1, 2]