Skip to content

Commit

Permalink
Merge pull request #317 from bashtage/remove-generator
Browse files Browse the repository at this point in the history
Remove generator
  • Loading branch information
bashtage authored Jul 18, 2022
2 parents 2d25646 + be92b9b commit 2aa1ddb
Show file tree
Hide file tree
Showing 80 changed files with 896 additions and 16,863 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
recursive-exclude randomgen *.c
include randomgen/py.typed
include randomgen/_version.py
include requirements.txt
include README.md
Expand Down
30 changes: 11 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,13 @@ or the [stable documentation](https://bashtage.github.io/randomgen/devel/change-

# WARNINGS

## Changes in v1.19
## Changes in v1.24

``Generator`` and ``RandomState`` have been officially deprecated, and will
``Generator`` and ``RandomState`` have been **removed**.

## Changes from 1.18 to 1.19

``Generator`` and ``RandomState`` have been officially deprecated in 1.19, and will
warn with a ``FutureWarning`` about their removal. They will also receive virtually
no maintenance. It is now time to move to NumPy's ``np.random.Generator`` which has
features not in ``randomstate.Generator`` and is maintained more actively.
Expand All @@ -54,8 +58,7 @@ to ``randomstate.ExtendedGenerator``:
There are no plans to remove any of the bit generators, e.g., ``AESCounter``,
``ThreeFry``, or ``PCG64``.

## Changes in v1.18

### Changes from 1.16 to 1.18
There are many changes between v1.16.x and v1.18.x. These reflect API
decision taken in conjunction with NumPy in preparation of the core
of `randomgen` being used as the preferred random number generator in
Expand All @@ -66,16 +69,6 @@ bit generators (or `BigGenerator`s).

## Future Plans

A substantial portion of randomgen has been merged into NumPy. Revamping NumPy's random
number generation was always the goal of this project (and its predecessor
[NextGen NumPy RandomState](https://github.com/bashtage/ng-numpy-randomstate>)),
and so it has succeeded.

While I have no immediate plans to remove anything, after a 1.19 release I will:

* Remove `Generator` and `RandomState`. These duplicate NumPy and will diverge over time.
The versions in NumPy are authoritative. **Deprecated**
* Preserve novel methods of `Generator` in a new class, `ExtendedGenerator`. **Done**
* Add some distributions that are not supported in NumPy. _Ongoing_
* Add any interesting bit generators I come across. _Recent additions include the DXSM and CM-DXSM variants of PCG64 and the LXM generator._

Expand All @@ -102,7 +95,6 @@ The RNGs include:
* Chaotic PRNGS: Small-Fast Chaotic (`SFC64`) and Jenkin's Small-Fast (`JSF`).



## Status

* Builds and passes all tests on:
Expand All @@ -114,8 +106,8 @@ The RNGs include:

## Version

The package version matches the latest version of NumPy where
`Generator(MT19937())` passes all NumPy test.
The package version matches the latest version of NumPy when the package
is released.

## Documentation

Expand All @@ -128,8 +120,8 @@ the latest commit (unreleased) is available under
## Requirements
Building requires:

* Python (3.6, 3.7, 3.8, 3.9)
* NumPy (1.14, 1.15, 1.16, 1.17, 1.18, 1.19)
* Python (3.6, 3.7, 3.8, 3.9, 3.10)
* NumPy (1.17+)
* Cython (0.29+)
* tempita (0.5+), if not provided by Cython

Expand Down
4 changes: 0 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,3 @@ build_script:

test_script:
- pytest randomgen

on_success:
- cd %GIT_DIR%\
- python benchmark.py
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
- template: ci/azure/azure_template_posix.yml
parameters:
name: macOS
vmImage: macOS-10.15
vmImage: macOS-latest

- template: ci/azure/azure_template_posix.yml
parameters:
name: Linux
vmImage: ubuntu-20.04
vmImage: ubuntu-latest

- template: ci/azure/azure_template_windows.yml
parameters:
name: Windows
vmImage: windows-2019
vmImage: windows-latest
3 changes: 2 additions & 1 deletion benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
rg = numpy.random.RandomState()
rg.random_sample()
else:
from randomgen import Generator, {bitgen}
from randomgen import {bitgen}
from numpy.random import Generator
rg = Generator({bitgen}())
rg.random()
"""
Expand Down
2 changes: 1 addition & 1 deletion ci/azure/azure_template_posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
python38_legacy:
python.version: '3.8'
coverage: true
NUMPY: 1.16.6
NUMPY: 1.17.0
python39_latest:
python.version: '3.9'
python310_latest:
Expand Down
6 changes: 3 additions & 3 deletions ci/azure/install-posix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ else
fi

# Not all available in conda
python -m pip install setuptools "setuptools_scm[toml]<7" "oldest-supported-numpy" wheel pip black==22.3.0 isort flake8 --upgrade
python -m pip install setuptools "setuptools_scm[toml]<7" "oldest-supported-numpy" wheel pip black==22.6.0 isort flake8 --upgrade

EXTRA="pytest pytest-xdist coverage pytest-cov"

if [[ -n ${NUMPY} ]]; then CMD="$CMD==${NUMPY}"; fi;
if [[ -n ${NUMPY} ]]; then CMD="$CMD~=${NUMPY}"; fi;
CMD="$CMD cython"
if [[ -n ${CYTHON} ]]; then CMD="$CMD==${CYTHON}"; fi;
if [[ -n ${CYTHON} ]]; then CMD="$CMD~=${CYTHON}"; fi;
CMD="$CMD pandas"
CMD="$CMD $EXTRA"
if [[ ${USE_CONDA} == "true" ]]; then CMD="$CMD numba"; fi;
Expand Down
2 changes: 1 addition & 1 deletion doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numba>=0.49
nbsphinx
sphinx-material
sphinx>=3
sphinx>=5
ipython>=6
numpydoc
pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability
2 changes: 1 addition & 1 deletion doc/source/bit_generators/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Bit Generators
--------------

The random values produced by :class:`numpy.random.Generator`
(and also :class:`~randomgen.generator.Generator`)
(and also ``Generator``)
are produced by a bit generator. These bit generators do not directly provide
random numbers and only contain methods used for seeding, getting or
setting the state, jumping or advancing the state, and for accessing
Expand Down
81 changes: 35 additions & 46 deletions doc/source/change-log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ Change Log

<p class="admonition-title"> Deprecated </p>

:class:`~randomgen.generator.Generator` and :class:`~randomgen.mtrand.RandomState`
are **DEPRECATED**. You should be using :class:`numpy.random.Generator` or
:class:`numpy.random.RandomState` which are better maintained. These will be
maintained until after NumPy 1.21 (or 2 releases after NumPy 1.19) for users who
cannot update NumPy.
``Generator`` and ``RandomState`` have been **REMOVED** in 1.23.
You should be using :class:`numpy.random.Generator` or
:class:`numpy.random.RandomState` which are maintained.

v1.23.0
=======
- Removed ``Generator`` and ``RandomState``.

v1.20.2
=======
Expand Down Expand Up @@ -44,7 +46,7 @@ v1.20.2

v1.20.1
=======
- Fixed a bug that affects :func:`~randomgen.generator.Generator.standard_gamma` when
- Fixed a bug that affects ``standard_gamma`` when
used with ``out`` and a Fortran contiguous array.
- Added :func:`~randomgen.generator.ExtendedGenerator.multivariate_complex_normal`.
- Added :func:`~randomgen.generator.ExtendedGenerator.standard_wishart` and
Expand Down Expand Up @@ -105,20 +107,20 @@ v1.19.0
- Added support for broadcasting inputs in :class:`randomgen.generator.ExtendedGenerator.multivariate_normal`.
- Added support for the `++` variant of :class:`randomgen.xoroshiro128.Xoroshiro128`.
- Fixed a bug the produced incorrect results in :func:`~randomgen.mt19937.MT19937.jumped`.
- Fixed multiple bugs in :class:`~randomgen.generator.Generator` that were fixed in :class:`numpy.random.Generator`.
- Fixed multiple bugs in ``Generator`` that were fixed in :class:`numpy.random.Generator`.

v1.18.0
=======
- :meth:`~randomgen.generator.Generator.choice` pulled in upstream performance improvement that
- ``choice`` pulled in upstream performance improvement that
use a hash set when choosing without replacement and without user-provided probabilities.
- Added support for :class:`~randomgen.seed_sequence.SeedSequence` (and NumPy's ``SeedSequence``).
- Fixed a bug that affected both :class:`~randomgen.generator.Generator.randint`
in :class:`~randomgen.generator.Generator` and :meth:`~randomgen.mtrand.RandomState.randint`
in :class:`~randomgen.mtrand.RandomState` when ``high=2**32``. This value is inbounds for
in ``Generator`` and ``randint``
in ``RandomState`` when ``high=2**32``. This value is inbounds for
a 32-bit unsigned closed interval generator, and so should have been redirected to
a 32-bit generator. It was erroneously sent to the 64-bit path. The random values produced
are fully random but inefficient. This fix breaks the stream in :class:`~randomgen.generator.Generator
is the value for ``high`` is used. The fix restores :class:`~randomgen.mtrand.RandomState` to
is the value for ``high`` is used. The fix restores ``RandomState`` to
NumPy 1.16 compatibility.
only affects the output if ``dtype`` is ``'int64'``
- This release brings many breaking changes. Most of these have been
Expand All @@ -127,20 +129,16 @@ v1.18.0
going into NumPy.
- Two changes that are more abrupt are:

* The ``.generator`` method of the bit generators raise
``NotImplementedError``
* The ``.generator`` method of the bit generators raise ``NotImplementedError``
* The internal structures that is used in C have been renamed.
The main rename is ``brng_t`` to ``bitgen_t``

- The other key changes are:

* Rename ``RandomGenerator`` to :class:`~randomgen.generator.Generator`.
* Rename :meth:`~randomgen.generator.Generator.randint` to
:meth:`~randomgen.generator.Generator.integers`.
* Rename :meth:`~randomgen.generator.Generator.random_integers` to
:meth:`~randomgen.generator.Generator.integers`.
* Rename :meth:`~randomgen.generator.Generator.random_sample`
to :meth:`~randomgen.generator.Generator.random`.
* Rename ``RandomGenerator`` to ``Generator``.
* Rename ``randint`` to ``integers``.
* Rename ``random_integers`` to ``integers``.
* Rename ``random_sample`` to ``random``.
* Change ``jump`` which operated in-place to
:meth:`~randomgen.xoshiro256.Xoshiro256.jumped` which
returns a new ``BitGenerator``.
Expand All @@ -163,40 +161,34 @@ v1.16.6
- Improved the performance of :class:`~randomgen.pcg64.PCG64` on Windows.
- Improved performance of :func:`~randomgen.dsfmt.DSFMT.jump` and
:func:`~randomgen.dsfmt.DSFMT.jumped`.
- Improves backward compatibility of :class:`~randomgen.mtrand.RandomState`
- Improves backward compatibility of ``RandomState``


v1.16.5
=======
- Fixed bugs in :func:`~randomgen.mtrand.RandomState.laplace`,
:func:`~randomgen.mtrand.RandomState.gumbel`,
:func:`~randomgen.mtrand.RandomState.logseries`,
:func:`~randomgen.mtrand.RandomState.normal`,
:func:`~randomgen.mtrand.RandomState.standard_normal`,
:func:`~randomgen.mtrand.RandomState.standard_exponential`,
:func:`~randomgen.mtrand.RandomState.exponential`, and
:func:`~randomgen.mtrand.RandomState.logistic` that could result in ``nan``
values in rare circumstances (about 1 in :math:`10^{53}` draws).
- Added keyword ``closed`` to :func:`~randomgen.generator.Generator.randint`
- Fixed bugs in ``laplace``, ``gumbel``, ``logseries``, ``normal``,
``standard_normal``, ``standard_exponential``, ``exponential``, and ``logistic``
that could result in ``nan`` values in rare circumstances (about 1 in :math:`10^{53}` draws).
- Added keyword ``closed`` to ``randint``
which changes sampling from the half-open interval ``[low, high)`` to the closed
interval ``[low, high]``.
- Fixed a bug in :func:`~randomgen.mtrand.RandomState.random_integers` that
- Fixed a bug in ``random_integers`` that
could lead to valid values being treated as invalid.

v1.16.4
=======
- Add a fast path for broadcasting :func:`~randomgen.generator.Generator.randint`
- Add a fast path for broadcasting ``randint``
when using ``uint64`` or ``int64``.
- Refactor PCG64 so that it does not rely on Cython conditional compilation.
- Add :func:`~randomgen.generator.Generator.brng` to access the basic RNG.
- Allow multidimensional arrays in :func:`~randomgen.generator.Generator.choice`.
- Speed-up :func:`~randomgen.generator.Generator.choice` when not replacing.
- Add ``brng`` to access the basic RNG.
- Allow multidimensional arrays in ``choice``.
- Speed-up ``choice`` when not replacing.
The gains can be very large (1000x or more) when the input array is large but
the sample size is small.
- Add parameter checks in :func:`~randomgen.generator.Generator.multinomial`.
- Fix an edge-case bug in :func:`~randomgen.generator.Generator.zipf`.
- Allow 0 for sample in :func:`~randomgen.generator.Generator.hypergeometric`.
- Add broadcasting to :func:`~randomgen.generator.Generator.multinomial` (see
- Add parameter checks in ``multinomial``.
- Fix an edge-case bug in ``zipf``.
- Allow 0 for sample in ``hypergeometric``.
- Add broadcasting to ``multinomial`` (see
`NumPy issue 9710 <https://github.com/numpy/numpy/pull/9710>`_)

v1.16.3
Expand All @@ -210,13 +202,10 @@ v1.16.2
into NumPy, including removing:

* ``random_raw``, which have been moved to the individual bit generators
* ``random_uintegers``, which can be replaced with
:func:`~randomgen.generator.Generator.randint`.
* ``random_uintegers``, which can be replaced with ``randint``.

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

v1.16.1
Expand Down
Loading

0 comments on commit 2aa1ddb

Please sign in to comment.