

def test_correct_RandomProjection_dimensions_embedding():
    for RandomProjection in all_RandomProjection:
        rp = RandomProjection(n_components='auto', random_state=0, eps=0.5).fit(data)
        assert_equal(rp.n_components, 'auto')
        assert_equal(rp.n_components_, 110)
        if (RandomProjection in all_SparseRandomProjection):
            assert_equal(rp.density, 'auto')
            assert_almost_equal(rp.density_, 0.03, 2)
        assert_equal(rp.components_.shape, (110, n_features))
        projected_1 = rp.transform(data)
        assert_equal(projected_1.shape, (n_samples, 110))
        projected_2 = rp.transform(data)
        assert_array_equal(projected_1, projected_2)
        rp2 = RandomProjection(random_state=0, eps=0.5)
        projected_3 = rp2.fit_transform(data)
        assert_array_equal(projected_1, projected_3)
        assert_raises(ValueError, rp.transform, data[:, 1:5])
        if (RandomProjection in all_SparseRandomProjection):
            rp = RandomProjection(n_components=100, density=0.001, random_state=0)
            projected = rp.fit_transform(data)
            assert_equal(projected.shape, (n_samples, 100))
            assert_equal(rp.components_.shape, (100, n_features))
            assert_less(rp.components_.nnz, 115)
            assert_less(85, RandomProjection.components_.nnz)

dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/tests/test_random_projection.py test_correct_RandomProjection_dimensions_embedding/VarMisuse@264/367 `rp`->`RandomProjection`