Esempio n. 1
0
"""
Jaime Sendra Berenguer-2020.
MLearner Machine Learning Library Extensions
Author:Jaime Sendra Berenguer<www.linkedin.com/in/jaisenbe>
License: MIT
"""

import numpy as np
import pytest
from mlearner.data import data_uniform, data_normal, data_gamma, create_dataset

n = 1000
config = {
    'A': data_uniform(0, 1, n),
    'B': data_normal(n),
    'C': data_normal(mu=5, sd=2, n=n),
    'D': data_gamma(a=5, n=n)
}
config_bad = np.array([1, 2, 3])


def test_config_bad():
    with pytest.raises(TypeError):
        create_dataset(config_bad, n)


def test_type_n():
    with pytest.raises(TypeError):
        create_dataset(config, float(n))

Esempio n. 2
0
def test_float_n_minor():
    with pytest.raises(NameError):
        data_normal(mu, sd, 0)
Esempio n. 3
0
def test_result():
    data = data_normal(mu, sd, n)
    np.testing.assert_allclose(np.mean(data), out, rtol=inc)
Esempio n. 4
0
def test_float_n():
    with pytest.raises(TypeError):
        data_normal(mu, sd, float(n))
Esempio n. 5
0
def test_type_n():
    with pytest.raises(TypeError):
        data_normal(mu, sd, str(n))
Esempio n. 6
0
def test_type_b():
    with pytest.raises(TypeError):
        data_normal(mu, str(sd), n)
Esempio n. 7
0
def test_type_a():
    with pytest.raises(TypeError):
        data_normal(str(mu), sd, n)
Esempio n. 8
0
def test_data_len():
    data = data_normal(mu, sd, n)
    assert (len(data) == n)