예제 #1
0
def test_median_axis_none_mask_none():
    for i in range(25):
        size = np.random.randint(1, 10000)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size)
        expected = np.median(a.astype(np.float32))
        actual = stats.median(a)
        assert np.float32(expected) == actual
예제 #2
0
파일: test_stats.py 프로젝트: Fingel/banzai
def test_median_axis_none_mask_none():
    for i in range(25):
        size = np.random.randint(1, 10000)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size)
        expected = np.median(a.astype(np.float32))
        actual = stats.median(a)
        assert np.float32(expected) == actual
예제 #3
0
def test_median_2d_axis_1_mask_none(set_random_seed):
    for i in range(5):
        size1 = np.random.randint(1, 300)
        size2 = np.random.randint(5, 300)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size=(size1, size2))
        expected = np.median(a.astype(np.float32), axis=1)
        actual = stats.median(a, axis=1)
        np.testing.assert_allclose(actual, expected.astype(np.float32), atol=1e-6)
예제 #4
0
파일: test_stats.py 프로젝트: Fingel/banzai
def test_median_2d_axis_1_mask_none():
    for i in range(5):
        size1 = np.random.randint(1, 300)
        size2 = np.random.randint(1, 300)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size=(size1, size2))
        expected = np.median(a.astype(np.float32), axis=1)
        actual = stats.median(a, axis=1)
        np.testing.assert_allclose(actual, expected.astype(np.float32), atol=1e-6)
예제 #5
0
def test_median_2d_axis_none_mask_none(set_random_seed):
    for i in range(5):
        size1 = np.random.randint(1, 300)
        size2 = np.random.randint(1, 300)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size=(size1, size2))
        expected = np.median(a.astype(np.float32))
        actual = stats.median(a)
        assert np.float32(expected) == actual
예제 #6
0
def test_median_axis_none_mask():
    for i in range(25):
        size = np.random.randint(1, 10000)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size)
        value_to_mask = np.random.uniform(0, 1.0)
        mask = np.random.uniform(0, 1, size) < value_to_mask
        expected = ma.median(ma.array(a, mask=mask, dtype=np.float32))
        actual = stats.median(a, mask=mask)
        assert np.float32(expected) == actual
예제 #7
0
파일: test_stats.py 프로젝트: Fingel/banzai
def test_median_axis_none_mask():
    for i in range(25):
        size = np.random.randint(1, 10000)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size)
        value_to_mask = np.random.uniform(0, 1.0)
        mask = np.random.uniform(0, 1, size) < value_to_mask
        expected = ma.median(ma.array(a, mask=mask, dtype=np.float32))
        actual = stats.median(a, mask=mask)
        assert np.float32(expected) == actual
예제 #8
0
파일: test_stats.py 프로젝트: LCOGT/banzai
def test_median_3d_axis_2_mask_none(set_random_seed):
    for i in range(5):
        size1 = np.random.randint(1, 50)
        size2 = np.random.randint(1, 50)
        size3 = np.random.randint(5, 50)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size=(size1, size2, size3))
        expected = np.median(a.astype(np.float32), axis=2)
        actual = stats.median(a, axis=2)
        np.testing.assert_allclose(actual, expected.astype(np.float32), atol=1e-6)
예제 #9
0
파일: test_stats.py 프로젝트: Fingel/banzai
def test_median_2d_axis_1_mask():
    for i in range(5):
        size1 = np.random.randint(1, 300)
        size2 = np.random.randint(1, 300)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        value_to_mask = np.random.uniform(0, 1)
        mask = np.random.uniform(0., 1.0, size=(size1, size2)) < value_to_mask
        a = np.random.normal(mean, sigma, size=(size1, size2))
        expected = ma.median(ma.array(a, mask=mask, dtype=np.float32), axis=1)
        actual = stats.median(a, mask=mask, axis=1)
        np.testing.assert_allclose(actual, expected.astype(np.float32), atol=1e-6)
예제 #10
0
def test_median_2d_axis_1_mask(set_random_seed):
    for i in range(5):
        size1 = np.random.randint(1, 300)
        size2 = np.random.randint(5, 300)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        value_to_mask = np.random.uniform(0, 1)
        mask = np.random.uniform(0., 1.0, size=(size1, size2)) < value_to_mask
        a = np.random.normal(mean, sigma, size=(size1, size2))
        expected = ma.median(ma.array(a, mask=mask, dtype=np.float32), axis=1)
        actual = stats.median(a, mask=mask, axis=1)
        np.testing.assert_allclose(actual, expected.astype(np.float32), atol=1e-6)
예제 #11
0
def test_median_2d_axis_none_mask(set_random_seed):
    for i in range(5):
        size1 = np.random.randint(1, 300)
        size2 = np.random.randint(1, 300)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        value_to_mask = np.random.uniform(0, 1)
        mask = np.random.uniform(0, 1, size=(size1, size2)) < value_to_mask
        a = np.random.normal(mean, sigma, size=(size1, size2))
        expected = ma.median(ma.array(a, mask=mask, dtype=np.float32))
        actual = stats.median(a, mask=mask)
        assert np.float32(expected) == actual
예제 #12
0
def test_median_3d_axis_2_mask_none():
    for i in range(5):
        size1 = np.random.randint(1, 50)
        size2 = np.random.randint(1, 50)
        size3 = np.random.randint(1, 50)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        a = np.random.normal(mean, sigma, size=(size1, size2, size3))
        expected = np.median(a.astype(np.float32), axis=2)
        actual = stats.median(a, axis=2)
        np.testing.assert_allclose(actual,
                                   expected.astype(np.float32),
                                   atol=1e-6)
예제 #13
0
파일: test_stats.py 프로젝트: LCOGT/banzai
def test_median_3d_axis_2_mask(set_random_seed):
    for i in range(5):
        size1 = np.random.randint(1, 50)
        size2 = np.random.randint(1, 50)
        size3 = np.random.randint(5, 50)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        value_to_mask = np.random.uniform(0, 1)
        mask = np.random.uniform(0, 1, size=(size1, size2, size3)) < value_to_mask
        a = np.random.normal(mean, sigma, size=(size1, size2, size3))
        expected = ma.median(ma.array(a, mask=mask, dtype=np.float32), axis=2)
        actual = stats.median(a, mask=mask, axis=2)
        np.testing.assert_allclose(actual, expected.astype(np.float32), atol=1e-6)
예제 #14
0
def test_median_3d_axis_2_mask():
    for i in range(5):
        size1 = np.random.randint(1, 50)
        size2 = np.random.randint(1, 50)
        size3 = np.random.randint(1, 50)
        mean = np.random.uniform(-1000, 1000)
        sigma = np.random.uniform(0, 1000)
        value_to_mask = np.random.uniform(0, 1)
        mask = np.random.uniform(0, 1,
                                 size=(size1, size2, size3)) < value_to_mask
        a = np.random.normal(mean, sigma, size=(size1, size2, size3))
        expected = ma.median(ma.array(a, mask=mask, dtype=np.float32), axis=2)
        actual = stats.median(a, mask=mask, axis=2)
        np.testing.assert_allclose(actual,
                                   expected.astype(np.float32),
                                   atol=1e-6)