| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(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
|
|
|
|
|
| |
As numpy is Python 3 only, these import statements are now unnecessary
and don't alter runtime behavior.
|
|\
| |
| | |
TST. API: test using distributions.h via cffi
|
| | |
|
|/ |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
| |
See https://mail.python.org/pipermail/numpy-discussion/2019-September/080088.html
for discussion. We need to do this right, and add tests and docs.
All this PR does is not install bitgen.h, common.pxd and bit_generator.pxd
(they're still shipped in the sdist, that is needed).
Should be backported to 1.17.x
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Summary of the changes:
* Move the functions random_hypergeometric_hyp, random_hypergeometric_hrua
and random_hypergeometric from distributions.c to legacy-distributions.c.
These are now the legacy implementation of hypergeometric.
* Add the files logfactorial.c and logfactorial.h,
containing the function logfactorial(int64_t k).
* Add the files random_hypergeometric.c and random_hypergeometric.h,
containing the function random_hypergeometric (the new implementation
of the hypergeometric distribution). See more details below.
* Fix two tests in numpy/random/tests/test_generator_mt19937.py that
used values returned by the hypergeometric distribution. The
new implementation changes the stream, so those tests needed to
be updated.
* Remove another test obviated by an added constraint on the arguments
of hypergeometric.
Details of the rewrite:
If you carefully step through the old function rk_hypergeometric_hyp(),
you'll see that the end result is basically the same as the new function
hypergeometric_sample(), but the new function accomplishes the result with
just integers. The floating point calculations in the old code caused
problems when the arguments were extremely large (explained in more detail
in the unmerged pull request https://github.com/numpy/numpy/pull/9834).
The new version of hypergeometric_hrua() is a new translation of
Stadlober's ratio-of-uniforms algorithm for the hypergeometric
distribution. It fixes a mistake in the old implementation that made the
method less efficient than it could be (see the details in the unmerged
pull request https://github.com/numpy/numpy/pull/11138), and uses a faster
function for computing log(k!).
The HRUA algorithm suffers from loss of floating point precision when
the arguments are *extremely* large (see the comments in github issue
11443). To avoid these problems, the arguments `ngood` and `nbad` of
hypergeometric must be less than 10**9. This constraint obviates an
existing regression test that was run on systems with 64 bit long
integers, so that test was removed.
|
|
|
|
|
|
| |
In numpy/random/src/legacy/, rename distributions-boxmuller.c to
legacy-distributions.c. This file holds all the legacy distributions,
so the new name is more accurate.
|
|
|
|
| |
This reverts commit 17e0070df93f4262908f884dca4b08cb7d0bba7f.
|
|
|
|
| |
Attempt to avoid defining variables that are incorrect for some platforms
|
| |
|
| |
|
|
|
|
| |
Let numpy detect SSE2
|
|
|
|
|
|
| |
Ensure integer type is stream compatible on 32 bit
Fix incorrect clause end
Add integer-generator tests that check long streams
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
| |
|
|
|
|
|
|
| |
skip doctests that require scipy
move original mtrand module to _mtrand
adjust documentation for namespace change
|
|
|
|
|
|
|
| |
remove files that were part of the origal repo
rework randomgen docs to integrate with numpy and fix some links
remove convenience functions, require explicit call to gen.brng
move code out of numpy.random.randomgen into numpy.random
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
first cut at building randomgen
upgrade 'cythonize' and fix absolute imports to relative
define NPY_NO_DEPRECATED_API and fix other warnings
enable pgc64 by always using PCG_EMULATED_MATH
refactor so import randomgen works
add TODO comments for pcg64 improvements
fix imports, module name in setup.py; remove _testing
make cythonize non-recursive, restore examples to proper place
update to randomgen 7bca296c0b9
replace mtrand with LegacyGenerator, tweak for compatibility
port f879ef4 to fix GH10839
minimized difference between generator.pyx and _legacy.pyx
fix namespace in doctests, mark results that are random
update to randomgen commit 95c8cdd1c
Incorporate testing of edge cases into main tests
Rename test files to describe their purpose
Import import locations to reflect numpy paths
Correct tolerance on float32 tests
Remove set_printoptions
Remove complex normal
Remove future imports
Pull in BasicRNG source changes from original author
Small doc fixes
_mtrand => _rand
Improve consistency of nan handling
Prevent nans prducing values from int functions
add randomgen documentation to the tree
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
declarations
The problem this fix resolves is to ensure that 32-bit and 64-bit functions
(e.g., fclear() and fclear64()) to access/manipulate "large files" are
defined properly - much as GNU and other platforms use one or more of
the defines _FILE_OFFSET_BITS, _LARGEFILE_SOURCE, and _LARGEFILE64_SOURCE.
Without this fix the numpy code only defines flags that are not recognized
in the AIX environment and have no effect in anyway.
The fix applies the AIX convention and does not "export" any of the flags
currently exported. For all other platforms the current flags:
_FILE_OFFSET_BITS, _LARGEFILE_SOURCE, and _LARGEFILE64_SOURCE are "exported".
This fix should not have any impact or side-effect based on the version
of python used.
History:
Starting around 1997 AIX started supporting so-called "large files",
i.e., length > signed 32-bit. In the period 1997-1998 the flag _LARGE_FILES
was established to simplify porting 32-bit applications to 64-bit.
The convention is to define _LARGE_FILES before including any
"system include files" either as an argument to ${CC} (e.g., in ${CFLAGS}
or as the first #define in every source file. This is to ensure that
that no relevant function calls would be redefined later in the build process.
|
| |
|
| |
|
|
|
|
|
| |
randomkit.c uses fopen which requires LFS mode to support larger than 64
bit files on 32 bit systems.
|
|
|
|
|
|
|
| |
Run the 2to3 ws_comma fixer on *.py files. Some lines are now too long
and will need to be broken at some point. OTOH, some lines were already
too long and need to be broken at some point. Now seems as good a time
as any to do this with open PRs at a minimum.
|
|
|
|
|
|
|
| |
Add `print_function` to all `from __future__ import ...` statements
and use the python3 print function syntax everywhere.
Closes #3078.
|
|
|
|
|
|
|
|
| |
This should be harmless, as we already are division clean. However,
placement of this import takes some care. In the future a script
can be used to append new features without worry, at least until
such time as it exceeds a single line. Having that ability will
make it easier to deal with absolute imports and printing updates.
|
| |
|