Skip to content

Commit

Permalink
Merge 11320c2 into 7779c6e
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed Apr 1, 2019
2 parents 7779c6e + 11320c2 commit 1a0c4e3
Show file tree
Hide file tree
Showing 49 changed files with 637 additions and 3,294 deletions.
1 change: 0 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ include = */randomgen/*
omit =
*/_version.py
*.pxd
*/_legacy.pyx
plugins = Cython.Coverage

[report]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ are Python 3, with an initial minimum version of 3.5.
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
compatibility, a legacy generator, ``RandomState``, has been created
which can fully reproduce the sequence produced by NumPy.

## Features
Expand Down Expand Up @@ -155,8 +155,8 @@ The RNGs include:

## Version

The version matched the latest version of NumPy where
`LegacyGenerator(MT19937())` passes all NumPy test.
The package version matches the latest version of NumPy where
`RandomState(MT19937())` passes all NumPy test.

## Documentation

Expand Down
9 changes: 4 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ Compatibility Warning
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.
require backward compatibility, a legacy generator, ``RandomState``, has
been created which can fully reproduce the sequence produced by NumPy.

Features
--------
Expand Down Expand Up @@ -173,8 +172,8 @@ Status
Version
-------

The version matched the latest version of NumPy where
``LegacyGenerator(MT19937())`` passes all NumPy test.
The package version matches the latest version of NumPy where
``RandomState(MT19937())`` passes all NumPy test.

Documentation
-------------
Expand Down
6 changes: 6 additions & 0 deletions doc/source/brng/dsfmt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@ Extending
~DSFMT.cffi
~DSFMT.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~DSFMT.random_raw

5 changes: 5 additions & 0 deletions doc/source/brng/mt19937.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ Extending
~MT19937.cffi
~MT19937.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~MT19937.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/pcg32.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ Extending
~PCG32.cffi
~PCG32.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~PCG32.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/pcg64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ Extending
~PCG64.cffi
~PCG64.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~PCG64.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/philox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ Extending
~Philox.cffi
~Philox.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~Philox.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/threefry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ Extending
~ThreeFry.cffi
~ThreeFry.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~ThreeFry.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/threefry32.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ Extending
~ThreeFry32.cffi
~ThreeFry32.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~ThreeFry32.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/xoroshiro128.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ Extending
~Xoroshiro128.cffi
~Xoroshiro128.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~Xoroshiro128.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/xorshift1024.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ Extending
~Xorshift1024.cffi
~Xorshift1024.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~Xorshift1024.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/xoshiro256starstar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ Extending
~Xoshiro256StarStar.cffi
~Xoshiro256StarStar.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~Xoshiro256StarStar.random_raw
5 changes: 5 additions & 0 deletions doc/source/brng/xoshiro512starstar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ Extending
~Xoshiro512StarStar.cffi
~Xoshiro512StarStar.ctypes

Testing
=======
.. autosummary::
:toctree: generated/

~Xoshiro512StarStar.random_raw
9 changes: 9 additions & 0 deletions doc/source/change-log.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
Change Log
----------

Since v1.16.1
=============
- Added :class:`~randomgen.mtrand.RandomState` as a clone of NumPy's
RandomState.
- Removed :class:`~randomgen.legacy.LegacyGenerator` since this is no
longer needed
- Fixed many small bugs, including in cffi and ctype interfaces

v1.16.1
=======
- Synchronized with upstream changes.
Expand Down
2 changes: 0 additions & 2 deletions doc/source/generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ Simple random data
~RandomGenerator.random_sample
~RandomGenerator.choice
~RandomGenerator.bytes
~RandomGenerator.random_uintegers
~RandomGenerator.random_raw

Permutations
============
Expand Down
2 changes: 1 addition & 1 deletion doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ What's New or Different
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
legacy generator, :class:`~randomgen.mtrand.RandomState`, has been created
which can fully reproduce the sequence produced by NumPy.

* The normal, exponential and gamma generators use 256-step Ziggurat
Expand Down
116 changes: 57 additions & 59 deletions doc/source/legacy.rst
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
Legacy Random Generation
------------------------
The :class:`~randomgen.legacy.LegacyGenerator` provides access to
legacy generators. These all depend on Box-Muller normals or
inverse CDF exponentials or gammas. This class should only be used
if it is essential to have randoms that are identical to what
would have been produced by NumPy.
The :class:`~randomgen.mtrand.RandomState` provides access to
legacy generators. These all depend on normals produced using a
polar transformation or inverse CDF exponentials or gammas. This
class should only be used if it is essential to have randoms that
are identical to what would have been produced by NumPy.

:class:`~randomgen.legacy.LegacyGenerator` add additional information
:class:`~randomgen.mtrand.RandomState` add additional information
to the state which is required when using Box-Muller normals since these
are produced in pairs. It is important to use
:attr:`~randomgen.legacy.LegacyGenerator.state`
:attr:`~randomgen.mtrand.RandomState.get_state()`
when accessing the state so that these extra values are saved.

