summaryrefslogtreecommitdiff
path: root/numpy/random/tests
Commit message (Collapse)AuthorAgeFilesLines
* Port error to RandomStateKevin Sheppard2021-02-262-1/+9
|
* ENH: Improve error message in multinomialKevin Sheppard2021-02-261-0/+8
| | | | | | | | Improve error message when the sum of pvals is larger than 1 when the input data is an ndarray closes #8317 xref #16732
* BUG: Prevent RandomState from changingKevin Sheppard2021-02-265-12/+32
| | | | | | | | Apply vonmises fix only to Generator Add tests for correctness closes #17378 closes #17275
* Added test for [-np.pi, np.pi] range for the von mises distribution using ↵Raúl Montón Pinillos2021-02-263-0/+9
| | | | large values of kappa (>1e6)
* TST: Add test for shuffle warning and assert stacklevelSebastian Berg2021-02-191-0/+12
| | | | | | | The test checks that the warning originates in the correct file (test_random.py). I am not quite sure how safe the test is, though. Unfortunately, there is no "obvious" way to test stacklevels.
* BUG: Remove check in shuffle for non-ndarraysKevin Sheppard2021-02-111-0/+8
| | | | | | Remove ndim for non-ndarrays and check axis is 0 closes #18142
* MAINT: gracefully shuffle memoryviewsTyler Reddy2021-02-011-0/+15
| | | | | | * allow graceful shuffling of memoryviews, with same behavior as arrays, instead of producing a warning on `memoryview` shuffle
* BUG: shuffling empty array with axis=1 was brokenRalf Gommers2021-01-232-2/+19
| | | | | | | | | | | | | This would trigger: ``` NotImplementedError: Axis argument is only supported on ndarray objects ``` because empty arrays and array scalars would take the "untyped" path. The bug exists only for Generator, not in RandomState (it doesn't have axis keyword for `shuffle`), but update both because it keeps implementations in sync and the change results in more understandable code also for RandomState.
* Revert changes to mtrandKevin Sheppard2020-12-112-6/+9
| | | | This doesn't qualify for fixing under the NEP.
* BUG: Enforce high >= low on uniform number generatorsKevin Sheppard2020-12-112-0/+12
| | | | | | Check that high is weakly larger than low and raise if now closes #17905
* TST: Make test suite work in FIPS (140-2) ModeNikola Forró2020-10-293-69/+69
| | | | | | | | | Tests using MD5 algorithms fail in FIPS Mode because MD5 is not FIPS compliant. Replace MD5 with SHA256 to overcome that. Signed-off-by: Nikola Forró <nforro@redhat.com>
* conversion of strings to fstringsJakob2020-10-245-13/+12
|
* ENH: random: Add the method `permuted` to Generator. (#15121)Warren Weckesser2020-09-021-0/+50
| | | | | | | | | | | * ENH: random: Make _shuffle_raw and _shuffle_int standalone functions. * ENH: random: Add the method `permuted` to Generator. The method permuted(x, axis=None, out=None) shuffles an array. Unlike the existing shuffle method, it shuffles the slices along the given axis independently. Closes gh-5173.
* BUG: Validate output size in bin- and multinomialKevin Sheppard2020-07-142-0/+20
| | | | | | Check that size is not being broadcast closes #16833
* BLD: update cython to 0.29.21mattip2020-07-101-2/+2
|
* BUG: Ensure SeedSequence 0-padding does not collide with spawn keysRobert Kern2020-06-091-1/+27
| | | | | | | | | | | | | Fixes #16539 The implicit 0-padding that is done to small entropy inputs to make them the size of the internal pool conflicts with the spawn keys, which start with an appended 0. In order to maintain stream compatibility with unspawned `SeedSequence`s, we explicitly 0-pad short inputs out to the pool size only if the spawn key is provided, and thus would trigger the bug. This should minimize the impact on users that were not encountering the bug.
* BUG: Correct broadcasting when size is not NoneKevin Sheppard2020-06-051-0/+41
| | | | | | | Broadcastable size with inputs does not produce an error when size produces a smaller output array than the broadcast input shape. Patch checks that the output shape matches the outer shape of the broadcast fo all inputs and the size when given.
* REF: Refactor jump codeKevin Sheppard2020-05-121-5/+11
| | | | | | Refactor polynomial to be unsigned long array Remove unused code Fix md5 calculation on BE
* BUG: Correct loop order in MT19937 jumpKevin Sheppard2020-05-121-3/+43
| | | | | | Use the original loop order instead of an inverted order closes #15394
* Merge pull request #16162 from mattip/add-pxdCharles Harris2020-05-071-3/+13
|\ | | | | BUG: add missing numpy/__init__.pxd to the wheel
| * TST: add tag to __init__.pxd and test that the tag is foundmattip2020-05-061-3/+13
| |
* | BUG: Fix numpy.random.dirichlet returns NaN for small 'alpha' parameters. ↵Benjamin Trendelkamp-Schroer2020-04-291-0/+25
|/ | | | | | | | | | | | | | | (#14924) * Add stick-breaking * Add tests demonstrating slowness for beta and dirichlet generators for small alpha (and beta) values * Remove the test for beta with small `a` and `b` * Switch from standard to stick-breaking method whenever alpha.max() < 0.1 Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com> Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Sebastian Berg <sebastian@sipsolutions.net>
* TST: random: Skip a test if integers are 32 bit.Warren Weckesser2020-04-271-0/+2
|
* TST: random: Add more repeatability tests for random integers.Warren Weckesser2020-04-272-0/+45
| | | | | | | Add repeatability tests for when the range of the integers is `2**32` (and `2**32 +/- 1` for good measure) with broadcasting. The underlying functions called by Generator.integers and random.randint when the inputs are broadcast are different than when the inputs are scalars.
* BUG: random: Generator.integers(2**32) always returned 0.Warren Weckesser2020-04-261-0/+15
| | | | | | | | | | | | When the input to Generator.integers was 2**32, the value 2**32-1 was being passed as the `rng` argument to the 32-bit Lemire method, but that method requires `rng` be strictly less then 2**32-1. The fix was to handle 2**32-1 by calling next_uint32 directly. This also works for the legacy code without changing the stream of random integers from `randint`. Closes gh-16066.
* BUG: Alpha parameter must be 1D in `generator.dirichlet` (#15951)panpiort82020-04-182-0/+12
| | | | | Only one dimensional alpha paramter is currently supported, but higher dimensions were silently allowed and gave an incorrect results. This fixes the regression. In the future, the API could be extended to allow higher dimensional arrays for alpha. Fixes gh-15915
* Merge pull request #15876 from panpiort8/multinomial_pvals_1dMatti Picus2020-04-112-0/+12
|\ | | | | BUG: Check that `pvals` is 1D in `_generator.multinomial`.
| * Add minor tests enhancementPan Jan2020-04-062-2/+2
| |
| * Add testing and replace checkPan Jan2020-04-012-0/+12
| |
* | BUG: random: Disallow p=0 in negative_binomialWarren Weckesser2020-04-051-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | Make `Generator.negative_binomial` raise a ValueError if p=0. `negative_binomial(n, p)` draws samples from the distribution of the number of failures until n successes are encountered. If p is 0, then a success is never encountered, so the probability distribution is 0 for any finite number of failures. In other words, it is not really a meaningful distribution, so we disallow p=0. Closes gh-15913.
* | Bug: Fix eigh mnd cholesky methods of numpy.random.multivariate_normalMax Balandat2020-04-041-0/+24
|/ | | | Fixes #15871
* MAINT: simplify code that assumes str/unicode and int/long are different ↵Eric Wieser2020-03-263-24/+0
| | | | | types (#15816) Cleanup from the dropping of python 2
* BUG: add missing c_distributions.pxd, enables cython use of random C-API ↵Matti Picus2020-03-162-5/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (gh-15463) xref gh-14778 As pointed out in the comment by @jamesthomasgriffin, we did not include a pxd file to expose the distribution functions documented in the random c-api. This PR adds a c_distributions.pxd file that exposes them. Squashed commits: * BUG: add missing c_distributions.pxd to enable cython use of random C-API * ENH, TST: add npyrandom library like npymath, test cython use of it * BUG: actually prefix f-string with f * MAINT: fixes from review, add _bit_generato_bit_generator.pxd * STY: fixes from review * BLD: don't use nprandom library for mtrand legacy build * TST: WindowsPath cannot be used in subprocess's list2cmdline * MAINT, API: move _bit_generator to bit_generator * DOC: add release note about moving bit_generator * DOC, MAINT: fixes from review * MAINT: redo dtype determination from review
* MAINT: cleanup unused imports; avoid redefinition of importsMike Taves2020-02-061-2/+2
| | | | | | | * Cleanup unused imports (F401) of mostly standard Python modules, or some internal but unlikely referenced modules * Where internal imports are potentially used, mark with noqa * Avoid redefinition of imports (F811)
* STY,MAINT: avoid 'multiple imports on one line' (flake8 E401)Mike Taves2020-01-281-2/+3
| | | | | | * PEP 8: "Imports should usually be on separate lines" * Where modified, sort imported modules alphabetically * Clean-up unused imports from these expanded lines
* NEP: issue deprecation warning when creating ragged array (NEP 34)Matti Picus2020-01-213-7/+10
| | | | This implements NEP 34.
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-058-37/+37
| | | | | | | Inheriting from object was necessary for Python 2 compatibility to use new-style classes. In Python 3, this is unnecessary as there are no old-style classes. Dropping the object is more idiomatic Python.
* MAINT: Remove unnecessary 'from __future__ import ...' statementsJon Dufresne2020-01-032-3/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* MAINT: remove dead code from reviewmattip2019-12-271-1/+0
|
* MAINT: unskip test on win32mattip2019-12-271-1/+0
|
* BUG: use tmp dir and check version for cython test (#15170)Matti Picus2019-12-261-16/+23
| | | | | | | | | | | | * BUG: use tmp dir and check version for cython test * TST, MAINT: skip on win32, fix formatting * TST: fixes from review * TST: fixes from review * TST: fixes from review
* MAINT: random: Remove a few unused imports from test files.Warren Weckesser2019-12-153-3/+0
|
* Revert "DEP: issue deprecation warning when creating ragged array (NEP 34)"revert-14794-nep-0034-implRalf Gommers2019-12-063-10/+7
|
* Merge pull request #14794 from mattip/nep-0034-implRalf Gommers2019-12-023-7/+10
|\ | | | | DEP: issue deprecation warning when creating ragged array (NEP 34)
| * MAINT: revert change to assert_array_equal, adjust testsmattip2019-10-313-3/+6
| |
| * DEP: issue deprecation warning when creating ragged array (NEP 34)mattip2019-10-313-4/+4
| |
* | Merge pull request #14954 from mattip/test-extending-cffiCharles Harris2019-11-272-2/+22
|\ \ | | | | | | TST. API: test using distributions.h via cffi
| * | TST: skip cffi tests when PYTHONOPTIMIZE>1, pycparser failsmattip2019-11-212-0/+12
| | |
| * | TST. API: test using distributions.h via cffimattip2019-11-211-2/+10
| | |
* | | TST: skip if cython is not availablemattip2019-11-221-0/+6
|/ /