summaryrefslogtreecommitdiff
path: root/numpy/random/tests/test_random.py
Commit message (Collapse)AuthorAgeFilesLines
* TST: Skip tests that are not currently supported in wasmHood Chatham2022-11-111-1/+2
|
* TST,MAINT: Replace most `setup` with `setup_method` (also teardown)Sebastian Berg2022-10-271-5/+5
| | | | | | | | In some cases, the replacement is clearly not what is intended, in those (where setup was called explicitly), I mostly renamed `setup` to `_setup`. The `test_ccompile_opt` is a bit confusing, so left it right now (this will probably fail)
* TST: Implemented an unused test for np.random.randintMatteo Raso2022-08-251-17/+16
| | | | In numpy/random/tests/test_random.py, a class called TestSingleEltArrayInput had a method called test_randint that was commented out, with the instructions to uncomment it once np.random.randint was able to broadcast arguments. Since np.random.randint has been able to broadcast arguments for a while now, I uncommented the test. The only modification I made to the code was fixing a small error, where the author incorrectly tried to call "assert_equal" as a method of the TestSingleEltArrayInput instead of a function that was imported from numpy.testing. I ran runtests.py, and the new test passed.
* BUG: random: Check 'writeable' flag in 'shuffle' and 'permuted'.warren2021-12-181-0/+6
|
* STY: Fix hanging indentation.Charles Harris2021-03-171-3/+3
|
* STY: Break long line.Charles Harris2021-03-171-1/+3
|
* BUG: Correct shuffling of objects in 1-d array likesSebastian Berg2021-02-221-0/+25
| | | | | | | | | While introducing the buffer fixed the in-place problem years ago, running valgrind (and masked arrays) pointed out to me that without the additional `...` NumPy will unpack and repack objects leading to slightly incorrect results. MAINT: Warn about shuffle bug instead of fixing it in old random API
* 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.
* 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
* TST: Make test suite work in FIPS (140-2) ModeNikola Forró2020-10-291-12/+12
| | | | | | | | | 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>
* BUG: Alpha parameter must be 1D in `generator.dirichlet` (#15951)panpiort82020-04-181-0/+6
| | | | | 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
* Add minor tests enhancementPan Jan2020-04-061-1/+1
|
* Add testing and replace checkPan Jan2020-04-011-0/+6
|
* MAINT: Remove implicit inheritance from object class (#15236)Jon Dufresne2020-01-051-9/+9
| | | | | | | 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-031-1/+0
| | | | | As numpy is Python 3 only, these import statements are now unnecessary and don't alter runtime behavior.
* MAINT: Remove uses of scalar aliasesEric Wieser2019-11-131-1/+1
| | | | Relates to gh-6103
* Merge pull request #13163 from mattip/randomgenSebastian Berg2019-05-281-11/+19
|\ | | | | | | | | ENH: randomgen This merges randomgen into numpy, which was originally developed at https://github.com/bashtage/randomgen and provides a new and improved API for random number generation with much new and improved functionality.
| * STY: Clean up codeKevin Sheppard2019-05-271-8/+16
| | | | | | | | | | | | Pep8 fixes Remove unused imports Fix name error
| * BUG: Change renamed attributeKevin Sheppard2019-05-231-1/+1
| | | | | | | | Change renamed attribute
| * MAINT: Implement API changes for randomgen-derived codemattip2019-05-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | remove numpy.random.gen, BRNG.generator, pcg*, rand, randn remove use_mask and Lemire's method, fix benchmarks for PCG removal convert brng to bitgen (in C) and bit_generator (in python) convert base R{NG,andom.*} to BitGenerator, fix last commit randint -> integers, remove rand, randn, random_integers RandomGenerator -> Generator, more "basic RNG" -> BitGenerator random_sample -> random, jump -> jumped, resync with randomgen Remove derived code from entropy Port over changes accepted in upstream to protect log(0.0) where relevant fix doctests for jumped, better document choice Remove Python 2.7 shims Use NPY_INLINE to simplify Fix performance.py to work Renam directory brng to bit_generators Fix examples wiht new directory structure Clarify relationship to historical RandomState Remove references to .generator Rename xoshiro256/512starstar
* | Deprecate collapsing shape-1 dtype fields to scalars.Antony Lee2019-05-241-2/+1
| | | | | | | | | | | | | | | | | | Currently, a field specified as `[(name, dtype, 1)]` is interpreted as a scalar field (i.e., the same as `[(name, dtype)]` or `[(name, dtype, ()]`). This now raises a FutureWarning; in a future version, it will be interpreted as a shape-(1,) field, i.e. the same as `[(name, dtype, (1,))]` (consistently with `[(name, dtype, n)]` with `n>1`, which is already equivalent to `[(name, dtype, (n,)]`).
* | MAINT: Fix errors seen on new python 3.8Sebastian Berg2019-05-211-2/+4
|/ | | | | | | | | | | | | | One of this is a small issue exposed by new warnings, the others are simply adapting our test suit to stricter integer coercion rules (avoiding float -> int conversions). The last one is that we assumed pickle protocol 5 would be in 3.8. It is not yet included in the alpha releases at least. It seems not necessary for the numpy test suit to check whether it is available based on the python version so removing that test. (Also testing if the pickle5 module works seems unnecessary.) Closes gh-13412
* Merge pull request #12547 from bashtage/mvnormal-tol-checkAllan Haldane2019-03-211-0/+6
|\ | | | | ENH: Cast covariance to double in random mvnormal
| * ENH: Cast covariance to double in random mvnormalKevin Sheppard2018-12-141-0/+6
| | | | | | | | | | | | | | Cast the covariance in the multivariate normal to double so that the interpretation of tol is cleaner. closes #10839
* | Added issue number in commentBharat123Rox2019-03-051-0/+1
| |
* | Added more tests as suggested by @eric-wieserBharat123Rox2019-03-051-0/+2
| |
* | Fix #13087 by raising a ValueError and adding a unit test for itBharat123Rox2019-03-051-0/+1
| |
* | DOC: Fix Wald docstringKevin Sheppard2019-02-181-0/+2
| | | | | | | | | | Fix Wald Docstring to reflect actual restriction on parameters Add a test to ensure these are enforced for scalar inputs
* | BUG: Ensure probabilities are not NaN in choiceKevin Sheppard2018-12-141-0/+5
|/ | | | | | Add a check for NaN probabilities in random.choice closes #11250
* BUG: random: Fix handling of a=0 for numpy.random.weibull.Warren Weckesser2018-11-121-1/+2
| | | | | | | Before this fix, np.random.weibull(a=0) often returned inf (and in theory could have returned 1). It should only return 0. Closes gh-12371.
* Merge pull request #11771 from asnasnasn/shuf-mmMatti Picus2018-10-121-0/+4
|\ | | | | BUG: Make `random.shuffle` work on 1-D instances of `ndarray` subclasses
| * BUG: Make `random.shuffle` work on 1-D instances of `ndarray` subclassesWenjamin Petrenko2018-08-181-0/+4
| | | | | | | | Closes #11442.
* | MAINT: remove redundant importsmattip2018-09-091-1/+0
| |
* | MAINT: reformat line spacing before test methodsmattip2018-08-191-1/+0
|/
* fixes from reviewmattip2018-06-211-4/+5
|
* ENH: Allow size=0 in numpy.random.choicemattip2018-06-191-0/+8
|
* HTTP -> HTTPS, and other linkrot fixesMike Toews2018-06-161-1/+1
|
* MAINT: Remove all uses of run_module_suite.Charles Harris2018-04-061-4/+1
| | | | | That function is nose specific and has not worked since `__init__` files were added to the tests directories.
* More misc. typosluz.paz2018-01-041-1/+1
| | | Found via `codespell`
* BUG: Prevent invalid array shapes in seedKevin Sheppard2017-10-181-0/+7
| | | | | | | Prevent empty arrays or arrays with more than 1 dimension from being used to seed RandomState closes #9832
* BUG: Check for NaN parameter in random.zipf.Charles Harris2017-10-061-2/+6
| | | | Avoids infinite loop.
* ENH: Remove unnecessary restriction in noncen-fKevin Sheppard2017-08-221-1/+7
| | | | | | Set dfnum restriction to be > 0 as required by noncentral chisquare closes #6638
* BUG: Missing dirichlet input validationKevin Sheppard2017-08-171-0/+5
| | | | | | | | Dirichlet does not validate inputs and hangs when values are zero. Adds check that values are strictly positive as required by the distribution. closes #2089
* MAINT/DOC: Use builtin when np.{x} is builtins.{x}.Eric Wieser2017-08-051-10/+10
| | | | | | | This is the case for x in {int, bool, str, float, complex, object}. Using the np.{x} version is deceptive as it suggests that there is a difference. This change doesn't affect any external behaviour. The `long` type is missing in python 3, so np.long is still useful
* TST: Remove unittest dependencies in numpy/random/tests.Charles Harris2017-07-241-27/+28
|
* BUG: Buttress handling of extreme values in randintgfyoung2017-05-091-1/+44
|
* BUG: Check for errors when PyInt_AsLong is called in np.randomSimon Gibbons2017-04-021-8/+15
| | | | | | | | | After #8883 was merged it was noticed that the same problem was occuring with calls to PyInt_AsLong. Namely that PyErr_Occoured wasn't being checked if it returned -1 indicating an exception could have been thrown. This PR adds those checks as well as a regression test.
* Fix testSimon Gibbons2017-04-011-1/+1
|
* BUG: Ensure Errors are correctly checked when PyFloat_AsDouble is called.Simon Gibbons2017-04-011-0/+14
| | | | | | | | | | | | | | There was an error in np.random.uniform where if np.random.uniform were called with a type that throwed exceptions when it was converted to a float this exception wouldn't be raised. This bug was due to an issue where PyFloat_AsDouble was called but no check for PyErr_Occurred was performed after. This PR fixes the issue by ensuring that Cython will always emit a call to PyErr_Occurred if PyFloat_AsDouble returns -1.0 Fixes: #8865
* DOC: update docs and comments for move of mailing list to python.orgRalf Gommers2017-03-261-1/+1
|