Skip to content

Commit

Permalink
Merge bff7baf into 052e5b7
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed Dec 23, 2019
2 parents 052e5b7 + bff7baf commit 0e54f23
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 9 deletions.
Binary file added doc/source/_static/images/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_favicon = 'images/favicon.ico'
html_favicon = '_static/images/favicon.ico'
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
Expand Down
2 changes: 2 additions & 0 deletions doc/source/generator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Seed and State Manipulation

~Generator.seed
~Generator.state
~Generator.bit_generator

Simple random data
==================
Expand All @@ -36,6 +37,7 @@ Simple random data
~Generator.random
~Generator.choice
~Generator.bytes
~Generator.uintegers

Permutations
============
Expand Down
30 changes: 29 additions & 1 deletion doc/source/new-or-different.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Differences from NumPy 1.17+
``/dev/urandom`` on Unix).
* Simulate from the complex normal distribution
(:meth:`~randomgen.generator.Generator.complex_normal`)
* Direct access to usigned integers is provided by
(:meth:`~randomgen.generator.Generator.uintegers`)
* A wider range of bit generators:

* Chaotic mappings
Expand Down Expand Up @@ -48,12 +50,38 @@ Differences from NumPy 1.17+
* :class:`~randomgen.xoshiro256.Xoshiro256`
* :class:`~randomgen.xoshiro512.Xoshiro512`

* randomgen's :class:`~randomgen.generator.Generator` continues to expose legacy
methods :func:`~randomgen.generator.Generator.random_sample` \,
:func:`~randomgen.generator.Generator.randint` \,
:func:`~randomgen.generator.Generator.random_integers` \,
:func:`~randomgen.generator.Generator.rand` \, :func:`~randomgen.generator.Generator.randn` \,
and :func:`~randomgen.generator.Generator.tomaxint`. **Note**: These should
not be used, and their modern replacements are preferred

* :func:`~randomgen.generator.Generator.random_sample`\, :func:`~randomgen.generator.Generator.rand` -> :func:`~randomgen.generator.Generator.random`
* :func:`~randomgen.generator.Generator.random_integers`\, :func:`~randomgen.generator.Generator.randint` -> :func:`~randomgen.generator.Generator.integers`
* :func:`~randomgen.generator.Generator.randn` -> :func:`~randomgen.generator.Generator.standard_normal`
* :func:`~randomgen.generator.Generator.tomaxint` -> :func:`~randomgen.generator.Generator.integers` with ``dtype`` set to ``np.long``

* randomgen's bit generators remain seedable and the convienciec function
:func:`~randomgen.generator.Generator.seed` is exposed as part of
:class:`~randomgen.generator.Generator`. Additionally, the convenience
property :func:`~randomgen.generator.Generator.state` is available
to get or set the state of the underlying bit generator.

* The legacy name :attr:`~randomgen.generator.Generator.brng` remains. You should use
:attr:`~randomgen.generator.Generator.bit_generator` instead.

* :func:`~numpy.random.multivariate_hypergeometric` was added after
:class:`~randomgen.generator.Generator` was merged into NumPy and will not
be ported over. Please use the NumPy version.


Differences from NumPy before 1.17
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* The normal, exponential and gamma generators use 256-step Ziggurat
methods which are 2-10 times faster than NumPy's default implementation in
:meth:`~randomgen.generator.Generator.standard_normal`,
:meth:`~randomgen.generator.Generator.standard_normal` \,
:meth:`~randomgen.generator.Generator.standard_exponential` or
:meth:`~randomgen.generator.Generator.standard_gamma`.

Expand Down
22 changes: 20 additions & 2 deletions randomgen/generator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,12 @@ cdef class Generator:
def state(self, value):
self._bit_generator.state = value

def random_uintegers(self, size=None, int bits=64):
def uintegers(self, size=None, int bits=64):
"""
random_uintegers(size=None, bits=64)
uintegers(size=None, bits=64)
Return random unsigned integers
Parameters
----------
size : int or tuple of ints, optional
Expand All @@ -240,10 +242,12 @@ cdef class Generator:
single value is returned.
bits : int {32, 64}
Size of the unsigned integer to return, either 32 bit or 64 bit.
Returns
-------
out : uint or ndarray
Drawn samples.
Notes
-----
This method effectively exposes access to the raw underlying
Expand Down Expand Up @@ -282,6 +286,20 @@ cdef class Generator:

return array

def random_uintegers(self, size=None, int bits=64):
"""
random_uintegers(size=None, bits=64)
.. deprecated:: 1.18.0
Alias for uintegers. Use uintegers.
"""
import warnings
warnings.warn("This function is deprecated. Please use uintegers.",
DeprecationWarning)

return self.uintegers(size=size, bits=bits)

def random_sample(self, *args, **kwargs):
import warnings
warnings.warn("random_sample is deprecated in favor of random",
Expand Down
11 changes: 6 additions & 5 deletions randomgen/tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,12 +922,13 @@ def test_complex_normal_zero_variance(self):
np.testing.assert_allclose(c.imag, n, atol=1e-8)

def test_random_uintegers(self):
assert len(self.rg.random_uintegers(10)) == 10
assert len(self.rg.random_uintegers(10, bits=32)) == 10
assert isinstance(self.rg.random_uintegers(), int)
assert isinstance(self.rg.random_uintegers(bits=32), int)
assert len(self.rg.uintegers(10)) == 10
assert len(self.rg.uintegers(10, bits=32)) == 10
assert isinstance(self.rg.uintegers(), int)
assert isinstance(self.rg.uintegers(bits=32), int)
with pytest.raises(ValueError):
self.rg.random_uintegers(bits=128)
with pytest.deprecated_call():
self.rg.random_uintegers(bits=128)

def test_bit_generator_raw_large(self):
bg = self.rg.bit_generator
Expand Down

0 comments on commit 0e54f23

Please sign in to comment.