added new type for rng_seed in _typehints module

This commit is contained in:
Daniel Otto de Mentock 2022-02-02 12:52:59 +01:00
parent dc5ab9aee9
commit 4b2e104f03
3 changed files with 8 additions and 5 deletions

View File

@ -9,3 +9,5 @@ import numpy as np
FloatSequence = Union[np.ndarray,Sequence[float]]
IntSequence = Union[np.ndarray,Sequence[int]]
FileHandle = Union[TextIO, str, Path]
NumpyRngSeed = Union[int, IntSequence, np.random.SeedSequence, np.random.BitGenerator, np.random.Generator]

View File

@ -1,3 +1,4 @@
"""Functionality for generation of seed points for Voronoi or Laguerre tessellation."""
from typing import Tuple as _Tuple
@ -5,7 +6,7 @@ from typing import Tuple as _Tuple
from scipy import spatial as _spatial
import numpy as _np
from ._typehints import FloatSequence as _FloatSequence, IntSequence as _IntSequence
from ._typehints import FloatSequence as _FloatSequence, IntSequence as _IntSequence, NumpyRngSeed
from . import util as _util
from . import grid_filters as _grid_filters
@ -13,7 +14,7 @@ from . import grid_filters as _grid_filters
def from_random(size: _FloatSequence,
N_seeds: int,
cells: _IntSequence = None,
rng_seed=None) -> _np.ndarray:
rng_seed: NumpyRngSeed = None) -> _np.ndarray:
"""
Place seeds randomly in space.
@ -53,7 +54,7 @@ def from_Poisson_disc(size: _FloatSequence,
N_candidates: int,
distance: float,
periodic: bool = True,
rng_seed=None) -> _np.ndarray:
rng_seed: NumpyRngSeed = None) -> _np.ndarray:
"""
Place seeds according to a Poisson disc distribution.

View File

@ -16,7 +16,7 @@ import numpy as np
import h5py
from . import version
from ._typehints import IntSequence, FloatSequence
from ._typehints import FloatSequence, NumpyRngSeed
# limit visibility
__all__=[
@ -396,7 +396,7 @@ def execution_stamp(class_name: str,
def hybrid_IA(dist: np.ndarray,
N: int,
rng_seed: Union[int, IntSequence] = None) -> np.ndarray:
rng_seed: NumpyRngSeed = None) -> np.ndarray:
"""
Hybrid integer approximation.