@File : types.py @Time : 2025/04/03 12:05:50 @Author : Alejandro Marrero @Version : 1.0 @Contact : amarrerd@ull.edu.es @License : (C)Copyright 2025, Alejandro Marrero @Desc : None

RNG

Bases: Protocol

Protocol to type check all operators have _rng of instances types in digneapy

Source code in digneapy/_core/types.py
18
19
20
21
22
23
24
25
26
class RNG(Protocol):
    """Protocol to type check all operators have _rng of instances types in digneapy"""

    _rng: np.random.Generator
    _seed: int

    def initialize_rng(self, seed: Optional[int] = None):
        self._seed = seed if seed else 42
        self._rng = np.random.default_rng(self._seed)