Пример #1
0
def test_plot_3d_animate():
    data_reduced_3d = reduc(data, ndims=3)
    _, _, data_3d, _ = plot.plot(data_reduced_3d,
                                 animate=True,
                                 show=False,
                                 return_data=True)
    assert all([i.shape[1] == 3 for i in data_3d])
Пример #2
0
def test_reduce_assert_exception():
    with pytest.raises(Exception) as e_info:
        reduc(data, ndims=4)
Пример #3
0
# -*- coding: utf-8 -*-

import pytest

import numpy as np

from hypertools.tools.reduce import reduce as reduc

data = [
    np.random.multivariate_normal(np.zeros(4), np.eye(4), size=100)
    for i in range(2)
]
reduced_data_3d = reduc(data)
reduced_data_2d = reduc(data, ndims=2)
reduced_data_1d = reduc(data, ndims=1)


def test_reduce_is_list():
    assert type(reduced_data_3d) is list


def test_reduce_is_array():
    assert isinstance(reduced_data_3d[0], np.ndarray)


def test_reduce_dims_3d():
    assert reduced_data_3d[0].shape == (100, 3)


def test_reduce_dims_2d():
    assert reduced_data_2d[0].shape == (100, 2)
Пример #4
0
def test_reduce_dims_1d_align():
    # Should return aligned data that is reduced to 1 dim
    reduced_aligned_data_1d = reduc(data, ndims=1, align=True)
    assert all(rad.shape == (100, 1) for rad in reduced_aligned_data_1d)
Пример #5
0
def test_reduce_dims_2d_align():
    # Should return aligned data that is reduced to 2 dims
    reduced_aligned_data_2d = reduc(data, ndims=2, align=True)
    assert all(rad.shape == (100, 2) for rad in reduced_aligned_data_2d)
Пример #6
0
def test_reduce_dims_3d_align():
    # Should return aligned data that is reduced to 3 dims
    reduced_aligned_data_3d = reduc(data, align=True)
    assert all(rad.shape == (100, 3) for rad in reduced_aligned_data_3d)
Пример #7
0
def test_plot_3d():
    data_reduced_3d = reduc(data, ndims=3)
    _, _, data_3d, _ = plot.plot(data_reduced_3d, show=False)
    assert all([i.shape[1] == 3 for i in data_3d])
Пример #8
0
def test_plot_2d():
    data_reduced_2d = reduc(data, ndims=2)
    _, _, data_2d, _ = plot.plot(data_reduced_2d, show=False)
    assert all([i.shape[1] == 2 for i in data_2d])
Пример #9
0
def test_plot_1d():
    data_reduced_1d = reduc(data, ndims=1)
    _, _, data_1d, _ = plot.plot(data_reduced_1d, show=False)
    assert all([i.shape[1] == 1 for i in data_1d])
Пример #10
0
def test_plot_2d_animate():
    data_reduced_2d = reduc(data, ndims=2)
    with pytest.raises(Exception) as e_info:
        plot.plot(data_reduced_2d, animate=True, show=False)
Пример #11
0
def test_plot_1d_animate():
    data_reduced_1d = reduc(data, ndims=1)
    with pytest.raises(Exception) as e_info:
        plot.plot(data_reduced_1d, animate=True, show=False, return_data=True)