Example #1
0
def test_depend_views(data):
    mvmds = MVMDS()
    fit = mvmds.fit_transform(data['dep_views'])
    
    for i in range(fit.shape[0]):
        for j in range(fit.shape[1]):     
            assert math.isnan(fit[i,j])
Example #2
0
def test_fit_transform_values(data):
    mvmds = MVMDS(len(data['samp_views'][0]))
    comp = mvmds.fit_transform(data['samp_views'])
    comp2 = np.array([[-0.81330129, 0.07216426, 0.57735027],
                      [0.34415456, -0.74042171, 0.57735027],
                      [0.46914673, 0.66825745, 0.57735027]])

    for i in range(comp.shape[0]):
        for j in range(comp.shape[1]):
            assert comp[i, j] - comp2[i, j] < .000001
Example #3
0
def test_fit_transform_values(data):
    n_components = len(data['samp_views'][0])
    mvmds = MVMDS(n_components = n_components)
    comp = mvmds.fit_transform(data['samp_views'])
    comp2 = np.array([[-0.81330129,  0.07216426,  0.5773503],
                      [0.34415456, -0.74042171,  0.5773503],
                      [0.46914673,  0.66825745, 0.5773503]])
    
    # Last component calculation varies across Python implementations.
    np.testing.assert_almost_equal(
        np.abs(comp[:,:n_components-1]),
        np.abs(comp2[:,:n_components-1])
    )
Example #4
0
def test_dissimilarity_precomputed_euclidean(data):
    test_views = []
    for i in data['samp_views']:
        test_views.append(euclidean_distances(i))
    mvmds1 = MVMDS(dissimilarity='euclidean')
    mvmds2 = MVMDS(dissimilarity='precomputed')

    fit1 = mvmds1.fit_transform(data['samp_views'])
    fit2 = mvmds2.fit_transform(test_views)

    np.testing.assert_almost_equal(np.abs(fit2), np.abs(fit1))
Example #5
0
def test_fit_transform_values_neg():
    with pytest.raises(ValueError):
        MVMDS(n_components=-4)
Example #6
0
def test_fit_transformdifferent_wrong_samples(data):
    with pytest.raises(ValueError):
       
        mvmds = MVMDS()
        mvmds.fit_transform(data['wrong_views'])
Example #7
0
def test_component_num_greater(data):
    mvmds = MVMDS(n_components = len(data['random_views'][0] + 1))
    comp = mvmds.fit_transform(data['random_views'])
    
    assert len(comp) == len(data['random_views'][0])       
Example #8
0
def test_dissimilarity_euclidean():
    with pytest.raises(ValueError):
        MVMDS(n_components=-3)
Example #9
0
def test_dissimilarity_wrong():
    with pytest.raises(ValueError):
        MVMDS(dissimilarity=3)
Example #10
0
def test_num_iter_value_fail():
    with pytest.raises(ValueError):
        MVMDS(num_iter=0)
Example #11
0
def test_fit_transform_values_0(data):
    with pytest.raises(ValueError):

        mvmds = MVMDS(n_components=0)
        comp = mvmds.fit_transform(data['samp_views'])
Example #12
0
def check_num_iter(data):
    with pytest.raises(ValueError):

        mvmds = MVMDS(n_components=-3)
        comp = mvmds.fit_transform(data['samp_views'])