summaryrefslogtreecommitdiff
path: root/numpy/random/tests
Commit message (Collapse)AuthorAgeFilesLines
* BUG: One element array inputs get one element arrays returned in np.randomgfyoung2016-01-241-1/+86
| | | | | | | | | | | | | | | Fixes bug in np.random methods that would return scalars when passed one-element array inputs. This is because one-element ndarrays can be cast to integers / floats, which is what functions like PyFloat_AsDouble do before converting to the intended data type. This commit changes the check used to determine whether the inputs are purely scalar by converting all inputs to arrays and checking if the resulting shape is an empty tuple (scalar) or not (array). Closes gh-4263.
* TST: Added broadcasting tests in test_random.pygfyoung2016-01-231-81/+635
| | | | | | Added a whole new suite of tests to ensure that functions in mtrand.pyx which are broadcastable actually broadcast their arguments properly.
* Revert to non-generative test.Antony Lee2016-01-161-5/+4
|
* MAINT: memcpy-based ~4x faster, typed shuffle.Antony Lee2016-01-161-23/+28
| | | | | | | | | | | | Only for 1d-ndarrays exactly, as subtypes (e.g. masked arrays) may not allow direct shuffle of the underlying buffer (in fact, the old implementation destroyed the underlying values of masked arrays while shuffling). Also handles struct-containing-object 1d ndarrays properly. See #6776 for an earlier, less general (but even faster: ~6x) improvement attempt, #5514 for the original issue.
* DEP: Deprecate random_integersgfyoung2016-01-101-0/+16
|
* Merge pull request #6910 from charris/add-64-bit-random-intCharles Harris2016-01-031-0/+77
|\ | | | | ENH: Add dtype argument to random.randint.
| * TST: Add tests for new randint functionality.Charles Harris2016-01-021-0/+77
| | | | | | | | | | | | | | | | | | | | * check exceptions * check extreme bounds are reachable * check that all values are in the specified bounds * check repeatability of sequences More exact statistical tests would be nice, but that is another project.
* | MAINT: Cleaned up unused variables and spelling mistakes in np.random modulesgfyoung2015-12-291-1/+1
|/
* ENH: Allow random_integers to include the maximum np.iinfo('l').maxgfyoung2015-12-281-0/+11
| | | | | | | Redistributes the code between the randint and random_integers methods so that we can generate integers up to and including np.iinfo('l').max with random_integers, which previously would have caused an OverflowError.
* MAINT: minor spelling and grammar correctionsgfyoung2015-12-161-3/+3
|
* MAINT: random: allow nonc==0 in noncentral_chisquare.Evgeni Burovski2015-11-021-0/+7
| | | | | Noncentral chi-square reduces to a central chi-square, so just defer to that.
* TST: fix OverflowError on win-amd64Christoph Gohlke2015-08-011-1/+1
|
* MAINT: adjust tolerance for validating the sum of probs in random.choicealex2015-07-291-1/+13
|
* BUG: np.random.beta with small parameters produces NaNsJaime Fernandez2015-05-101-0/+8
| | | | Fixes #5851
* BUG: Fixes random.noncentral_chisquare when 0 < df <= 1behzad nouri2015-04-271-0/+6
| | | | Closes #5766.
* BUG: Fix potential overflows in rk_hypergeometric_hrua()Anton Ovchinnikov2015-03-031-0/+11
|
* Throws if range is too large for 'random.uniform'Masud Rahman2014-09-281-0/+12
| | | | | | | | This fixes issue #2138 by checking that the range (i.e. high - low) is finite before invoking `rk_uniform`. A test case was added to ensure valid ranges do not throw, but invalid ranges do.
* TST: gnufreebsd has fixed the thread control word lossJulian Taylor2014-09-141-3/+1
| | | | http://lists.alioth.debian.org/pipermail/glibc-bsd-commits/2014-September/004163.html
* Merge pull request #5051 from juliantaylor/thread-test-fixCharles Harris2014-09-061-1/+8
|\ | | | | TST: accept small error in threaded random test
| * TST: accept small error in threaded random testJulian Taylor2014-09-061-1/+8
| | | | | | | | | | | | | | freebsd and windows change x87 precision mode (fctrl bit 8 and 9) from extended to double in child threads so the random numbers cannot be exactly the same from master and child threads. see gh-4909
* | STY: PEP8 fixups for numpy/random.Charles Harris2014-07-312-166/+163
|/
* BUG: avoid infinite loop for small kappa in vonmisesJulian Taylor2014-05-281-0/+6
| | | | | | | rho results in 0. for kappa < 1.4e-8 whch leads to nans appearing and an infinite loop. the second order taylor expansion is more precise up to at least 1e-5. Closes gh-4720
* BUG: reject too large seeds to RandomStateJulian Taylor2014-05-151-0/+29
| | | | | | mtrand accepts seeds larger than 32 bit but silently truncates them back to 32 bit. This can lead to accidentally getting the same random stream for two different seeds, e.g. 1 and 1 + 2**40.
* ENH: replace GIL of random module with a per state lockJulian Taylor2014-05-021-0/+40
| | | | | | | | | | | | | | | The random module currently relies on the GIL for the state synchronization which hampers threading performance. Instead add a lock to the RandomState object and take it for all operations calling into randomkit while releasing the GIL. This allows parallizing random number generation using multiple states or asynchronous generation in a worker thread. Note that with a large number of threads the standard mersenne twister used may exhibit overlap if the number of parallel streams is large compared to the size of the state space, though due to the limited scalability of Python in regards to threads this is likely not a big issue.
* BUG: Explicitly reject nan values for p in binomial(n, p). Fixes #4571.Daniel da Silva2014-04-041-0/+4
| | | | Adds check with np.isnan(p) and raises ValueError if check is positive.
* TST: Add some tests for random.multivariate_normal.Charles Harris2014-03-221-10/+23
| | | | | | | | Explicitly Test that the default shape does not raise a DeprecationWarning. Check that a covariance matrix that is not positive-semidefinite raises a RuntimeWarning.
* BUG: handle non integer types for multinomial/dirichlet sizeJulian Taylor2014-02-221-1/+27
| | | | Closes gh-3173
* BUG: fix shuffling of flexible dtypes and masked arraysJulian Taylor2014-02-131-0/+23
| | | | | closes gh-4270 and gh-3263 also regenerate with cython 0.20.1
* STY: Giant comma spacing fixup.Charles Harris2013-08-181-31/+31
| | | | | | | Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long and will need to be broken at some point. OTOH, some lines were already too long and need to be broken at some point. Now seems as good a time as any to do this with open PRs at a minimum.
* BUG: numpy.random.binomial raised ValueError for n == 0HaroldMills2013-06-281-0/+11
| | | | | | Range test for n was incorrect. Closes #3480
* ENH: random: Allow ngood=0 or nbad=0 in mtrand.hypergeometric.Warren Weckesser2013-06-131-0/+18
| | | | | Also edited the 'Parameters' section of the docstring to comply with the numpy docstring standard.
* Merge pull request #3243 from seberg/deprecate-non-integer-arguments-newCharles Harris2013-06-091-1/+1
|\ | | | | Deprecate non integer arguments
| * STY: Style fixes for integer deprecation changesSebastian Berg2013-06-091-1/+1
| | | | | | | | Also minor changes in the documentation.
| * MAINT: adept divisions for truedivideSebastian Berg2013-05-311-1/+1
| | | | | | | | Following deprecations would cause problems otherwise.
* | TST: remove docstrings from test_ functionsChristoph Gohlke2013-05-271-13/+8
| | | | | | | | See doc/TESTS.rst.txt for the reason.
* | BUG: Fix multivariate_normal issue with 'size' argumentChristoph Gohlke2013-05-271-5/+16
| | | | | | | | Ensure that the multivariate_normal size argument can be a numpy integer. Add regression test. Apply PEP8 to test_regression.py. Regenerate mtrand.c.
* | TST: remove docstring from test_randint_range functionChristoph Gohlke2013-05-271-1/+1
| | | | | | See doc/TESTS.rst.txt for the reason.
* | TST: rename one test_hypergeometric_range functionChristoph Gohlke2013-05-271-1/+1
|/ | | There are two test functions named `test_hypergeometric_range`
* 2to3: Apply the `numliterals` fixer and skip the `long` fixer.Charles Harris2013-04-131-1/+2
| | | | | | | | | | | | | | | | | | | The numliterals fixer replaces the old style octal number like '01' by '0o1' removes the 'L' suffix. Octal values were previously mistakenly specified in some dates, those uses have been corrected by removing the leading zeros. Simply Removing the 'L' suffix should not be a problem, but in some testing code it looks neccesary, so in those places the Python long constructor is used instead. The 'long' type is no longer defined in Python 3. Because we need to have it defined for Python 2 it is added to numpy/compat/np3k.py where it is defined as 'int' for Python 3 and 'long' for Python 2. The `long` fixer then needs to be skipped so that it doesn't undo the good work. Closes #3074, #3067.
* 2to3: Apply `print` fixer.Charles Harris2013-04-062-2/+2
| | | | | | | Add `print_function` to all `from __future__ import ...` statements and use the python3 print function syntax everywhere. Closes #3078.
* 2to3: Use absolute imports.Charles Harris2013-03-282-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new import `absolute_import` is added the `from __future__ import` statement and The 2to3 `import` fixer is run to make the imports compatible. There are several things that need to be dealt with to make this work. 1) Files meant to be run as scripts run in a different environment than files imported as part of a package, and so changes to those files need to be skipped. The affected script files are: * all setup.py files * numpy/core/code_generators/generate_umath.py * numpy/core/code_generators/generate_numpy_api.py * numpy/core/code_generators/generate_ufunc_api.py 2) Some imported modules are not available as they are created during the build process and consequently 2to3 is unable to handle them correctly. Files that import those modules need a bit of extra work. The affected files are: * core/__init__.py, * core/numeric.py, * core/_internal.py, * core/arrayprint.py, * core/fromnumeric.py, * numpy/__init__.py, * lib/npyio.py, * lib/function_base.py, * fft/fftpack.py, * random/__init__.py Closes #3172
* Merge pull request #2992 from seberg/choice-object-scalarseberg2013-03-041-1/+12
|\ | | | | BUG: fix random.choice scalar object result and disallow 0-d arrays
| * BUG: fix random.choice scalar object result and disallow 0-d arraysSebastian Berg2013-03-041-1/+12
| | | | | | | | | | | | | | | | | | | | | | Object arrays failed due to bad check for finding out if the result should be a scalar type and not an array when size=None. Also in this case the creation of the new array was wrong. This should be fixed with this. The second fix is to forbid 0-d arrays. Allowing 0-d arrays does not make much sense. But it is dangerous because for example floats will be interpreted as 1-d arrays, while one may expect that they are interpreted as integers. This also saves the trouble of reliably detecting all integers...
* | 2to3: Put `from __future__ import division in every python file.Charles Harris2013-03-012-0/+4
|/ | | | | | | | This should be harmless, as we already are division clean. However, placement of this import takes some care. In the future a script can be used to append new features without worry, at least until such time as it exceeds a single line. Having that ability will make it easier to deal with absolute imports and printing updates.
* BUG: internal call fix in random.choiceSebastian Berg2012-12-151-0/+10
| | | | | | An random.random call from within mtrand was done by a call to np.random.random instead of inside the class. This can possibly lead to non-deterministic results after seeding.
* TST: Add tests for new feature and fix in random.choiceSebastian Berg2012-12-061-1/+27
|
* FIX: loosen numerical tolerance in test_pareto()Nathaniel J. Smith2012-09-071-1/+7
| | | | | | | | | | | | | | | | | The problem was that in 32bit Ubuntu 12.04, one gets the following: > /home/njs/numpy/.tox/py27/local/lib/python2.7/site-packages/numpy/random/tests/test_random.py(363)test_pareto() -> np.testing.assert_array_almost_equal(actual, desired, decimal=15) (Pdb) actual[1, 0] 52828779.702948704 (Pdb) desired[1, 0] 52828779.702948518 and the test was comparing the numbers to 1e-14, which obviously failed. Fixes #424.
* [FIX] Make np.random.shuffle less brain-deadNathaniel J. Smith2012-07-172-6/+21
| | | | | | | | | The logic in np.random.shuffle was... not very sensible. Fixes trac ticket #2074. This patch also exposes a completely unrelated issue in numpy.testing. Filed as Github issue #347 and marked as knownfail for now.
* FIX: Add release notes, use inverse cdf method for non-uniformChris Jordan-Squire2011-12-171-1/+1
| | | | | sampling with replacement, change searchsorted to use side='right', and regenerate mtrand.c.
* FIX: Changed named to choice, reverted other changes.Chris Jordan-Squire2011-12-171-12/+12
|