Python matplotlib.mlab.prctile() Examples

The following are 5 code examples of matplotlib.mlab.prctile(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module matplotlib.mlab , or try the search function .
Example #1
Source File: test_mlab.py    From neural-network-animation with MIT License 6 votes vote down vote up
def test_prctile(self):
        # test odd lengths
        x = [1, 2, 3]
        assert_equal(mlab.prctile(x, 50), np.median(x))

        # test even lengths
        x = [1, 2, 3, 4]
        assert_equal(mlab.prctile(x, 50), np.median(x))

        # derived from email sent by jason-sage to MPL-user on 20090914
        ob1 = [1, 1, 2, 2, 1, 2, 4, 3, 2, 2, 2, 3,
               4, 5, 6, 7, 8, 9, 7, 6, 4, 5, 5]
        p = [0, 75, 100]
        expected = [1, 5.5, 9]

        # test vectorized
        actual = mlab.prctile(ob1, p)
        assert_allclose(expected, actual)

        # test scalar
        for pi, expectedi in zip(p, expected):
            actuali = mlab.prctile(ob1, pi)
            assert_allclose(expectedi, actuali) 
Example #2
Source File: test_mlab.py    From ImageFusion with MIT License 6 votes vote down vote up
def test_prctile(self):
        # test odd lengths
        x = [1, 2, 3]
        assert_equal(mlab.prctile(x, 50), np.median(x))

        # test even lengths
        x = [1, 2, 3, 4]
        assert_equal(mlab.prctile(x, 50), np.median(x))

        # derived from email sent by jason-sage to MPL-user on 20090914
        ob1 = [1, 1, 2, 2, 1, 2, 4, 3, 2, 2, 2, 3,
               4, 5, 6, 7, 8, 9, 7, 6, 4, 5, 5]
        p = [0, 75, 100]
        expected = [1, 5.5, 9]

        # test vectorized
        actual = mlab.prctile(ob1, p)
        assert_allclose(expected, actual)

        # test scalar
        for pi, expectedi in zip(p, expected):
            actuali = mlab.prctile(ob1, pi)
            assert_allclose(expectedi, actuali) 
Example #3
Source File: test_mlab.py    From python3_ios with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_prctile(input, percentile):
    with pytest.warns(MatplotlibDeprecationWarning):
        assert_allclose(mlab.prctile(input, percentile),
                        np.percentile(input, percentile)) 
Example #4
Source File: test_mlab.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_prctile(input, percentile):
    with pytest.warns(MatplotlibDeprecationWarning):
        assert_allclose(mlab.prctile(input, percentile),
                        np.percentile(input, percentile)) 
Example #5
Source File: test_mlab.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_prctile(input, percentile):
    with pytest.warns(MatplotlibDeprecationWarning):
        assert_allclose(mlab.prctile(input, percentile),
                        np.percentile(input, percentile))