Skip to content

Commit

Permalink
REF: Regenerate test date with new seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed Sep 17, 2024
1 parent a65cdbe commit 9b01531
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 35 deletions.
4 changes: 2 additions & 2 deletions randomgen/_seed_sequence.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABCMeta, abstractmethod
from typing import Any, Dict, List, Literal, Optional, Sequence, Type, Union
from typing import Any, Dict, List, Optional, Sequence, Type, Union

from numpy import uint32, uint64, unsignedinteger
from numpy import unsignedinteger

DEFAULT_POOL_SIZE: int

Expand Down
4 changes: 2 additions & 2 deletions randomgen/common.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ from libc.stdint cimport (
)

import numpy as np
from numpy.random cimport bitgen_t
from numpy.random.bit_generator cimport BitGenerator as _BitGenerator

cimport numpy as np
from numpy.random cimport bitgen_t
from numpy.random.bit_generator cimport BitGenerator as _BitGenerator


cdef bint RANDOMGEN_BIG_ENDIAN
Expand Down
2 changes: 1 addition & 1 deletion randomgen/efiix64.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from typing import Dict, Optional, Union
import numpy as np

from randomgen.common import BitGenerator
from randomgen.typing import IntegerSequenceSeed, SeedMode
from randomgen.typing import IntegerSequenceSeed

class EFIIX64(BitGenerator):
def __init__(self, seed: Optional[IntegerSequenceSeed] = ...) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion randomgen/generator.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from threading import Lock
from typing import Any, Dict, Literal, Optional, Sequence, Tuple, Union, overload
from typing import Any, Dict, Literal, Optional, Union, overload

from numpy import ndarray

Expand Down
2 changes: 1 addition & 1 deletion randomgen/mt19937.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ from typing import Dict, Literal, Optional, Tuple, Union
import numpy as np

from randomgen.common import BitGenerator
from randomgen.typing import IntegerSequenceSeed, SeedMode
from randomgen.typing import IntegerSequenceSeed

class MT19937(BitGenerator):
def __init__(
Expand Down
2 changes: 1 addition & 1 deletion randomgen/mt64.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, Optional, Tuple, Union
from typing import Dict, Optional, Union

import numpy as np

Expand Down
11 changes: 2 additions & 9 deletions randomgen/tests/test_direct.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
)
from randomgen.common import interface
from randomgen.seed_sequence import ISeedSequence
from randomgen.tests.data.compute_hashes import kwargs

try:
from numpy.random import SeedSequence
Expand Down Expand Up @@ -1300,15 +1299,11 @@ def setup_class(cls):
]

def test_seed_sequence(self):
bg = self.bit_generator_base(
number=self.number, width=self.width
)
bg = self.bit_generator_base(number=self.number, width=self.width)
assert isinstance(bg, self.bit_generator_base)
assert isinstance(bg.seed_seq, SeedSequence)

bg = self.bit_generator_base(
0, number=self.number, width=self.width
)
bg = self.bit_generator_base(0, number=self.number, width=self.width)
assert bg.seed_seq.entropy == 0

ss = SeedSequence(0)
Expand Down Expand Up @@ -1573,9 +1568,7 @@ def setup_class(cls):
cls.state_name = "key"

def setup_bitgenerator(self, seed, **kwargs):
stream = 3735928559 * 2**64 + 3735928559 * 2**96
seed = [0] if None in seed else seed
key = seed[0] + stream + 2**128 * stream
bg = self.bit_generator(*seed, **kwargs)
return bg

Expand Down
18 changes: 3 additions & 15 deletions randomgen/tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def _extra_setup(cls):
cls.seed_error = TypeError

def init_generator(self, seed=None, mode="sequence"):
kwargs = {} if mode == "sequence" else {"mode":mode}
kwargs = {} if mode == "sequence" else {"mode": mode}
if seed is not None:
return np.random.Generator(self.bit_generator(*seed, **kwargs))
else:
Expand Down Expand Up @@ -603,11 +603,6 @@ def test_array_scalar_seed_diff(self):
assert_(not comp_state(state1, state2))

def test_seed_array_error(self):
if self.seed_vector_bits == 32:
out_of_bounds = 2**32
else:
out_of_bounds = 2**64

seed = -1
with pytest.raises(ValueError):
self.rg.bit_generator.seed(seed)
Expand Down Expand Up @@ -795,7 +790,7 @@ def test_output_fill_error(self):
rg.standard_gamma(1.0, out=existing[::3])

def test_integers_broadcast(self, dtype):
if dtype == bool:
if dtype is bool:
upper = 2
lower = 0
else:
Expand Down Expand Up @@ -844,7 +839,7 @@ def test_integers_numpy(self, dtype):
assert out.shape == (1,)

def test_integers_broadcast_errors(self, dtype):
if dtype == bool:
if dtype is bool:
upper = 2
lower = 0
else:
Expand Down Expand Up @@ -967,16 +962,10 @@ def setup_class(cls):

def test_seed_array_error(self):
# GH #82 for error type changes
if self.seed_vector_bits == 32:
out_of_bounds = 2**32
else:
out_of_bounds = 2**64

seed = -1
with pytest.raises(ValueError):
self.rg.bit_generator.seed(seed)

error_type = ValueError if self.seed_vector_bits else TypeError
seed = np.array([-1], dtype=np.int32)
with pytest.raises(ValueError):
self.rg.bit_generator.seed(seed)
Expand All @@ -985,7 +974,6 @@ def test_seed_array_error(self):
with pytest.raises(ValueError):
self.rg.bit_generator.seed(seed)


def test_array_scalar_seed_diff(self):
pass

Expand Down
5 changes: 4 additions & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ pytest-cov
pytest-xdist
scipy>=1.13.1
setuptools_scm[toml]>=8.0.0,<9.0.0
packaging>=21.0
packaging>=21.0
ruff
flake8
flake8-pyi
4 changes: 2 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ license_files =
LICENSE.md

[flake8]
max-line-length = 99
ignore = E203,W503,BLK100
max-line-length = 88
extend-ignore = E203,E701

[isort]
sections=FUTURE,COMPAT,STDLIB,THIRDPARTY,FIRSTPARTY,LOCALFOLDER
Expand Down

0 comments on commit 9b01531

Please sign in to comment.