summaryrefslogtreecommitdiff
path: root/numpy/random/tests
Commit message (Collapse)AuthorAgeFilesLines
* 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
|/ /
* | MAINT: move numpy/random/examples -> numpy/random/_examplesmattip2019-11-191-3/+3
| |
* | API: restructure and document numpy.random C-API (#14604)Matti Picus2019-11-191-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * API: restructure and document numpy.random C-API * DOC: fix bad reference * API: ship, document, and start to test numpy.random C-API examples * API, DOC, TST: fix tests, refactor documentation to include snippets * BUILD: move public headers to numpy/core/include/numpy/random * TST: ignore DeprecationWarnings in setuptools and numba * DOC: document the C-API as used from Cython
* | MAINT: Remove uses of scalar aliasesEric Wieser2019-11-134-15/+14
| | | | | | | | Relates to gh-6103
* | merge latest changes on master branchRedRuM2019-11-036-29/+271
|\ \ | |/
| * BUG: random: biased samples from integers() with 8 or 16 bit dtype.Warren Weckesser2019-10-241-2/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an 8 or 16 bit dtype was given to the integers() method of the Generator class, the resulting sample was biased. The problem was the lines of the form const uint8_t threshold = -rng_excl % rng_excl; in the implementations of Lemire's method, in the C file distributions.c. The intent was to compute (UINT8_MAX+1 - rng_excl) % rng_excl However, when the type of rng_excl has integer conversion rank lower than a C int (which is almost certainly the case for the 8 and 16 bit types), the terms in the expression -rng_excl % rng_excl are promoted to int, and the result of the calculation is always 0. The fix is to make the expression explicit, and write it as const uint8_t threshold = (UINT8_MAX - rng) % rng_excl; rng is used, because rng_excl is simply rng + 1; by using rng, we we only need the constant UINT#_MAX, without the extra +1. For consistency, I made the same change for all the data types (8, 16, 32 and 64 bit). Closes gh-14774.
| * ENH: random: Add the multivariate hypergeometric distributionWarren Weckesser2019-10-181-1/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new method multivariate_hypergeometric(self, object colors, object nsample, size=None, method='marginals') of the class numpy.random.Generator implements the multivariate hypergeometric distribution; see https://en.wikipedia.org/wiki/Hypergeometric_distribution, specifically the section "Multivariate hypergeometric distribution". Two algorithms are implemented. The user selects which algorithm to use with the `method` parameter. The default, `method='marginals'`, is based on repeated calls of the univariate hypergeometric distribution function. The other algorithm, selected with `method='count'`, is a brute-force method that allocates an internal array of length ``sum(colors)``. It should only be used when that value is small, but it can be much faster than the "marginals" algorithm in that case. The C implementations of the two methods are in the files random_mvhg_count.c and random_mvhg_marginals.c in numpy/random/src/distributions.
| * TEST, DOC: fixes from reviewmattip2019-10-171-1/+1
| |
| * API: move bit_generator and generator to be privatemattip2019-10-112-2/+2
| |
| * API: make BitGenerators privatemattip2019-10-112-2/+3
| |
| * API: rename common, bounded_integers -> _common, _bounded_integers; cleanupmattip2019-10-111-1/+1
| |
| * BUG: random: Use correct length when axis is given to shuffle.Warren Weckesser2019-10-081-0/+9
| | | | | | | | | | | | | | When an axis argument was given, shuffle was using the original length of the array instead of the length of the given axis. This meant that, for example, if an array with shape (2, 10) was shuffled with axis=1, only the first two columns were shuffled.
| * BUG: random: Create a legacy implementation of random.binomial.Warren Weckesser2019-09-161-1/+17
| | | | | | | | | | | | | | | | | | Create a legacy implementation of the random_binomial method of RandomState that does not include the "short-circuit" check for n == 0 or p == 0. This ensures that the stream of variates is consistent with the behavior in 1.16. Closes gh-14522.
| * Merge pull request #13829 from kianasun/add-permutation-axisMatti Picus2019-09-161-0/+45
| |\ | | | | | | ENH: Add axis argument to random.permutation and random.shuffle
| | * ENH: Improve permutation and shuffle functions on a given axisKexuan Sun2019-09-141-0/+45
| | |
| * | Merge pull request #14498 from mattip/random-namespaceRalf Gommers2019-09-151-21/+1
| |\ \ | | | | | | | | MAINT: remove the entropy c-extension module
| | * | MAINT: remove the entropy c-extension modulemattip2019-09-131-21/+1
| | |/
| * | BUG: Fix randint when range is 2**32Kevin Sheppard2019-09-141-0/+11
| |/ | | | | | | | | | | Fix randint to use 32-bit path when range is exactly 2**32 closes #14189
| * BUG: Fix segfault in `random.permutation(x)` when x is a string. (#14241)Maxwell Aladago2019-08-222-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fixing segfault error in np.random.permutation(x) where x is str * removed whitespace * changing error type to ValueError * changing error type to ValueError * changing error type to ValueError * tests * changed error to IndexError for backward compatibility with numpy 1.16 * fixes numpy.randomstate.permutation segfault too * Rolled back to ValueError for Generator.permutation() for all 0-dimensional * fixes refuige erro and rolls backs to AxisError
* | MAINT: remove stray commentsRedRuM2019-10-161-4/+0
| |
* | TST: Parametrize tests using different methodsRedRuM2019-10-161-26/+11
| |
* | Back out use_factor changes, to be restored in a separate PREric Wieser2019-10-161-40/+0
| |
* | MNT: simplify the API by requiring the user to ensure the correct factor is ↵RedRuM2019-08-181-2/+0
| | | | | | | | supplied.
* | ENH: re-write the implementation with new keywords method and use_factorRedRuM2019-08-171-6/+81
| |
* | REV: Undo all changes to codebaseRedRuM2019-08-171-50/+8
| |
* | ENH: Add test cases for proposed API for samlping from a multivariate normal ↵RedRuM2019-08-161-8/+50
|/ | | | distribution
* test shuffle keywordGuillaume Horel2019-07-111-0/+3
|
* fix testsGuillaume Horel2019-07-111-2/+2
|
* fix testsGuillaume Horel2019-07-111-1/+1
|
* fix testsGuillaume Horel2019-07-111-2/+2
|
* ENH: Rename tests for default_rngRobert Kern2019-06-292-2/+2
|
* ENH: Rename default_gen to default_rngRobert Kern2019-06-292-13/+13
|
* BUG: Ensure consistent interpretation of uint64 states. (#13861)Robert Kern2019-06-281-1/+15
| | | * BUG: test, fix for big-endian systems