summaryrefslogtreecommitdiff
path: root/numpy/random
Commit message (Collapse)AuthorAgeFilesLines
* MNT: compatibility with cython3Thomas A Caswell2023-05-132-8/+7
| | | | This is fallout from https://github.com/cython/cython/pull/5386
* Also annotate the implementation of the kahan_sum() function, not just the ↵Stefan Behnel2023-05-041-1/+1
| | | | declaration.
* Revert useless changes.Stefan Behnel2023-05-042-15/+15
|
* Merge branch 'main' into cython3_noexceptscoder2023-05-0450-870/+6691
|\
| * MAINT: random: In a test module, don't use a global non-deterministically ↵warren2023-05-011-24/+21
| | | | | | | | Generator.
| * BUG: random: Don't return negative values from Generator.geometric.warren2023-04-302-1/+16
| | | | | | | | | | | | | | | | | | | | In C, when the integer part of a double exceeds the maximum int64, casting the double to int64_t is undefined behavior. On some platforms, the result is 2**64-1 and on others it is -2**64. That results in rng.geometric() returning -2**64 when p was sufficiently small on some platforms. The fix is to never invoke undefined behavior by ensuring we don't attempt to cast very large double values to int64_t.
| * BUG: accept zeros on numpy.random dirichlet function (#23440)Paulo Almeida2023-04-112-3/+7
| | | | | | | | | | Changed alpha value error to pass a null value. This way, dirichlet function (on the generator, not mtrand) won't raise a value exception at 0. Also added test.
| * DOC: Add `n_children` param to rng.spawn() and bitgen.spawn() docsSebastian Berg2023-03-142-0/+12
| | | | | | | | | | The original PR forgot to include the Parameters section (and thus the paraeter itself).
| * Merge pull request #23103 from SimonAltrogge/typing-fixBas van Beek2023-03-051-28/+70
| |\ | | | | | | TYP: Fix return type to float on _FloatLike_co arguments
| | * TYP: Update even more `_generator` argument types to `_FloatLike_co`BvB932023-03-051-27/+68
| | |
| | * TYP: Fix return type to float on _FloatLike_co argumentsSimonAltrogge2023-01-261-1/+2
| | | | | | | | | | | | | | | | | | | | | Currently, `rng.exponential(scale=np.sum(np.arange(10.0)))` indicates its return value as `np.ndarray[Any, dtype[float64]]` even though a `float` is returned on `_FloatLike_co` values of the `scale` argument. This commit fixes this problem such that `rng.exponential` indicates the correct return type on `_FloatLike_co` inputs.
| * | DEP: deprecate `product`, `cumproduct`, `sometrue`, `alltrue`Ralf Gommers2023-03-022-2/+2
| | | | | | | | | | | | [skip cirrus]
| * | Merge pull request #23195 from seberg/public-rng-spawnCharles Harris2023-02-235-0/+157
| |\ \ | | | | | | | | API: Add `rng.spawn()`, `bit_gen.spawn()`, and `bit_gen.seed_seq`
| | * | DOC: Try to add Generator spawning to parallel generation and link itSebastian Berg2023-02-142-4/+10
| | | |
| | * | DOC: Improve docs around generator spawningSebastian Berg2023-02-142-15/+59
| | | | | | | | | | | | | | | | Trying to address Robert Kerns review comments.
| | * | DOC: Add release note and versionadded tagsSebastian Berg2023-02-142-0/+6
| | | |
| | * | API: Add `rng.spawn()`, `bit_gen.spawn()`, and `bit_gen.seed_seq`Sebastian Berg2023-02-145-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes the seed sequence interface more public facing by: 1. Adding `BitGenerator.seed_seq` to give clear access to `_seed_seq` 2. Add `spawn()` to both the generator and the bit generator as convenience methods for spawning new instances. I somewhat remember that we always meant to consider making this more public and adding such convenient methods, but did not do so originally. So, now, I do wonder whether it is time to make this fully public? It would be nice to follow up at some point with a bit of best practices. This also doesn't add it to the `RandomState`, although doing it via `RandomState._bit_generator` is of course valid. Can we define as this kind of access as stable enough that downstream libraries could use it? I fear that backcompat with `RandomState` might make adopting newer things like spawning hard for libraries?
| * | | BUILD: add a windows meson CI job, tweak meson build parameters, fix typomattip2023-02-201-1/+1
| | | |
| * | | TST: Add a random integers bounds checking test that previously failedSebastian Berg2023-02-131-0/+2
| | | |
| * | | MAINT: Fixup random bounds checking codeSebastian Berg2023-02-131-31/+57
| |/ /
| * | Revert type change for random_fJonathan Kohler2023-02-051-1/+1
| | |
| * | Correct types, add missing functions to c_distributions.pxdJonathan Kohler2023-02-051-4/+10
| |/ | | | | Correct floating point types on several npyrandom functions exposed for Cython in c_distributions.pyx, add missing float functions
| * Merge pull request #22779 from LeonaTaric/numpy_issue22745Charles Harris2023-01-091-0/+2
| |\ | | | | | | DOC: All integer values must be non-negative
| | * 去掉noteLeonaTaric2023-01-091-3/+2
| | |
| | * change note toLeonaTaric2022-12-161-2/+2
| | | | | | | | | | | | "All integer values must be non-negative"
| | * All entropy/seed not None must be non-negativeLeonaTaric2022-12-131-0/+3
| | |
| * | DOC: Update docstring of `multivariate_normal` (#22938)Malte Londschien2023-01-071-2/+8
| |/ | | | | | | | | Make a note on results depending on system due. Closes gh-22919
| * DOC: Add random generator exponential example (#22284)lzha972022-12-102-0/+32
| | | | | | | | | | | | | | | | | | | | | | * DOC: add examples for random generator exponential function (Issue #22270) * DOC: fix doc test for random exponential generator example (Issue #22270) * DOC: fix formatting on np.random.exponential example (Issue: #22270) * DOC: fix test and problem context on np.random.exponential example (Issue: #22270) * DOC: use may vary instead of will vary for exponential example (Issue: #22270)
| * DOC: Fix doc `numpy.<exception>` to `numpy.exceptions.<exception>`Sebastian Berg2022-12-061-1/+1
| |
| * Merge pull request #22713 from seberg/numba-systemerrorCharles Harris2022-12-021-1/+2
| |\ | | | | | | TST: Skip when numba/numpy compat issues cause SystemError
| | * TST: Skip when numba/numpy compat issues cause SystemErrorSebastian Berg2022-12-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | numba is a bit buggy when wrapping ufuncs, so what should be nothing is (on non dev versions) a SystemError and not even an ImportError. So simply catch those too, since it can be a confusing error during dev otherwise.
| * | Merge pull request #22619 from seberg/move-set_moduleMatti Picus2022-11-291-1/+1
| |\ \ | | | | | | | | MAINT: Move set_module from numpy.core to numpy._utils
| | * | MAINT: Move _inspect and _pep440 from compat to _utilsSebastian Berg2022-11-251-1/+1
| | |/ | | | | | | | | | | | | Note that unfortunately, compat does expose _inspect as well, so the import remains (just the definition place moves).
| * | Merge pull request #22663 from rgommers/build-with-mesonRalf Gommers2022-11-271-0/+164
| |\ \ | | | | | | | | | | | | | | | | BLD: enable building NumPy with Meson [ci skip]
| | * | BLD: enable building NumPy with MesonRalf Gommers2022-11-251-0/+164
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This enables building with NumPy on Linux and macOS. Windows support should be complete to, but is untested as of now and may need a few tweaks. This contains: - A set of `meson.build` files and related code generation script tweaks, header templates, etc. - One CI job on Linux - Basic docs on using Meson to build NumPy (not yet integrated in the html docs, it's too early for that - this is for early adopters right now). The build should be complete, with the major exception of SIMD support. The full test suite passes. See gh-22546 for the tracking issue with detailed notes on the plan for switching NumPy to Meson as its build system. Co-authored-by: Stefan van der Walt <stefanv@berkeley.edu>
| * | MAINT: replace `NPY_INLINE` with `inline`Ralf Gommers2022-11-258-59/+59
| |/ | | | | | | Closes gh-22100
| * TST: Skip tests that are not currently supported in wasmHood Chatham2022-11-114-3/+10
| |
| * TST,MAINT: Replace most `setup` with `setup_method` (also teardown)Sebastian Berg2022-10-273-16/+16
| | | | | | | | | | | | | | | | 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)
| * Merge pull request #22450 from seberg/logseries-boundsCharles Harris2022-10-246-19/+46
| |\ | | | | | | BUG: Fix boundschecking for random.logseries
| | * BUG: Fix boundschecking for `random.logseries`Sebastian Berg2022-10-186-19/+46
| | | | | | | | | | | | | | | | | | | | | | | | Logseries previously did not enforce bounds to be strictly exclusive for the upper bound, where it leads to incorrect behavior. The NOT_NAN check is removed, since it was never used: The current bounded version always excludes NaNs.
| * | MAINT: Use Python integers for int to array of uint32 calculationSebastian Berg2022-10-121-4/+4
| |/ | | | | | | | | | | | | | | | | | | | | The new weak promotion preserves the original type, this makes the `//= 2**32` fail for certain inputs. The alternative would be typing that as `np.int64(2**32)`, but using Python integers seems easier and cleaner. The code was effectively OK before, since the inputs were guaranteed signed (or Python integers) at that point and 2**32 would have been considered like a NumPy `int64`. (Which would be an alternative fix.)
| * MAINT: Fix typos found by codespellDimitri Papadopoulos2022-10-071-2/+2
| |
| * DOC: Update notes with API linkBrigitta Sipőcz2022-09-161-84/+138
| |
| * DOC: clarify docs that inform that one should use a GeneratorMonika Kubek2022-09-161-42/+42
| |
| * MAINT: random: remove `get_info` from "extending with Cython" exampleRalf Gommers2022-09-111-6/+9
| | | | | | | | xref gh-21431
| * BLD: add back stdlib.h include in pcg64.hChristoph Reiter2022-09-111-1/+4
| | | | | | | | | | | | | | | | | | This seems to have been removed by accident in #21887 stdlib.h is required for _rotr64() further down. Fixes: error: call to undeclared function '_rotr64'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
| * Merge pull request #22171 from MatteoRaso/bug_fixSebastian Berg2022-09-062-4/+4
| |\ | | | | | | DOC: Note symmetry requirement in `multivariate_normal` error
| | * BUG: Made the error and warning messages for ↵Matteo Raso2022-08-242-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | numpy.random.multivariate_normal more descriptive (closes #22140) Issue #22140 says that numpy.random.multivariate_normal incorrectly warns that a non-symmetric positive-semidefinite matrix isn't positive-semidefinite. In the replies, there was some ambiguity over whether it was possible for a positive-semidefinite matrix to be non-symmetric, with reliable sources saying that symmetry is a common condition to add but not actually necessary. To solve this problem, two different members of the Numpy organization decided that the warning and error message "covariance is not positive-semidefinite" should be changed to "covariance is not symmetric positive-semidefinite". However, this change was never actually made yet. Since this change only required me to change a few strings instead of actually changing the code, I've decided to skip the CI jobs. [skip ci]
| * | 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.
| * DEP: drop support for msvc<=1900 and Interix (#22139)Matti Picus2022-08-191-4/+4
| | | | | | | | | | [ci skip] Co-authored-by: h-vetinari <h.vetinari@gmx.com>