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])
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
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]) )
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))
def test_fit_transform_values_neg(): with pytest.raises(ValueError): MVMDS(n_components=-4)
def test_fit_transformdifferent_wrong_samples(data): with pytest.raises(ValueError): mvmds = MVMDS() mvmds.fit_transform(data['wrong_views'])
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])
def test_dissimilarity_euclidean(): with pytest.raises(ValueError): MVMDS(n_components=-3)
def test_dissimilarity_wrong(): with pytest.raises(ValueError): MVMDS(dissimilarity=3)
def test_num_iter_value_fail(): with pytest.raises(ValueError): MVMDS(num_iter=0)
def test_fit_transform_values_0(data): with pytest.raises(ValueError): mvmds = MVMDS(n_components=0) comp = mvmds.fit_transform(data['samp_views'])
def check_num_iter(data): with pytest.raises(ValueError): mvmds = MVMDS(n_components=-3) comp = mvmds.fit_transform(data['samp_views'])