diff options
| -rw-r--r-- | .circleci/config.yml | 2 | ||||
| -rw-r--r-- | .gitignore | 10 | ||||
| -rw-r--r-- | MANIFEST.in | 3 | ||||
| -rw-r--r-- | _randomgen/.gitattributes | 1 | ||||
| -rw-r--r-- | _randomgen/.gitignore | 26 | ||||
| -rw-r--r-- | _randomgen/.travis.yml | 72 | ||||
| -rw-r--r-- | _randomgen/README-git.md | 26 | ||||
| -rw-r--r-- | _randomgen/README.md | 288 | ||||
| -rw-r--r-- | _randomgen/README.rst | 320 | ||||
| -rw-r--r-- | _randomgen/benchmark.py | 201 | ||||
| -rw-r--r-- | _randomgen/setup.py | 325 | ||||
| -rw-r--r-- | benchmarks/benchmarks/bench_random.py | 99 | ||||
| -rw-r--r-- | doc/source/reference/randomgen/extending.rst | 2 | ||||
| -rw-r--r-- | doc/source/reference/randomgen/generator.rst | 29 | ||||
| -rw-r--r-- | doc/source/reference/randomgen/index.rst | 120 | ||||
| -rw-r--r-- | doc/source/reference/randomgen/new-or-different.rst | 4 | ||||
| -rw-r--r-- | numpy/random/LICENSE.md (renamed from numpy/random/randomgen/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/__init__.py | 36 | ||||
| -rw-r--r-- | numpy/random/_mtrand/Python.pxi (renamed from numpy/random/mtrand/Python.pxi) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/distributions.c (renamed from numpy/random/mtrand/distributions.c) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/distributions.h (renamed from numpy/random/mtrand/distributions.h) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/generate_mtrand_c.py | 42 | ||||
| -rw-r--r-- | numpy/random/_mtrand/initarray.c (renamed from numpy/random/mtrand/initarray.c) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/initarray.h (renamed from numpy/random/mtrand/initarray.h) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/mtrand.pyx (renamed from numpy/random/mtrand/mtrand.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/mtrand_py_helper.h (renamed from numpy/random/mtrand/mtrand_py_helper.h) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/numpy.pxd (renamed from numpy/random/mtrand/numpy.pxd) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/randint_helpers.pxi.in (renamed from numpy/random/mtrand/randint_helpers.pxi.in) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/randomkit.c (renamed from numpy/random/mtrand/randomkit.c) | 0 | ||||
| -rw-r--r-- | numpy/random/_mtrand/randomkit.h (renamed from numpy/random/mtrand/randomkit.h) | 0 | ||||
| -rw-r--r-- | numpy/random/_pickle.py (renamed from numpy/random/randomgen/_pickle.py) | 0 | ||||
| -rw-r--r-- | numpy/random/bounded_integers.pxd.in (renamed from numpy/random/randomgen/bounded_integers.pxd.in) | 0 | ||||
| -rw-r--r-- | numpy/random/bounded_integers.pyx.in (renamed from numpy/random/randomgen/bounded_integers.pyx.in) | 0 | ||||
| -rw-r--r-- | numpy/random/common.pxd (renamed from numpy/random/randomgen/common.pxd) | 0 | ||||
| -rw-r--r-- | numpy/random/common.pyx (renamed from numpy/random/randomgen/common.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/distributions.pxd (renamed from numpy/random/randomgen/distributions.pxd) | 0 | ||||
| -rw-r--r-- | numpy/random/dsfmt.pyx (renamed from numpy/random/randomgen/dsfmt.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/entropy.pyx (renamed from numpy/random/randomgen/entropy.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/examples/cython/extending.pyx (renamed from numpy/random/randomgen/examples/cython/extending.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/examples/cython/extending_distributions.pyx (renamed from numpy/random/randomgen/examples/cython/extending_distributions.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/examples/cython/setup.py (renamed from numpy/random/randomgen/examples/cython/setup.py) | 0 | ||||
| -rw-r--r-- | numpy/random/examples/numba/extending.py (renamed from numpy/random/randomgen/examples/numba/extending.py) | 0 | ||||
| -rw-r--r-- | numpy/random/examples/numba/extending_distributions.py (renamed from numpy/random/randomgen/examples/numba/extending_distributions.py) | 0 | ||||
| -rw-r--r-- | numpy/random/generator.pyx (renamed from numpy/random/randomgen/generator.pyx) | 74 | ||||
| -rw-r--r-- | numpy/random/legacy/__init__.py (renamed from numpy/random/randomgen/legacy/__init__.py) | 0 | ||||
| -rw-r--r-- | numpy/random/legacy/legacy_distributions.pxd (renamed from numpy/random/randomgen/legacy/legacy_distributions.pxd) | 0 | ||||
| -rw-r--r-- | numpy/random/mt19937.pyx (renamed from numpy/random/randomgen/mt19937.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/mtrand.pyx (renamed from numpy/random/randomgen/mtrand.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/pcg32.pyx (renamed from numpy/random/randomgen/pcg32.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/pcg64.pyx (renamed from numpy/random/randomgen/pcg64.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/philox.pyx (renamed from numpy/random/randomgen/philox.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/randomgen/__init__.py | 21 | ||||
| -rw-r--r-- | numpy/random/randomgen/_version.py | 520 | ||||
| -rw-r--r-- | numpy/random/randomgen/setup.py | 191 | ||||
| -rw-r--r-- | numpy/random/randomgen/tests/data/__init__.py | 0 | ||||
| -rw-r--r-- | numpy/random/setup.py | 153 | ||||
| -rw-r--r-- | numpy/random/src/aligned_malloc/aligned_malloc.c (renamed from numpy/random/randomgen/src/aligned_malloc/aligned_malloc.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/aligned_malloc/aligned_malloc.h (renamed from numpy/random/randomgen/src/aligned_malloc/aligned_malloc.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/common/LICENSE.md (renamed from numpy/random/randomgen/src/common/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/common/inttypes.h (renamed from numpy/random/randomgen/src/common/inttypes.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/common/stdint.h (renamed from numpy/random/randomgen/src/common/stdint.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/distributions/LICENSE.md (renamed from numpy/random/randomgen/src/distributions/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/distributions/binomial.h (renamed from numpy/random/randomgen/src/distributions/binomial.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/distributions/distributions.c (renamed from numpy/random/randomgen/src/distributions/distributions.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/distributions/distributions.h (renamed from numpy/random/randomgen/src/distributions/distributions.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/distributions/ziggurat.h (renamed from numpy/random/randomgen/src/distributions/ziggurat.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/distributions/ziggurat_constants.h (renamed from numpy/random/randomgen/src/distributions/ziggurat_constants.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/128-bit-jump.poly.txt (renamed from numpy/random/randomgen/src/dsfmt/128-bit-jump.poly.txt) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/96-bit-jump.poly.txt (renamed from numpy/random/randomgen/src/dsfmt/96-bit-jump.poly.txt) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/LICENSE.md (renamed from numpy/random/randomgen/src/dsfmt/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/calc-jump.cpp (renamed from numpy/random/randomgen/src/dsfmt/calc-jump.cpp) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-benchmark.c (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-benchmark.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-calc-jump.hpp (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-calc-jump.hpp) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-common.h (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-common.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-jump.c (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-jump.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-jump.h (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-jump.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-params.h (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-params.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-params19937.h (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-params19937.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-poly.h (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-poly.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT-test-gen.c (renamed from numpy/random/randomgen/src/dsfmt/dSFMT-test-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT.c (renamed from numpy/random/randomgen/src/dsfmt/dSFMT.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/dsfmt/dSFMT.h (renamed from numpy/random/randomgen/src/dsfmt/dSFMT.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/entropy/LICENSE.md (renamed from numpy/random/randomgen/src/entropy/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/entropy/entropy.c (renamed from numpy/random/randomgen/src/entropy/entropy.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/entropy/entropy.h (renamed from numpy/random/randomgen/src/entropy/entropy.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/legacy/LICENSE.md (renamed from numpy/random/randomgen/src/legacy/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/legacy/distributions-boxmuller.c (renamed from numpy/random/randomgen/src/legacy/distributions-boxmuller.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/legacy/distributions-boxmuller.h (renamed from numpy/random/randomgen/src/legacy/distributions-boxmuller.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/LICENSE.md (renamed from numpy/random/randomgen/src/mt19937/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/mt19937-benchmark.c (renamed from numpy/random/randomgen/src/mt19937/mt19937-benchmark.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/mt19937-jump.c (renamed from numpy/random/randomgen/src/mt19937/mt19937-jump.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/mt19937-jump.h (renamed from numpy/random/randomgen/src/mt19937/mt19937-jump.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/mt19937-poly.h (renamed from numpy/random/randomgen/src/mt19937/mt19937-poly.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/mt19937-test-data-gen.c (renamed from numpy/random/randomgen/src/mt19937/mt19937-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/mt19937.c (renamed from numpy/random/randomgen/src/mt19937/mt19937.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/mt19937.h (renamed from numpy/random/randomgen/src/mt19937/mt19937.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/randomkit.c (renamed from numpy/random/randomgen/src/mt19937/randomkit.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/mt19937/randomkit.h (renamed from numpy/random/randomgen/src/mt19937/randomkit.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg32/LICENSE.md (renamed from numpy/random/randomgen/src/pcg32/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg32/pcg-advance-64.c (renamed from numpy/random/randomgen/src/pcg32/pcg-advance-64.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg32/pcg32-test-data-gen.c (renamed from numpy/random/randomgen/src/pcg32/pcg32-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg32/pcg32.c (renamed from numpy/random/randomgen/src/pcg32/pcg32.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg32/pcg32.h (renamed from numpy/random/randomgen/src/pcg32/pcg32.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg32/pcg_variants.h (renamed from numpy/random/randomgen/src/pcg32/pcg_variants.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg64/LICENSE.md (renamed from numpy/random/randomgen/src/pcg64/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg64/pcg64-benchmark.c (renamed from numpy/random/randomgen/src/pcg64/pcg64-benchmark.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg64/pcg64-test-data-gen.c (renamed from numpy/random/randomgen/src/pcg64/pcg64-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg64/pcg64.c (renamed from numpy/random/randomgen/src/pcg64/pcg64.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg64/pcg64.h (renamed from numpy/random/randomgen/src/pcg64/pcg64.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg64/pcg64.orig.c (renamed from numpy/random/randomgen/src/pcg64/pcg64.orig.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/pcg64/pcg64.orig.h (renamed from numpy/random/randomgen/src/pcg64/pcg64.orig.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/philox/LICENSE.md (renamed from numpy/random/randomgen/src/philox/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/philox/philox-benchmark.c (renamed from numpy/random/randomgen/src/philox/philox-benchmark.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/philox/philox-test-data-gen.c (renamed from numpy/random/randomgen/src/philox/philox-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/philox/philox.c (renamed from numpy/random/randomgen/src/philox/philox.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/philox/philox.h (renamed from numpy/random/randomgen/src/philox/philox.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/splitmix64/LICENSE.md (renamed from numpy/random/randomgen/src/splitmix64/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/splitmix64/splitmix64.c (renamed from numpy/random/randomgen/src/splitmix64/splitmix64.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/splitmix64/splitmix64.h (renamed from numpy/random/randomgen/src/splitmix64/splitmix64.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/splitmix64/splitmix64.orig.c (renamed from numpy/random/randomgen/src/splitmix64/splitmix64.orig.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry/LICENSE.md (renamed from numpy/random/randomgen/src/threefry/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry/threefry-benchmark.c (renamed from numpy/random/randomgen/src/threefry/threefry-benchmark.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry/threefry-orig.c (renamed from numpy/random/randomgen/src/threefry/threefry-orig.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry/threefry-test-data-gen.c (renamed from numpy/random/randomgen/src/threefry/threefry-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry/threefry.c (renamed from numpy/random/randomgen/src/threefry/threefry.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry/threefry.h (renamed from numpy/random/randomgen/src/threefry/threefry.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry32/LICENSE.md (renamed from numpy/random/randomgen/src/threefry32/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry32/threefry32-test-data-gen.c (renamed from numpy/random/randomgen/src/threefry32/threefry32-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry32/threefry32.c (renamed from numpy/random/randomgen/src/threefry32/threefry32.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/threefry32/threefry32.h (renamed from numpy/random/randomgen/src/threefry32/threefry32.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoroshiro128/LICENSE.md (renamed from numpy/random/randomgen/src/xoroshiro128/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128-benchmark.c (renamed from numpy/random/randomgen/src/xoroshiro128/xoroshiro128-benchmark.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128-test-data-gen.c (renamed from numpy/random/randomgen/src/xoroshiro128/xoroshiro128-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128.c (renamed from numpy/random/randomgen/src/xoroshiro128/xoroshiro128.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128.h (renamed from numpy/random/randomgen/src/xoroshiro128/xoroshiro128.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128plus.orig.c (renamed from numpy/random/randomgen/src/xoroshiro128/xoroshiro128plus.orig.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoroshiro128/xoroshiro128plus.orig.h (renamed from numpy/random/randomgen/src/xoroshiro128/xoroshiro128plus.orig.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xorshift1024/LICENSE.md (renamed from numpy/random/randomgen/src/xorshift1024/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024-benchmark.c (renamed from numpy/random/randomgen/src/xorshift1024/xorshift1024-benchmark.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024-test-data-gen.c (renamed from numpy/random/randomgen/src/xorshift1024/xorshift1024-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.c (renamed from numpy/random/randomgen/src/xorshift1024/xorshift1024.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.h (renamed from numpy/random/randomgen/src/xorshift1024/xorshift1024.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.orig.c (renamed from numpy/random/randomgen/src/xorshift1024/xorshift1024.orig.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xorshift1024/xorshift1024.orig.h (renamed from numpy/random/randomgen/src/xorshift1024/xorshift1024.orig.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro256starstar/LICENSE.md (renamed from numpy/random/randomgen/src/xoshiro256starstar/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro256starstar/xoshiro256starstar-test-data-gen.c (renamed from numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro256starstar/xoshiro256starstar.c (renamed from numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro256starstar/xoshiro256starstar.h (renamed from numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro256starstar/xoshiro256starstar.orig.c (renamed from numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.orig.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro256starstar/xoshiro256starstar.orig.h (renamed from numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.orig.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro512starstar/LICENSE.md (renamed from numpy/random/randomgen/src/xoshiro512starstar/LICENSE.md) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro512starstar/xoshiro512starstar-test-data-gen.c (renamed from numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar-test-data-gen.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro512starstar/xoshiro512starstar.c (renamed from numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro512starstar/xoshiro512starstar.h (renamed from numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.h) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro512starstar/xoshiro512starstar.orig.c (renamed from numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.orig.c) | 0 | ||||
| -rw-r--r-- | numpy/random/src/xoshiro512starstar/xoshiro512starstar.orig.h (renamed from numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.orig.h) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/__init__.py (renamed from numpy/random/randomgen/tests/__init__.py) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/dSFMT-testset-1.csv (renamed from numpy/random/randomgen/tests/data/dSFMT-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/dSFMT-testset-2.csv (renamed from numpy/random/randomgen/tests/data/dSFMT-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/mt19937-testset-1.csv (renamed from numpy/random/randomgen/tests/data/mt19937-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/mt19937-testset-2.csv (renamed from numpy/random/randomgen/tests/data/mt19937-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/pcg32-testset-1.csv (renamed from numpy/random/randomgen/tests/data/pcg32-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/pcg32-testset-2.csv (renamed from numpy/random/randomgen/tests/data/pcg32-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/pcg64-testset-1.csv (renamed from numpy/random/randomgen/tests/data/pcg64-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/pcg64-testset-2.csv (renamed from numpy/random/randomgen/tests/data/pcg64-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/philox-testset-1.csv (renamed from numpy/random/randomgen/tests/data/philox-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/philox-testset-2.csv (renamed from numpy/random/randomgen/tests/data/philox-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/threefry-testset-1.csv (renamed from numpy/random/randomgen/tests/data/threefry-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/threefry-testset-2.csv (renamed from numpy/random/randomgen/tests/data/threefry-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/threefry32-testset-1.csv (renamed from numpy/random/randomgen/tests/data/threefry32-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/threefry32-testset-2.csv (renamed from numpy/random/randomgen/tests/data/threefry32-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xoroshiro128-testset-1.csv (renamed from numpy/random/randomgen/tests/data/xoroshiro128-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xoroshiro128-testset-2.csv (renamed from numpy/random/randomgen/tests/data/xoroshiro128-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xorshift1024-testset-1.csv (renamed from numpy/random/randomgen/tests/data/xorshift1024-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xorshift1024-testset-2.csv (renamed from numpy/random/randomgen/tests/data/xorshift1024-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xoshiro256starstar-testset-1.csv (renamed from numpy/random/randomgen/tests/data/xoshiro256starstar-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xoshiro256starstar-testset-2.csv (renamed from numpy/random/randomgen/tests/data/xoshiro256starstar-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xoshiro512starstar-testset-1.csv (renamed from numpy/random/randomgen/tests/data/xoshiro512starstar-testset-1.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/data/xoshiro512starstar-testset-2.csv (renamed from numpy/random/randomgen/tests/data/xoshiro512starstar-testset-2.csv) | 0 | ||||
| -rw-r--r-- | numpy/random/tests/test_against_numpy.py (renamed from numpy/random/randomgen/tests/test_against_numpy.py) | 38 | ||||
| -rw-r--r-- | numpy/random/tests/test_direct.py (renamed from numpy/random/randomgen/tests/test_direct.py) | 108 | ||||
| -rw-r--r-- | numpy/random/tests/test_generator_mt19937.py (renamed from numpy/random/randomgen/tests/test_generator_mt19937.py) | 169 | ||||
| -rw-r--r-- | numpy/random/tests/test_generator_mt19937_regressions.py (renamed from numpy/random/randomgen/tests/test_generator_mt19937_regressions.py) | 26 | ||||
| -rw-r--r-- | numpy/random/tests/test_randomstate.py (renamed from numpy/random/randomgen/tests/test_randomstate.py) | 2 | ||||
| -rw-r--r-- | numpy/random/tests/test_randomstate_regression.py (renamed from numpy/random/randomgen/tests/test_randomstate_regression.py) | 2 | ||||
| -rw-r--r-- | numpy/random/tests/test_smoke.py (renamed from numpy/random/randomgen/tests/test_smoke.py) | 228 | ||||
| -rw-r--r-- | numpy/random/threefry.pyx (renamed from numpy/random/randomgen/threefry.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/threefry32.pyx (renamed from numpy/random/randomgen/threefry32.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/xoroshiro128.pyx (renamed from numpy/random/randomgen/xoroshiro128.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/xorshift1024.pyx (renamed from numpy/random/randomgen/xorshift1024.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/xoshiro256starstar.pyx (renamed from numpy/random/randomgen/xoshiro256starstar.pyx) | 0 | ||||
| -rw-r--r-- | numpy/random/xoshiro512starstar.pyx (renamed from numpy/random/randomgen/xoshiro512starstar.pyx) | 0 | ||||
| -rwxr-xr-x | setup.py | 4 |
193 files changed, 693 insertions, 2449 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index e7fbf55fe..ff26afeb8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,7 +20,7 @@ jobs: command: | python3 -m venv venv . venv/bin/activate - pip install cython sphinx>=1.8.5 matplotlib ipython + pip install cython sphinx==1.8.5 matplotlib ipython sudo apt-get update sudo apt-get install -y graphviz texlive-fonts-recommended texlive-latex-recommended texlive-latex-extra texlive-generic-extra latexmk texlive-xetex diff --git a/.gitignore b/.gitignore index ac5693fad..485f37957 100644 --- a/.gitignore +++ b/.gitignore @@ -176,8 +176,8 @@ benchmarks/numpy # cythonized files cythonize.dat numpy/random/mtrand/mtrand.c -numpy/random/randomgen/*.c -numpy/random/randomgen/legacy/*.c -numpy/random/mtrand/randint_helpers.pxi -numpy/random/randomgen/bounded_integers.pyx -numpy/random/randomgen/bounded_integers.pxd +numpy/random/*.c +numpy/random/legacy/*.c +numpy/random/_mtrand/randint_helpers.pxi +numpy/random/bounded_integers.pyx +numpy/random/bounded_integers.pxd diff --git a/MANIFEST.in b/MANIFEST.in index 16d066519..e27b843a9 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -9,7 +9,8 @@ include pytest.ini include *.txt include README.md include site.cfg.example -recursive-include numpy/random/mtrand *.pyx *.pxd +include numpy/random/_mtrand/generate_mtrand_c.py +recursive-include numpy/random *.pyx *.pxd *.pyx.in *.pxd.in # Add build support that should go in sdist, but not go in bdist/be installed # Note that sub-directories that don't have __init__ are apparently not # included by 'recursive-include', so list those separately diff --git a/_randomgen/.gitattributes b/_randomgen/.gitattributes deleted file mode 100644 index 9b447556a..000000000 --- a/_randomgen/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -randomgen/_version.py export-subst diff --git a/_randomgen/.gitignore b/_randomgen/.gitignore deleted file mode 100644 index 381421b39..000000000 --- a/_randomgen/.gitignore +++ /dev/null @@ -1,26 +0,0 @@ -.idea/ -build/ -*.egg-info/ -*.pyd -*.pyc -*.html -*.obj -*.exe -**/Random123 -settings.json -*.so -randomgen/bounded_integers.pyx -randomgen/bounded_integers.pxd -randomgen/bounded_integers.c -randomgen/common.c -randomgen/dsfmt.c -randomgen/entropy.c -randomgen/generator.c -randomgen/mt19937.c -randomgen/pcg32.c -randomgen/pcg64.c -randomgen/philox.c -randomgen/threefry.c -randomgen/threefry32.c -randomgen/xoroshiro128.c -randomgen/xorshift1024.c diff --git a/_randomgen/.travis.yml b/_randomgen/.travis.yml deleted file mode 100644 index 89c5be3fa..000000000 --- a/_randomgen/.travis.yml +++ /dev/null @@ -1,72 +0,0 @@ -group: edge -dist: trusty -sudo: required -language: python - -env: - global: - # Doctr deploy key for bashtage/randomgen - - secure: "czwFlflS1lcfbSQ9ktv+pLAPV9/6+wmwiMTyIYyv5xgQVWRL5NRebWH+ZhQ6s2T5x17wFMtlafcAvkdV0CHQZLru34V2UNldCapuEtQ8b32EDHBXHKbs45b7SSkLx4TFXdjiJurleY4ZIKle0gX6BW21zYBwaHJqbN6I8nRv9Rp47XEU1UV1Mdf/PhfTnxY31rFrPYL77xeWJzoFfT8zao39V4gQds+1Ag7FjdNVdSDVKwDduF4kS7tIbKqb4M+jsbc3PIKyP9nyQpEQF5ebJuG7mqXJhVJGEL83rBx8MLFPA/1X3cUzKacgKyp2+Wmlt0EVhwCa1aRf9cSK6I7TbMC7/eGtDnC2ToiRlFJurVRblaEmhzVQS1yQ4Dkooqsj9hNVl6nhu7JfR52GLogns33Ec/yYuRcWcULKSlR5Cerfef/5YijBEhlr9X76SJiOpjvS4lwWFYX+h8xzuVhRLGwIVB9oQNllxYItzcDSGmRx+EOMXWASHmoUDnBOZg4GMVukqOcF5l0ynoepiA1YHLdZlMy6SB3P7BZKF/aNCOn9nXw+N9X4U/yUpkM3Pb7HoGdNrC8RO4SwrNjGrarkdEB6e1lBReK/dqcylaF/mpK9VLpfQszDI8xnR4VCmlEM+le0xOsyHfeGciabdI4KH0i0SfYl4ls5XrN+CaqFWdo=" - - PYPI=false - -cache: - directories: - - $HOME/.cache/pip - -matrix: - fast_finish: true - include: - - os: linux - env: [PYTHON=2.7, NUMPY=1.13, CYTHON=0.26] - - os: linux - env: [PYTHON=2.7] - - os: linux - env: [PYTHON=3.5, NUMPY=1.14] - - os: linux - env: [PYTHON=3.6, NUMPY=1.15, CYTHON=0.27] - - os: linux - python: 3.6 - env: [PYPI=true] - - os: linux - env: [PYTHON=3.7, DOCBUILD=true] - - os: osx - language: generic - env: [PYTHON=3.6] - - -before_install: - - git fetch --tags - - if [[ $PYPI = true ]]; then source ci/pypi-install.sh; else source ci/conda-install.sh; fi - - pip install tempita coverage coveralls pytest-cov codecov -q - - pip list - - export BUILD_DIR=${PWD} - - if [[ ${DOCBUILD} == true ]]; then pip install sphinx sphinx_rtd_theme guzzle_sphinx_theme ipython doctr -q; fi - - gcc --version || true - - clang --version || true - -install: - - python setup.py develop - -script: - - set -e - - pytest randomgen - - | - if [[ ${DOCBUILD} == true ]]; then - cd ${BUILD_DIR}/doc - make html - make html - cd ${BUILD_DIR} - doctr deploy devel --build-tags - if [[ -z ${TRAVIS_TAG} ]]; then - echo "Not a tagged build." - else - doctr deploy . --build-tags - fi - fi - -after_success: - - | - if [[ ${DOCBUILD} == true ]]; then - cd ${BUILD_DIR} - python benchmark.py; - fi diff --git a/_randomgen/README-git.md b/_randomgen/README-git.md deleted file mode 100644 index c77169390..000000000 --- a/_randomgen/README-git.md +++ /dev/null @@ -1,26 +0,0 @@ -These are the bash commands used to get the bashtage/randomgen repo into numpy/numpy - -```bash -# from a directory just above a numpy git checkout -git clone https://github.com/bashtage/randomgen.git -cd randomgen -# rewrite the checkout, pushing the content into '_randomgen' -git filter-branch --index-filter ' - git ls-files -s | - sed "s-\t-\t_randomgen/-" | - GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info && - mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE -' HEAD -# write this file, commit it -git add _randomgen/README-git.md -git commit -m"Add README-git.md" -git checkout -b randomgen -cd ../numpy -git checkout -b randomgen -git remote add randomgen ../randomgen -git fetch randomgen randomgen -git merge --allow-unrelated-histories randomgen/randomgen -git remote remove randomgen -# Now all the randomgen commits are on the randomgen branch in numpy, -# and there is a subdirectory _randomgen with the content -``` diff --git a/_randomgen/README.md b/_randomgen/README.md deleted file mode 100644 index 2e8073645..000000000 --- a/_randomgen/README.md +++ /dev/null @@ -1,288 +0,0 @@ -# RandomGen - -[](https://travis-ci.org/bashtage/randomgen) -[](https://ci.appveyor.com/project/bashtage/randomgen/branch/master) -[](https://pypi.org/project/randomgen/) - -Random Number Generator using settable Basic RNG interface for future -NumPy RandomState evolution. - -This is a library and generic interface for alternative random -generators in Python and NumPy. - -## Python 2.7 Support - -v1.16 is the final major version that supports Python 2.7. Any bugs -in v1.16 will be patched until the end of 2019. All future releases -are Python 3, with an initial minimum version of 3.5. - -## Compatibility Warning - -`RandomGenerator` does not support Box-Muller normal variates and so it not -100% compatible with NumPy (or randomstate). Box-Muller normals are slow -to generate and all functions which previously relied on Box-Muller -normals now use the faster Ziggurat implementation. If you require backward -compatibility, a legacy generator, ``LegacyGenerator``, has been created -which can fully reproduce the sequence produced by NumPy. - -## Features - -* Replacement for NumPy's RandomState - - ```python - from randomgen import RandomGenerator, MT19937 - rnd = RandomGenerator(MT19937()) - x = rnd.standard_normal(100) - y = rnd.random_sample(100) - z = rnd.randn(10,10) - ``` - -* Default random generator is a fast generator called Xoroshiro128plus -* Support for random number generators that support independent streams - and jumping ahead so that sub-streams can be generated -* Faster random number generation, especially for normal, standard - exponential and standard gamma using the Ziggurat method - - ```python - from randomgen import RandomGenerator - # Default basic PRNG is Xoroshiro128 - rnd = RandomGenerator() - w = rnd.standard_normal(10000) - x = rnd.standard_exponential(10000) - y = rnd.standard_gamma(5.5, 10000) - ``` - -* Support for 32-bit floating randoms for core generators. - Currently supported: - - * Uniforms (`random_sample`) - * Exponentials (`standard_exponential`, both Inverse CDF and Ziggurat) - * Normals (`standard_normal`) - * Standard Gammas (via `standard_gamma`) - - **WARNING**: The 32-bit generators are **experimental** and subject - to change. - - **Note**: There are _no_ plans to extend the alternative precision - generation to all distributions. - -* Support for filling existing arrays using `out` keyword argument. Currently - supported in (both 32- and 64-bit outputs) - - * Uniforms (`random_sample`) - * Exponentials (`standard_exponential`) - * Normals (`standard_normal`) - * Standard Gammas (via `standard_gamma`) - -* Support for Lemire's method of generating uniform integers on an - arbitrary interval by setting `use_masked=True`. - -## Included Pseudo Random Number Generators - -This module includes a number of alternative random -number generators in addition to the MT19937 that is included in NumPy. -The RNGs include: - -* [MT19937](https://github.com/numpy/numpy/blob/master/numpy/random/mtrand/), - the NumPy rng -* [dSFMT](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/) a - SSE2-aware version of the MT19937 generator that is especially fast at - generating doubles -* [xoroshiro128+](http://xoroshiro.di.unimi.it/), - [xorshift1024*φ](http://xorshift.di.unimi.it/), - [xoshiro256**](http://xorshift.di.unimi.it/), - and [xoshiro512**](http://xorshift.di.unimi.it/) -* [PCG64](http://www.pcg-random.org/) -* ThreeFry and Philox from [Random123](https://www.deshawresearch.com/resources_random123.html) - -## Differences from `numpy.random.RandomState` - -### New Features - -* `standard_normal`, `normal`, `randn` and `multivariate_normal` all - use the much faster (100%+) Ziggurat method. -* `standard_gamma` and `gamma` both use the much faster Ziggurat method. -* `standard_exponential` `exponential` both support an additional - `method` keyword argument which can be `inv` or - `zig` where `inv` corresponds to the current method using the inverse - CDF and `zig` uses the much faster (100%+) Ziggurat method. -* Core random number generators can produce either single precision - (`np.float32`) or double precision (`np.float64`, the default) using - the optional keyword argument `dtype` -* Core random number generators can fill existing arrays using the - `out` keyword argument -* Standardizes integer-values random values as int64 for all platforms. -* `randint` supports generating using rejection sampling on masked - values (the default) or Lemire's method. Lemire's method can be much - faster when the required interval length is much smaller than the - closes power of 2. - -### New Functions - -* `random_entropy` - Read from the system entropy provider, which is - commonly used in cryptographic applications -* `random_raw` - Direct access to the values produced by the underlying - PRNG. The range of the values returned depends on the specifics of the - PRNG implementation. -* `random_uintegers` - unsigned integers, either 32- (`[0, 2**32-1]`) - or 64-bit (`[0, 2**64-1]`) -* `jump` - Jumps RNGs that support it. `jump` moves the state a great - distance. _Only available if supported by the RNG._ -* `advance` - Advanced the RNG 'as-if' a number of draws were made, - without actually drawing the numbers. _Only available if supported by - the RNG._ - -## Status - -* Builds and passes all tests on: - * Linux 32/64 bit, Python 2.7, 3.4, 3.5, 3.6, 3.6 - * PC-BSD (FreeBSD) 64-bit, Python 2.7 - * OSX 64-bit, Python 2.7, 3.5, 3.6, 3.7 - * Windows 32/64 bit, Python 2.7, 3.5, 3.6 and 3.7 - -## Version - -The version matched the latest version of NumPy where -`LegacyGenerator(MT19937())` passes all NumPy test. - -## Documentation - -Documentation for the latest release is available on -[my GitHub pages](http://bashtage.github.io/randomgen/). Documentation for -the latest commit (unreleased) is available under -[devel](http://bashtage.github.io/randomgen/devel/). - -## Plans - -This module is essentially complete. There are a few rough edges that -need to be smoothed. - -* Creation of additional streams from where supported - (i.e. a `next_stream()` method) - -## Requirements -Building requires: - -* Python (2.7, 3.5, 3.6, 3.7) -* NumPy (1.13, 1.14, 1.15, 1.16) -* Cython (0.26+) -* tempita (0.5+), if not provided by Cython - -Testing requires pytest (4.0+). - -**Note:** it might work with other versions but only tested with these -versions. - -## Development and Testing - -All development has been on 64-bit Linux, and it is regularly tested on -Travis-CI (Linux/OSX) and Appveyor (Windows). The library is occasionally -tested on Linux 32-bit and Free BSD 11.1. - -Basic tests are in place for all RNGs. The MT19937 is tested against -NumPy's implementation for identical results. It also passes NumPy's -test suite where still relevant. - -## Installing - -Either install from PyPi using - -```bash -pip install randomgen -``` - -or, if you want the latest version, - -```bash -pip install git+https://github.com/bashtage/randomgen.git -``` - -or from a cloned repo, - -```bash -python setup.py install -``` - -### SSE2 - -`dSFTM` makes use of SSE2 by default. If you have a very old computer -or are building on non-x86, you can install using: - -```bash -python setup.py install --no-sse2 -``` - -### Windows - -Either use a binary installer, or if building from scratch, use -Python 3.6 with Visual Studio 2015/2017 Community Edition. It can also -be build using Microsoft Visual C++ Compiler for Python 2.7 and -Python 2.7. - -## Using - -The separate generators are importable from `randomgen` - -```python -from randomgen import RandomGenerator, ThreeFry, PCG64, MT19937 -rg = RandomGenerator(ThreeFry()) -rg.random_sample(100) - -rg = RandomGenerator(PCG64()) -rg.random_sample(100) - -# Identical to NumPy -rg = RandomGenerator(MT19937()) -rg.random_sample(100) -``` - -## License - -Standard NCSA, plus sub licenses for components. - -## Performance - -Performance is promising, and even the mt19937 seems to be faster than -NumPy's mt19937. - - Speed-up relative to NumPy (Uniform Doubles) - ************************************************************ - DSFMT 184.9% - MT19937 17.3% - PCG32 83.3% - PCG64 108.3% - Philox -4.9% - ThreeFry -12.0% - ThreeFry32 -63.9% - Xoroshiro128 159.5% - Xorshift1024 150.4% - Xoshiro256StarStar 145.7% - Xoshiro512StarStar 113.1% - - Speed-up relative to NumPy (64-bit unsigned integers) - ************************************************************ - DSFMT 17.4% - MT19937 7.8% - PCG32 60.3% - PCG64 73.5% - Philox -25.5% - ThreeFry -30.5% - ThreeFry32 -67.8% - Xoroshiro128 124.0% - Xorshift1024 109.4% - Xoshiro256StarStar 100.3% - Xoshiro512StarStar 63.5% - - Speed-up relative to NumPy (Standard normals) - ************************************************************ - DSFMT 183.0% - MT19937 169.0% - PCG32 240.7% - PCG64 231.6% - Philox 131.3% - ThreeFry 118.3% - ThreeFry32 21.6% - Xoroshiro128 332.1% - Xorshift1024 232.4% - Xoshiro256StarStar 306.6% - Xoshiro512StarStar 274.6% diff --git a/_randomgen/README.rst b/_randomgen/README.rst deleted file mode 100644 index 7e91b898d..000000000 --- a/_randomgen/README.rst +++ /dev/null @@ -1,320 +0,0 @@ -RandomGen -========= - -|Travis Build Status| |Appveyor Build Status| |PyPI version| - -Random Number Generator using settable Basic RNG interface for future -NumPy RandomState evolution. - -This is a library and generic interface for alternative random -generators in Python and NumPy. - -Python 2.7 Support ------------------- - -Release 1.16.0 is the final version that supports Python 2.7. Any bugs -in v1.16.0 will be patched until the end of 2019. All future releases -are Python 3, with an initial minimum version of 3.5. - -Compatibility Warning ---------------------- - -``RandomGenerator`` does not support Box-Muller normal variates and so -it not 100% compatible with NumPy (or randomstate). Box-Muller normals -are slow to generate and all functions which previously relied on -Box-Muller normals now use the faster Ziggurat implementation. If you -require backward compatibility, a legacy generator, ``LegacyGenerator``, -has been created which can fully reproduce the sequence produced by -NumPy. - -Features --------- - -- Replacement for NumPy’s RandomState - - .. code:: python - - from randomgen import RandomGenerator, MT19937 - rnd = RandomGenerator(MT19937()) - x = rnd.standard_normal(100) - y = rnd.random_sample(100) - z = rnd.randn(10,10) - -- Default random generator is a fast generator called Xoroshiro128plus -- Support for random number generators that support independent streams - and jumping ahead so that sub-streams can be generated -- Faster random number generation, especially for normal, standard - exponential and standard gamma using the Ziggurat method - - .. code:: python - - from randomgen import RandomGenerator - # Default basic PRNG is Xoroshiro128 - rnd = RandomGenerator() - w = rnd.standard_normal(10000) - x = rnd.standard_exponential(10000) - y = rnd.standard_gamma(5.5, 10000) - -- Support for 32-bit floating randoms for core generators. Currently - supported: - - - Uniforms (``random_sample``) - - Exponentials (``standard_exponential``, both Inverse CDF and - Ziggurat) - - Normals (``standard_normal``) - - Standard Gammas (via ``standard_gamma``) - - **WARNING**: The 32-bit generators are **experimental** and subject - to change. - - **Note**: There are *no* plans to extend the alternative precision - generation to all distributions. - -- Support for filling existing arrays using ``out`` keyword argument. - Currently supported in (both 32- and 64-bit outputs) - - - Uniforms (``random_sample``) - - Exponentials (``standard_exponential``) - - Normals (``standard_normal``) - - Standard Gammas (via ``standard_gamma``) - -- Support for Lemire’s method of generating uniform integers on an - arbitrary interval by setting ``use_masked=True``. - -Included Pseudo Random Number Generators ----------------------------------------- - -This module includes a number of alternative random number generators in -addition to the MT19937 that is included in NumPy. The RNGs include: - -- `MT19937 <https://github.com/numpy/numpy/blob/master/numpy/random/mtrand/>`__, - the NumPy rng -- `dSFMT <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/>`__ a - SSE2-aware version of the MT19937 generator that is especially fast - at generating doubles -- `xoroshiro128+ <http://xoroshiro.di.unimi.it/>`__, - `xorshift1024*φ <http://xorshift.di.unimi.it/>`__, - `xoshiro256*\* <http://xorshift.di.unimi.it/>`__, and - `xoshiro512*\* <http://xorshift.di.unimi.it/>`__ -- `PCG64 <http://www.pcg-random.org/>`__ -- ThreeFry and Philox from - `Random123 <https://www.deshawresearch.com/resources_random123.html>`__ - -Differences from ``numpy.random.RandomState`` ---------------------------------------------- - -New Features -~~~~~~~~~~~~ - -- ``standard_normal``, ``normal``, ``randn`` and - ``multivariate_normal`` all use the much faster (100%+) Ziggurat - method. -- ``standard_gamma`` and ``gamma`` both use the much faster Ziggurat - method. -- ``standard_exponential`` ``exponential`` both support an additional - ``method`` keyword argument which can be ``inv`` or ``zig`` where - ``inv`` corresponds to the current method using the inverse CDF and - ``zig`` uses the much faster (100%+) Ziggurat method. -- Core random number generators can produce either single precision - (``np.float32``) or double precision (``np.float64``, the default) - using the optional keyword argument ``dtype`` -- Core random number generators can fill existing arrays using the - ``out`` keyword argument -- Standardizes integer-values random values as int64 for all platforms. -- ``randint`` supports generating using rejection sampling on masked - values (the default) or Lemire’s method. Lemire’s method can be much - faster when the required interval length is much smaller than the - closes power of 2. - -New Functions -~~~~~~~~~~~~~ - -- ``random_entropy`` - Read from the system entropy provider, which is - commonly used in cryptographic applications -- ``random_raw`` - Direct access to the values produced by the - underlying PRNG. The range of the values returned depends on the - specifics of the PRNG implementation. -- ``random_uintegers`` - unsigned integers, either 32- - (``[0, 2**32-1]``) or 64-bit (``[0, 2**64-1]``) -- ``jump`` - Jumps RNGs that support it. ``jump`` moves the state a - great distance. *Only available if supported by the RNG.* -- ``advance`` - Advanced the RNG ‘as-if’ a number of draws were made, - without actually drawing the numbers. *Only available if supported by - the RNG.* - -Status ------- - -- Builds and passes all tests on: - - - Linux 32/64 bit, Python 2.7, 3.5, 3.6, 3.7 - - PC-BSD (FreeBSD) 64-bit, Python 2.7 - - OSX 64-bit, Python 2.7, 3.5, 3.6, 3.7 - - Windows 32/64 bit, Python 2.7, 3.5, 3.6, and 3.7 - -Version -------- - -The version matched the latest version of NumPy where -``LegacyGenerator(MT19937())`` passes all NumPy test. - -Documentation -------------- - -Documentation for the latest release is available on `my GitHub -pages <http://bashtage.github.io/randomgen/>`__. Documentation for the -latest commit (unreleased) is available under -`devel <http://bashtage.github.io/randomgen/devel/>`__. - -Plans ------ - -This module is essentially complete. There are a few rough edges that -need to be smoothed. - -- Creation of additional streams from where supported (i.e. a - ``next_stream()`` method) - -Requirements ------------- - -Building requires: - -- Python (2.7, 3.5, 3.6, 3.7) -- NumPy (1.13, 1.14, 1.15, 1.16) -- Cython (0.26+) -- tempita (0.5+), if not provided by Cython - -Testing requires pytest (4.0+). - -**Note:** it might work with other versions but only tested with these -versions. - -Development and Testing ------------------------ - -All development has been on 64-bit Linux, and it is regularly tested on -Travis-CI (Linux/OSX) and Appveyor (Windows). The library is -occasionally tested on Linux 32-bit and Free BSD 11.1. - -Basic tests are in place for all RNGs. The MT19937 is tested against -NumPy’s implementation for identical results. It also passes NumPy’s -test suite where still relevant. - -Installing ----------- - -Either install from PyPi using - -.. code:: bash - - pip install randomgen - -or, if you want the latest version, - -.. code:: bash - - pip install git+https://github.com/bashtage/randomgen.git - -or from a cloned repo, - -.. code:: bash - - python setup.py install - -SSE2 -~~~~ - -``dSFTM`` makes use of SSE2 by default. If you have a very old computer -or are building on non-x86, you can install using: - -.. code:: bash - - python setup.py install --no-sse2 - -Windows -~~~~~~~ - -Either use a binary installer, or if building from scratch, use Python -3.6 with Visual Studio 2015/2017 Community Edition. It can also be build -using Microsoft Visual C++ Compiler for Python 2.7 and Python 2.7. - -Using ------ - -The separate generators are importable from ``randomgen`` - -.. code:: python - - from randomgen import RandomGenerator, ThreeFry, PCG64, MT19937 - rg = RandomGenerator(ThreeFry()) - rg.random_sample(100) - - rg = RandomGenerator(PCG64()) - rg.random_sample(100) - - # Identical to NumPy - rg = RandomGenerator(MT19937()) - rg.random_sample(100) - -License -------- - -Standard NCSA, plus sub licenses for components. - -Performance ------------ - -Performance is promising, and even the mt19937 seems to be faster than -NumPy’s mt19937. - -:: - - Speed-up relative to NumPy (Uniform Doubles) - ************************************************************ - DSFMT 184.9% - MT19937 17.3% - PCG32 83.3% - PCG64 108.3% - Philox -4.9% - ThreeFry -12.0% - ThreeFry32 -63.9% - Xoroshiro128 159.5% - Xorshift1024 150.4% - Xoshiro256StarStar 145.7% - Xoshiro512StarStar 113.1% - - Speed-up relative to NumPy (64-bit unsigned integers) - ************************************************************ - DSFMT 17.4% - MT19937 7.8% - PCG32 60.3% - PCG64 73.5% - Philox -25.5% - ThreeFry -30.5% - ThreeFry32 -67.8% - Xoroshiro128 124.0% - Xorshift1024 109.4% - Xoshiro256StarStar 100.3% - Xoshiro512StarStar 63.5% - - Speed-up relative to NumPy (Standard normals) - ************************************************************ - DSFMT 183.0% - MT19937 169.0% - PCG32 240.7% - PCG64 231.6% - Philox 131.3% - ThreeFry 118.3% - ThreeFry32 21.6% - Xoroshiro128 332.1% - Xorshift1024 232.4% - Xoshiro256StarStar 306.6% - Xoshiro512StarStar 274.6% - -.. |Travis Build Status| image:: https://travis-ci.org/bashtage/randomgen.svg?branch=master - :target: https://travis-ci.org/bashtage/randomgen -.. |Appveyor Build Status| image:: https://ci.appveyor.com/api/projects/status/odc5c4ukhru5xicl/branch/master?svg=true - :target: https://ci.appveyor.com/project/bashtage/randomgen/branch/master -.. |PyPI version| image:: https://badge.fury.io/py/randomgen.svg - :target: https://pypi.org/project/randomgen/ diff --git a/_randomgen/benchmark.py b/_randomgen/benchmark.py deleted file mode 100644 index c4c4ab93d..000000000 --- a/_randomgen/benchmark.py +++ /dev/null @@ -1,201 +0,0 @@ -import os -import struct -import timeit - -import numpy as np -import pandas as pd -from numpy.random import RandomState - -rs = RandomState() - -SETUP = ''' -import numpy as np -if '{brng}' == 'numpy': - import numpy.random - rg = numpy.random.RandomState() -else: - from randomgen import RandomGenerator, {brng} - rg = RandomGenerator({brng}()) -rg.random_sample() -''' - -scale_32 = scale_64 = 1 -if struct.calcsize('P') == 8 and os.name != 'nt': - # 64 bit - scale_32 = 0.5 -else: - scale_64 = 2 - -PRNGS = ['DSFMT', 'PCG64', 'PCG32', 'MT19937', 'Xoroshiro128', 'Xorshift1024', - 'Xoshiro256StarStar', 'Xoshiro512StarStar', 'Philox', 'ThreeFry', - 'ThreeFry32', 'numpy'] - - -def timer(code, setup): - return 1000 * min(timeit.Timer(code, setup=setup).repeat(10, 10)) / 10.0 - - -def print_legend(legend): - print('\n' + legend + '\n' + '*' * max(60, len(legend))) - - -def run_timer(dist, command, numpy_command=None, setup='', random_type=''): - print('-' * 80) - if numpy_command is None: - numpy_command = command - - res = {} - for brng in PRNGS: - cmd = numpy_command if brng == 'numpy' else command - res[brng] = timer(cmd, setup=setup.format(brng=brng)) - - s = pd.Series(res) - t = s.apply(lambda x: '{0:0.2f} ms'.format(x)) - print_legend('Time to produce 1,000,000 ' + random_type) - print(t.sort_index()) - - p = 1000.0 / s - p = p.apply(lambda x: '{0:0.2f} million'.format(x)) - print_legend(random_type + ' per second') - print(p.sort_index()) - - baseline = [k for k in p.index if 'numpy' in k][0] - p = 1000.0 / s - p = p / p[baseline] * 100 - 100 - p = p.drop(baseline, 0) - p = p.apply(lambda x: '{0:0.1f}%'.format(x)) - print_legend('Speed-up relative to NumPy') - print(p.sort_index()) - print('-' * 80) - - -def timer_raw(): - dist = 'random_raw' - command = 'rg.random_raw(size=1000000, output=False)' - info = np.iinfo(np.int32) - command_numpy = 'rg.random_integers({max},size=1000000)' - command_numpy = command_numpy.format(max=info.max) - run_timer(dist, command, command_numpy, SETUP, 'Raw Values') - - -def timer_uniform(): - dist = 'random_sample' - command = 'rg.random_sample(1000000)' - run_timer(dist, command, None, SETUP, 'Uniforms') - - -def timer_bounded(bits=8, max=95, use_masked=True): - """ - Timer for 8-bit bounded values. - - Parameters - ---------- - bits : {8, 16, 32, 64} - Bit width of unsigned output type - max : int - Upper bound for range. Lower is always 0. Must be <= 2**bits. - use_masked: bool - If True, masking and rejection sampling is used to generate a random - number in an interval. If False, Lemire's algorithm is used if - available to generate a random number in an interval. - - Notes - ----- - Lemire's algorithm has improved performance when {max}+1 is not a - power of two. - """ - if bits not in (8, 16, 32, 64): - raise ValueError('bits must be one of 8, 16, 32, 64.') - minimum = 0 - - dist = 'random_uintegers' - - if use_masked: # Use masking & rejection. - command = 'rg.randint({min}, {max}+1, 1000000, dtype=np.uint{bits}, use_masked=True)' - else: # Use Lemire's algo. - command = 'rg.randint({min}, {max}+1, 1000000, dtype=np.uint{bits}, use_masked=False)' - - command = command.format(min=minimum, max=max, bits=bits) - - command_numpy = 'rg.randint({min}, {max}+1, 1000000, dtype=np.uint{bits})' - command_numpy = command_numpy.format(min=minimum, max=max, bits=bits) - - run_timer(dist, command, command_numpy, SETUP, - '{bits}-bit bounded unsigned integers (max={max}, ' - 'use_masked={use_masked})'.format(max=max, use_masked=use_masked, bits=bits)) - - -def timer_32bit(): - info = np.iinfo(np.uint32) - minimum, maximum = info.min, info.max - dist = 'random_uintegers' - command = 'rg.random_uintegers(1000000, 32)' - command_numpy = 'rg.randint({min}, {max}+1, 1000000, dtype=np.uint32)' - command_numpy = command_numpy.format(min=minimum, max=maximum) - run_timer(dist, command, command_numpy, SETUP, '32-bit unsigned integers') - - -def timer_64bit(): - info = np.iinfo(np.uint64) - minimum, maximum = info.min, info.max - dist = 'random_uintegers' - command = 'rg.random_uintegers(1000000)' - command_numpy = 'rg.randint({min}, {max}+1, 1000000, dtype=np.uint64)' - command_numpy = command_numpy.format(min=minimum, max=maximum) - run_timer(dist, command, command_numpy, SETUP, '64-bit unsigned integers') - - -def timer_normal_zig(): - dist = 'standard_normal' - command = 'rg.standard_normal(1000000)' - command_numpy = 'rg.standard_normal(1000000)' - run_timer(dist, command, command_numpy, SETUP, - 'Standard normals (Ziggurat)') - - -if __name__ == '__main__': - import argparse - - parser = argparse.ArgumentParser() - parser.add_argument('-f', '--full', - help='Run benchmarks for a wide range of distributions.' - ' If not provided, only tests the production of ' - 'uniform values.', - dest='full', action='store_true') - parser.add_argument('-bi', '--bounded-ints', - help='Included benchmark coverage of the bounded ' - 'integer generators in a full run.', - dest='bounded_ints', action='store_true') - args = parser.parse_args() - - timer_uniform() - if args.full: - timer_raw() - if args.bounded_ints: - timer_bounded(use_masked=True) - timer_bounded(max=64, use_masked=False) # Worst case for Numpy. - timer_bounded(max=95, use_masked=False) # Typ. avrg. case for Numpy. - timer_bounded(max=127, use_masked=False) # Best case for Numpy. - - timer_bounded(16, use_masked=True) - timer_bounded(16, max=1024, use_masked=False) # Worst case for Numpy. - timer_bounded(16, max=1535, use_masked=False) # Typ. avrg. case for Numpy. - timer_bounded(16, max=2047, use_masked=False) # Best case for Numpy. - - timer_32bit() - - if args.bounded_ints: - timer_bounded(32, use_masked=True) - timer_bounded(32, max=1024, use_masked=False) # Worst case for Numpy. - timer_bounded(32, max=1535, use_masked=False) # Typ. avrg. case for Numpy. - timer_bounded(32, max=2047, use_masked=False) # Best case for Numpy. - - timer_64bit() - - if args.bounded_ints: - timer_bounded(64, use_masked=True) - timer_bounded(64, max=1024, use_masked=False) # Worst case for Numpy. - timer_bounded(64, max=1535, use_masked=False) # Typ. avrg. case for Numpy. - timer_bounded(64, max=2047, use_masked=False) # Best case for Numpy. - - timer_normal_zig() diff --git a/_randomgen/setup.py b/_randomgen/setup.py deleted file mode 100644 index 9e9517e97..000000000 --- a/_randomgen/setup.py +++ /dev/null @@ -1,325 +0,0 @@ -import os -import glob -import platform -import struct -import sys -from os.path import join - -import Cython.Compiler.Options -import numpy as np -from Cython.Build import cythonize -from setuptools import setup, find_packages, Distribution -from setuptools.extension import Extension - -try: - import Cython.Tempita as tempita -except ImportError: - try: - import tempita - except ImportError: - raise ImportError('tempita required to install, ' - 'use pip install tempita') - -try: - import pypandoc - # With an input file: it will infer the input format from the filename - with open('README.rst', 'wb') as readme: - readme.write(pypandoc.convert_file('README.md', 'rst').encode('utf8')) -except ImportError: - import warnings - warnings.warn( - 'Unable to import pypandoc. Do not use this as a release build!') - -import versioneer - -with open('requirements.txt') as f: - required = f.read().splitlines() - -Cython.Compiler.Options.annotate = True - -# Make a guess as to whether SSE2 is present for now, TODO: Improve -USE_SSE2 = False -for k in platform.uname(): - for val in ('x86', 'i686', 'i386', 'amd64'): - USE_SSE2 = USE_SSE2 or val in k.lower() -print('Building with SSE?: {0}'.format(USE_SSE2)) -if '--no-sse2' in sys.argv: - USE_SSE2 = False - sys.argv.remove('--no-sse2') - -MOD_DIR = './randomgen' - -DEBUG = False -PCG_EMULATED_MATH = False - -EXTRA_INCLUDE_DIRS = [] -EXTRA_LINK_ARGS = [] -EXTRA_LIBRARIES = ['m'] if os.name != 'nt' else [] -# Undef for manylinux -EXTRA_COMPILE_ARGS = [] if os.name == 'nt' else [ - '-std=c99', '-U__GNUC_GNU_INLINE__'] -if os.name == 'nt': - EXTRA_LINK_ARGS = ['/LTCG', '/OPT:REF', 'Advapi32.lib', 'Kernel32.lib'] - if DEBUG: - EXTRA_LINK_ARGS += ['-debug'] - EXTRA_COMPILE_ARGS += ["-Zi", "/Od"] - if sys.version_info < (3, 0): - EXTRA_INCLUDE_DIRS += [join(MOD_DIR, 'src', 'common')] - -PCG64_DEFS = [] -if sys.maxsize < 2 ** 32 or os.name == 'nt': - # Force emulated mode here - PCG_EMULATED_MATH = True - PCG64_DEFS += [('PCG_FORCE_EMULATED_128BIT_MATH', '1')] - -DSFMT_DEFS = [('DSFMT_MEXP', '19937')] -if USE_SSE2: - if os.name == 'nt': - EXTRA_COMPILE_ARGS += ['/wd4146', '/GL'] - if struct.calcsize('P') < 8: - EXTRA_COMPILE_ARGS += ['/arch:SSE2'] - else: - EXTRA_COMPILE_ARGS += ['-msse2'] - DSFMT_DEFS += [('HAVE_SSE2', '1')] -if struct.calcsize('P') < 8: - PCG_EMULATED_MATH = True - -files = glob.glob('./randomgen/*.in') -for templated_file in files: - output_file_name = os.path.splitext(templated_file)[0] - if (os.path.exists(output_file_name) and - (os.path.getmtime(templated_file) < os.path.getmtime(output_file_name))): - continue - with open(templated_file, 'r') as source_file: - template = tempita.Template(source_file.read()) - with open(output_file_name, 'w') as output_file: - output_file.write(template.substitute()) - - -extensions = [Extension('randomgen.entropy', - sources=[join(MOD_DIR, 'entropy.pyx'), - join(MOD_DIR, 'src', 'entropy', 'entropy.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'entropy')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.dsfmt", - ["randomgen/dsfmt.pyx", - join(MOD_DIR, 'src', 'dsfmt', 'dSFMT.c'), - join(MOD_DIR, 'src', 'dsfmt', 'dSFMT-jump.c'), - join(MOD_DIR, 'src', 'aligned_malloc', 'aligned_malloc.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'dsfmt')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - define_macros=DSFMT_DEFS, - ), - Extension("randomgen.mt19937", - ["randomgen/mt19937.pyx", - join(MOD_DIR, 'src', 'mt19937', 'mt19937.c'), - join(MOD_DIR, 'src', 'mt19937', 'mt19937-jump.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'mt19937')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.philox", - ["randomgen/philox.pyx", - join(MOD_DIR, 'src', 'philox', 'philox.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'philox')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.pcg64", - ["randomgen/pcg64.pyx", - join(MOD_DIR, 'src', 'pcg64', 'pcg64.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'pcg64')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - define_macros=PCG64_DEFS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.pcg32", - ["randomgen/pcg32.pyx", - join(MOD_DIR, 'src', 'pcg32', 'pcg32.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'pcg32')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.threefry", - ["randomgen/threefry.pyx", - join(MOD_DIR, 'src', 'threefry', 'threefry.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'threefry')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.threefry32", - ["randomgen/threefry32.pyx", - join(MOD_DIR, 'src', 'threefry32', 'threefry32.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'threefry32')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.xoroshiro128", - ["randomgen/xoroshiro128.pyx", - join(MOD_DIR, 'src', 'xoroshiro128', - 'xoroshiro128.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join( - MOD_DIR, 'src', - 'xoroshiro128')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.xorshift1024", - ["randomgen/xorshift1024.pyx", - join(MOD_DIR, 'src', 'xorshift1024', - 'xorshift1024.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join(MOD_DIR, 'src', - 'xorshift1024')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.xoshiro256starstar", - ["randomgen/xoshiro256starstar.pyx", - join(MOD_DIR, 'src', 'xoshiro256starstar', - 'xoshiro256starstar.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join( - MOD_DIR, 'src', - 'xoshiro256starstar')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.xoshiro512starstar", - ["randomgen/xoshiro512starstar.pyx", - join(MOD_DIR, 'src', 'xoshiro512starstar', - 'xoshiro512starstar.c')], - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include(), - join( - MOD_DIR, 'src', - 'xoshiro512starstar')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.generator", - ["randomgen/generator.pyx", - join(MOD_DIR, 'src', 'distributions', - 'distributions.c')], - libraries=EXTRA_LIBRARIES, - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include()], - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.common", - ["randomgen/common.pyx"], - libraries=EXTRA_LIBRARIES, - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include()], - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.bounded_integers", - ["randomgen/bounded_integers.pyx", - join(MOD_DIR, 'src', 'distributions', - 'distributions.c')], - libraries=EXTRA_LIBRARIES, - include_dirs=EXTRA_INCLUDE_DIRS + [np.get_include()], - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - Extension("randomgen.legacy.legacy", - ["randomgen/legacy/legacy.pyx", - join(MOD_DIR, 'src', 'legacy', - 'distributions-boxmuller.c'), - join(MOD_DIR, 'src', 'distributions', 'distributions.c')], - libraries=EXTRA_LIBRARIES, - include_dirs=EXTRA_INCLUDE_DIRS + - [np.get_include()] + [join(MOD_DIR, 'legacy')], - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS - ), - ] - - -classifiers = ['Development Status :: 5 - Production/Stable', - 'Environment :: Console', - 'Intended Audience :: End Users/Desktop', - 'Intended Audience :: Financial and Insurance Industry', - 'Intended Audience :: Information Technology', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX :: Linux', - 'Operating System :: Unix', - 'Programming Language :: C', - 'Programming Language :: Cython', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Topic :: Adaptive Technologies', - 'Topic :: Artistic Software', - 'Topic :: Office/Business :: Financial', - 'Topic :: Scientific/Engineering', - 'Topic :: Security :: Cryptography'] - - -class BinaryDistribution(Distribution): - def is_pure(self): - return False - - -setup( - name='randomgen', - version=versioneer.get_version(), - classifiers=classifiers, - cmdclass=versioneer.get_cmdclass(), - ext_modules=cythonize(extensions, - compile_time_env={"PCG_EMULATED_MATH": PCG_EMULATED_MATH}, - compiler_directives={'language_level': '3'}), - packages=find_packages(), - package_dir={'randomgen': './randomgen'}, - package_data={'': ['*.h', '*.pxi', '*.pyx', '*.pxd', '*.in'], - 'randomgen.tests.data': ['*.csv']}, - include_package_data=True, - license='NSCA', - author='Kevin Sheppard', - author_email='kevin.k.sheppard@gmail.com', - distclass=BinaryDistribution, - long_description=open('README.rst').read(), - description='Random generator supporting multiple PRNGs', - url='https://github.com/bashtage/randomgen', - keywords=['pseudo random numbers', 'PRNG', 'RNG', 'RandomState', 'random', - 'random numbers', 'parallel random numbers', 'PCG', - 'XorShift', 'dSFMT', 'MT19937', 'Random123', 'ThreeFry', - 'Philox'], - zip_safe=False, - install_requires=required -) diff --git a/benchmarks/benchmarks/bench_random.py b/benchmarks/benchmarks/bench_random.py index 9d84d83d3..38a079e84 100644 --- a/benchmarks/benchmarks/bench_random.py +++ b/benchmarks/benchmarks/bench_random.py @@ -4,6 +4,8 @@ from .common import Benchmark import numpy as np +from numpy.random import RandomState +from numpy.random.randomgen import RandomGenerator class Random(Benchmark): params = ['normal', 'uniform', 'weibull 1', 'binomial 10 0.5', @@ -80,3 +82,100 @@ class Permutation(Benchmark): def time_permutation_int(self): np.random.permutation(self.n) + +nom_size = 100000 + +class RNG(Benchmark): + param_names = ['rng'] + params = ['DSFMT', 'PCG64', 'PCG32', 'MT19937', 'Xoroshiro128', + 'Xorshift1024', 'Xoshiro256StarStar', 'Xoshiro512StarStar', + 'Philox', 'ThreeFry', 'ThreeFry32', 'numpy'] + + def setup(self, brng): + if brng == 'numpy': + self.rg = np.random.RandomState() + else: + self.rg = RandomGenerator(getattr(np.random.randomgen, brng)()) + self.rg.random_sample() + self.int32info = np.iinfo(np.int32) + self.uint32info = np.iinfo(np.uint32) + self.uint64info = np.iinfo(np.uint64) + + def time_raw(self, brng): + if brng == 'numpy': + self.rg.random_integers(self.int32info.max, size=nom_size) + else: + self.rg.random_integers(self.int32info.max, size=nom_size) + + def time_32bit(self, brng): + min, max = self.uint32info.min, self.uint32info.max + self.rg.randint(min, max + 1, nom_size, dtype=np.uint32) + + def time_64bit(self, brng): + min, max = self.uint64info.min, self.uint64info.max + self.rg.randint(min, max + 1, nom_size, dtype=np.uint64) + + def time_normal_zig(self, brng): + self.rg.standard_normal(nom_size) + +class Bounded(Benchmark): + u8 = np.uint8 + u16 = np.uint16 + u32 = np.uint32 + u64 = np.uint64 + param_names = ['rng', 'dt_max_masked'] + params = [['DSFMT', 'PCG64', 'PCG32', 'MT19937', 'Xoroshiro128', + 'Xorshift1024', 'Xoshiro256StarStar', 'Xoshiro512StarStar', + 'Philox', 'ThreeFry', 'ThreeFry32', 'numpy'], + [[u8, 95, True], + [u8, 64, False], # Worst case for legacy + [u8, 95, False], # Typ. avg. case for legacy + [u8, 127, False], # Best case for legacy + [u16, 95, True], + [u16, 1024, False], # Worst case for legacy + [u16, 1535, False], # Typ. avg. case for legacy + [u16, 2047, False], # Best case for legacy + [u32, 95, True], + [u32, 1024, False], # Worst case for legacy + [u32, 1535, False], # Typ. avg. case for legacy + [u32, 2047, False], # Best case for legacy + [u64, 95, True], + [u64, 1024, False], # Worst case for legacy + [u64, 1535, False], # Typ. avg. case for legacy + [u64, 2047, False], # Best case for legacy + ]] + + def setup(self, brng, args): + if brng == 'numpy': + self.rg = np.random.RandomState() + else: + self.rg = RandomGenerator(getattr(np.random.randomgen, brng)()) + self.rg.random_sample() + + def time_bounded(self, brng, args): + """ + Timer for 8-bit bounded values. + + Parameters (packed as args) + ---------- + dt : {uint8, uint16, uint32, unit64} + output dtype + max : int + Upper bound for range. Lower is always 0. Must be <= 2**bits. + use_masked: bool + If True, masking and rejection sampling is used to generate a random + number in an interval. If False, Lemire's algorithm is used if + available to generate a random number in an interval. + + Notes + ----- + Lemire's algorithm has improved performance when max+1 is not a + power of two. + """ + dt, max, use_masked = args + if brng == 'numpy': + self.rg.randint(0, max + 1, nom_size, dtype=dt) + else: + self.rg.randint(0, max + 1, nom_size, dtype=dt, + use_masked=use_masked) + diff --git a/doc/source/reference/randomgen/extending.rst b/doc/source/reference/randomgen/extending.rst index c9d987b59..64f2ddcc1 100644 --- a/doc/source/reference/randomgen/extending.rst +++ b/doc/source/reference/randomgen/extending.rst @@ -59,6 +59,8 @@ directly in Numba after compiling the file distributions.c into a DLL or so. An example showing the use of a more complicated distribution is in the examples folder. +.. _randomgen_cython: + Cython ====== diff --git a/doc/source/reference/randomgen/generator.rst b/doc/source/reference/randomgen/generator.rst index d59efd68c..54325f4d3 100644 --- a/doc/source/reference/randomgen/generator.rst +++ b/doc/source/reference/randomgen/generator.rst @@ -1,29 +1,26 @@ +.. currentmodule:: numpy.random.randomgen + Random Generator ---------------- -The :class:`~randomgen.generator.RandomGenerator` provides access to -a wide range of distributions, and served as a replacement for -:class:`~numpy.random.RandomState`. The main difference between -the two is that :class:`~randomgen.generator.RandomGenerator` relies -on an additional basic RNG to manage state and generate the random -bits which are then transformed into random values from useful -distributions. The default basic RNG used by -:class:`~randomgen.generator.RandomGenerator` is -:class:`~randomgen.xoroshiro128.Xoroshiro128`. The basic RNG can be -changed by passing an instantized basic RNG to -:class:`~randomgen.generator.RandomGenerator`. +The :class:`~RandomGenerator` provides access to +a wide range of distributions, and served as a replacement for +:class:`~numpy.random.RandomState`. The main difference between +the two is that ``RandomGenerator`` relies on an additional basic RNG to +manage state and generate the random bits, which are then transformed into +random values from useful distributions. The default basic RNG used by +``RandomGenerator`` is :class:`~xoroshiro128.Xoroshiro128`. The basic RNG can be +changed by passing an instantized basic RNG to ``RandomGenerator``. -.. currentmodule:: numpy.random.randomgen.generator .. autoclass:: RandomGenerator :exclude-members: -Seed and State Manipulation -=========================== +Accessing the RNG +================= .. autosummary:: :toctree: generated/ - ~RandomGenerator.seed - ~RandomGenerator.state + ~RandomGenerator.brng Simple random data ================== diff --git a/doc/source/reference/randomgen/index.rst b/doc/source/reference/randomgen/index.rst index 67d0441a2..a8b6f1c9b 100644 --- a/doc/source/reference/randomgen/index.rst +++ b/doc/source/reference/randomgen/index.rst @@ -1,17 +1,21 @@ -Randomgen.RandomGen -=================== -This package contains replacements for the NumPy -:class:`~numpy.random.RandomState` object that allows the core random number -generator be be changed. - .. current_module numpy.random.randomgen +numpy.random.randomgen +====================== + +This package modernizes the legacy +`~numpy.random.RandomState` object and allows changing the core random +number generator (RNG). The `~numpy.random.randomgen.RandomGenerator` can +be initialized with a number of different RNGs, and exposes many different +probability distributions. + + Quick Start ----------- -Like :mod:`numpy.random`, RandomGen can be used at the module level. -This uses the default :class:`~randomgen.generator.RandomGenerator` which -uses normals provided by :class:`~randomgen.xoroshiro128.Xoroshiro128`. +By default, `generator.RandomGenerator` uses normals provided by +`xoroshiro128.Xoroshiro128` which will be faster than the legacy methods in +`numpy.random` .. code-block:: python @@ -19,12 +23,11 @@ uses normals provided by :class:`~randomgen.xoroshiro128.Xoroshiro128`. import randomgen.generator as random random.standard_normal() -:class:`~randomgen.generator.RandomGenerator` can also be used as a -replacement for :class:`~numpy.random.RandomState`, although the random -values are generated by :class:`~randomgen.xoroshiro128.Xoroshiro128`. It -also isn't possible to directly seed a -:class:`~randomgen.generator.RandomGenerator`. - +`numpy.random.randomgen.RandomGenerator` can also be used as a replacement for +`~numpy.random.RandomState`, although the random values are generated by +`~numpyrandom.randomgen.xoroshiro128.Xoroshiro128`. Since ``randomgen`` +separates the `~numpy.random.randomgen.RandomGenerator` from the RNG, it is not +possible to directly seed the generator. .. code-block:: python @@ -34,9 +37,9 @@ also isn't possible to directly seed a rg.standard_normal() -Seeds can be passed to any of the basic RNGs. Here :class:`~randomgen.mt19937.MT19937` -is used and the :class:`~randomgen.generator.RandomGenerator` is accessed via -the property :attr:`~randomgen.mt19937.MT19937.generator`. +Seeds can be passed to any of the basic RNGs. Here `numpy.random.randomgen. +mt19937.MT19937` is used and the `~numpy.random.randomgen.RandomGenerator` is +accessed via the attribute `~numpy.random.randomgen.mt19937.MT19937.generator`. .. code-block:: python @@ -48,24 +51,23 @@ the property :attr:`~randomgen.mt19937.MT19937.generator`. Introduction ------------ RandomGen takes a different approach to producing random numbers from the -:class:`numpy.random.RandomState` object used in NumPy. Random number -generation is separated into two components, a basic RNG and a random -generator. +:class:`numpy.random.RandomState` object. Random number generation is +separated into two components, a basic RNG and a random generator. -The basic RNG has a limited set of responsibilities -- it manages the +The basic RNG has a limited set of responsibilities. It manages the underlying RNG state and provides functions to produce random doubles and random unsigned 32- and 64-bit values. The basic random generator also handles all seeding since this varies when using alternative basic RNGs. -The random generator (:class:`~randomgen.generator.RandomGenerator`) takes the +The `random generator <~numpy.random.randomgen.RandomGenerator>` takes the basic RNG-provided functions and transforms them into more useful distributions, e.g., simulated normal random values. This structure allows alternative basic RNGs to be used without code duplication. -The :class:`~randomgen.generator.RandomGenerator` is the user-facing object +The `~numpy.random.randomgen.RandomGenerator` is the user-facing object that is nearly identical to :class:`~numpy.random.RandomState`. The canonical -method to initialize a generator passes a basic RNG -- -:class:`~randomgen.mt19937.MT19937`, the underlying RNG in NumPy -- as the +method to initialize a generator passes a basic RNG -- `~numpy.random. +randomgen.mt19937.MT19937`, the underlying RNG in NumPy -- as the sole argument. Note that the basic RNG must be instantized. .. code-block:: python @@ -81,9 +83,9 @@ Seed information is directly passed to the basic RNG. rg = RandomGenerator(MT19937(12345)) rg.random_sample() -A shorthand method is also available which uses the -:meth:`~randomgen.mt19937.MT19937.generator` property from a basic RNG to -access an embedded random generator. +A shorthand method is also available which uses the `~numpy.random.randomgen. +mt19937.MT19937.generator` property from a basic RNG to access an embedded +random generator. .. code-block:: python @@ -95,13 +97,14 @@ What's New or Different .. warning:: The Box-Muller method used to produce NumPy's normals is no longer available - in :class:`~randomgen.generator.RandomGenerator`. It is not possible to - reproduce the random values using :class:`~randomgen.generator.RandomGenerator` - for the normal distribution or any other distribution that relies on the - normal such as the gamma or student's t. If you require backward compatibility, a - legacy generator, :class:`~randomgen.legacy.LegacyGenerator`, has been created - which can fully reproduce the sequence produced by NumPy. - + in `~numpy.random.randomgen.RandomGenerator`. It is not possible to + reproduce the random values using `~numpy.random.randomgen.RandomGenerator` + for the normal distribution or any other distribution that + relies on the normal such as the gamma or student's t. If you require + backward compatibility, a legacy generator, `~numpy.random.randomgen.legacy. + LegacyGenerator`, has been created which can fully reproduce the sequence + produced by NumPy. + * The normal, exponential and gamma generators use 256-step Ziggurat methods which are 2-10 times faster than NumPy's Box-Muller or inverse CDF implementations. @@ -110,20 +113,18 @@ What's New or Different select distributions * Optional ``out`` argument that allows existing arrays to be filled for select distributions -* Simulate from the complex normal distribution - (:meth:`~randomgen.generator.RandomGenerator.complex_normal`) -* :func:`~randomgen.entropy.random_entropy` provides access to the system +* `~numpy.random.randomgen.entropy.random_entropy` provides access to the system source of randomness that is used in cryptographic applications (e.g., ``/dev/urandom`` on Unix). -* All basic random generators functions to produce doubles, uint64s and - uint32s via CTypes (:meth:`~randomgen.xoroshiro128.Xoroshiro128.ctypes`) - and CFFI (:meth:`~randomgen.xoroshiro128.Xoroshiro128.cffi`). This allows - these basic RNGs to be used in numba. +* All basic random generators functions can produce doubles, uint64s and + uint32s via CTypes (`~numpy.random.randomgen.xoroshiro128.Xoroshiro128.ctypes`) + and CFFI (:meth:`~numpy.random.randomgen.xoroshiro128.Xoroshiro128.cffi`). + This allows these basic RNGs to be used in numba. * The basic random number generators can be used in downstream projects via - Cython. + :ref:`Cython <randomgen_cython>`. * Support for Lemire’s method [Lemire]_ of generating uniform integers on an arbitrary interval by setting ``use_masked=True`` in - (:meth:`~randomgen.generator.RandomGenerator.randint`). + `~umpy.random.randomgen.generator.RandomGenerator.randint`. See :ref:`new-or-different` for a complete list of improvements and @@ -144,9 +145,9 @@ The main innovation is the inclusion of a number of alternative pseudo-random nu generators, 'in addition' to the standard PRNG in NumPy. The included PRNGs are: * MT19937 - The standard NumPy generator. Produces identical results to NumPy - using the same seed/state. Adds a jump function that advances the generator - as-if 2**128 draws have been made (:meth:`~randomgen.mt19937.MT19937.jump`). - See `NumPy's documentation`_. + using the same seed/state. Adds a + `~numpy.random.randomgen.mt19937.MT19937.jump` function that advances the + generator as-if ``2**128`` draws have been made. See `numpy.random`. * dSFMT - SSE2 enabled versions of the MT19937 generator. Theoretically the same, but with a different state and so it is not possible to produce a sequence identical to MT19937. Supports ``jump`` and so can @@ -154,31 +155,30 @@ generators, 'in addition' to the standard PRNG in NumPy. The included PRNGs are * XoroShiro128+ - Improved version of XorShift128+ with better performance and statistical quality. Like the XorShift generators, it can be jumped to produce multiple streams in parallel applications. See - :meth:`~randomgen.xoroshiro128.Xoroshiro128.jump` for details. + `~numpy.random.randomgen.xoroshiro128.Xoroshiro128.jump` for details. More information about this PRNG is available at the `xorshift, xoroshiro and xoshiro authors' page`_. * XorShift1024*φ - Fast fast generator based on the XSadd generator. Supports ``jump`` and so can be used in parallel applications. See the documentation for - :meth:`~randomgen.xorshift1024.Xorshift1024.jump` for details. More information - about these PRNGs is available at the + `~numpy.random.randomgen.xorshift1024.Xorshift1024.jump` for details. More + information about these PRNGs is available at the `xorshift, xoroshiro and xoshiro authors' page`_. * Xorshiro256** and Xorshiro512** - The most recently introduced XOR, shift, and rotate generator. Supports ``jump`` and so can be used in parallel applications. See the documentation for - :meth:`~randomgen.xoshiro256starstar.Xoshirt256StarStar.jump` for details. More - information about these PRNGs is available at the + `~numpy.random.randomgen.xoshiro256starstar.Xoshirt256StarStar.jump` for + details. More information about these PRNGs is available at the `xorshift, xoroshiro and xoshiro authors' page`_. * PCG-64 - Fast generator that support many parallel streams and can be advanced by an arbitrary amount. See the documentation for - :meth:`~randomgen.pcg64.PCG64.advance`. PCG-64 has a period of + `~numpy.random.randomgen.pcg64.PCG64.advance`. PCG-64 has a period of :math:`2^{128}`. See the `PCG author's page`_ for more details about this class of PRNG. * ThreeFry and Philox - counter-based generators capable of being advanced an arbitrary number of steps or generating independent streams. See the `Random123`_ page for more details about this class of PRNG. -.. _`NumPy's documentation`: https://docs.scipy.org/doc/numpy/reference/routines.random.html .. _`dSFMT authors' page`: http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/ .. _`xorshift, xoroshiro and xoshiro authors' page`: http://xoroshiro.di.unimi.it/ .. _`PCG author's page`: http://www.pcg-random.org/ @@ -215,14 +215,12 @@ New Features Changes ~~~~~~~ + +This package was developed independently of NumPy and was integrated in version +1.17.0. The original repo is at https://github.com/bashtage/randomgen. + .. toctree:: :maxdepth: 2 Change Log <change-log> -Indices and tables -~~~~~~~~~~~~~~~~~~ - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/doc/source/reference/randomgen/new-or-different.rst b/doc/source/reference/randomgen/new-or-different.rst index 0a27b9aa1..089efd6fb 100644 --- a/doc/source/reference/randomgen/new-or-different.rst +++ b/doc/source/reference/randomgen/new-or-different.rst @@ -64,9 +64,9 @@ What's New or Different .. ipython:: python - rg.seed(0) + rg.brng.seed(0) rg.random_sample(3, dtype='d') - rg.seed(0) + rg.brng.seed(0) rg.random_sample(3, dtype='f') * Optional ``out`` argument that allows existing arrays to be filled for diff --git a/numpy/random/randomgen/LICENSE.md b/numpy/random/LICENSE.md index caa665373..caa665373 100644 --- a/numpy/random/randomgen/LICENSE.md +++ b/numpy/random/LICENSE.md diff --git a/numpy/random/__init__.py b/numpy/random/__init__.py index 53e947797..89015d6a2 100644 --- a/numpy/random/__init__.py +++ b/numpy/random/__init__.py @@ -83,6 +83,22 @@ get_state Get tuple representing internal state of generator. set_state Set state of generator. ==================== ========================================================= +==================== ========================================================= +Random Number Streams that work with RandomGenerator +============================================================================== +MT19937 +DSFMT +PCG32 +PCG64 +Philox +ThreeFry +ThreeFry32 +Xoroshiro128 +Xoroshift1024 +Xoshiro256StarStar +Xoshiro512StarStar +==================== ========================================================= + """ from __future__ import division, absolute_import, print_function @@ -136,8 +152,24 @@ __all__ = [ 'zipf' ] -from .randomgen import mtrand -from .randomgen.mtrand import * +from . import mtrand +from .mtrand import * +from .dsfmt import DSFMT +from .generator import RandomGenerator +from .mt19937 import MT19937 +from .pcg32 import PCG32 +from .pcg64 import PCG64 +from .philox import Philox +from .threefry import ThreeFry +from .threefry32 import ThreeFry32 +from .xoroshiro128 import Xoroshiro128 +from .xorshift1024 import Xorshift1024 +from .xoshiro256starstar import Xoshiro256StarStar +from .xoshiro512starstar import Xoshiro512StarStar +from .mtrand import RandomState +__all__ += ['RandomGenerator', 'DSFMT', 'MT19937', 'PCG64', 'PCG32', 'Philox', + 'ThreeFry', 'ThreeFry32', 'Xoroshiro128', 'Xorshift1024', + 'Xoshiro256StarStar', 'Xoshiro512StarStar', 'RandomState'] # Some aliases: ranf = random = sample = random_sample diff --git a/numpy/random/mtrand/Python.pxi b/numpy/random/_mtrand/Python.pxi index 08aadbaa1..08aadbaa1 100644 --- a/numpy/random/mtrand/Python.pxi +++ b/numpy/random/_mtrand/Python.pxi diff --git a/numpy/random/mtrand/distributions.c b/numpy/random/_mtrand/distributions.c index 1b410db57..1b410db57 100644 --- a/numpy/random/mtrand/distributions.c +++ b/numpy/random/_mtrand/distributions.c diff --git a/numpy/random/mtrand/distributions.h b/numpy/random/_mtrand/distributions.h index 0b42bc794..0b42bc794 100644 --- a/numpy/random/mtrand/distributions.h +++ b/numpy/random/_mtrand/distributions.h diff --git a/numpy/random/_mtrand/generate_mtrand_c.py b/numpy/random/_mtrand/generate_mtrand_c.py new file mode 100644 index 000000000..ec935e6dd --- /dev/null +++ b/numpy/random/_mtrand/generate_mtrand_c.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +from __future__ import division, absolute_import, print_function + +import sys +import re +import os + +unused_internal_funcs = ['__Pyx_PrintItem', + '__Pyx_PrintNewline', + '__Pyx_ReRaise', + #'__Pyx_GetExcValue', + '__Pyx_ArgTypeTest', + '__Pyx_SetVtable', + '__Pyx_GetVtable', + '__Pyx_CreateClass'] + +if __name__ == '__main__': + # Use cython here so that long docstrings are broken up. + # This is needed for some VC++ compilers. + os.system('cython mtrand.pyx') + mtrand_c = open('mtrand.c', 'r') + processed = open('mtrand_pp.c', 'w') + unused_funcs_str = '(' + '|'.join(unused_internal_funcs) + ')' + uifpat = re.compile(r'static \w+ \*?'+unused_funcs_str+r'.*/\*proto\*/') + linepat = re.compile(r'/\* ".*/mtrand.pyx":') + for linenum, line in enumerate(mtrand_c): + m = re.match(r'^(\s+arrayObject\w*\s*=\s*[(])[(]PyObject\s*[*][)]', + line) + if m: + line = '%s(PyArrayObject *)%s' % (m.group(1), line[m.end():]) + m = uifpat.match(line) + if m: + line = '' + m = re.search(unused_funcs_str, line) + if m: + print("%s was declared unused, but is used at line %d" % (m.group(), + linenum+1), file=sys.stderr) + line = linepat.sub(r'/* "mtrand.pyx":', line) + processed.write(line) + mtrand_c.close() + processed.close() + os.rename('mtrand_pp.c', 'mtrand.c') diff --git a/numpy/random/mtrand/initarray.c b/numpy/random/_mtrand/initarray.c index beff78510..beff78510 100644 --- a/numpy/random/mtrand/initarray.c +++ b/numpy/random/_mtrand/initarray.c diff --git a/numpy/random/mtrand/initarray.h b/numpy/random/_mtrand/initarray.h index f5e5e5332..f5e5e5332 100644 --- a/numpy/random/mtrand/initarray.h +++ b/numpy/random/_mtrand/initarray.h diff --git a/numpy/random/mtrand/mtrand.pyx b/numpy/random/_mtrand/mtrand.pyx index 329d5cd68..329d5cd68 100644 --- a/numpy/random/mtrand/mtrand.pyx +++ b/numpy/random/_mtrand/mtrand.pyx diff --git a/numpy/random/mtrand/mtrand_py_helper.h b/numpy/random/_mtrand/mtrand_py_helper.h index 266847cbe..266847cbe 100644 --- a/numpy/random/mtrand/mtrand_py_helper.h +++ b/numpy/random/_mtrand/mtrand_py_helper.h diff --git a/numpy/random/mtrand/numpy.pxd b/numpy/random/_mtrand/numpy.pxd index e146054b1..e146054b1 100644 --- a/numpy/random/mtrand/numpy.pxd +++ b/numpy/random/_mtrand/numpy.pxd diff --git a/numpy/random/mtrand/randint_helpers.pxi.in b/numpy/random/_mtrand/randint_helpers.pxi.in index 894a25167..894a25167 100644 --- a/numpy/random/mtrand/randint_helpers.pxi.in +++ b/numpy/random/_mtrand/randint_helpers.pxi.in diff --git a/numpy/random/mtrand/randomkit.c b/numpy/random/_mtrand/randomkit.c index 6371ebe33..6371ebe33 100644 --- a/numpy/random/mtrand/randomkit.c +++ b/numpy/random/_mtrand/randomkit.c diff --git a/numpy/random/mtrand/randomkit.h b/numpy/random/_mtrand/randomkit.h index a24dabebf..a24dabebf 100644 --- a/numpy/random/mtrand/randomkit.h +++ b/numpy/random/_mtrand/randomkit.h diff --git a/numpy/random/randomgen/_pickle.py b/numpy/random/_pickle.py index 1c365b0c7..1c365b0c7 100644 --- a/numpy/random/randomgen/_pickle.py +++ b/numpy/random/_pickle.py diff --git a/numpy/random/randomgen/bounded_integers.pxd.in b/numpy/random/bounded_integers.pxd.in index 4ab389fd9..4ab389fd9 100644 --- a/numpy/random/randomgen/bounded_integers.pxd.in +++ b/numpy/random/bounded_integers.pxd.in diff --git a/numpy/random/randomgen/bounded_integers.pyx.in b/numpy/random/bounded_integers.pyx.in index 03068a8fd..03068a8fd 100644 --- a/numpy/random/randomgen/bounded_integers.pyx.in +++ b/numpy/random/bounded_integers.pyx.in diff --git a/numpy/random/randomgen/common.pxd b/numpy/random/common.pxd index f6748e5aa..f6748e5aa 100644 --- a/numpy/random/randomgen/common.pxd +++ b/numpy/random/common.pxd diff --git a/numpy/random/randomgen/common.pyx b/numpy/random/common.pyx index ebd2e60d1..ebd2e60d1 100644 --- a/numpy/random/randomgen/common.pyx +++ b/numpy/random/common.pyx diff --git a/numpy/random/randomgen/distributions.pxd b/numpy/random/distributions.pxd index ddb7a84bf..ddb7a84bf 100644 --- a/numpy/random/randomgen/distributions.pxd +++ b/numpy/random/distributions.pxd diff --git a/numpy/random/randomgen/dsfmt.pyx b/numpy/random/dsfmt.pyx index 9a7199e85..9a7199e85 100644 --- a/numpy/random/randomgen/dsfmt.pyx +++ b/numpy/random/dsfmt.pyx diff --git a/numpy/random/randomgen/entropy.pyx b/numpy/random/entropy.pyx index 0e429e9f2..0e429e9f2 100644 --- a/numpy/random/randomgen/entropy.pyx +++ b/numpy/random/entropy.pyx diff --git a/numpy/random/randomgen/examples/cython/extending.pyx b/numpy/random/examples/cython/extending.pyx index b472312b4..b472312b4 100644 --- a/numpy/random/randomgen/examples/cython/extending.pyx +++ b/numpy/random/examples/cython/extending.pyx diff --git a/numpy/random/randomgen/examples/cython/extending_distributions.pyx b/numpy/random/examples/cython/extending_distributions.pyx index 26d749b10..26d749b10 100644 --- a/numpy/random/randomgen/examples/cython/extending_distributions.pyx +++ b/numpy/random/examples/cython/extending_distributions.pyx diff --git a/numpy/random/randomgen/examples/cython/setup.py b/numpy/random/examples/cython/setup.py index d7a04f75a..d7a04f75a 100644 --- a/numpy/random/randomgen/examples/cython/setup.py +++ b/numpy/random/examples/cython/setup.py diff --git a/numpy/random/randomgen/examples/numba/extending.py b/numpy/random/examples/numba/extending.py index 72e903b1f..72e903b1f 100644 --- a/numpy/random/randomgen/examples/numba/extending.py +++ b/numpy/random/examples/numba/extending.py diff --git a/numpy/random/randomgen/examples/numba/extending_distributions.py b/numpy/random/examples/numba/extending_distributions.py index 17ba2704c..17ba2704c 100644 --- a/numpy/random/randomgen/examples/numba/extending_distributions.py +++ b/numpy/random/examples/numba/extending_distributions.py diff --git a/numpy/random/randomgen/generator.pyx b/numpy/random/generator.pyx index a244bca57..e68edb98a 100644 --- a/numpy/random/randomgen/generator.pyx +++ b/numpy/random/generator.pyx @@ -49,7 +49,7 @@ cdef class RandomGenerator: Notes ----- - The Python stdlib module "random" contains pseudo-random number generator + The Python stdlib module `random` contains pseudo-random number generator with a number of methods that are similar to the ones available in ``RandomGenerator``. It uses Mersenne Twister, and this basic RNG can be accessed using ``MT19937``. ``RandomGenerator``, besides being @@ -72,7 +72,7 @@ cdef class RandomGenerator: >>> rg = MT19937().generator >>> rg.standard_normal() """ - cdef public object _basicrng + cdef public object brng cdef brng_t *_brng cdef binomial_t *_binomial cdef object lock @@ -81,7 +81,7 @@ cdef class RandomGenerator: def __init__(self, brng=None): if brng is None: brng = Xoroshiro128() - self._basicrng = brng + self.brng = brng capsule = brng.capsule cdef const char *name = "BasicRNG" @@ -99,79 +99,21 @@ cdef class RandomGenerator: def __str__(self): _str = self.__class__.__name__ - _str += '(' + self._basicrng.__class__.__name__ + ')' + _str += '(' + self.brng.__class__.__name__ + ')' return _str # Pickling support: def __getstate__(self): - return self.state + return self.brng.state def __setstate__(self, state): - self.state = state + self.brng.state = state def __reduce__(self): from ._pickle import __generator_ctor return (__generator_ctor, - (self.state['brng'],), - self.state) - - def seed(self, *args, **kwargs): - """ - Reseed the basic RNG. - - Parameters depend on the basic RNG used. - - Notes - ----- - Arguments are directly passed to the basic RNG. This is a convenience - function. - - The best method to access seed is to directly use a basic RNG instance. - This example demonstrates this best practice. - - >>> from numpy.random.randomgen import RandomGenerator, PCG64 - >>> brng = PCG64(1234567891011) - >>> rg = brng.generator - >>> brng.seed(1110987654321) - - The method used to create the generator is not important. - - >>> brng = PCG64(1234567891011) - >>> rg = RandomGenerator(brng) - >>> brng.seed(1110987654321) - - These best practice examples are equivalent to - - >>> rg = RandomGenerator(PCG64(1234567891011)) - >>> rg.seed(1110987654321) - - """ - # TODO: Should this remain - self._basicrng.seed(*args, **kwargs) - return self - - @property - def state(self): - """ - Get or set the Basic RNG's state - - Returns - ------- - state : dict - Dictionary containing the information required to describe the - state of the Basic RNG - - Notes - ----- - This is a trivial pass-through function. RandomGenerator does not - directly contain or manipulate the basic RNG's state. - - """ - return self._basicrng.state - - @state.setter - def state(self, value): - self._basicrng.state = value + (self.brng.state['brng'],), + self.brng.state) def random_sample(self, size=None, dtype=np.float64, out=None): """ diff --git a/numpy/random/randomgen/legacy/__init__.py b/numpy/random/legacy/__init__.py index 9ce1f665d..9ce1f665d 100644 --- a/numpy/random/randomgen/legacy/__init__.py +++ b/numpy/random/legacy/__init__.py diff --git a/numpy/random/randomgen/legacy/legacy_distributions.pxd b/numpy/random/legacy/legacy_distributions.pxd index bc00994db..bc00994db 100644 --- a/numpy/random/randomgen/legacy/legacy_distributions.pxd +++ b/numpy/random/legacy/legacy_distributions.pxd diff --git a/numpy/random/randomgen/mt19937.pyx b/numpy/random/mt19937.pyx index 306ce23e2..306ce23e2 100644 --- a/numpy/random/randomgen/mt19937.pyx +++ b/numpy/random/mt19937.pyx diff --git a/numpy/random/randomgen/mtrand.pyx b/numpy/random/mtrand.pyx index b5d6ff9bc..b5d6ff9bc 100644 --- a/numpy/random/randomgen/mtrand.pyx +++ b/numpy/random/mtrand.pyx diff --git a/numpy/random/randomgen/pcg32.pyx b/numpy/random/pcg32.pyx index 5f2b34807..5f2b34807 100644 --- a/numpy/random/randomgen/pcg32.pyx +++ b/numpy/random/pcg32.pyx diff --git a/numpy/random/randomgen/pcg64.pyx b/numpy/random/pcg64.pyx index f67d9623c..f67d9623c 100644 --- a/numpy/random/randomgen/pcg64.pyx +++ b/numpy/random/pcg64.pyx diff --git a/numpy/random/randomgen/philox.pyx b/numpy/random/philox.pyx index 70afd55ab..70afd55ab 100644 --- a/numpy/random/randomgen/philox.pyx +++ b/numpy/random/philox.pyx diff --git a/numpy/random/randomgen/__init__.py b/numpy/random/randomgen/__init__.py deleted file mode 100644 index 1af2fc3b2..000000000 --- a/numpy/random/randomgen/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -from .dsfmt import DSFMT -from .generator import RandomGenerator -from .mt19937 import MT19937 -from .pcg32 import PCG32 -from .pcg64 import PCG64 -from .philox import Philox -from .threefry import ThreeFry -from .threefry32 import ThreeFry32 -from .xoroshiro128 import Xoroshiro128 -from .xorshift1024 import Xorshift1024 -from .xoshiro256starstar import Xoshiro256StarStar -from .xoshiro512starstar import Xoshiro512StarStar -from .mtrand import RandomState -__all__ = ['RandomGenerator', 'DSFMT', 'MT19937', 'PCG64', 'PCG32', 'Philox', - 'ThreeFry', 'ThreeFry32', 'Xoroshiro128', 'Xorshift1024', - 'Xoshiro256StarStar', 'Xoshiro512StarStar', 'RandomState'] - -#from ._version import get_versions - -#__version__ = get_versions()['version'] -#del get_versions diff --git a/numpy/random/randomgen/_version.py b/numpy/random/randomgen/_version.py deleted file mode 100644 index e400e3efb..000000000 --- a/numpy/random/randomgen/_version.py +++ /dev/null @@ -1,520 +0,0 @@ - -# This file helps to compute a version number in source trees obtained from -# git-archive tarball (such as those provided by githubs download-from-tag -# feature). Distribution tarballs (built by setup.py sdist) and build -# directories (produced by setup.py build) will contain a much shorter file -# that just contains the computed version number. - -# This file is released into the public domain. Generated by -# versioneer-0.18 (https://github.com/warner/python-versioneer) - -"""Git implementation of _version.py.""" - -import errno -import os -import re -import subprocess -import sys - - -def get_keywords(): - """Get the keywords needed to look up the version information.""" - # these strings will be replaced by git during git-archive. - # setup.py/versioneer.py will grep for the variable names, so they must - # each be defined on a line of their own. _version.py will just call - # get_keywords(). - git_refnames = "$Format:%d$" - git_full = "$Format:%H$" - git_date = "$Format:%ci$" - keywords = {"refnames": git_refnames, "full": git_full, "date": git_date} - return keywords - - -class VersioneerConfig: - """Container for Versioneer configuration parameters.""" - - -def get_config(): - """Create, populate and return the VersioneerConfig() object.""" - # these strings are filled in when 'setup.py versioneer' creates - # _version.py - cfg = VersioneerConfig() - cfg.VCS = "git" - cfg.style = "pep440" - cfg.tag_prefix = "" - cfg.parentdir_prefix = "randomgen-" - cfg.versionfile_source = "randomgen/_version.py" - cfg.verbose = False - return cfg - - -class NotThisMethod(Exception): - """Exception raised if a method is not valid for the current scenario.""" - - -LONG_VERSION_PY = {} -HANDLERS = {} - - -def register_vcs_handler(vcs, method): # decorator - """Decorator to mark a method as the handler for a particular VCS.""" - def decorate(f): - """Store f in HANDLERS[vcs][method].""" - if vcs not in HANDLERS: - HANDLERS[vcs] = {} - HANDLERS[vcs][method] = f - return f - return decorate - - -def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, - env=None): - """Call the given command(s).""" - assert isinstance(commands, list) - p = None - for c in commands: - try: - dispcmd = str([c] + args) - # remember shell=False, so use git.cmd on windows, not just git - p = subprocess.Popen([c] + args, cwd=cwd, env=env, - stdout=subprocess.PIPE, - stderr=(subprocess.PIPE if hide_stderr - else None)) - break - except EnvironmentError: - e = sys.exc_info()[1] - if e.errno == errno.ENOENT: - continue - if verbose: - print("unable to run %s" % dispcmd) - print(e) - return None, None - else: - if verbose: - print("unable to find command, tried %s" % (commands,)) - return None, None - stdout = p.communicate()[0].strip() - if sys.version_info[0] >= 3: - stdout = stdout.decode() - if p.returncode != 0: - if verbose: - print("unable to run %s (error)" % dispcmd) - print("stdout was %s" % stdout) - return None, p.returncode - return stdout, p.returncode - - -def versions_from_parentdir(parentdir_prefix, root, verbose): - """Try to determine the version from the parent directory name. - - Source tarballs conventionally unpack into a directory that includes both - the project name and a version string. We will also support searching up - two directory levels for an appropriately named parent directory - """ - rootdirs = [] - - for i in range(3): - dirname = os.path.basename(root) - if dirname.startswith(parentdir_prefix): - return {"version": dirname[len(parentdir_prefix):], - "full-revisionid": None, - "dirty": False, "error": None, "date": None} - else: - rootdirs.append(root) - root = os.path.dirname(root) # up a level - - if verbose: - print("Tried directories %s but none started with prefix %s" % - (str(rootdirs), parentdir_prefix)) - raise NotThisMethod("rootdir doesn't start with parentdir_prefix") - - -@register_vcs_handler("git", "get_keywords") -def git_get_keywords(versionfile_abs): - """Extract version information from the given file.""" - # the code embedded in _version.py can just fetch the value of these - # keywords. When used from setup.py, we don't want to import _version.py, - # so we do it with a regexp instead. This function is not used from - # _version.py. - keywords = {} - try: - f = open(versionfile_abs, "r") - for line in f.readlines(): - if line.strip().startswith("git_refnames ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["refnames"] = mo.group(1) - if line.strip().startswith("git_full ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["full"] = mo.group(1) - if line.strip().startswith("git_date ="): - mo = re.search(r'=\s*"(.*)"', line) - if mo: - keywords["date"] = mo.group(1) - f.close() - except EnvironmentError: - pass - return keywords - - -@register_vcs_handler("git", "keywords") -def git_versions_from_keywords(keywords, tag_prefix, verbose): - """Get version information from git keywords.""" - if not keywords: - raise NotThisMethod("no keywords at all, weird") - date = keywords.get("date") - if date is not None: - # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant - # datestamp. However we prefer "%ci" (which expands to an "ISO-8601 - # -like" string, which we must then edit to make compliant), because - # it's been around since git-1.5.3, and it's too difficult to - # discover which version we're using, or to work around using an - # older one. - date = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - refnames = keywords["refnames"].strip() - if refnames.startswith("$Format"): - if verbose: - print("keywords are unexpanded, not using") - raise NotThisMethod("unexpanded keywords, not a git-archive tarball") - refs = set([r.strip() for r in refnames.strip("()").split(",")]) - # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of - # just "foo-1.0". If we see a "tag: " prefix, prefer those. - TAG = "tag: " - tags = set([r[len(TAG):] for r in refs if r.startswith(TAG)]) - if not tags: - # Either we're using git < 1.8.3, or there really are no tags. We use - # a heuristic: assume all version tags have a digit. The old git %d - # expansion behaves like git log --decorate=short and strips out the - # refs/heads/ and refs/tags/ prefixes that would let us distinguish - # between branches and tags. By ignoring refnames without digits, we - # filter out many common branch names like "release" and - # "stabilization", as well as "HEAD" and "master". - tags = set([r for r in refs if re.search(r'\d', r)]) - if verbose: - print("discarding '%s', no digits" % ",".join(refs - tags)) - if verbose: - print("likely tags: %s" % ",".join(sorted(tags))) - for ref in sorted(tags): - # sorting will prefer e.g. "2.0" over "2.0rc1" - if ref.startswith(tag_prefix): - r = ref[len(tag_prefix):] - if verbose: - print("picking %s" % r) - return {"version": r, - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": None, - "date": date} - # no suitable tags, so version is "0+unknown", but full hex is still there - if verbose: - print("no suitable tags, using unknown + full revision id") - return {"version": "0+unknown", - "full-revisionid": keywords["full"].strip(), - "dirty": False, "error": "no suitable tags", "date": None} - - -@register_vcs_handler("git", "pieces_from_vcs") -def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): - """Get version from 'git describe' in the root of the source tree. - - This only gets called if the git-archive 'subst' keywords were *not* - expanded, and _version.py hasn't already been rewritten with a short - version string, meaning we're inside a checked out source tree. - """ - GITS = ["git"] - if sys.platform == "win32": - GITS = ["git.cmd", "git.exe"] - - out, rc = run_command(GITS, ["rev-parse", "--git-dir"], cwd=root, - hide_stderr=True) - if rc != 0: - if verbose: - print("Directory %s not under git control" % root) - raise NotThisMethod("'git rev-parse --git-dir' returned error") - - # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty] - # if there isn't one, this yields HEX[-dirty] (no NUM) - describe_out, rc = run_command(GITS, ["describe", "--tags", "--dirty", - "--always", "--long", - "--match", "%s*" % tag_prefix], - cwd=root) - # --long was added in git-1.5.5 - if describe_out is None: - raise NotThisMethod("'git describe' failed") - describe_out = describe_out.strip() - full_out, rc = run_command(GITS, ["rev-parse", "HEAD"], cwd=root) - if full_out is None: - raise NotThisMethod("'git rev-parse' failed") - full_out = full_out.strip() - - pieces = {} - pieces["long"] = full_out - pieces["short"] = full_out[:7] # maybe improved later - pieces["error"] = None - - # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty] - # TAG might have hyphens. - git_describe = describe_out - - # look for -dirty suffix - dirty = git_describe.endswith("-dirty") - pieces["dirty"] = dirty - if dirty: - git_describe = git_describe[:git_describe.rindex("-dirty")] - - # now we have TAG-NUM-gHEX or HEX - - if "-" in git_describe: - # TAG-NUM-gHEX - mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe) - if not mo: - # unparseable. Maybe git-describe is misbehaving? - pieces["error"] = ("unable to parse git-describe output: '%s'" - % describe_out) - return pieces - - # tag - full_tag = mo.group(1) - if not full_tag.startswith(tag_prefix): - if verbose: - fmt = "tag '%s' doesn't start with prefix '%s'" - print(fmt % (full_tag, tag_prefix)) - pieces["error"] = ("tag '%s' doesn't start with prefix '%s'" - % (full_tag, tag_prefix)) - return pieces - pieces["closest-tag"] = full_tag[len(tag_prefix):] - - # distance: number of commits since tag - pieces["distance"] = int(mo.group(2)) - - # commit: short hex revision ID - pieces["short"] = mo.group(3) - - else: - # HEX: no tags - pieces["closest-tag"] = None - count_out, rc = run_command(GITS, ["rev-list", "HEAD", "--count"], - cwd=root) - pieces["distance"] = int(count_out) # total number of commits - - # commit date: see ISO-8601 comment in git_versions_from_keywords() - date = run_command(GITS, ["show", "-s", "--format=%ci", "HEAD"], - cwd=root)[0].strip() - pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1) - - return pieces - - -def plus_or_dot(pieces): - """Return a + if we don't already have one, else return a .""" - if "+" in pieces.get("closest-tag", ""): - return "." - return "+" - - -def render_pep440(pieces): - """Build up version string, with post-release "local version identifier". - - Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you - get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty - - Exceptions: - 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += plus_or_dot(pieces) - rendered += "%d.g%s" % (pieces["distance"], pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - else: - # exception #1 - rendered = "0+untagged.%d.g%s" % (pieces["distance"], - pieces["short"]) - if pieces["dirty"]: - rendered += ".dirty" - return rendered - - -def render_pep440_pre(pieces): - """TAG[.post.devDISTANCE] -- No -dirty. - - Exceptions: - 1: no tags. 0.post.devDISTANCE - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += ".post.dev%d" % pieces["distance"] - else: - # exception #1 - rendered = "0.post.dev%d" % pieces["distance"] - return rendered - - -def render_pep440_post(pieces): - """TAG[.postDISTANCE[.dev0]+gHEX] . - - The ".dev0" means dirty. Note that .dev0 sorts backwards - (a dirty tree will appear "older" than the corresponding clean one), - but you shouldn't be releasing software with -dirty anyways. - - Exceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += plus_or_dot(pieces) - rendered += "g%s" % pieces["short"] - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - rendered += "+g%s" % pieces["short"] - return rendered - - -def render_pep440_old(pieces): - """TAG[.postDISTANCE[.dev0]] . - - The ".dev0" means dirty. - - Eexceptions: - 1: no tags. 0.postDISTANCE[.dev0] - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - else: - # exception #1 - rendered = "0.post%d" % pieces["distance"] - if pieces["dirty"]: - rendered += ".dev0" - return rendered - - -def render_git_describe(pieces): - """TAG[-DISTANCE-gHEX][-dirty]. - - Like 'git describe --tags --dirty --always'. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - if pieces["distance"]: - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render_git_describe_long(pieces): - """TAG-DISTANCE-gHEX[-dirty]. - - Like 'git describe --tags --dirty --always -long'. - The distance/hash is unconditional. - - Exceptions: - 1: no tags. HEX[-dirty] (note: no 'g' prefix) - """ - if pieces["closest-tag"]: - rendered = pieces["closest-tag"] - rendered += "-%d-g%s" % (pieces["distance"], pieces["short"]) - else: - # exception #1 - rendered = pieces["short"] - if pieces["dirty"]: - rendered += "-dirty" - return rendered - - -def render(pieces, style): - """Render the given version pieces into the requested style.""" - if pieces["error"]: - return {"version": "unknown", - "full-revisionid": pieces.get("long"), - "dirty": None, - "error": pieces["error"], - "date": None} - - if not style or style == "default": - style = "pep440" # the default - - if style == "pep440": - rendered = render_pep440(pieces) - elif style == "pep440-pre": - rendered = render_pep440_pre(pieces) - elif style == "pep440-post": - rendered = render_pep440_post(pieces) - elif style == "pep440-old": - rendered = render_pep440_old(pieces) - elif style == "git-describe": - rendered = render_git_describe(pieces) - elif style == "git-describe-long": - rendered = render_git_describe_long(pieces) - else: - raise ValueError("unknown style '%s'" % style) - - return {"version": rendered, "full-revisionid": pieces["long"], - "dirty": pieces["dirty"], "error": None, - "date": pieces.get("date")} - - -def get_versions(): - """Get version information or return default if unable to do so.""" - # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have - # __file__, we can work backwards from there to the root. Some - # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which - # case we can only use expanded keywords. - - cfg = get_config() - verbose = cfg.verbose - - try: - return git_versions_from_keywords(get_keywords(), cfg.tag_prefix, - verbose) - except NotThisMethod: - pass - - try: - root = os.path.realpath(__file__) - # versionfile_source is the relative path from the top of the source - # tree (where the .git directory might live) to this file. Invert - # this to find the root from __file__. - for i in cfg.versionfile_source.split('/'): - root = os.path.dirname(root) - except NameError: - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to find root of source tree", - "date": None} - - try: - pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose) - return render(pieces, cfg.style) - except NotThisMethod: - pass - - try: - if cfg.parentdir_prefix: - return versions_from_parentdir(cfg.parentdir_prefix, root, verbose) - except NotThisMethod: - pass - - return {"version": "0+unknown", "full-revisionid": None, - "dirty": None, - "error": "unable to compute version", "date": None} diff --git a/numpy/random/randomgen/setup.py b/numpy/random/randomgen/setup.py deleted file mode 100644 index 5b7be4559..000000000 --- a/numpy/random/randomgen/setup.py +++ /dev/null @@ -1,191 +0,0 @@ -from os.path import join -import sys -import os -import platform -import struct -from distutils.dep_util import newer -from distutils.msvccompiler import get_build_version as get_msvc_build_version - -def needs_mingw_ftime_workaround(): - # We need the mingw workaround for _ftime if the msvc runtime version is - # 7.1 or above and we build with mingw ... - # ... but we can't easily detect compiler version outside distutils command - # context, so we will need to detect in randomkit whether we build with gcc - msver = get_msvc_build_version() - if msver and msver >= 8: - return True - - return False - - -def configuration(parent_package='',top_path=None): - from numpy.distutils.misc_util import Configuration, get_mathlibs - config = Configuration('randomgen', parent_package, top_path) - - def generate_libraries(ext, build_dir): - config_cmd = config.get_config_cmd() - libs = get_mathlibs() - if sys.platform == 'win32': - libs.append('Advapi32') - ext.libraries.extend(libs) - return None - - # enable unix large file support on 32 bit systems - # (64 bit off_t, lseek -> lseek64 etc.) - if sys.platform[:3] == "aix": - defs = [('_LARGE_FILES', None)] - else: - defs = [('_FILE_OFFSET_BITS', '64'), - ('_LARGEFILE_SOURCE', '1'), - ('_LARGEFILE64_SOURCE', '1')] - if needs_mingw_ftime_workaround(): - defs.append(("NPY_NEEDS_MINGW_TIME_WORKAROUND", None)) - - libs = [] - defs.append(('NPY_NO_DEPRECATED_API', 0)) - config.add_data_dir('tests') - - ############################## - # randomgen - ############################## - - # Make a guess as to whether SSE2 is present for now, TODO: Improve - USE_SSE2 = False - for k in platform.uname(): - for val in ('x86', 'i686', 'i386', 'amd64'): - USE_SSE2 = USE_SSE2 or val in k.lower() - print('Building with SSE?: {0}'.format(USE_SSE2)) - if '--no-sse2' in sys.argv: - USE_SSE2 = False - sys.argv.remove('--no-sse2') - - DEBUG = False - PCG_EMULATED_MATH = False - EXTRA_LINK_ARGS = [] - EXTRA_LIBRARIES = ['m'] if os.name != 'nt' else [] - EXTRA_COMPILE_ARGS = [] if os.name == 'nt' else [ - '-std=c99', '-U__GNUC_GNU_INLINE__'] - if os.name == 'nt': - EXTRA_LINK_ARGS = ['/LTCG', '/OPT:REF', 'Advapi32.lib', 'Kernel32.lib'] - if DEBUG: - EXTRA_LINK_ARGS += ['-debug'] - EXTRA_COMPILE_ARGS += ["-Zi", "/Od"] - if sys.version_info < (3, 0): - EXTRA_INCLUDE_DIRS += [join(MOD_DIR, 'src', 'common')] - - PCG64_DEFS = [] - # TODO: remove the unconditional forced emulation, move code from pcg64.pyx - # to an #ifdef - if 1 or sys.maxsize < 2 ** 32 or os.name == 'nt': - # Force emulated mode here - PCG_EMULATED_MATH = True - PCG64_DEFS += [('PCG_FORCE_EMULATED_128BIT_MATH', '1')] - - if struct.calcsize('P') < 8: - PCG_EMULATED_MATH = True - defs.append(('PCG_EMULATED_MATH', int(PCG_EMULATED_MATH))) - - DSFMT_DEFS = [('DSFMT_MEXP', '19937')] - if USE_SSE2: - if os.name == 'nt': - EXTRA_COMPILE_ARGS += ['/wd4146', '/GL'] - if struct.calcsize('P') < 8: - EXTRA_COMPILE_ARGS += ['/arch:SSE2'] - else: - EXTRA_COMPILE_ARGS += ['-msse2'] - DSFMT_DEFS += [('HAVE_SSE2', '1')] - - config.add_extension('entropy', - sources=['entropy.c', 'src/entropy/entropy.c'], - include_dirs=[join('randomgen', 'src', 'entropy')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - depends=[join('src', 'splitmix64', 'splitmix.h'), - join('src', 'entropy', 'entropy.h'), - 'entropy.pyx', - ], - define_macros=defs, - ) - config.add_extension('dsfmt', - sources=['dsfmt.c', 'src/dsfmt/dSFMT.c', - 'src/dsfmt/dSFMT-jump.c', - 'src/aligned_malloc/aligned_malloc.c'], - include_dirs=[join('src', 'dsfmt')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - depends=[join('src', 'dsfmt', 'dsfmt.h'), - 'dsfmt.pyx', - ], - define_macros=defs + DSFMT_DEFS, - ) - for gen in ['mt19937']: - # gen.pyx, src/gen/gen.c, src/gen/gen-jump.c - config.add_extension(gen, - sources=['{0}.c'.format(gen), 'src/{0}/{0}.c'.format(gen), - 'src/{0}/{0}-jump.c'.format(gen)], - include_dirs=[join('src', gen)], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - depends=['%s.pyx' % gen], - define_macros=defs, - ) - for gen in ['philox', 'threefry', 'threefry32', - 'xoroshiro128', 'xorshift1024', 'xoshiro256starstar', - 'xoshiro512starstar', - 'pcg64', 'pcg32', - ]: - # gen.pyx, src/gen/gen.c - if gen == 'pcg64': - _defs = defs + PCG64_DEFS - else: - _defs = defs - config.add_extension(gen, - sources=['{0}.c'.format(gen), 'src/{0}/{0}.c'.format(gen)], - include_dirs=[join('src', gen)], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - depends=['%s.pyx' % gen], - define_macros=_defs, - ) - for gen in ['common']: - # gen.pyx - config.add_extension(gen, - sources=['{0}.c'.format(gen)], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - depends=['%s.pyx' % gen], - define_macros=defs, - ) - for gen in ['generator', 'bounded_integers']: - # gen.pyx, src/distributions/distributions.c - config.add_extension(gen, - sources=['{0}.c'.format(gen), - join('src', 'distributions', - 'distributions.c')], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - depends=['%s.pyx' % gen], - define_macros=defs, - ) - config.add_extension('mtrand', - sources=['mtrand.c', - 'src/legacy/distributions-boxmuller.c', - 'src/distributions/distributions.c' ], - include_dirs=['.', 'legacy'], - libraries=EXTRA_LIBRARIES, - extra_compile_args=EXTRA_COMPILE_ARGS, - extra_link_args=EXTRA_LINK_ARGS, - depends=['mtrand.pyx'], - define_macros=defs + DSFMT_DEFS, - ) - config.add_subpackage('legacy') - return config -if __name__ == '__main__': - from numpy.distutils.core import setup - setup(configuration=configuration) diff --git a/numpy/random/randomgen/tests/data/__init__.py b/numpy/random/randomgen/tests/data/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/numpy/random/randomgen/tests/data/__init__.py +++ /dev/null diff --git a/numpy/random/setup.py b/numpy/random/setup.py index 481c4e380..088764791 100644 --- a/numpy/random/setup.py +++ b/numpy/random/setup.py @@ -46,21 +46,160 @@ def configuration(parent_package='',top_path=None): libs = [] defs.append(('NPY_NO_DEPRECATED_API', 0)) # Configure mtrand - config.add_extension('mtrand', - sources=[join('mtrand', x) for x in + config.add_extension('_mtrand', + sources=[join('_mtrand', x) for x in ['mtrand.c', 'randomkit.c', 'initarray.c', 'distributions.c']]+[generate_libraries], libraries=libs, - depends=[join('mtrand', '*.h'), - join('mtrand', '*.pyx'), - join('mtrand', '*.pxi'),], + depends=[join('_mtrand', '*.h'), + join('_mtrand', '*.pyx'), + join('_mtrand', '*.pxi'),], define_macros=defs, ) - config.add_data_files(('.', join('mtrand', 'randomkit.h'))) + config.add_data_files(('.', join('_mtrand', 'randomkit.h'))) config.add_data_dir('tests') - config.add_subpackage('randomgen') + ############################## + # randomgen + ############################## + + # Make a guess as to whether SSE2 is present for now, TODO: Improve + USE_SSE2 = False + for k in platform.uname(): + for val in ('x86', 'i686', 'i386', 'amd64'): + USE_SSE2 = USE_SSE2 or val in k.lower() + print('Building with SSE?: {0}'.format(USE_SSE2)) + if '--no-sse2' in sys.argv: + USE_SSE2 = False + sys.argv.remove('--no-sse2') + + DEBUG = False + PCG_EMULATED_MATH = False + EXTRA_LINK_ARGS = [] + EXTRA_LIBRARIES = ['m'] if os.name != 'nt' else [] + EXTRA_COMPILE_ARGS = [] if os.name == 'nt' else [ + '-std=c99', '-U__GNUC_GNU_INLINE__'] + if os.name == 'nt': + EXTRA_LINK_ARGS = ['/LTCG', '/OPT:REF', 'Advapi32.lib', 'Kernel32.lib'] + if DEBUG: + EXTRA_LINK_ARGS += ['-debug'] + EXTRA_COMPILE_ARGS += ["-Zi", "/Od"] + if sys.version_info < (3, 0): + EXTRA_INCLUDE_DIRS += [join(MOD_DIR, 'src', 'common')] + + PCG64_DEFS = [] + # TODO: remove the unconditional forced emulation, move code from pcg64.pyx + # to an #ifdef + if 1 or sys.maxsize < 2 ** 32 or os.name == 'nt': + # Force emulated mode here + PCG_EMULATED_MATH = True + PCG64_DEFS += [('PCG_FORCE_EMULATED_128BIT_MATH', '1')] + + if struct.calcsize('P') < 8: + PCG_EMULATED_MATH = True + defs.append(('PCG_EMULATED_MATH', int(PCG_EMULATED_MATH))) + + DSFMT_DEFS = [('DSFMT_MEXP', '19937')] + if USE_SSE2: + if os.name == 'nt': + EXTRA_COMPILE_ARGS += ['/wd4146', '/GL'] + if struct.calcsize('P') < 8: + EXTRA_COMPILE_ARGS += ['/arch:SSE2'] + else: + EXTRA_COMPILE_ARGS += ['-msse2'] + DSFMT_DEFS += [('HAVE_SSE2', '1')] + + config.add_extension('entropy', + sources=['entropy.c', 'src/entropy/entropy.c'], + include_dirs=[join('randomgen', 'src', 'entropy')], + libraries=EXTRA_LIBRARIES, + extra_compile_args=EXTRA_COMPILE_ARGS, + extra_link_args=EXTRA_LINK_ARGS, + depends=[join('src', 'splitmix64', 'splitmix.h'), + join('src', 'entropy', 'entropy.h'), + 'entropy.pyx', + ], + define_macros=defs, + ) + config.add_extension('dsfmt', + sources=['dsfmt.c', 'src/dsfmt/dSFMT.c', + 'src/dsfmt/dSFMT-jump.c', + 'src/aligned_malloc/aligned_malloc.c'], + include_dirs=[join('src', 'dsfmt')], + libraries=EXTRA_LIBRARIES, + extra_compile_args=EXTRA_COMPILE_ARGS, + extra_link_args=EXTRA_LINK_ARGS, + depends=[join('src', 'dsfmt', 'dsfmt.h'), + 'dsfmt.pyx', + ], + define_macros=defs + DSFMT_DEFS, + ) + for gen in ['mt19937']: + # gen.pyx, src/gen/gen.c, src/gen/gen-jump.c + config.add_extension(gen, + sources=['{0}.c'.format(gen), 'src/{0}/{0}.c'.format(gen), + 'src/{0}/{0}-jump.c'.format(gen)], + include_dirs=[join('src', gen)], + libraries=EXTRA_LIBRARIES, + extra_compile_args=EXTRA_COMPILE_ARGS, + extra_link_args=EXTRA_LINK_ARGS, + depends=['%s.pyx' % gen], + define_macros=defs, + ) + for gen in ['philox', 'threefry', 'threefry32', + 'xoroshiro128', 'xorshift1024', 'xoshiro256starstar', + 'xoshiro512starstar', + 'pcg64', 'pcg32', + ]: + # gen.pyx, src/gen/gen.c + if gen == 'pcg64': + _defs = defs + PCG64_DEFS + else: + _defs = defs + config.add_extension(gen, + sources=['{0}.c'.format(gen), 'src/{0}/{0}.c'.format(gen)], + include_dirs=[join('src', gen)], + libraries=EXTRA_LIBRARIES, + extra_compile_args=EXTRA_COMPILE_ARGS, + extra_link_args=EXTRA_LINK_ARGS, + depends=['%s.pyx' % gen], + define_macros=_defs, + ) + for gen in ['common']: + # gen.pyx + config.add_extension(gen, + sources=['{0}.c'.format(gen)], + libraries=EXTRA_LIBRARIES, + extra_compile_args=EXTRA_COMPILE_ARGS, + extra_link_args=EXTRA_LINK_ARGS, + depends=['%s.pyx' % gen], + define_macros=defs, + ) + for gen in ['generator', 'bounded_integers']: + # gen.pyx, src/distributions/distributions.c + config.add_extension(gen, + sources=['{0}.c'.format(gen), + join('src', 'distributions', + 'distributions.c')], + libraries=EXTRA_LIBRARIES, + extra_compile_args=EXTRA_COMPILE_ARGS, + extra_link_args=EXTRA_LINK_ARGS, + depends=['%s.pyx' % gen], + define_macros=defs, + ) + config.add_extension('mtrand', + sources=['mtrand.c', + 'src/legacy/distributions-boxmuller.c', + 'src/distributions/distributions.c' ], + include_dirs=['.', 'legacy'], + libraries=EXTRA_LIBRARIES, + extra_compile_args=EXTRA_COMPILE_ARGS, + extra_link_args=EXTRA_LINK_ARGS, + depends=['mtrand.pyx'], + define_macros=defs + DSFMT_DEFS, + ) + config.add_subpackage('legacy') return config if __name__ == '__main__': diff --git a/numpy/random/randomgen/src/aligned_malloc/aligned_malloc.c b/numpy/random/src/aligned_malloc/aligned_malloc.c index 6e8192cfb..6e8192cfb 100644 --- a/numpy/random/randomgen/src/aligned_malloc/aligned_malloc.c +++ b/numpy/random/src/aligned_malloc/aligned_malloc.c diff --git a/numpy/random/randomgen/src/aligned_malloc/aligned_malloc.h b/numpy/random/src/aligned_malloc/aligned_malloc.h index ea24f6d23..ea24f6d23 100644 --- a/numpy/random/randomgen/src/aligned_malloc/aligned_malloc.h +++ b/numpy/random/src/aligned_malloc/aligned_malloc.h diff --git a/numpy/random/randomgen/src/common/LICENSE.md b/numpy/random/src/common/LICENSE.md index 71bf8cf46..71bf8cf46 100644 --- a/numpy/random/randomgen/src/common/LICENSE.md +++ b/numpy/random/src/common/LICENSE.md diff --git a/numpy/random/randomgen/src/common/inttypes.h b/numpy/random/src/common/inttypes.h index 8f8b61108..8f8b61108 100644 --- a/numpy/random/randomgen/src/common/inttypes.h +++ b/numpy/random/src/common/inttypes.h diff --git a/numpy/random/randomgen/src/common/stdint.h b/numpy/random/src/common/stdint.h index 710de1570..710de1570 100644 --- a/numpy/random/randomgen/src/common/stdint.h +++ b/numpy/random/src/common/stdint.h diff --git a/numpy/random/randomgen/src/distributions/LICENSE.md b/numpy/random/src/distributions/LICENSE.md index 31576ba4b..31576ba4b 100644 --- a/numpy/random/randomgen/src/distributions/LICENSE.md +++ b/numpy/random/src/distributions/LICENSE.md diff --git a/numpy/random/randomgen/src/distributions/binomial.h b/numpy/random/src/distributions/binomial.h index e69de29bb..e69de29bb 100644 --- a/numpy/random/randomgen/src/distributions/binomial.h +++ b/numpy/random/src/distributions/binomial.h diff --git a/numpy/random/randomgen/src/distributions/distributions.c b/numpy/random/src/distributions/distributions.c index 83806de38..83806de38 100644 --- a/numpy/random/randomgen/src/distributions/distributions.c +++ b/numpy/random/src/distributions/distributions.c diff --git a/numpy/random/randomgen/src/distributions/distributions.h b/numpy/random/src/distributions/distributions.h index 7ca31a16c..7ca31a16c 100644 --- a/numpy/random/randomgen/src/distributions/distributions.h +++ b/numpy/random/src/distributions/distributions.h diff --git a/numpy/random/randomgen/src/distributions/ziggurat.h b/numpy/random/src/distributions/ziggurat.h index 7808c0e68..7808c0e68 100644 --- a/numpy/random/randomgen/src/distributions/ziggurat.h +++ b/numpy/random/src/distributions/ziggurat.h diff --git a/numpy/random/randomgen/src/distributions/ziggurat_constants.h b/numpy/random/src/distributions/ziggurat_constants.h index 17eccec0f..17eccec0f 100644 --- a/numpy/random/randomgen/src/distributions/ziggurat_constants.h +++ b/numpy/random/src/distributions/ziggurat_constants.h diff --git a/numpy/random/randomgen/src/dsfmt/128-bit-jump.poly.txt b/numpy/random/src/dsfmt/128-bit-jump.poly.txt index fea1318fb..fea1318fb 100644 --- a/numpy/random/randomgen/src/dsfmt/128-bit-jump.poly.txt +++ b/numpy/random/src/dsfmt/128-bit-jump.poly.txt diff --git a/numpy/random/randomgen/src/dsfmt/96-bit-jump.poly.txt b/numpy/random/src/dsfmt/96-bit-jump.poly.txt index 15c68d155..15c68d155 100644 --- a/numpy/random/randomgen/src/dsfmt/96-bit-jump.poly.txt +++ b/numpy/random/src/dsfmt/96-bit-jump.poly.txt diff --git a/numpy/random/randomgen/src/dsfmt/LICENSE.md b/numpy/random/src/dsfmt/LICENSE.md index d59568f6b..d59568f6b 100644 --- a/numpy/random/randomgen/src/dsfmt/LICENSE.md +++ b/numpy/random/src/dsfmt/LICENSE.md diff --git a/numpy/random/randomgen/src/dsfmt/calc-jump.cpp b/numpy/random/src/dsfmt/calc-jump.cpp index 495b2797c..495b2797c 100644 --- a/numpy/random/randomgen/src/dsfmt/calc-jump.cpp +++ b/numpy/random/src/dsfmt/calc-jump.cpp diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-benchmark.c b/numpy/random/src/dsfmt/dSFMT-benchmark.c index af29d0e1f..af29d0e1f 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-benchmark.c +++ b/numpy/random/src/dsfmt/dSFMT-benchmark.c diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-calc-jump.hpp b/numpy/random/src/dsfmt/dSFMT-calc-jump.hpp index b960826be..b960826be 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-calc-jump.hpp +++ b/numpy/random/src/dsfmt/dSFMT-calc-jump.hpp diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-common.h b/numpy/random/src/dsfmt/dSFMT-common.h index 30c26c08b..30c26c08b 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-common.h +++ b/numpy/random/src/dsfmt/dSFMT-common.h diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-jump.c b/numpy/random/src/dsfmt/dSFMT-jump.c index 1832bb885..1832bb885 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-jump.c +++ b/numpy/random/src/dsfmt/dSFMT-jump.c diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-jump.h b/numpy/random/src/dsfmt/dSFMT-jump.h index 689f9499a..689f9499a 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-jump.h +++ b/numpy/random/src/dsfmt/dSFMT-jump.h diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-params.h b/numpy/random/src/dsfmt/dSFMT-params.h index aa0247800..aa0247800 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-params.h +++ b/numpy/random/src/dsfmt/dSFMT-params.h diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-params19937.h b/numpy/random/src/dsfmt/dSFMT-params19937.h index a600b0dbc..a600b0dbc 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-params19937.h +++ b/numpy/random/src/dsfmt/dSFMT-params19937.h diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-poly.h b/numpy/random/src/dsfmt/dSFMT-poly.h index f8e15c3eb..f8e15c3eb 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-poly.h +++ b/numpy/random/src/dsfmt/dSFMT-poly.h diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT-test-gen.c b/numpy/random/src/dsfmt/dSFMT-test-gen.c index 697a3010a..697a3010a 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT-test-gen.c +++ b/numpy/random/src/dsfmt/dSFMT-test-gen.c diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT.c b/numpy/random/src/dsfmt/dSFMT.c index 0f122c26c..0f122c26c 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT.c +++ b/numpy/random/src/dsfmt/dSFMT.c diff --git a/numpy/random/randomgen/src/dsfmt/dSFMT.h b/numpy/random/src/dsfmt/dSFMT.h index 224d0108f..224d0108f 100644 --- a/numpy/random/randomgen/src/dsfmt/dSFMT.h +++ b/numpy/random/src/dsfmt/dSFMT.h diff --git a/numpy/random/randomgen/src/entropy/LICENSE.md b/numpy/random/src/entropy/LICENSE.md index b7276aad7..b7276aad7 100644 --- a/numpy/random/randomgen/src/entropy/LICENSE.md +++ b/numpy/random/src/entropy/LICENSE.md diff --git a/numpy/random/randomgen/src/entropy/entropy.c b/numpy/random/src/entropy/entropy.c index ead4bef83..ead4bef83 100644 --- a/numpy/random/randomgen/src/entropy/entropy.c +++ b/numpy/random/src/entropy/entropy.c diff --git a/numpy/random/randomgen/src/entropy/entropy.h b/numpy/random/src/entropy/entropy.h index 785603dd3..785603dd3 100644 --- a/numpy/random/randomgen/src/entropy/entropy.h +++ b/numpy/random/src/entropy/entropy.h diff --git a/numpy/random/randomgen/src/legacy/LICENSE.md b/numpy/random/src/legacy/LICENSE.md index 88b1791b2..88b1791b2 100644 --- a/numpy/random/randomgen/src/legacy/LICENSE.md +++ b/numpy/random/src/legacy/LICENSE.md diff --git a/numpy/random/randomgen/src/legacy/distributions-boxmuller.c b/numpy/random/src/legacy/distributions-boxmuller.c index 5d3ba27f8..5d3ba27f8 100644 --- a/numpy/random/randomgen/src/legacy/distributions-boxmuller.c +++ b/numpy/random/src/legacy/distributions-boxmuller.c diff --git a/numpy/random/randomgen/src/legacy/distributions-boxmuller.h b/numpy/random/src/legacy/distributions-boxmuller.h index 445686e6c..445686e6c 100644 --- a/numpy/random/randomgen/src/legacy/distributions-boxmuller.h +++ b/numpy/random/src/legacy/distributions-boxmuller.h diff --git a/numpy/random/randomgen/src/mt19937/LICENSE.md b/numpy/random/src/mt19937/LICENSE.md index f65c3d46e..f65c3d46e 100644 --- a/numpy/random/randomgen/src/mt19937/LICENSE.md +++ b/numpy/random/src/mt19937/LICENSE.md diff --git a/numpy/random/randomgen/src/mt19937/mt19937-benchmark.c b/numpy/random/src/mt19937/mt19937-benchmark.c index 039f8030a..039f8030a 100644 --- a/numpy/random/randomgen/src/mt19937/mt19937-benchmark.c +++ b/numpy/random/src/mt19937/mt19937-benchmark.c diff --git a/numpy/random/randomgen/src/mt19937/mt19937-jump.c b/numpy/random/src/mt19937/mt19937-jump.c index 46b28cf96..46b28cf96 100644 --- a/numpy/random/randomgen/src/mt19937/mt19937-jump.c +++ b/numpy/random/src/mt19937/mt19937-jump.c diff --git a/numpy/random/randomgen/src/mt19937/mt19937-jump.h b/numpy/random/src/mt19937/mt19937-jump.h index 394c150a0..394c150a0 100644 --- a/numpy/random/randomgen/src/mt19937/mt19937-jump.h +++ b/numpy/random/src/mt19937/mt19937-jump.h diff --git a/numpy/random/randomgen/src/mt19937/mt19937-poly.h b/numpy/random/src/mt19937/mt19937-poly.h index b03747881..b03747881 100644 --- a/numpy/random/randomgen/src/mt19937/mt19937-poly.h +++ b/numpy/random/src/mt19937/mt19937-poly.h diff --git a/numpy/random/randomgen/src/mt19937/mt19937-test-data-gen.c b/numpy/random/src/mt19937/mt19937-test-data-gen.c index 4f4ec1d64..4f4ec1d64 100644 --- a/numpy/random/randomgen/src/mt19937/mt19937-test-data-gen.c +++ b/numpy/random/src/mt19937/mt19937-test-data-gen.c diff --git a/numpy/random/randomgen/src/mt19937/mt19937.c b/numpy/random/src/mt19937/mt19937.c index e5ca9e0cf..e5ca9e0cf 100644 --- a/numpy/random/randomgen/src/mt19937/mt19937.c +++ b/numpy/random/src/mt19937/mt19937.c diff --git a/numpy/random/randomgen/src/mt19937/mt19937.h b/numpy/random/src/mt19937/mt19937.h index 8105329ec..8105329ec 100644 --- a/numpy/random/randomgen/src/mt19937/mt19937.h +++ b/numpy/random/src/mt19937/mt19937.h diff --git a/numpy/random/randomgen/src/mt19937/randomkit.c b/numpy/random/src/mt19937/randomkit.c index f8ed4b49e..f8ed4b49e 100644 --- a/numpy/random/randomgen/src/mt19937/randomkit.c +++ b/numpy/random/src/mt19937/randomkit.c diff --git a/numpy/random/randomgen/src/mt19937/randomkit.h b/numpy/random/src/mt19937/randomkit.h index abb082cb2..abb082cb2 100644 --- a/numpy/random/randomgen/src/mt19937/randomkit.h +++ b/numpy/random/src/mt19937/randomkit.h diff --git a/numpy/random/randomgen/src/pcg32/LICENSE.md b/numpy/random/src/pcg32/LICENSE.md index 3db2ac2e8..3db2ac2e8 100644 --- a/numpy/random/randomgen/src/pcg32/LICENSE.md +++ b/numpy/random/src/pcg32/LICENSE.md diff --git a/numpy/random/randomgen/src/pcg32/pcg-advance-64.c b/numpy/random/src/pcg32/pcg-advance-64.c index 8210e7565..8210e7565 100644 --- a/numpy/random/randomgen/src/pcg32/pcg-advance-64.c +++ b/numpy/random/src/pcg32/pcg-advance-64.c diff --git a/numpy/random/randomgen/src/pcg32/pcg32-test-data-gen.c b/numpy/random/src/pcg32/pcg32-test-data-gen.c index cccaf84b9..cccaf84b9 100644 --- a/numpy/random/randomgen/src/pcg32/pcg32-test-data-gen.c +++ b/numpy/random/src/pcg32/pcg32-test-data-gen.c diff --git a/numpy/random/randomgen/src/pcg32/pcg32.c b/numpy/random/src/pcg32/pcg32.c index 5fbf6759f..5fbf6759f 100644 --- a/numpy/random/randomgen/src/pcg32/pcg32.c +++ b/numpy/random/src/pcg32/pcg32.c diff --git a/numpy/random/randomgen/src/pcg32/pcg32.h b/numpy/random/src/pcg32/pcg32.h index 557113d8f..557113d8f 100644 --- a/numpy/random/randomgen/src/pcg32/pcg32.h +++ b/numpy/random/src/pcg32/pcg32.h diff --git a/numpy/random/randomgen/src/pcg32/pcg_variants.h b/numpy/random/src/pcg32/pcg_variants.h index 32daac1ce..32daac1ce 100644 --- a/numpy/random/randomgen/src/pcg32/pcg_variants.h +++ b/numpy/random/src/pcg32/pcg_variants.h diff --git a/numpy/random/randomgen/src/pcg64/LICENSE.md b/numpy/random/src/pcg64/LICENSE.md index dd6a17ee8..dd6a17ee8 100644 --- a/numpy/random/randomgen/src/pcg64/LICENSE.md +++ b/numpy/random/src/pcg64/LICENSE.md diff --git a/numpy/random/randomgen/src/pcg64/pcg64-benchmark.c b/numpy/random/src/pcg64/pcg64-benchmark.c index 76f3ec78c..76f3ec78c 100644 --- a/numpy/random/randomgen/src/pcg64/pcg64-benchmark.c +++ b/numpy/random/src/pcg64/pcg64-benchmark.c diff --git a/numpy/random/randomgen/src/pcg64/pcg64-test-data-gen.c b/numpy/random/src/pcg64/pcg64-test-data-gen.c index 0c2b079a3..0c2b079a3 100644 --- a/numpy/random/randomgen/src/pcg64/pcg64-test-data-gen.c +++ b/numpy/random/src/pcg64/pcg64-test-data-gen.c diff --git a/numpy/random/randomgen/src/pcg64/pcg64.c b/numpy/random/src/pcg64/pcg64.c index c7c1eb045..c7c1eb045 100644 --- a/numpy/random/randomgen/src/pcg64/pcg64.c +++ b/numpy/random/src/pcg64/pcg64.c diff --git a/numpy/random/randomgen/src/pcg64/pcg64.h b/numpy/random/src/pcg64/pcg64.h index 156c73a36..156c73a36 100644 --- a/numpy/random/randomgen/src/pcg64/pcg64.h +++ b/numpy/random/src/pcg64/pcg64.h diff --git a/numpy/random/randomgen/src/pcg64/pcg64.orig.c b/numpy/random/src/pcg64/pcg64.orig.c index 07e97e4b6..07e97e4b6 100644 --- a/numpy/random/randomgen/src/pcg64/pcg64.orig.c +++ b/numpy/random/src/pcg64/pcg64.orig.c diff --git a/numpy/random/randomgen/src/pcg64/pcg64.orig.h b/numpy/random/src/pcg64/pcg64.orig.h index 74be91f31..74be91f31 100644 --- a/numpy/random/randomgen/src/pcg64/pcg64.orig.h +++ b/numpy/random/src/pcg64/pcg64.orig.h diff --git a/numpy/random/randomgen/src/philox/LICENSE.md b/numpy/random/src/philox/LICENSE.md index 4a9f6bb29..4a9f6bb29 100644 --- a/numpy/random/randomgen/src/philox/LICENSE.md +++ b/numpy/random/src/philox/LICENSE.md diff --git a/numpy/random/randomgen/src/philox/philox-benchmark.c b/numpy/random/src/philox/philox-benchmark.c index 0cab04cf5..0cab04cf5 100644 --- a/numpy/random/randomgen/src/philox/philox-benchmark.c +++ b/numpy/random/src/philox/philox-benchmark.c diff --git a/numpy/random/randomgen/src/philox/philox-test-data-gen.c b/numpy/random/src/philox/philox-test-data-gen.c index 442e18b55..442e18b55 100644 --- a/numpy/random/randomgen/src/philox/philox-test-data-gen.c +++ b/numpy/random/src/philox/philox-test-data-gen.c diff --git a/numpy/random/randomgen/src/philox/philox.c b/numpy/random/src/philox/philox.c index 3382c60d6..3382c60d6 100644 --- a/numpy/random/randomgen/src/philox/philox.c +++ b/numpy/random/src/philox/philox.c diff --git a/numpy/random/randomgen/src/philox/philox.h b/numpy/random/src/philox/philox.h index 411404b55..411404b55 100644 --- a/numpy/random/randomgen/src/philox/philox.h +++ b/numpy/random/src/philox/philox.h diff --git a/numpy/random/randomgen/src/splitmix64/LICENSE.md b/numpy/random/src/splitmix64/LICENSE.md index 3c4d73b92..3c4d73b92 100644 --- a/numpy/random/randomgen/src/splitmix64/LICENSE.md +++ b/numpy/random/src/splitmix64/LICENSE.md diff --git a/numpy/random/randomgen/src/splitmix64/splitmix64.c b/numpy/random/src/splitmix64/splitmix64.c index 79a845982..79a845982 100644 --- a/numpy/random/randomgen/src/splitmix64/splitmix64.c +++ b/numpy/random/src/splitmix64/splitmix64.c diff --git a/numpy/random/randomgen/src/splitmix64/splitmix64.h b/numpy/random/src/splitmix64/splitmix64.h index 880132970..880132970 100644 --- a/numpy/random/randomgen/src/splitmix64/splitmix64.h +++ b/numpy/random/src/splitmix64/splitmix64.h diff --git a/numpy/random/randomgen/src/splitmix64/splitmix64.orig.c b/numpy/random/src/splitmix64/splitmix64.orig.c index df6133aab..df6133aab 100644 --- a/numpy/random/randomgen/src/splitmix64/splitmix64.orig.c +++ b/numpy/random/src/splitmix64/splitmix64.orig.c diff --git a/numpy/random/randomgen/src/threefry/LICENSE.md b/numpy/random/src/threefry/LICENSE.md index 4a9f6bb29..4a9f6bb29 100644 --- a/numpy/random/randomgen/src/threefry/LICENSE.md +++ b/numpy/random/src/threefry/LICENSE.md diff --git a/numpy/random/randomgen/src/threefry/threefry-benchmark.c b/numpy/random/src/threefry/threefry-benchmark.c index 6d6239cd3..6d6239cd3 100644 --- a/numpy/random/randomgen/src/threefry/threefry-benchmark.c +++ b/numpy/random/src/threefry/threefry-benchmark.c diff --git a/numpy/random/randomgen/src/threefry/threefry-orig.c b/numpy/random/src/threefry/threefry-orig.c index d27cfd797..d27cfd797 100644 --- a/numpy/random/randomgen/src/threefry/threefry-orig.c +++ b/numpy/random/src/threefry/threefry-orig.c diff --git a/numpy/random/randomgen/src/threefry/threefry-test-data-gen.c b/numpy/random/src/threefry/threefry-test-data-gen.c index 328eb2575..328eb2575 100644 --- a/numpy/random/randomgen/src/threefry/threefry-test-data-gen.c +++ b/numpy/random/src/threefry/threefry-test-data-gen.c diff --git a/numpy/random/randomgen/src/threefry/threefry.c b/numpy/random/src/threefry/threefry.c index 19c37df1b..19c37df1b 100644 --- a/numpy/random/randomgen/src/threefry/threefry.c +++ b/numpy/random/src/threefry/threefry.c diff --git a/numpy/random/randomgen/src/threefry/threefry.h b/numpy/random/src/threefry/threefry.h index 297c1241a..297c1241a 100644 --- a/numpy/random/randomgen/src/threefry/threefry.h +++ b/numpy/random/src/threefry/threefry.h diff --git a/numpy/random/randomgen/src/threefry32/LICENSE.md b/numpy/random/src/threefry32/LICENSE.md index 591cd75f4..591cd75f4 100644 --- a/numpy/random/randomgen/src/threefry32/LICENSE.md +++ b/numpy/random/src/threefry32/LICENSE.md diff --git a/numpy/random/randomgen/src/threefry32/threefry32-test-data-gen.c b/numpy/random/src/threefry32/threefry32-test-data-gen.c index 0e6229995..0e6229995 100644 --- a/numpy/random/randomgen/src/threefry32/threefry32-test-data-gen.c +++ b/numpy/random/src/threefry32/threefry32-test-data-gen.c diff --git a/numpy/random/randomgen/src/threefry32/threefry32.c b/numpy/random/src/threefry32/threefry32.c index 500e9482d..500e9482d 100644 --- a/numpy/random/randomgen/src/threefry32/threefry32.c +++ b/numpy/random/src/threefry32/threefry32.c diff --git a/numpy/random/randomgen/src/threefry32/threefry32.h b/numpy/random/src/threefry32/threefry32.h index 74a85c42b..74a85c42b 100644 --- a/numpy/random/randomgen/src/threefry32/threefry32.h +++ b/numpy/random/src/threefry32/threefry32.h diff --git a/numpy/random/randomgen/src/xoroshiro128/LICENSE.md b/numpy/random/src/xoroshiro128/LICENSE.md index 969430149..969430149 100644 --- a/numpy/random/randomgen/src/xoroshiro128/LICENSE.md +++ b/numpy/random/src/xoroshiro128/LICENSE.md diff --git a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128-benchmark.c b/numpy/random/src/xoroshiro128/xoroshiro128-benchmark.c index 9a7b52bfb..9a7b52bfb 100644 --- a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128-benchmark.c +++ b/numpy/random/src/xoroshiro128/xoroshiro128-benchmark.c diff --git a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128-test-data-gen.c b/numpy/random/src/xoroshiro128/xoroshiro128-test-data-gen.c index d50e63f5e..d50e63f5e 100644 --- a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128-test-data-gen.c +++ b/numpy/random/src/xoroshiro128/xoroshiro128-test-data-gen.c diff --git a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128.c b/numpy/random/src/xoroshiro128/xoroshiro128.c index 060eb8a51..060eb8a51 100644 --- a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128.c +++ b/numpy/random/src/xoroshiro128/xoroshiro128.c diff --git a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128.h b/numpy/random/src/xoroshiro128/xoroshiro128.h index 0db82b173..0db82b173 100644 --- a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128.h +++ b/numpy/random/src/xoroshiro128/xoroshiro128.h diff --git a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128plus.orig.c b/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.c index 1b5f46e4b..1b5f46e4b 100644 --- a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128plus.orig.c +++ b/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.c diff --git a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128plus.orig.h b/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.h index 20c96fe04..20c96fe04 100644 --- a/numpy/random/randomgen/src/xoroshiro128/xoroshiro128plus.orig.h +++ b/numpy/random/src/xoroshiro128/xoroshiro128plus.orig.h diff --git a/numpy/random/randomgen/src/xorshift1024/LICENSE.md b/numpy/random/src/xorshift1024/LICENSE.md index 3ca8ed4b9..3ca8ed4b9 100644 --- a/numpy/random/randomgen/src/xorshift1024/LICENSE.md +++ b/numpy/random/src/xorshift1024/LICENSE.md diff --git a/numpy/random/randomgen/src/xorshift1024/xorshift1024-benchmark.c b/numpy/random/src/xorshift1024/xorshift1024-benchmark.c index 0eef33537..0eef33537 100644 --- a/numpy/random/randomgen/src/xorshift1024/xorshift1024-benchmark.c +++ b/numpy/random/src/xorshift1024/xorshift1024-benchmark.c diff --git a/numpy/random/randomgen/src/xorshift1024/xorshift1024-test-data-gen.c b/numpy/random/src/xorshift1024/xorshift1024-test-data-gen.c index a2ae08df4..a2ae08df4 100644 --- a/numpy/random/randomgen/src/xorshift1024/xorshift1024-test-data-gen.c +++ b/numpy/random/src/xorshift1024/xorshift1024-test-data-gen.c diff --git a/numpy/random/randomgen/src/xorshift1024/xorshift1024.c b/numpy/random/src/xorshift1024/xorshift1024.c index 8737b5a82..8737b5a82 100644 --- a/numpy/random/randomgen/src/xorshift1024/xorshift1024.c +++ b/numpy/random/src/xorshift1024/xorshift1024.c diff --git a/numpy/random/randomgen/src/xorshift1024/xorshift1024.h b/numpy/random/src/xorshift1024/xorshift1024.h index e0ef77826..e0ef77826 100644 --- a/numpy/random/randomgen/src/xorshift1024/xorshift1024.h +++ b/numpy/random/src/xorshift1024/xorshift1024.h diff --git a/numpy/random/randomgen/src/xorshift1024/xorshift1024.orig.c b/numpy/random/src/xorshift1024/xorshift1024.orig.c index 03c1c17fe..03c1c17fe 100644 --- a/numpy/random/randomgen/src/xorshift1024/xorshift1024.orig.c +++ b/numpy/random/src/xorshift1024/xorshift1024.orig.c diff --git a/numpy/random/randomgen/src/xorshift1024/xorshift1024.orig.h b/numpy/random/src/xorshift1024/xorshift1024.orig.h index 9b7597967..9b7597967 100644 --- a/numpy/random/randomgen/src/xorshift1024/xorshift1024.orig.h +++ b/numpy/random/src/xorshift1024/xorshift1024.orig.h diff --git a/numpy/random/randomgen/src/xoshiro256starstar/LICENSE.md b/numpy/random/src/xoshiro256starstar/LICENSE.md index d863f3b29..d863f3b29 100644 --- a/numpy/random/randomgen/src/xoshiro256starstar/LICENSE.md +++ b/numpy/random/src/xoshiro256starstar/LICENSE.md diff --git a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar-test-data-gen.c b/numpy/random/src/xoshiro256starstar/xoshiro256starstar-test-data-gen.c index 8522229dd..8522229dd 100644 --- a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar-test-data-gen.c +++ b/numpy/random/src/xoshiro256starstar/xoshiro256starstar-test-data-gen.c diff --git a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.c b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.c index 30b6c7d85..30b6c7d85 100644 --- a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.c +++ b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.c diff --git a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.h b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.h index 1d7d8ea40..1d7d8ea40 100644 --- a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.h +++ b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.h diff --git a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.orig.c b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.orig.c index ecf87bab9..ecf87bab9 100644 --- a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.orig.c +++ b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.orig.c diff --git a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.orig.h b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.orig.h index 3aa788ec9..3aa788ec9 100644 --- a/numpy/random/randomgen/src/xoshiro256starstar/xoshiro256starstar.orig.h +++ b/numpy/random/src/xoshiro256starstar/xoshiro256starstar.orig.h diff --git a/numpy/random/randomgen/src/xoshiro512starstar/LICENSE.md b/numpy/random/src/xoshiro512starstar/LICENSE.md index aa34c1966..aa34c1966 100644 --- a/numpy/random/randomgen/src/xoshiro512starstar/LICENSE.md +++ b/numpy/random/src/xoshiro512starstar/LICENSE.md diff --git a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar-test-data-gen.c b/numpy/random/src/xoshiro512starstar/xoshiro512starstar-test-data-gen.c index bcc3574e4..bcc3574e4 100644 --- a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar-test-data-gen.c +++ b/numpy/random/src/xoshiro512starstar/xoshiro512starstar-test-data-gen.c diff --git a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.c b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.c index a9f56699f..a9f56699f 100644 --- a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.c +++ b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.c diff --git a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.h b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.h index 0fa0ba3cd..0fa0ba3cd 100644 --- a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.h +++ b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.h diff --git a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.orig.c b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.orig.c index 0cf884edb..0cf884edb 100644 --- a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.orig.c +++ b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.orig.c diff --git a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.orig.h b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.orig.h index 0b7892473..0b7892473 100644 --- a/numpy/random/randomgen/src/xoshiro512starstar/xoshiro512starstar.orig.h +++ b/numpy/random/src/xoshiro512starstar/xoshiro512starstar.orig.h diff --git a/numpy/random/randomgen/tests/__init__.py b/numpy/random/tests/data/__init__.py index e69de29bb..e69de29bb 100644 --- a/numpy/random/randomgen/tests/__init__.py +++ b/numpy/random/tests/data/__init__.py diff --git a/numpy/random/randomgen/tests/data/dSFMT-testset-1.csv b/numpy/random/tests/data/dSFMT-testset-1.csv index 9f3f68aee..9f3f68aee 100644 --- a/numpy/random/randomgen/tests/data/dSFMT-testset-1.csv +++ b/numpy/random/tests/data/dSFMT-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/dSFMT-testset-2.csv b/numpy/random/tests/data/dSFMT-testset-2.csv index 2ec2d7a51..2ec2d7a51 100644 --- a/numpy/random/randomgen/tests/data/dSFMT-testset-2.csv +++ b/numpy/random/tests/data/dSFMT-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/mt19937-testset-1.csv b/numpy/random/tests/data/mt19937-testset-1.csv index 3d4995840..3d4995840 100644 --- a/numpy/random/randomgen/tests/data/mt19937-testset-1.csv +++ b/numpy/random/tests/data/mt19937-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/mt19937-testset-2.csv b/numpy/random/tests/data/mt19937-testset-2.csv index d2f6c156c..d2f6c156c 100644 --- a/numpy/random/randomgen/tests/data/mt19937-testset-2.csv +++ b/numpy/random/tests/data/mt19937-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/pcg32-testset-1.csv b/numpy/random/tests/data/pcg32-testset-1.csv index 6bddc8d5c..6bddc8d5c 100644 --- a/numpy/random/randomgen/tests/data/pcg32-testset-1.csv +++ b/numpy/random/tests/data/pcg32-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/pcg32-testset-2.csv b/numpy/random/tests/data/pcg32-testset-2.csv index 2d4c8aed1..2d4c8aed1 100644 --- a/numpy/random/randomgen/tests/data/pcg32-testset-2.csv +++ b/numpy/random/tests/data/pcg32-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/pcg64-testset-1.csv b/numpy/random/tests/data/pcg64-testset-1.csv index da6d77d40..da6d77d40 100644 --- a/numpy/random/randomgen/tests/data/pcg64-testset-1.csv +++ b/numpy/random/tests/data/pcg64-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/pcg64-testset-2.csv b/numpy/random/tests/data/pcg64-testset-2.csv index 779761d0f..779761d0f 100644 --- a/numpy/random/randomgen/tests/data/pcg64-testset-2.csv +++ b/numpy/random/tests/data/pcg64-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/philox-testset-1.csv b/numpy/random/tests/data/philox-testset-1.csv index 64c1516cb..64c1516cb 100644 --- a/numpy/random/randomgen/tests/data/philox-testset-1.csv +++ b/numpy/random/tests/data/philox-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/philox-testset-2.csv b/numpy/random/tests/data/philox-testset-2.csv index 1c2d4eba0..1c2d4eba0 100644 --- a/numpy/random/randomgen/tests/data/philox-testset-2.csv +++ b/numpy/random/tests/data/philox-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/threefry-testset-1.csv b/numpy/random/tests/data/threefry-testset-1.csv index ddfa736dc..ddfa736dc 100644 --- a/numpy/random/randomgen/tests/data/threefry-testset-1.csv +++ b/numpy/random/tests/data/threefry-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/threefry-testset-2.csv b/numpy/random/tests/data/threefry-testset-2.csv index 275604557..275604557 100644 --- a/numpy/random/randomgen/tests/data/threefry-testset-2.csv +++ b/numpy/random/tests/data/threefry-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/threefry32-testset-1.csv b/numpy/random/tests/data/threefry32-testset-1.csv index 3aec7304d..3aec7304d 100644 --- a/numpy/random/randomgen/tests/data/threefry32-testset-1.csv +++ b/numpy/random/tests/data/threefry32-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/threefry32-testset-2.csv b/numpy/random/tests/data/threefry32-testset-2.csv index b7753638f..b7753638f 100644 --- a/numpy/random/randomgen/tests/data/threefry32-testset-2.csv +++ b/numpy/random/tests/data/threefry32-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/xoroshiro128-testset-1.csv b/numpy/random/tests/data/xoroshiro128-testset-1.csv index 4ef7172e1..4ef7172e1 100644 --- a/numpy/random/randomgen/tests/data/xoroshiro128-testset-1.csv +++ b/numpy/random/tests/data/xoroshiro128-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/xoroshiro128-testset-2.csv b/numpy/random/tests/data/xoroshiro128-testset-2.csv index 2de341ecd..2de341ecd 100644 --- a/numpy/random/randomgen/tests/data/xoroshiro128-testset-2.csv +++ b/numpy/random/tests/data/xoroshiro128-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/xorshift1024-testset-1.csv b/numpy/random/tests/data/xorshift1024-testset-1.csv index 661b157b1..661b157b1 100644 --- a/numpy/random/randomgen/tests/data/xorshift1024-testset-1.csv +++ b/numpy/random/tests/data/xorshift1024-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/xorshift1024-testset-2.csv b/numpy/random/tests/data/xorshift1024-testset-2.csv index ef10e6872..ef10e6872 100644 --- a/numpy/random/randomgen/tests/data/xorshift1024-testset-2.csv +++ b/numpy/random/tests/data/xorshift1024-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/xoshiro256starstar-testset-1.csv b/numpy/random/tests/data/xoshiro256starstar-testset-1.csv index 534799b04..534799b04 100644 --- a/numpy/random/randomgen/tests/data/xoshiro256starstar-testset-1.csv +++ b/numpy/random/tests/data/xoshiro256starstar-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/xoshiro256starstar-testset-2.csv b/numpy/random/tests/data/xoshiro256starstar-testset-2.csv index b688fcb2a..b688fcb2a 100644 --- a/numpy/random/randomgen/tests/data/xoshiro256starstar-testset-2.csv +++ b/numpy/random/tests/data/xoshiro256starstar-testset-2.csv diff --git a/numpy/random/randomgen/tests/data/xoshiro512starstar-testset-1.csv b/numpy/random/tests/data/xoshiro512starstar-testset-1.csv index 78fb903ee..78fb903ee 100644 --- a/numpy/random/randomgen/tests/data/xoshiro512starstar-testset-1.csv +++ b/numpy/random/tests/data/xoshiro512starstar-testset-1.csv diff --git a/numpy/random/randomgen/tests/data/xoshiro512starstar-testset-2.csv b/numpy/random/tests/data/xoshiro512starstar-testset-2.csv index 264308f1a..264308f1a 100644 --- a/numpy/random/randomgen/tests/data/xoshiro512starstar-testset-2.csv +++ b/numpy/random/tests/data/xoshiro512starstar-testset-2.csv diff --git a/numpy/random/randomgen/tests/test_against_numpy.py b/numpy/random/tests/test_against_numpy.py index 431c7bd85..b930fcbff 100644 --- a/numpy/random/randomgen/tests/test_against_numpy.py +++ b/numpy/random/tests/test_against_numpy.py @@ -5,7 +5,7 @@ from numpy.testing import (assert_allclose, assert_array_equal, assert_equal, import pytest -from numpy.random.randomgen import RandomGenerator, MT19937, generator +from numpy.random import RandomGenerator, MT19937, generator from numpy.random import RandomState @@ -98,12 +98,12 @@ class TestAgainstNumPy(object): cls.rg = RandomGenerator(cls.brng(*cls.seed)) cls.rs = RandomState(cls.brng(*cls.seed)) cls.nprs = cls.np.RandomState(*cls.seed) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls._set_common_state() @classmethod def _set_common_state(cls): - state = cls.rg.state + state = cls.rg.brng.state st = [[]] * 5 st[0] = 'MT19937' st[1] = state['state']['key'] @@ -125,7 +125,7 @@ class TestAgainstNumPy(object): def _is_state_common(self): state = self.nprs.get_state() - state2 = self.rg.state + state2 = self.rg.brng.state assert (state[1] == state2['state']['key']).all() assert (state[2] == state2['state']['pos']) @@ -138,10 +138,10 @@ class TestAgainstNumPy(object): assert_allclose(state[4], state2['gauss'], atol=1e-10) def test_common_seed(self): - self.rg.seed(1234) + self.rg.brng.seed(1234) self.nprs.seed(1234) self._is_state_common() - self.rg.seed(23456) + self.rg.brng.seed(23456) self.nprs.seed(23456) self._is_state_common() @@ -149,8 +149,8 @@ class TestAgainstNumPy(object): nprs = np.random.RandomState() nprs.standard_normal(99) state = nprs.get_state() - self.rg.state = state - state2 = self.rg.state + self.rg.brng.state = state + state2 = self.rg.brng.state assert (state[1] == state2['state']['key']).all() assert (state[2] == state2['state']['pos']) @@ -383,7 +383,7 @@ class TestAgainstNumPy(object): assert_equal(s1.randint(1000), 419) assert_equal(s1.randint(1000), s.randint(1000)) - self.rg.seed(4294967295) + self.rg.brng.seed(4294967295) self.nprs.seed(4294967295) self._is_state_common() @@ -400,26 +400,6 @@ class TestAgainstNumPy(object): s = RandomGenerator(MT19937([4294967295])) assert_equal(s.randint(1000), 265) - def test_dir(self): - nprs_d = set(dir(self.nprs)) - rs_d = dir(self.rg) - excluded = {'get_state', 'set_state'} - nprs_d.difference_update(excluded) - assert (len(nprs_d.difference(rs_d)) == 0) - - npmod = dir(numpy.random) - mod = dir(generator) - known_exlcuded = ['__all__', '__cached__', '__path__', 'Tester', - 'info', 'bench', '__RandomState_ctor', 'mtrand', - 'test', '__warningregistry__', '_numpy_tester', - 'division', 'get_state', 'set_state', 'seed', - 'ranf', 'random', 'sample', 'absolute_import', - 'print_function', 'RandomState', 'randomgen', - 'tests', 'Lock'] - mod += known_exlcuded - diff = set(npmod).difference(mod) - assert_equal(len(diff), 0) - # Tests using legacy generator def test_chisquare(self): self._set_common_state_legacy() diff --git a/numpy/random/randomgen/tests/test_direct.py b/numpy/random/tests/test_direct.py index 22fdcd865..d6042100a 100644 --- a/numpy/random/randomgen/tests/test_direct.py +++ b/numpy/random/tests/test_direct.py @@ -7,10 +7,10 @@ from numpy.testing import assert_equal, assert_allclose, assert_array_equal, \ assert_raises import pytest -from ...randomgen import RandomGenerator, MT19937, DSFMT, ThreeFry32, ThreeFry, \ +from numpy.random import RandomGenerator, MT19937, DSFMT, ThreeFry32, ThreeFry, \ PCG32, PCG64, Philox, Xoroshiro128, Xorshift1024, Xoshiro256StarStar, \ Xoshiro512StarStar, RandomState -from ...randomgen.common import interface +from numpy.random.common import interface try: import cffi # noqa: F401 @@ -206,30 +206,30 @@ class Base(object): def test_seed_float(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(self.seed_error_type, rs.seed, np.pi) - assert_raises(self.seed_error_type, rs.seed, -np.pi) + assert_raises(self.seed_error_type, rs.brng.seed, np.pi) + assert_raises(self.seed_error_type, rs.brng.seed, -np.pi) def test_seed_float_array(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(self.seed_error_type, rs.seed, np.array([np.pi])) - assert_raises(self.seed_error_type, rs.seed, np.array([-np.pi])) - assert_raises(ValueError, rs.seed, np.array([np.pi, -np.pi])) - assert_raises(TypeError, rs.seed, np.array([0, np.pi])) - assert_raises(TypeError, rs.seed, [np.pi]) - assert_raises(TypeError, rs.seed, [0, np.pi]) + assert_raises(self.seed_error_type, rs.brng.seed, np.array([np.pi])) + assert_raises(self.seed_error_type, rs.brng.seed, np.array([-np.pi])) + assert_raises(ValueError, rs.brng.seed, np.array([np.pi, -np.pi])) + assert_raises(TypeError, rs.brng.seed, np.array([0, np.pi])) + assert_raises(TypeError, rs.brng.seed, [np.pi]) + assert_raises(TypeError, rs.brng.seed, [0, np.pi]) def test_seed_out_of_range(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(ValueError, rs.seed, 2 ** (2 * self.bits + 1)) - assert_raises(ValueError, rs.seed, -1) + assert_raises(ValueError, rs.brng.seed, 2 ** (2 * self.bits + 1)) + assert_raises(ValueError, rs.brng.seed, -1) def test_seed_out_of_range_array(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(ValueError, rs.seed, [2 ** (2 * self.bits + 1)]) - assert_raises(ValueError, rs.seed, [-1]) + assert_raises(ValueError, rs.brng.seed, [2 ** (2 * self.bits + 1)]) + assert_raises(ValueError, rs.brng.seed, [-1]) def test_repr(self): rs = RandomGenerator(self.brng(*self.data1['seed'])) @@ -412,18 +412,18 @@ class TestPCG64(Base): def test_seed_float_array(self): rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(self.seed_error_type, rs.seed, np.array([np.pi])) - assert_raises(self.seed_error_type, rs.seed, np.array([-np.pi])) - assert_raises(self.seed_error_type, rs.seed, np.array([np.pi, -np.pi])) - assert_raises(self.seed_error_type, rs.seed, np.array([0, np.pi])) - assert_raises(self.seed_error_type, rs.seed, [np.pi]) - assert_raises(self.seed_error_type, rs.seed, [0, np.pi]) + assert_raises(self.seed_error_type, rs.brng.seed, np.array([np.pi])) + assert_raises(self.seed_error_type, rs.brng.seed, np.array([-np.pi])) + assert_raises(self.seed_error_type, rs.brng.seed, np.array([np.pi, -np.pi])) + assert_raises(self.seed_error_type, rs.brng.seed, np.array([0, np.pi])) + assert_raises(self.seed_error_type, rs.brng.seed, [np.pi]) + assert_raises(self.seed_error_type, rs.brng.seed, [0, np.pi]) def test_seed_out_of_range_array(self): rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(self.seed_error_type, rs.seed, + assert_raises(self.seed_error_type, rs.brng.seed, [2 ** (2 * self.bits + 1)]) - assert_raises(self.seed_error_type, rs.seed, [-1]) + assert_raises(self.seed_error_type, rs.brng.seed, [-1]) class TestPhilox(Base): @@ -464,43 +464,45 @@ class TestMT19937(Base): def test_seed_out_of_range(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(ValueError, rs.seed, 2 ** (self.bits + 1)) - assert_raises(ValueError, rs.seed, -1) - assert_raises(ValueError, rs.seed, 2 ** (2 * self.bits + 1)) + assert_raises(ValueError, rs.brng.seed, 2 ** (self.bits + 1)) + assert_raises(ValueError, rs.brng.seed, -1) + assert_raises(ValueError, rs.brng.seed, 2 ** (2 * self.bits + 1)) def test_seed_out_of_range_array(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(ValueError, rs.seed, [2 ** (self.bits + 1)]) - assert_raises(ValueError, rs.seed, [-1]) - assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits + 1)]) + assert_raises(ValueError, rs.brng.seed, [2 ** (self.bits + 1)]) + assert_raises(ValueError, rs.brng.seed, [-1]) + assert_raises(TypeError, rs.brng.seed, [2 ** (2 * self.bits + 1)]) def test_seed_float(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(TypeError, rs.seed, np.pi) - assert_raises(TypeError, rs.seed, -np.pi) + assert_raises(TypeError, rs.brng.seed, np.pi) + assert_raises(TypeError, rs.brng.seed, -np.pi) def test_seed_float_array(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(TypeError, rs.seed, np.array([np.pi])) - assert_raises(TypeError, rs.seed, np.array([-np.pi])) - assert_raises(TypeError, rs.seed, np.array([np.pi, -np.pi])) - assert_raises(TypeError, rs.seed, np.array([0, np.pi])) - assert_raises(TypeError, rs.seed, [np.pi]) - assert_raises(TypeError, rs.seed, [0, np.pi]) + brng = rs.brng + assert_raises(TypeError, brng.seed, np.array([np.pi])) + assert_raises(TypeError, brng.seed, np.array([-np.pi])) + assert_raises(TypeError, brng.seed, np.array([np.pi, -np.pi])) + assert_raises(TypeError, brng.seed, np.array([0, np.pi])) + assert_raises(TypeError, brng.seed, [np.pi]) + assert_raises(TypeError, brng.seed, [0, np.pi]) def test_state_tuple(self): rs = RandomGenerator(self.brng(*self.data1['seed'])) - state = rs.state + brng = rs.brng + state = brng.state desired = rs.randint(2 ** 16) tup = (state['brng'], state['state']['key'], state['state']['pos']) - rs.state = tup + brng.state = tup actual = rs.randint(2 ** 16) assert_equal(actual, desired) tup = tup + (0, 0.0) - rs.state = tup + brng.state = tup actual = rs.randint(2 ** 16) assert_equal(actual, desired) @@ -542,25 +544,25 @@ class TestDSFMT(Base): def test_seed_out_of_range_array(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(ValueError, rs.seed, [2 ** (self.bits + 1)]) - assert_raises(ValueError, rs.seed, [-1]) - assert_raises(TypeError, rs.seed, [2 ** (2 * self.bits + 1)]) + assert_raises(ValueError, rs.brng.seed, [2 ** (self.bits + 1)]) + assert_raises(ValueError, rs.brng.seed, [-1]) + assert_raises(TypeError, rs.brng.seed, [2 ** (2 * self.bits + 1)]) def test_seed_float(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(TypeError, rs.seed, np.pi) - assert_raises(TypeError, rs.seed, -np.pi) + assert_raises(TypeError, rs.brng.seed, np.pi) + assert_raises(TypeError, rs.brng.seed, -np.pi) def test_seed_float_array(self): # GH #82 rs = RandomGenerator(self.brng(*self.data1['seed'])) - assert_raises(TypeError, rs.seed, np.array([np.pi])) - assert_raises(TypeError, rs.seed, np.array([-np.pi])) - assert_raises(TypeError, rs.seed, np.array([np.pi, -np.pi])) - assert_raises(TypeError, rs.seed, np.array([0, np.pi])) - assert_raises(TypeError, rs.seed, [np.pi]) - assert_raises(TypeError, rs.seed, [0, np.pi]) + assert_raises(TypeError, rs.brng.seed, np.array([np.pi])) + assert_raises(TypeError, rs.brng.seed, np.array([-np.pi])) + assert_raises(TypeError, rs.brng.seed, np.array([np.pi, -np.pi])) + assert_raises(TypeError, rs.brng.seed, np.array([0, np.pi])) + assert_raises(TypeError, rs.brng.seed, [np.pi]) + assert_raises(TypeError, rs.brng.seed, [0, np.pi]) def test_uniform_float(self): rs = RandomGenerator(self.brng(*self.data1['seed'])) @@ -578,9 +580,9 @@ class TestDSFMT(Base): def test_buffer_reset(self): rs = RandomGenerator(self.brng(*self.data1['seed'])) rs.random_sample(1) - assert rs.state['buffer_loc'] != 382 - rs.seed(*self.data1['seed']) - assert rs.state['buffer_loc'] == 382 + assert rs.brng.state['buffer_loc'] != 382 + rs.brng.seed(*self.data1['seed']) + assert rs.brng.state['buffer_loc'] == 382 class TestThreeFry32(Base): diff --git a/numpy/random/randomgen/tests/test_generator_mt19937.py b/numpy/random/tests/test_generator_mt19937.py index 10dd8733a..3eda84d84 100644 --- a/numpy/random/randomgen/tests/test_generator_mt19937.py +++ b/numpy/random/tests/test_generator_mt19937.py @@ -7,7 +7,7 @@ from numpy.testing import ( assert_warns, assert_no_warnings, assert_array_equal, assert_array_almost_equal, suppress_warnings) -from ...randomgen import RandomGenerator, MT19937 +from numpy.random import RandomGenerator, MT19937 random = RandomGenerator(MT19937()) @@ -96,21 +96,22 @@ class TestSetState(object): def setup(self): self.seed = 1234567890 self.rg = RandomGenerator(MT19937(self.seed)) - self.state = self.rg.state + self.brng = self.rg.brng + self.state = self.brng.state self.legacy_state = (self.state['brng'], self.state['state']['key'], self.state['state']['pos']) def test_basic(self): old = self.rg.tomaxint(16) - self.rg.state = self.state + self.brng.state = self.state new = self.rg.tomaxint(16) assert_(np.all(old == new)) def test_gaussian_reset(self): # Make sure the cached every-other-Gaussian is reset. old = self.rg.standard_normal(size=3) - self.rg.state = self.state + self.brng.state = self.state new = self.rg.standard_normal(size=3) assert_(np.all(old == new)) @@ -119,9 +120,9 @@ class TestSetState(object): # cached Gaussian is restored. self.rg.standard_normal() - state = self.rg.state + state = self.brng.state old = self.rg.standard_normal(size=3) - self.rg.state = state + self.brng.state = state new = self.rg.standard_normal(size=3) assert_(np.all(old == new)) @@ -244,7 +245,7 @@ class TestRandint(object): def test_in_bounds_fuzz(self): # Don't use fixed seed - random.seed() + random.brng.seed() for dt in self.itype[1:]: for ubnd in [4, 8, 16]: @@ -263,13 +264,13 @@ class TestRandint(object): ubnd = 2 if dt is bool else np.iinfo(dt).max + 1 size = 1000 - random.seed(1234) + random.brng.seed(1234) scalar = self.rfunc(lbnd, ubnd, size=size, dtype=dt) - random.seed(1234) + random.brng.seed(1234) scalar_array = self.rfunc([lbnd], [ubnd], size=size, dtype=dt) - random.seed(1234) + random.brng.seed(1234) array = self.rfunc([lbnd] * size, [ubnd] * size, size=size, dtype=dt) assert_array_equal(scalar, scalar_array) @@ -291,7 +292,7 @@ class TestRandint(object): 'uint8': '27dd30c4e08a797063dffac2490b0be6'} for dt in self.itype[1:]: - random.seed(1234) + random.brng.seed(1234) # view as little endian for hash if sys.byteorder == 'little': @@ -303,7 +304,7 @@ class TestRandint(object): assert_(tgt[np.dtype(dt).name] == res) # bools do not depend on endianness - random.seed(1234) + random.brng.seed(1234) val = self.rfunc(0, 2, size=1000, dtype=bool).view(np.int8) res = hashlib.md5(val).hexdigest() assert_(tgt[np.dtype(bool).name] == res) @@ -316,15 +317,15 @@ class TestRandint(object): np.bool, bool, np.bool_) else np.iinfo(dt).max + 1 # view as little endian for hash - random.seed(1234) + random.brng.seed(1234) val = self.rfunc(lbnd, ubnd, size=1000, dtype=dt) - random.seed(1234) + random.brng.seed(1234) val_bc = self.rfunc([lbnd] * 1000, ubnd, dtype=dt) assert_array_equal(val, val_bc) - random.seed(1234) + random.brng.seed(1234) val_bc = self.rfunc([lbnd] * 1000, [ubnd] * 1000, dtype=dt) assert_array_equal(val, val_bc) @@ -400,7 +401,7 @@ class TestRandomDist(object): self.seed = 1234567890 def test_rand(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.rand(3, 2) desired = np.array([[0.61879477158567997, 0.59162362775974664], [0.88868358904449662, 0.89165480011560816], @@ -408,25 +409,25 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_rand_singleton(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.rand() desired = 0.61879477158567997 assert_array_almost_equal(actual, desired, decimal=15) def test_randn(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.randn(3, 2) desired = np.array([[-3.472754000610961, -0.108938564229143], [-0.245965753396411, -0.704101550261701], [0.360102487116356, 0.127832101772367]]) assert_array_almost_equal(actual, desired, decimal=15) - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.randn() assert_array_almost_equal(actual, desired[0, 0], decimal=15) def test_randint(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.randint(-99, 99, size=(3, 2)) desired = np.array([[31, 3], [-52, 41], @@ -436,7 +437,7 @@ class TestRandomDist(object): def test_randint_masked(self): # Test masked rejection sampling algorithm to generate array of # uint32 in an interval. - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.randint(0, 99, size=(3, 2), dtype=np.uint32, use_masked=True) desired = np.array([[2, 47], @@ -446,7 +447,7 @@ class TestRandomDist(object): def test_randint_lemire_32(self): # Test lemire algorithm to generate array of uint32 in an interval. - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.randint(0, 99, size=(3, 2), dtype=np.uint32, use_masked=False) desired = np.array([[61, 33], @@ -456,7 +457,7 @@ class TestRandomDist(object): def test_randint_lemire_64(self): # Test lemire algorithm to generate array of uint64 in an interval. - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.randint(0, 99 + 0xFFFFFFFFF, size=(3, 2), dtype=np.uint64, use_masked=False) desired = np.array([[42523252834, 40656066204], @@ -465,7 +466,7 @@ class TestRandomDist(object): assert_array_equal(actual, desired) def test_random_integers(self): - random.seed(self.seed) + random.brng.seed(self.seed) with suppress_warnings() as sup: w = sup.record(DeprecationWarning) actual = random.random_integers(-99, 99, size=(3, 2)) @@ -505,19 +506,19 @@ class TestRandomDist(object): np.iinfo('l').max, np.iinfo('l').max) def test_random_sample(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.random_sample((3, 2)) desired = np.array([[0.61879477158567997, 0.59162362775974664], [0.88868358904449662, 0.89165480011560816], [0.4575674820298663, 0.7781880808593471]]) assert_array_almost_equal(actual, desired, decimal=15) - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.random_sample() assert_array_almost_equal(actual, desired[0, 0], decimal=15) def test_random_sample_float(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.random_sample((3, 2)) desired = np.array([[0.6187948, 0.5916236], [0.8886836, 0.8916548], @@ -525,7 +526,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=7) def test_random_sample_float_scalar(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.random_sample(dtype=np.float32) desired = 0.6187948 assert_array_almost_equal(actual, desired, decimal=7) @@ -534,31 +535,31 @@ class TestRandomDist(object): assert_raises(TypeError, random.random_sample, dtype='int32') def test_choice_uniform_replace(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.choice(4, 4) desired = np.array([2, 3, 2, 3]) assert_array_equal(actual, desired) def test_choice_nonuniform_replace(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.choice(4, 4, p=[0.4, 0.4, 0.1, 0.1]) desired = np.array([1, 1, 2, 2]) assert_array_equal(actual, desired) def test_choice_uniform_noreplace(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.choice(4, 3, replace=False) desired = np.array([0, 1, 3]) assert_array_equal(actual, desired) def test_choice_nonuniform_noreplace(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.choice(4, 3, replace=False, p=[0.1, 0.3, 0.5, 0.1]) desired = np.array([2, 3, 1]) assert_array_equal(actual, desired) def test_choice_noninteger(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.choice(['a', 'b', 'c', 'd'], 4) desired = np.array(['c', 'd', 'c', 'd']) assert_array_equal(actual, desired) @@ -634,7 +635,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.choice, a, p=p) def test_bytes(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.bytes(10) desired = b'\x82Ui\x9e\xff\x97+Wf\xa5' assert_equal(actual, desired) @@ -659,7 +660,7 @@ class TestRandomDist(object): lambda x: np.asarray([(i, i) for i in x], [("a", object, 1), ("b", np.int32, 1)])]: - random.seed(self.seed) + random.brng.seed(self.seed) alist = conv([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) random.shuffle(alist) actual = alist @@ -681,19 +682,19 @@ class TestRandomDist(object): sorted(b.data[~b.mask]), sorted(b_orig.data[~b_orig.mask])) def test_permutation(self): - random.seed(self.seed) + random.brng.seed(self.seed) alist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] actual = random.permutation(alist) desired = [0, 1, 9, 6, 2, 4, 5, 8, 7, 3] assert_array_equal(actual, desired) - random.seed(self.seed) + random.brng.seed(self.seed) arr_2d = np.atleast_2d([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]).T actual = random.permutation(arr_2d) assert_array_equal(actual, np.atleast_2d(desired).T) def test_beta(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.beta(.1, .9, size=(3, 2)) desired = np.array( [[1.45341850513746058e-02, 5.31297615662868145e-04], @@ -702,20 +703,20 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_binomial(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.binomial(100.123, .456, size=(3, 2)) desired = np.array([[37, 43], [42, 48], [46, 45]]) assert_array_equal(actual, desired) - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.binomial(100.123, .456) desired = 37 assert_array_equal(actual, desired) def test_chisquare(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.chisquare(50, size=(3, 2)) desired = np.array([[22.2534560369812, 46.9302393710074], [52.9974164611614, 85.3559029505718], @@ -723,7 +724,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=13) def test_dirichlet(self): - random.seed(self.seed) + random.brng.seed(self.seed) alpha = np.array([51.72840233779265162, 39.74494232180943953]) actual = random.dirichlet(alpha, size=(3, 2)) desired = np.array([[[0.444382290764855, 0.555617709235145], @@ -736,7 +737,7 @@ class TestRandomDist(object): bad_alpha = np.array([5.4e-01, -1.0e-16]) assert_raises(ValueError, random.dirichlet, bad_alpha) - random.seed(self.seed) + random.brng.seed(self.seed) alpha = np.array([51.72840233779265162, 39.74494232180943953]) actual = random.dirichlet(alpha) assert_array_almost_equal(actual, desired[0, 0], decimal=15) @@ -759,7 +760,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.dirichlet, alpha) def test_exponential(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.exponential(1.1234, size=(3, 2)) desired = np.array([[5.350682337747634, 1.152307441755771], [3.867015473358779, 1.538765912839396], @@ -771,7 +772,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.exponential, scale=-0.) def test_f(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.f(12, 77, size=(3, 2)) desired = np.array([[0.809498839488467, 2.867222762455471], [0.588036831639353, 1.012185639664636], @@ -779,7 +780,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_gamma(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.gamma(5, 3, size=(3, 2)) desired = np.array([[12.46569350177219, 16.46580642087044], [43.65744473309084, 11.98722785682592], @@ -791,7 +792,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.gamma, shape=-0., scale=-0.) def test_geometric(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.geometric(.123456789, size=(3, 2)) desired = np.array([[8, 7], [17, 17], @@ -809,7 +810,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.geometric, [np.nan] * 10) def test_gumbel(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.gumbel(loc=.123456789, scale=2.0, size=(3, 2)) desired = np.array([[0.19591898743416816, 0.34405539668096674], [-1.4492522252274278, -1.47374816298446865], @@ -821,7 +822,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.gumbel, scale=-0.) def test_hypergeometric(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.hypergeometric(10.1, 5.5, 14, size=(3, 2)) desired = np.array([[10, 10], [10, 10], @@ -847,7 +848,7 @@ class TestRandomDist(object): assert_array_equal(actual, desired) def test_laplace(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.laplace(loc=.123456789, scale=2.0, size=(3, 2)) desired = np.array([[0.66599721112760157, 0.52829452552221945], [3.12791959514407125, 3.18202813572992005], @@ -859,7 +860,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.laplace, scale=-0.) def test_logistic(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.logistic(loc=.123456789, scale=2.0, size=(3, 2)) desired = np.array([[1.09232835305011444, 0.8648196662399954], [4.27818590694950185, 4.33897006346929714], @@ -867,7 +868,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_lognormal(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.lognormal(mean=.123456789, sigma=2.0, size=(3, 2)) desired = np.array([[1.0894838661036e-03, 9.0990021488311e-01], [6.9178869932225e-01, 2.7672077560016e-01], @@ -879,7 +880,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.lognormal, sigma=-0.) def test_logseries(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.logseries(p=.923456789, size=(3, 2)) desired = np.array([[2, 2], [6, 17], @@ -893,7 +894,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.logseries, [np.nan] * 10) def test_multinomial(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.multinomial(20, [1 / 6.] * 6, size=(3, 2)) desired = np.array([[[4, 3, 5, 4, 2, 2], [5, 2, 8, 2, 2, 1]], @@ -904,7 +905,7 @@ class TestRandomDist(object): assert_array_equal(actual, desired) def test_multivariate_normal(self): - random.seed(self.seed) + random.brng.seed(self.seed) mean = (.123456789, 10) cov = [[1, 0], [0, 1]] size = (3, 2) @@ -955,7 +956,7 @@ class TestRandomDist(object): mu, np.eye(3)) def test_negative_binomial(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.negative_binomial(n=100, p=.12345, size=(3, 2)) desired = np.array([[521, 736], [665, 690], @@ -970,7 +971,7 @@ class TestRandomDist(object): [np.nan] * 10) def test_noncentral_chisquare(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.noncentral_chisquare(df=5, nonc=5, size=(3, 2)) desired = np.array([[9.47783251920357, 10.02066178260461], [3.15869984192364, 10.5581565031544], @@ -983,7 +984,7 @@ class TestRandomDist(object): [1.41985055641800, 0.15451287602753]]) assert_array_almost_equal(actual, desired, decimal=14) - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.noncentral_chisquare(df=5, nonc=0, size=(3, 2)) desired = np.array([[3.64881368071039, 5.48224544747803], [20.41999842025404, 3.44075915187367], @@ -991,7 +992,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=14) def test_noncentral_f(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.noncentral_f(dfnum=5, dfden=2, nonc=1, size=(3, 2)) desired = np.array([[1.22680230963236, 2.56457837623956], @@ -1000,12 +1001,12 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=14) def test_noncentral_f_nan(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.noncentral_f(dfnum=5, dfden=2, nonc=np.nan) assert np.isnan(actual) def test_normal(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.normal(loc=.123456789, scale=2.0, size=(3, 2)) desired = np.array([[-6.822051212221923, -0.094420339458285], [-0.368474717792823, -1.284746311523402], @@ -1017,7 +1018,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.normal, scale=-0.) def test_pareto(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.pareto(a=.123456789, size=(3, 2)) desired = np.array([[5.6883528121891552e+16, 4.0569373841667057e+03], [1.2854967019379475e+12, 6.5833156486851483e+04], @@ -1031,7 +1032,7 @@ class TestRandomDist(object): np.testing.assert_array_almost_equal_nulp(actual, desired, nulp=30) def test_poisson(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.poisson(lam=.123456789, size=(3, 2)) desired = np.array([[0, 0], [1, 0], @@ -1051,7 +1052,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.poisson, [np.nan] * 10) def test_power(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.power(a=.123456789, size=(3, 2)) desired = np.array([[9.328833342693975e-01, 2.742250409261003e-02], [7.684513237993961e-01, 9.297548209160028e-02], @@ -1059,7 +1060,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_rayleigh(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.rayleigh(scale=10, size=(3, 2)) desired = np.array([[13.8882496494248393, 13.383318339044731], [20.95413364294492098, 21.08285015800712614], @@ -1071,7 +1072,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.rayleigh, scale=-0.) def test_standard_cauchy(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.standard_cauchy(size=(3, 2)) desired = np.array([[31.87809592667601, 0.349332782046838], [2.816995747731641, 10.552372563459114], @@ -1079,7 +1080,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_standard_exponential(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.standard_exponential(size=(3, 2), method='inv') desired = np.array([[0.96441739162374596, 0.89556604882105506], [2.1953785836319808, 2.22243285392490542], @@ -1090,7 +1091,7 @@ class TestRandomDist(object): assert_raises(TypeError, random.standard_exponential, dtype=np.int32) def test_standard_gamma(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.standard_gamma(shape=3, size=(3, 2)) desired = np.array([[2.28483515569645, 3.29899524967824], [11.12492298902645, 2.16784417297277], @@ -1098,13 +1099,13 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=14) def test_standard_gammma_scalar_float(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.standard_gamma(3, dtype=np.float32) desired = 1.3877466 assert_array_almost_equal(actual, desired, decimal=6) def test_standard_gamma_float(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.standard_gamma(shape=3, size=(3, 2)) desired = np.array([[2.2848352, 3.2989952], [11.124923, 2.1678442], @@ -1113,14 +1114,14 @@ class TestRandomDist(object): def test_standard_gammma_float_out(self): actual = np.zeros((3, 2), dtype=np.float32) - random.seed(self.seed) + random.brng.seed(self.seed) random.standard_gamma(10.0, out=actual, dtype=np.float32) desired = np.array([[6.9824033, 7.3731737], [14.860578, 7.5327270], [11.767487, 6.2320185]], dtype=np.float32) assert_array_almost_equal(actual, desired, decimal=5) - random.seed(self.seed) + random.brng.seed(self.seed) random.standard_gamma(10.0, out=actual, size=(3, 2), dtype=np.float32) assert_array_almost_equal(actual, desired, decimal=5) @@ -1140,7 +1141,7 @@ class TestRandomDist(object): assert_raises(ValueError, random.standard_gamma, shape=-0.) def test_standard_normal(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.standard_normal(size=(3, 2)) desired = np.array([[-3.472754000610961, -0.108938564229143], [-0.245965753396411, -0.704101550261701], @@ -1151,7 +1152,7 @@ class TestRandomDist(object): assert_raises(TypeError, random.standard_normal, dtype=np.int32) def test_standard_t(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.standard_t(df=10, size=(3, 2)) desired = np.array([[-3.68722108185508, -0.672031186266171], [2.900224996448669, -0.199656996187739], @@ -1159,7 +1160,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_triangular(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.triangular(left=5.12, mode=10.23, right=20.34, size=(3, 2)) desired = np.array([[12.68117178949215784, 12.4129206149193152], @@ -1168,7 +1169,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=14) def test_uniform(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.uniform(low=1.23, high=10.54, size=(3, 2)) desired = np.array([[6.99097932346268003, 6.73801597444323974], [9.50364421400426274, 9.53130618907631089], @@ -1214,7 +1215,7 @@ class TestRandomDist(object): assert_raises(TypeError, random.hypergeometric, throwing_int, 1, 1) def test_vonmises(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.vonmises(mu=1.23, kappa=1.54, size=(3, 2)) desired = np.array([[2.28567572673902042, 2.89163838442285037], [0.38198375564286025, 2.57638023113890746], @@ -1223,17 +1224,17 @@ class TestRandomDist(object): def test_vonmises_small(self): # check infinite loop, gh-4720 - random.seed(self.seed) + random.brng.seed(self.seed) r = random.vonmises(mu=0., kappa=1.1e-8, size=10**6) assert_(np.isfinite(r).all()) def test_vonmises_nan(self): - random.seed(self.seed) + random.brng.seed(self.seed) r = random.vonmises(mu=0., kappa=np.nan) assert_(np.isnan(r)) def test_wald(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.wald(mean=1.23, scale=1.54, size=(3, 2)) desired = np.array([[0.10653278160339, 0.98771068102461], [0.89276055317879, 0.13640126419923], @@ -1241,7 +1242,7 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=14) def test_weibull(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.weibull(a=1.23, size=(3, 2)) desired = np.array([[3.557276979846361, 1.020870580998542], [2.731847777612348, 1.29148068905082], @@ -1249,12 +1250,12 @@ class TestRandomDist(object): assert_array_almost_equal(actual, desired, decimal=15) def test_weibull_0(self): - random.seed(self.seed) + random.brng.seed(self.seed) assert_equal(random.weibull(a=0, size=12), np.zeros(12)) assert_raises(ValueError, random.weibull, a=-0.) def test_zipf(self): - random.seed(self.seed) + random.brng.seed(self.seed) actual = random.zipf(a=1.23, size=(3, 2)) desired = np.array([[66, 29], [1, 1], @@ -1269,7 +1270,7 @@ class TestBroadcast(object): self.seed = 123456789 def set_seed(self): - random.seed(self.seed) + random.brng.seed(self.seed) def test_uniform(self): low = [0] diff --git a/numpy/random/randomgen/tests/test_generator_mt19937_regressions.py b/numpy/random/tests/test_generator_mt19937_regressions.py index 75064720f..f9478ccf6 100644 --- a/numpy/random/randomgen/tests/test_generator_mt19937_regressions.py +++ b/numpy/random/tests/test_generator_mt19937_regressions.py @@ -3,7 +3,7 @@ from numpy.testing import (assert_, assert_array_equal) from numpy.compat import long import numpy as np import pytest -from ...randomgen import RandomGenerator, MT19937 +from numpy.random import RandomGenerator, MT19937 mt19937 = RandomGenerator(MT19937()) @@ -36,7 +36,7 @@ class TestRegression(object): def test_logseries_convergence(self): # Test for ticket #923 N = 1000 - mt19937.seed(0) + mt19937.brng.seed(0) rvsn = mt19937.logseries(0.8, size=N) # these two frequency counts should be close to theoretical # numbers with this large sample @@ -50,9 +50,9 @@ class TestRegression(object): assert_(freq < 0.23, msg) def test_permutation_longs(self): - mt19937.seed(1234) + mt19937.brng.seed(1234) a = mt19937.permutation(12) - mt19937.seed(1234) + mt19937.brng.seed(1234) b = mt19937.permutation(long(12)) assert_array_equal(a, b) @@ -62,7 +62,7 @@ class TestRegression(object): [(1, 1), (2, 2), (3, 3), None], [1, (2, 2), (3, 3), None], [(1, 1), 2, 3, None]]: - mt19937.seed(12345) + mt19937.brng.seed(12345) shuffled = list(t) mt19937.shuffle(shuffled) assert_array_equal(shuffled, [t[0], t[3], t[1], t[2]]) @@ -72,8 +72,8 @@ class TestRegression(object): m = RandomGenerator(MT19937()) # mt19937.RandomState() res = np.array([0, 8, 7, 2, 1, 9, 4, 7, 0, 3]) for i in range(3): - mt19937.seed(i) - m.seed(4321) + mt19937.brng.seed(i) + m.brng.seed(4321) # If m.state is not honored, the result will change assert_array_equal(m.choice(10, size=10, p=np.ones(10)/10.), res) @@ -88,7 +88,7 @@ class TestRegression(object): def test_beta_small_parameters(self): # Test that beta with small a and b parameters does not produce # NaNs due to roundoff errors causing 0 / 0, gh-5851 - mt19937.seed(1234567890) + mt19937.brng.seed(1234567890) x = mt19937.beta(0.0001, 0.0001, size=100) assert_(not np.any(np.isnan(x)), 'Nans in mt19937.beta') @@ -96,7 +96,7 @@ class TestRegression(object): # The sum of probs should be 1.0 with some tolerance. # For low precision dtypes the tolerance was too tight. # See numpy github issue 6123. - mt19937.seed(1234) + mt19937.brng.seed(1234) a = [1, 2, 3] counts = [4, 4, 2] for dt in np.float16, np.float32, np.float64: @@ -110,7 +110,7 @@ class TestRegression(object): # Test that permuting an array of different length strings # will not cause a segfault on garbage collection # Tests gh-7710 - mt19937.seed(1234) + mt19937.brng.seed(1234) a = np.array(['a', 'a' * 1000]) @@ -125,7 +125,7 @@ class TestRegression(object): # Test that permuting an array of objects will not cause # a segfault on garbage collection. # See gh-7719 - mt19937.seed(1234) + mt19937.brng.seed(1234) a = np.array([np.arange(1), np.arange(4)]) for _ in range(1000): @@ -139,7 +139,7 @@ class TestRegression(object): class N(np.ndarray): pass - mt19937.seed(1) + mt19937.brng.seed(1) orig = np.arange(3).view(N) perm = mt19937.permutation(orig) assert_array_equal(perm, np.array([0, 2, 1])) @@ -151,7 +151,7 @@ class TestRegression(object): def __array__(self): return self.a - mt19937.seed(1) + mt19937.brng.seed(1) m = M() perm = mt19937.permutation(m) assert_array_equal(perm, np.array([2, 1, 4, 0, 3])) diff --git a/numpy/random/randomgen/tests/test_randomstate.py b/numpy/random/tests/test_randomstate.py index 6adde6c2a..d0ad5e794 100644 --- a/numpy/random/randomgen/tests/test_randomstate.py +++ b/numpy/random/tests/test_randomstate.py @@ -9,7 +9,7 @@ from numpy.testing import ( suppress_warnings ) -from ...randomgen import MT19937, Xoshiro256StarStar, mtrand as random +from numpy.random import MT19937, Xoshiro256StarStar, mtrand as random def assert_mt19937_state_equal(a, b): diff --git a/numpy/random/randomgen/tests/test_randomstate_regression.py b/numpy/random/tests/test_randomstate_regression.py index cf21ee756..9c319319e 100644 --- a/numpy/random/randomgen/tests/test_randomstate_regression.py +++ b/numpy/random/tests/test_randomstate_regression.py @@ -5,7 +5,7 @@ from numpy.testing import ( from numpy.compat import long import numpy as np -from ...randomgen import mtrand as random +from numpy.random import mtrand as random class TestRegression(object): diff --git a/numpy/random/randomgen/tests/test_smoke.py b/numpy/random/tests/test_smoke.py index 816ce6ddc..fa7a0b567 100644 --- a/numpy/random/randomgen/tests/test_smoke.py +++ b/numpy/random/tests/test_smoke.py @@ -8,7 +8,7 @@ import numpy as np import pytest from numpy.testing import (assert_almost_equal, assert_equal, assert_, assert_array_equal, suppress_warnings) -from ...randomgen import (RandomGenerator, MT19937, DSFMT, ThreeFry32, ThreeFry, +from numpy.random import (RandomGenerator, MT19937, DSFMT, ThreeFry32, ThreeFry, PCG32, PCG64, Philox, Xoroshiro128, Xorshift1024, Xoshiro256StarStar, Xoshiro512StarStar, entropy) @@ -106,7 +106,7 @@ class RNG(object): cls.advance = None cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -118,39 +118,39 @@ class RNG(object): cls.seed_error = TypeError def _reset_state(self): - self.rg.state = self.initial_state + self.rg.brng.state = self.initial_state def test_init(self): rg = RandomGenerator(self.brng()) - state = rg.state + state = rg.brng.state rg.standard_normal(1) rg.standard_normal(1) - rg.state = state - new_state = rg.state + rg.brng.state = state + new_state = rg.brng.state assert_(comp_state(state, new_state)) def test_advance(self): - state = self.rg.state - if hasattr(self.rg._basicrng, 'advance'): - self.rg._basicrng.advance(self.advance) - assert_(not comp_state(state, self.rg.state)) + state = self.rg.brng.state + if hasattr(self.rg.brng, 'advance'): + self.rg.brng.advance(self.advance) + assert_(not comp_state(state, self.rg.brng.state)) else: - brng_name = self.rg._basicrng.__class__.__name__ + brng_name = self.rg.brng.__class__.__name__ pytest.skip('Advance is not supported by {0}'.format(brng_name)) def test_jump(self): - state = self.rg.state - if hasattr(self.rg._basicrng, 'jump'): - self.rg._basicrng.jump() - jumped_state = self.rg.state + state = self.rg.brng.state + if hasattr(self.rg.brng, 'jump'): + self.rg.brng.jump() + jumped_state = self.rg.brng.state assert_(not comp_state(state, jumped_state)) self.rg.random_sample(2 * 3 * 5 * 7 * 11 * 13 * 17) - self.rg.state = state - self.rg._basicrng.jump() - rejumped_state = self.rg.state + self.rg.brng.state = state + self.rg.brng.jump() + rejumped_state = self.rg.brng.state assert_(comp_state(jumped_state, rejumped_state)) else: - brng_name = self.rg._basicrng.__class__.__name__ + brng_name = self.rg.brng.__class__.__name__ pytest.skip('Jump is not supported by {0}'.format(brng_name)) def test_uniform(self): @@ -221,51 +221,51 @@ class RNG(object): assert_(self.rg.binomial(1000, .5) >= 0) def test_reset_state(self): - state = self.rg.state + state = self.rg.brng.state int_1 = self.rg.randint(2**31) - self.rg.state = state + self.rg.brng.state = state int_2 = self.rg.randint(2**31) assert_(int_1 == int_2) def test_entropy_init(self): rg = RandomGenerator(self.brng()) rg2 = RandomGenerator(self.brng()) - assert_(not comp_state(rg.state, rg2.state)) + assert_(not comp_state(rg.brng.state, rg2.brng.state)) def test_seed(self): rg = RandomGenerator(self.brng(*self.seed)) rg2 = RandomGenerator(self.brng(*self.seed)) rg.random_sample() rg2.random_sample() - assert_(comp_state(rg.state, rg2.state)) + assert_(comp_state(rg.brng.state, rg2.brng.state)) def test_reset_state_gauss(self): rg = RandomGenerator(self.brng(*self.seed)) rg.standard_normal() - state = rg.state + state = rg.brng.state n1 = rg.standard_normal(size=10) rg2 = RandomGenerator(self.brng()) - rg2.state = state + rg2.brng.state = state n2 = rg2.standard_normal(size=10) assert_array_equal(n1, n2) def test_reset_state_uint32(self): rg = RandomGenerator(self.brng(*self.seed)) rg.randint(0, 2 ** 24, 120, dtype=np.uint32) - state = rg.state + state = rg.brng.state n1 = rg.randint(0, 2 ** 24, 10, dtype=np.uint32) rg2 = RandomGenerator(self.brng()) - rg2.state = state + rg2.brng.state = state n2 = rg2.randint(0, 2 ** 24, 10, dtype=np.uint32) assert_array_equal(n1, n2) def test_reset_state_float(self): rg = RandomGenerator(self.brng(*self.seed)) rg.random_sample(dtype='float32') - state = rg.state + state = rg.brng.state n1 = rg.random_sample(size=10, dtype='float32') rg2 = RandomGenerator(self.brng()) - rg2.state = state + rg2.brng.state = state n2 = rg2.random_sample(size=10, dtype='float32') assert_((n1 == n2).all()) @@ -354,29 +354,29 @@ class RNG(object): assert_(len(vals) == 10) def test_rand(self): - state = self.rg.state + state = self.rg.brng.state vals = self.rg.rand(10, 10, 10) - self.rg.state = state + self.rg.brng.state = state assert_((vals == self.rg.random_sample((10, 10, 10))).all()) assert_(vals.shape == (10, 10, 10)) vals = self.rg.rand(10, 10, 10, dtype=np.float32) assert_(vals.shape == (10, 10, 10)) def test_randn(self): - state = self.rg.state + state = self.rg.brng.state vals = self.rg.randn(10, 10, 10) - self.rg.state = state + self.rg.brng.state = state assert_equal(vals, self.rg.standard_normal((10, 10, 10))) assert_equal(vals.shape, (10, 10, 10)) - state = self.rg.state + state = self.rg.brng.state vals = self.rg.randn(10, 10, 10) - self.rg.state = state + self.rg.brng.state = state assert_equal(vals, self.rg.standard_normal((10, 10, 10))) - state = self.rg.state + state = self.rg.brng.state self.rg.randn(10, 10, 10) - self.rg.state = state + self.rg.brng.state = state vals = self.rg.randn(10, 10, 10, dtype=np.float32) assert_(vals.shape == (10, 10, 10)) @@ -487,12 +487,12 @@ class RNG(object): pick = pickle.dumps(self.rg) unpick = pickle.loads(pick) assert_((type(self.rg) == type(unpick))) - assert_(comp_state(self.rg.state, unpick.state)) + assert_(comp_state(self.rg.brng.state, unpick.brng.state)) pick = pickle.dumps(self.rg) unpick = pickle.loads(pick) assert_((type(self.rg) == type(unpick))) - assert_(comp_state(self.rg.state, unpick.state)) + assert_(comp_state(self.rg.brng.state, unpick.brng.state)) def test_seed_array(self): if self.seed_vector_bits is None: @@ -505,32 +505,32 @@ class RNG(object): else: dtype = np.uint64 seed = np.array([1], dtype=dtype) - self.rg.seed(seed) - state1 = self.rg.state - self.rg.seed(1) - state2 = self.rg.state + self.rg.brng.seed(seed) + state1 = self.rg.brng.state + self.rg.brng.seed(1) + state2 = self.rg.brng.state assert_(comp_state(state1, state2)) seed = np.arange(4, dtype=dtype) - self.rg.seed(seed) - state1 = self.rg.state - self.rg.seed(seed[0]) - state2 = self.rg.state + self.rg.brng.seed(seed) + state1 = self.rg.brng.state + self.rg.brng.seed(seed[0]) + state2 = self.rg.brng.state assert_(not comp_state(state1, state2)) seed = np.arange(1500, dtype=dtype) - self.rg.seed(seed) - state1 = self.rg.state - self.rg.seed(seed[0]) - state2 = self.rg.state + self.rg.brng.seed(seed) + state1 = self.rg.brng.state + self.rg.brng.seed(seed[0]) + state2 = self.rg.brng.state assert_(not comp_state(state1, state2)) seed = 2 ** np.mod(np.arange(1500, dtype=dtype), self.seed_vector_bits - 1) + 1 - self.rg.seed(seed) - state1 = self.rg.state - self.rg.seed(seed[0]) - state2 = self.rg.state + self.rg.brng.seed(seed) + state1 = self.rg.brng.state + self.rg.brng.seed(seed[0]) + state2 = self.rg.brng.state assert_(not comp_state(state1, state2)) def test_seed_array_error(self): @@ -541,164 +541,164 @@ class RNG(object): seed = -1 with pytest.raises(ValueError): - self.rg.seed(seed) + self.rg.brng.seed(seed) seed = np.array([-1], dtype=np.int32) with pytest.raises(ValueError): - self.rg.seed(seed) + self.rg.brng.seed(seed) seed = np.array([1, 2, 3, -5], dtype=np.int32) with pytest.raises(ValueError): - self.rg.seed(seed) + self.rg.brng.seed(seed) seed = np.array([1, 2, 3, out_of_bounds]) with pytest.raises(ValueError): - self.rg.seed(seed) + self.rg.brng.seed(seed) def test_uniform_float(self): rg = RandomGenerator(self.brng(12345)) warmup(rg) - state = rg.state + state = rg.brng.state r1 = rg.random_sample(11, dtype=np.float32) rg2 = RandomGenerator(self.brng()) warmup(rg2) - rg2.state = state + rg2.brng.state = state r2 = rg2.random_sample(11, dtype=np.float32) assert_array_equal(r1, r2) assert_equal(r1.dtype, np.float32) - assert_(comp_state(rg.state, rg2.state)) + assert_(comp_state(rg.brng.state, rg2.brng.state)) def test_gamma_floats(self): rg = RandomGenerator(self.brng()) warmup(rg) - state = rg.state + state = rg.brng.state r1 = rg.standard_gamma(4.0, 11, dtype=np.float32) rg2 = RandomGenerator(self.brng()) warmup(rg2) - rg2.state = state + rg2.brng.state = state r2 = rg2.standard_gamma(4.0, 11, dtype=np.float32) assert_array_equal(r1, r2) assert_equal(r1.dtype, np.float32) - assert_(comp_state(rg.state, rg2.state)) + assert_(comp_state(rg.brng.state, rg2.brng.state)) def test_normal_floats(self): rg = RandomGenerator(self.brng()) warmup(rg) - state = rg.state + state = rg.brng.state r1 = rg.standard_normal(11, dtype=np.float32) rg2 = RandomGenerator(self.brng()) warmup(rg2) - rg2.state = state + rg2.brng.state = state r2 = rg2.standard_normal(11, dtype=np.float32) assert_array_equal(r1, r2) assert_equal(r1.dtype, np.float32) - assert_(comp_state(rg.state, rg2.state)) + assert_(comp_state(rg.brng.state, rg2.brng.state)) def test_normal_zig_floats(self): rg = RandomGenerator(self.brng()) warmup(rg) - state = rg.state + state = rg.brng.state r1 = rg.standard_normal(11, dtype=np.float32) rg2 = RandomGenerator(self.brng()) warmup(rg2) - rg2.state = state + rg2.brng.state = state r2 = rg2.standard_normal(11, dtype=np.float32) assert_array_equal(r1, r2) assert_equal(r1.dtype, np.float32) - assert_(comp_state(rg.state, rg2.state)) + assert_(comp_state(rg.brng.state, rg2.brng.state)) def test_output_fill(self): rg = self.rg - state = rg.state + state = rg.brng.state size = (31, 7, 97) existing = np.empty(size) - rg.state = state + rg.brng.state = state rg.standard_normal(out=existing) - rg.state = state + rg.brng.state = state direct = rg.standard_normal(size=size) assert_equal(direct, existing) sized = np.empty(size) - rg.state = state + rg.brng.state = state rg.standard_normal(out=sized, size=sized.shape) existing = np.empty(size, dtype=np.float32) - rg.state = state + rg.brng.state = state rg.standard_normal(out=existing, dtype=np.float32) - rg.state = state + rg.brng.state = state direct = rg.standard_normal(size=size, dtype=np.float32) assert_equal(direct, existing) def test_output_filling_uniform(self): rg = self.rg - state = rg.state + state = rg.brng.state size = (31, 7, 97) existing = np.empty(size) - rg.state = state + rg.brng.state = state rg.random_sample(out=existing) - rg.state = state + rg.brng.state = state direct = rg.random_sample(size=size) assert_equal(direct, existing) existing = np.empty(size, dtype=np.float32) - rg.state = state + rg.brng.state = state rg.random_sample(out=existing, dtype=np.float32) - rg.state = state + rg.brng.state = state direct = rg.random_sample(size=size, dtype=np.float32) assert_equal(direct, existing) def test_output_filling_exponential(self): rg = self.rg - state = rg.state + state = rg.brng.state size = (31, 7, 97) existing = np.empty(size) - rg.state = state + rg.brng.state = state rg.standard_exponential(out=existing) - rg.state = state + rg.brng.state = state direct = rg.standard_exponential(size=size) assert_equal(direct, existing) existing = np.empty(size, dtype=np.float32) - rg.state = state + rg.brng.state = state rg.standard_exponential(out=existing, dtype=np.float32) - rg.state = state + rg.brng.state = state direct = rg.standard_exponential(size=size, dtype=np.float32) assert_equal(direct, existing) def test_output_filling_gamma(self): rg = self.rg - state = rg.state + state = rg.brng.state size = (31, 7, 97) existing = np.zeros(size) - rg.state = state + rg.brng.state = state rg.standard_gamma(1.0, out=existing) - rg.state = state + rg.brng.state = state direct = rg.standard_gamma(1.0, size=size) assert_equal(direct, existing) existing = np.zeros(size, dtype=np.float32) - rg.state = state + rg.brng.state = state rg.standard_gamma(1.0, out=existing, dtype=np.float32) - rg.state = state + rg.brng.state = state direct = rg.standard_gamma(1.0, size=size, dtype=np.float32) assert_equal(direct, existing) def test_output_filling_gamma_broadcast(self): rg = self.rg - state = rg.state + state = rg.brng.state size = (31, 7, 97) mu = np.arange(97.0) + 1.0 existing = np.zeros(size) - rg.state = state + rg.brng.state = state rg.standard_gamma(mu, out=existing) - rg.state = state + rg.brng.state = state direct = rg.standard_gamma(mu, size=size) assert_equal(direct, existing) existing = np.zeros(size, dtype=np.float32) - rg.state = state + rg.brng.state = state rg.standard_gamma(mu, out=existing, dtype=np.float32) - rg.state = state + rg.brng.state = state direct = rg.standard_gamma(mu, size=size, dtype=np.float32) assert_equal(direct, existing) @@ -796,7 +796,7 @@ class TestMT19937(RNG): cls.advance = None cls.seed = [2 ** 21 + 2 ** 16 + 2 ** 5 + 1] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 32 cls._extra_setup() cls.seed_error = ValueError @@ -805,8 +805,8 @@ class TestMT19937(RNG): nprg = np.random.RandomState() nprg.standard_normal(99) state = nprg.get_state() - self.rg.state = state - state2 = self.rg.state + self.rg.brng.state = state + state2 = self.rg.brng.state assert_((state[1] == state2['state']['key']).all()) assert_((state[2] == state2['state']['pos'])) @@ -819,7 +819,7 @@ class TestPCG64(RNG): cls.seed = [2 ** 96 + 2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = None cls._extra_setup() @@ -832,20 +832,20 @@ class TestPCG64(RNG): seed = -1 with pytest.raises(ValueError): - self.rg.seed(seed) + self.rg.brng.seed(seed) error_type = ValueError if self.seed_vector_bits else TypeError seed = np.array([-1], dtype=np.int32) with pytest.raises(error_type): - self.rg.seed(seed) + self.rg.brng.seed(seed) seed = np.array([1, 2, 3, -5], dtype=np.int32) with pytest.raises(error_type): - self.rg.seed(seed) + self.rg.brng.seed(seed) seed = np.array([1, 2, 3, out_of_bounds]) with pytest.raises(error_type): - self.rg.seed(seed) + self.rg.brng.seed(seed) class TestPhilox(RNG): @@ -855,7 +855,7 @@ class TestPhilox(RNG): cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -867,7 +867,7 @@ class TestThreeFry(RNG): cls.advance = 2 ** 63 + 2 ** 31 + 2 ** 15 + 1 cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -879,7 +879,7 @@ class TestXoroshiro128(RNG): cls.advance = None cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -891,7 +891,7 @@ class TestXoshiro256StarStar(RNG): cls.advance = None cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -903,7 +903,7 @@ class TestXoshiro512StarStar(RNG): cls.advance = None cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -915,7 +915,7 @@ class TestXorshift1024(RNG): cls.advance = None cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() @@ -927,7 +927,7 @@ class TestDSFMT(RNG): cls.advance = None cls.seed = [12345] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls._extra_setup() cls.seed_vector_bits = 32 @@ -939,7 +939,7 @@ class TestThreeFry32(RNG): cls.advance = 2**63 + 2**31 + 2**15 + 1 cls.seed = [2 ** 21 + 2 ** 16 + 2 ** 5 + 1] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = 64 cls._extra_setup() cls.seed_error = ValueError @@ -972,6 +972,6 @@ class TestPCG32(TestPCG64): cls.seed = [2 ** 48 + 2 ** 21 + 2 ** 16 + 2 ** 5 + 1, 2 ** 21 + 2 ** 16 + 2 ** 5 + 1] cls.rg = RandomGenerator(cls.brng(*cls.seed)) - cls.initial_state = cls.rg.state + cls.initial_state = cls.rg.brng.state cls.seed_vector_bits = None cls._extra_setup() diff --git a/numpy/random/randomgen/threefry.pyx b/numpy/random/threefry.pyx index 8140c6a9b..8140c6a9b 100644 --- a/numpy/random/randomgen/threefry.pyx +++ b/numpy/random/threefry.pyx diff --git a/numpy/random/randomgen/threefry32.pyx b/numpy/random/threefry32.pyx index 1fa98eabd..1fa98eabd 100644 --- a/numpy/random/randomgen/threefry32.pyx +++ b/numpy/random/threefry32.pyx diff --git a/numpy/random/randomgen/xoroshiro128.pyx b/numpy/random/xoroshiro128.pyx index 7795500e8..7795500e8 100644 --- a/numpy/random/randomgen/xoroshiro128.pyx +++ b/numpy/random/xoroshiro128.pyx diff --git a/numpy/random/randomgen/xorshift1024.pyx b/numpy/random/xorshift1024.pyx index 3c7ffac52..3c7ffac52 100644 --- a/numpy/random/randomgen/xorshift1024.pyx +++ b/numpy/random/xorshift1024.pyx diff --git a/numpy/random/randomgen/xoshiro256starstar.pyx b/numpy/random/xoshiro256starstar.pyx index c3856b6f7..c3856b6f7 100644 --- a/numpy/random/randomgen/xoshiro256starstar.pyx +++ b/numpy/random/xoshiro256starstar.pyx diff --git a/numpy/random/randomgen/xoshiro512starstar.pyx b/numpy/random/xoshiro512starstar.pyx index 761d1f1d0..761d1f1d0 100644 --- a/numpy/random/randomgen/xoshiro512starstar.pyx +++ b/numpy/random/xoshiro512starstar.pyx @@ -225,10 +225,10 @@ class sdist_checked(sdist): def generate_cython(): cwd = os.path.abspath(os.path.dirname(__file__)) print("Cythonizing sources") - for d in ('mtrand', 'randomgen', 'randomgen/legacy'): + for d in ('random/_mtrand', 'random'): p = subprocess.call([sys.executable, os.path.join(cwd, 'tools', 'cythonize.py'), - 'numpy/random/{0}'.format(d)], + 'numpy/{0}'.format(d)], cwd=cwd) if p != 0: raise RuntimeError("Running cythonize failed!") |
