| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Generator.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
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.
|
|\
| |
| | |
API: Add `rng.spawn()`, `bit_gen.spawn()`, and `bit_gen.seed_seq`
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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?
|
|/ |
|
|\
| |
| | |
TST: Skip when numba/numpy compat issues cause SystemError
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|/
|
|
|
| |
Note that unfortunately, compat does expose _inspect as well,
so the import remains (just the definition place moves).
|
| |
|
|
|
|
|
|
|
|
| |
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)
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
Add a new version or seed that supports seeding any bit gen
Add set/get_bit_generator as explicity methodds to support swapping
closes #21808
|
| |
|
|
|
|
|
|
|
| |
Allow bit generators to supply their own constructors to enable Generator
objects using arbitrary bit generators to be supported
closes #22012
|
|
|
|
|
|
|
| |
* Disallow both mean and cov from being complex.
* Raise a TypeError instead of a NotImplementedError if mean or cov is
complex.
* Expand and fix the unit test.
|
|
|
|
|
| |
This commit disallows complex covariances in multivariate_normal
as passing them can silently lead to incorrect results.
|
|
|
|
|
|
| |
Cython 0.29.30 is required for building Numpy with Python 3.11. This commit updates that in the core/tests/test_cython.py and random/tests/test_exending.py files.
It also mentions that Cython 0.29.30 is needed in the INSTALL documentation.
|
|\
| |
| | |
BUG: Add parameter check to negative_binomial
|
| | |
|
| |
| |
| |
| | |
negative_binomial
|
|/
|
|
|
|
|
|
| |
LooseVersion is provided by Python distutils, which is going away in
3.12. This PR vendors _pep440 from scipy and uses it as a replacement.
Numpy distutils is not touched, replacing LooseVersion in that package
was considered too risky, and numpy distutils will need to go away when
Python distutils does.
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
| |
Guard against empty pvals
closes #20483
* MAINT: Correct exception type
Raise TypeError for enhanced backward compat when pvals
is scalar
|
|
|
|
|
|
|
| |
`load_module` is deprecated since python 3.4 and will be removed in python 3.12.
Use `exec_module` instead. Provide a convenience function in `distutils.misc_utils`
instead of `npy_load_module` from `compat.py3k`.
|
|
|
|
| |
xref github issue #15201
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The formula to convert a 32 bit random integer to a random float32,
(next_uint32(bitgen_state) >> 9) * (1.0f / 8388608.0f)
shifts by one bit too many, resulting in uniform float32 samples always
having a 0 in the least significant bit. The formula is corrected to
(next_uint32(bitgen_state) >> 8) * (1.0f / 16777216.0f)
Occurrences of the incorrect formula in numpy/random/tests/test_direct.py
were also corrected.
Closes gh-17478.
|
|\
| |
| | |
MAINT: Remove unused imports and remove duplicated tests
|
| | |
|
|/
|
|
|
|
|
| |
Correct incorrect implemetation of carry in PCG64 and PCG64DXSM
when advancing more than 2**64 steps
closes #20048
|
| |
|
|
|
|
|
| |
This makes the test reproducible. See comments on failing test
in #19540.
|
| |
|
|
|
|
|
|
| |
Check that out is C-contiguous when using user-supplied arguments
closes #18704
|
|
|
|
| |
Use exponentials rather than generating exponentials via inversion
|
|\
| |
| | |
BUG: Correct shuffling of objects in 1-d array likes
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |
| |
| |
| |
| |
| |
| | |
Improve the exception when low is 0 in case the single input
form was used.
closes #14333
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Improve error message when the sum of pvals is larger than 1
when the input data is an ndarray
closes #8317
xref #16732
|
| |
| |
| |
| |
| |
| |
| |
| | |
Apply vonmises fix only to Generator
Add tests for correctness
closes #17378
closes #17275
|
|/
|
|
| |
large values of kappa (>1e6)
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Remove ndim for non-ndarrays and check axis is 0
closes #18142
|
|
|
|
|
|
| |
* allow graceful shuffling of memoryviews, with
same behavior as arrays, instead of producing
a warning on `memoryview` shuffle
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|