""" 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))
def test_float_n_minor(): with pytest.raises(NameError): data_normal(mu, sd, 0)
def test_result(): data = data_normal(mu, sd, n) np.testing.assert_allclose(np.mean(data), out, rtol=inc)
def test_float_n(): with pytest.raises(TypeError): data_normal(mu, sd, float(n))
def test_type_n(): with pytest.raises(TypeError): data_normal(mu, sd, str(n))
def test_type_b(): with pytest.raises(TypeError): data_normal(mu, str(sd), n)
def test_type_a(): with pytest.raises(TypeError): data_normal(str(mu), sd, n)
def test_data_len(): data = data_normal(mu, sd, n) assert (len(data) == n)