Skip to content

Commit 2aa1ddb

Browse files
authored
Merge pull request #317 from bashtage/remove-generator
Remove generator
2 parents 2d25646 + be92b9b commit 2aa1ddb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+896
-16863
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
recursive-exclude randomgen *.c
2+
include randomgen/py.typed
23
include randomgen/_version.py
34
include requirements.txt
45
include README.md

README.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ or the [stable documentation](https://bashtage.github.io/randomgen/devel/change-
3737

3838
# WARNINGS
3939

40-
## Changes in v1.19
40+
## Changes in v1.24
4141

42-
``Generator`` and ``RandomState`` have been officially deprecated, and will
42+
``Generator`` and ``RandomState`` have been **removed**.
43+
44+
## Changes from 1.18 to 1.19
45+
46+
``Generator`` and ``RandomState`` have been officially deprecated in 1.19, and will
4347
warn with a ``FutureWarning`` about their removal. They will also receive virtually
4448
no maintenance. It is now time to move to NumPy's ``np.random.Generator`` which has
4549
features not in ``randomstate.Generator`` and is maintained more actively.
@@ -54,8 +58,7 @@ to ``randomstate.ExtendedGenerator``:
5458
There are no plans to remove any of the bit generators, e.g., ``AESCounter``,
5559
``ThreeFry``, or ``PCG64``.
5660

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

6770
## Future Plans
6871

69-
A substantial portion of randomgen has been merged into NumPy. Revamping NumPy's random
70-
number generation was always the goal of this project (and its predecessor
71-
[NextGen NumPy RandomState](https://github.com/bashtage/ng-numpy-randomstate>)),
72-
and so it has succeeded.
73-
74-
While I have no immediate plans to remove anything, after a 1.19 release I will:
75-
76-
* Remove `Generator` and `RandomState`. These duplicate NumPy and will diverge over time.
77-
The versions in NumPy are authoritative. **Deprecated**
78-
* Preserve novel methods of `Generator` in a new class, `ExtendedGenerator`. **Done**
7972
* Add some distributions that are not supported in NumPy. _Ongoing_
8073
* Add any interesting bit generators I come across. _Recent additions include the DXSM and CM-DXSM variants of PCG64 and the LXM generator._
8174

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

10497

105-
10698
## Status
10799

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

115107
## Version
116108

117-
The package version matches the latest version of NumPy where
118-
`Generator(MT19937())` passes all NumPy test.
109+
The package version matches the latest version of NumPy when the package
110+
is released.
119111

120112
## Documentation
121113

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

131-
* Python (3.6, 3.7, 3.8, 3.9)
132-
* NumPy (1.14, 1.15, 1.16, 1.17, 1.18, 1.19)
123+
* Python (3.6, 3.7, 3.8, 3.9, 3.10)
124+
* NumPy (1.17+)
133125
* Cython (0.29+)
134126
* tempita (0.5+), if not provided by Cython
135127

appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,3 @@ build_script:
2828

2929
test_script:
3030
- pytest randomgen
31-
32-
on_success:
33-
- cd %GIT_DIR%\
34-
- python benchmark.py

azure-pipelines.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ jobs:
2121
- template: ci/azure/azure_template_posix.yml
2222
parameters:
2323
name: macOS
24-
vmImage: macOS-10.15
24+
vmImage: macOS-latest
2525

2626
- template: ci/azure/azure_template_posix.yml
2727
parameters:
2828
name: Linux
29-
vmImage: ubuntu-20.04
29+
vmImage: ubuntu-latest
3030

3131
- template: ci/azure/azure_template_windows.yml
3232
parameters:
3333
name: Windows
34-
vmImage: windows-2019
34+
vmImage: windows-latest

benchmark.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
rg = numpy.random.RandomState()
1616
rg.random_sample()
1717
else:
18-
from randomgen import Generator, {bitgen}
18+
from randomgen import {bitgen}
19+
from numpy.random import Generator
1920
rg = Generator({bitgen}())
2021
rg.random()
2122
"""

ci/azure/azure_template_posix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
python38_legacy:
2626
python.version: '3.8'
2727
coverage: true
28-
NUMPY: 1.16.6
28+
NUMPY: 1.17.0
2929
python39_latest:
3030
python.version: '3.9'
3131
python310_latest:

ci/azure/install-posix.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ else
1313
fi
1414

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

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

20-
if [[ -n ${NUMPY} ]]; then CMD="$CMD==${NUMPY}"; fi;
20+
if [[ -n ${NUMPY} ]]; then CMD="$CMD~=${NUMPY}"; fi;
2121
CMD="$CMD cython"
22-
if [[ -n ${CYTHON} ]]; then CMD="$CMD==${CYTHON}"; fi;
22+
if [[ -n ${CYTHON} ]]; then CMD="$CMD~=${CYTHON}"; fi;
2323
CMD="$CMD pandas"
2424
CMD="$CMD $EXTRA"
2525
if [[ ${USE_CONDA} == "true" ]]; then CMD="$CMD numba"; fi;

doc/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
numba>=0.49
22
nbsphinx
33
sphinx-material
4-
sphinx>=3
4+
sphinx>=5
55
ipython>=6
66
numpydoc
77
pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability

doc/source/bit_generators/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Bit Generators
22
--------------
33

44
The random values produced by :class:`numpy.random.Generator`
5-
(and also :class:`~randomgen.generator.Generator`)
5+
(and also ``Generator``)
66
are produced by a bit generator. These bit generators do not directly provide
77
random numbers and only contain methods used for seeding, getting or
88
setting the state, jumping or advancing the state, and for accessing

doc/source/change-log.rst

Lines changed: 35 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ Change Log
99

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

12-
:class:`~randomgen.generator.Generator` and :class:`~randomgen.mtrand.RandomState`
13-
are **DEPRECATED**. You should be using :class:`numpy.random.Generator` or
14-
:class:`numpy.random.RandomState` which are better maintained. These will be
15-
maintained until after NumPy 1.21 (or 2 releases after NumPy 1.19) for users who
16-
cannot update NumPy.
12+
``Generator`` and ``RandomState`` have been **REMOVED** in 1.23.
13+
You should be using :class:`numpy.random.Generator` or
14+
:class:`numpy.random.RandomState` which are maintained.
15+
16+
v1.23.0
17+
=======
18+
- Removed ``Generator`` and ``RandomState``.
1719

1820
v1.20.2
1921
=======
@@ -44,7 +46,7 @@ v1.20.2
4446

4547
v1.20.1
4648
=======
47-
- Fixed a bug that affects :func:`~randomgen.generator.Generator.standard_gamma` when
49+
- Fixed a bug that affects ``standard_gamma`` when
4850
used with ``out`` and a Fortran contiguous array.
4951
- Added :func:`~randomgen.generator.ExtendedGenerator.multivariate_complex_normal`.
5052
- Added :func:`~randomgen.generator.ExtendedGenerator.standard_wishart` and
@@ -105,20 +107,20 @@ v1.19.0
105107
- Added support for broadcasting inputs in :class:`randomgen.generator.ExtendedGenerator.multivariate_normal`.
106108
- Added support for the `++` variant of :class:`randomgen.xoroshiro128.Xoroshiro128`.
107109
- Fixed a bug the produced incorrect results in :func:`~randomgen.mt19937.MT19937.jumped`.
108-
- Fixed multiple bugs in :class:`~randomgen.generator.Generator` that were fixed in :class:`numpy.random.Generator`.
110+
- Fixed multiple bugs in ``Generator`` that were fixed in :class:`numpy.random.Generator`.
109111

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

130-
* The ``.generator`` method of the bit generators raise
131-
``NotImplementedError``
132+
* The ``.generator`` method of the bit generators raise ``NotImplementedError``
132133
* The internal structures that is used in C have been renamed.
133134
The main rename is ``brng_t`` to ``bitgen_t``
134135

135136
- The other key changes are:
136137

137-
* Rename ``RandomGenerator`` to :class:`~randomgen.generator.Generator`.
138-
* Rename :meth:`~randomgen.generator.Generator.randint` to
139-
:meth:`~randomgen.generator.Generator.integers`.
140-
* Rename :meth:`~randomgen.generator.Generator.random_integers` to
141-
:meth:`~randomgen.generator.Generator.integers`.
142-
* Rename :meth:`~randomgen.generator.Generator.random_sample`
143-
to :meth:`~randomgen.generator.Generator.random`.
138+
* Rename ``RandomGenerator`` to ``Generator``.
139+
* Rename ``randint`` to ``integers``.
140+
* Rename ``random_integers`` to ``integers``.
141+
* Rename ``random_sample`` to ``random``.
144142
* Change ``jump`` which operated in-place to
145143
:meth:`~randomgen.xoshiro256.Xoshiro256.jumped` which
146144
returns a new ``BitGenerator``.
@@ -163,40 +161,34 @@ v1.16.6
163161
- Improved the performance of :class:`~randomgen.pcg64.PCG64` on Windows.
164162
- Improved performance of :func:`~randomgen.dsfmt.DSFMT.jump` and
165163
:func:`~randomgen.dsfmt.DSFMT.jumped`.
166-
- Improves backward compatibility of :class:`~randomgen.mtrand.RandomState`
164+
- Improves backward compatibility of ``RandomState``
167165

168166

169167
v1.16.5
170168
=======
171-
- Fixed bugs in :func:`~randomgen.mtrand.RandomState.laplace`,
172-
:func:`~randomgen.mtrand.RandomState.gumbel`,
173-
:func:`~randomgen.mtrand.RandomState.logseries`,
174-
:func:`~randomgen.mtrand.RandomState.normal`,
175-
:func:`~randomgen.mtrand.RandomState.standard_normal`,
176-
:func:`~randomgen.mtrand.RandomState.standard_exponential`,
177-
:func:`~randomgen.mtrand.RandomState.exponential`, and
178-
:func:`~randomgen.mtrand.RandomState.logistic` that could result in ``nan``
179-
values in rare circumstances (about 1 in :math:`10^{53}` draws).
180-
- Added keyword ``closed`` to :func:`~randomgen.generator.Generator.randint`
169+
- Fixed bugs in ``laplace``, ``gumbel``, ``logseries``, ``normal``,
170+
``standard_normal``, ``standard_exponential``, ``exponential``, and ``logistic``
171+
that could result in ``nan`` values in rare circumstances (about 1 in :math:`10^{53}` draws).
172+
- Added keyword ``closed`` to ``randint``
181173
which changes sampling from the half-open interval ``[low, high)`` to the closed
182174
interval ``[low, high]``.
183-
- Fixed a bug in :func:`~randomgen.mtrand.RandomState.random_integers` that
175+
- Fixed a bug in ``random_integers`` that
184176
could lead to valid values being treated as invalid.
185177

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

202194
v1.16.3
@@ -210,13 +202,10 @@ v1.16.2
210202
into NumPy, including removing:
211203

212204
* ``random_raw``, which have been moved to the individual bit generators
213-
* ``random_uintegers``, which can be replaced with
214-
:func:`~randomgen.generator.Generator.randint`.
205+
* ``random_uintegers``, which can be replaced with ``randint``.
215206

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

222211
v1.16.1

0 commit comments

Comments
 (0)