Skip to content

random_state=None yields out of bound error #22

Description

@qian-chu

When random_state is None (default) like in the following example:

from pycircstat2.distributions import vonmises
samples = vonmises.rvs(size=100, random_state=None, mu=0, kappa=1)

It gives the following error:

Traceback (most recent call last):
  File "xxxxx.py", line 2, in <module>
    samples_1 = vonmises.rvs(size=100, mu=0, kappa=1)
  File "xxx\miniforge3\envs\ephys\Lib\site-packages\pycircstat2\distributions.py", line 3687, in rvs
    return self._rvs(mu, kappa, size=size, random_state=random_state)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "xxx\miniforge3\envs\ephys\Lib\site-packages\pycircstat2\distributions.py", line 3608, in _rvs
    rng = self._init_rng(random_state)
  File "xxx\miniforge3\envs\ephys\Lib\site-packages\pycircstat2\distributions.py", line 247, in _init_rng
    seed = candidate.randint(0, 2**32)
  File "numpy/random/mtrand.pyx", line 799, in numpy.random.mtrand.RandomState.randint
  File "numpy/random/_bounded_integers.pyx", line 2881, in numpy.random._bounded_integers._rand_int32
ValueError: high is out of bounds for int32

But works fine otherwise. The same bug persists for a few other distributions I tried. I guess there's a bug somewhere when setting a default random state?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions