예제 #1
0
def test_numpy():
    # Generate 10,000 uniformly distributed random numbers with numpy.
    num_list = np.random.uniform(0, 1, 10000)
    # Test that your mean is a proper numerical match to the numpy one.
    obs = mean(num_list)
    exp = np.mean(num_list)
    np.testing.assert_almost_equal(obs, exp)
예제 #2
0
파일: tests.py 프로젝트: amaslan/testing
def test_complex():
    # given that complex numbers are an unordered field
    # the arithmetic mean of complex numbers is meaningless
    num_list = [2 + 3j, 3 + 4j, -32 - 2j]
    obs = mean(num_list)
    exp = NotImplemented
    assert obs == exp
예제 #3
0
def test_numpy():
    # testing with numpy
    import numpy as np
    num_list = np.random.uniform(0, 10, 10000)
    obs = mean(num_list)
    exp = np.mean(num_list)
    np.testing.assert_almost_equal(obs, exp, decimal=10)
예제 #4
0
def test_uniform():
    # test the mean of 10,000 uniforms
    import numpy as np
    np.random.seed(259)
    unif_list = np.random.uniform(size=10000)
    obs = mean(unif_list)
    exp = np.mean(unif_list)
    assert np.isclose(obs, exp)
예제 #5
0
파일: tests.py 프로젝트: amaslan/testing
def test_ints():
    num_list = [1, 2, 3, 4, 5]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #6
0
파일: tests.py 프로젝트: amaslan/testing
def test_mean():
    assert mean([1]) == 1
예제 #7
0
파일: tests.py 프로젝트: amaslan/testing
def test_rand():
    x = np.random.uniform(size=10000)
    # npt.assert_almost_equal(mean(x), np.mean(x))
    npt.assert_allclose(mean(x), np.mean(x), rtol=1e-12)
예제 #8
0
파일: tests.py 프로젝트: amaslan/testing
def test_long():
    big = 100000000
    obs = mean(range(1, big))
    exp = big / 2.0
    assert obs == exp
예제 #9
0
파일: tests.py 프로젝트: amaslan/testing
def test_double():
    # This one will fail in Python 2
    num_list = [1, 2, 3, 4]
    obs = mean(num_list)
    exp = 2.5
    assert obs == exp
예제 #10
0
파일: tests.py 프로젝트: amaslan/testing
def test_zero():
    num_list = [0, 2, 4, 6]
    obs = mean(num_list)
    exp = 3
    assert obs == exp
예제 #11
0
파일: test.py 프로젝트: edwardguo61/Testing
def test_mean_random():
    data = np.random.rand(10000)
    npm = np.mean(data)
    mea = mean(data)
    assert np.isclose(npm,mea)
예제 #12
0
파일: tests.py 프로젝트: gabywang/testing
def test_npmean():
    np_list = np.random.uniform(size=10_000)
    obs = mean(np_list)
    exp = np.mean(np_list)
    np.testing.assert_allclose(obs, exp, rtol=1e-12)
예제 #13
0
def test_np_mean():
    uni = np.random.uniform(size=10_000)
    npt.assert_allclose(mean(uni), np.mean(uni))
예제 #14
0
파일: tests.py 프로젝트: tianxia1990/ttest
def test_numpy():
    import numpy as np
    nums = np.random.uniform(0, 1, 10000)
    np.testing.assert_allclose(np.mean(nums), mean(nums), atol=1e-07)
예제 #15
0
파일: tests.py 프로젝트: liampurvis/testing
def test_mean():
    array = np.random.uniform(0, 100, 10000)
    assert np.mean(array) == mean(array)
예제 #16
0
파일: tests.py 프로젝트: fperez/testing
def test_numpy():
    "Test against numpy's mean with a reasonably large array"
    npr = np.random.uniform(size=10_000)
    npm = npr.mean()
    mym = mean(npr)
    npt.assert_allclose(mym, npm, rtol=1e-12)