diff options
author | Jaime <jaime.frio@gmail.com> | 2017-04-02 00:16:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-02 00:16:53 +0200 |
commit | 02e4a57d73d093db347e5afbeaf23153a86f4136 (patch) | |
tree | 53afd72c1cd8bee99509470a962c0a62d6db82b8 /numpy/random/tests/test_random.py | |
parent | c93201acabd010bcd15464d058faa02da207a292 (diff) | |
parent | db2f5089fc5442ea8fca49188e2750a6c39b5664 (diff) | |
download | numpy-02e4a57d73d093db347e5afbeaf23153a86f4136.tar.gz |
Merge pull request #8883 from simongibbons/fix-uniform-error
BUG: Ensure Errors are correctly checked when PyFloat_AsDouble is called
Diffstat (limited to 'numpy/random/tests/test_random.py')
-rw-r--r-- | numpy/random/tests/test_random.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/random/tests/test_random.py b/numpy/random/tests/test_random.py index 09ed5bb54..9c098eef0 100644 --- a/numpy/random/tests/test_random.py +++ b/numpy/random/tests/test_random.py @@ -822,6 +822,20 @@ class TestRandomDist(TestCase): # DBL_MAX by increasing fmin a bit np.random.uniform(low=np.nextafter(fmin, 1), high=fmax / 1e17) + def test_uniform_propogates_exeptions(self): + # Tests that uniform correctly propogates exceptions + # when called with a type which throws when converted to + # a float + # + # Regression test for gh: 8865 + + class ThrowableType(np.ndarray): + def __float__(self): + raise ValueError + + x = np.array(1.0).view(ThrowableType) + assert_raises(ValueError, np.random.uniform, x, x) + def test_vonmises(self): np.random.seed(self.seed) actual = np.random.vonmises(mu=1.23, kappa=1.54, size=(3, 2)) |