.. code-block:: python
from randomgen import MT19937
from randomgen.legacy import LegacyGenerator
from randomgen.mtrand import RandomState
from numpy.random import RandomState
# Use same seed
rs = RandomState(12345)
mt19937 = MT19937(12345)
lg = LegacyGenerator(mt19937)
lg = RandomState(mt19937)
# Identical output
rs.standard_normal()
Expand All @@ -33,80 +33,78 @@ when accessing the state so that these extra values are saved.
lg.standard_exponential()
.. currentmodule:: randomgen.legacy.legacy
.. currentmodule:: randomgen.mtrand

.. autoclass::
LegacyGenerator
RandomState

Seeding and State
=================

.. autosummary::
:toctree: generated/

~LegacyGenerator.state
~RandomState.get_state
~RandomState.set_state

Simple random data
==================
.. autosummary::
:toctree: generated/

~LegacyGenerator.rand
~LegacyGenerator.randn
~LegacyGenerator.randint
~LegacyGenerator.random_integers
~LegacyGenerator.random_sample
~LegacyGenerator.choice
~LegacyGenerator.bytes
~LegacyGenerator.random_uintegers
~LegacyGenerator.random_raw
~RandomState.rand
~RandomState.randn
~RandomState.randint
~RandomState.random_integers
~RandomState.random_sample
~RandomState.choice
~RandomState.bytes

Permutations
============
.. autosummary::
:toctree: generated/

~LegacyGenerator.shuffle
~LegacyGenerator.permutation
~RandomState.shuffle
~RandomState.permutation

Distributions
=============
.. autosummary::
:toctree: generated/

~LegacyGenerator.beta
~LegacyGenerator.binomial
~LegacyGenerator.chisquare
~LegacyGenerator.complex_normal
~LegacyGenerator.dirichlet
~LegacyGenerator.exponential
~LegacyGenerator.f
~LegacyGenerator.gamma
~LegacyGenerator.geometric
~LegacyGenerator.gumbel
~LegacyGenerator.hypergeometric
~LegacyGenerator.laplace
~LegacyGenerator.logistic
~LegacyGenerator.lognormal
~LegacyGenerator.logseries
~LegacyGenerator.multinomial
~LegacyGenerator.multivariate_normal
~LegacyGenerator.negative_binomial
~LegacyGenerator.noncentral_chisquare
~LegacyGenerator.noncentral_f
~LegacyGenerator.normal
~LegacyGenerator.pareto
~LegacyGenerator.poisson
~LegacyGenerator.power
~LegacyGenerator.rayleigh
~LegacyGenerator.standard_cauchy
~LegacyGenerator.standard_exponential
~LegacyGenerator.standard_gamma
~LegacyGenerator.standard_normal
~LegacyGenerator.standard_t
~LegacyGenerator.triangular
~LegacyGenerator.uniform
~LegacyGenerator.vonmises
~LegacyGenerator.wald
~LegacyGenerator.weibull
~LegacyGenerator.zipf
~RandomState.beta
~RandomState.binomial
~RandomState.chisquare
~RandomState.dirichlet
~RandomState.exponential
~RandomState.f
~RandomState.gamma
~RandomState.geometric
~RandomState.gumbel
~RandomState.hypergeometric
~RandomState.laplace
~RandomState.logistic
~RandomState.lognormal
~RandomState.logseries
~RandomState.multinomial
~RandomState.multivariate_normal
~RandomState.negative_binomial
~RandomState.noncentral_chisquare
~RandomState.noncentral_f
~RandomState.normal
~RandomState.pareto
~RandomState.poisson
~RandomState.power
~RandomState.rayleigh
~RandomState.standard_cauchy
~RandomState.standard_exponential
~RandomState.standard_gamma
~RandomState.standard_normal
~RandomState.standard_t
~RandomState.triangular
~RandomState.uniform
~RandomState.vonmises
~RandomState.wald
~RandomState.weibull
~RandomState.zipf
2 changes: 1 addition & 1 deletion doc/source/new-or-different.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ What's New or Different
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
legacy generator, :class:`~randomgen.mtrand.RandomState`, has been created
which can fully reproduce the sequence produced by NumPy.


Expand Down
5 changes: 2 additions & 3 deletions randomgen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
from randomgen.xorshift1024 import Xorshift1024
from randomgen.xoshiro256starstar import Xoshiro256StarStar
from randomgen.xoshiro512starstar import Xoshiro512StarStar

from randomgen.mtrand import RandomState
__all__ = ['RandomGenerator', 'DSFMT', 'MT19937', 'PCG64', 'PCG32', 'Philox',
'ThreeFry', 'ThreeFry32', 'Xoroshiro128', 'Xorshift1024',
'Xoshiro256StarStar', 'Xoshiro512StarStar',
'hypergeometric', 'multinomial', 'random_sample']
'Xoshiro256StarStar', 'Xoshiro512StarStar', 'RandomState']

from ._version import get_versions

Expand Down
2 changes: 1 addition & 1 deletion randomgen/bounded_integers.pxd.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from __future__ import absolute_import
from libc.stdint cimport (uint8_t, uint16_t, uint32_t, uint64_t,
int8_t, int16_t, int32_t, int64_t, intptr_t)
import numpy as np
cimport numpy as np
cimport numpy as np
ctypedef np.npy_bool bool_t

from randomgen.common cimport brng_t
Expand Down

0 comments on commit 1a0c4e3

Please sign in to comment.