SciStanPy API Reference¶
At the root level, SciStanPy exposes the operations
, utils
, parameters
, and results
modules, as well as the Model
and Constant
classes. These components will be sufficient for most users of SciStanPy; however, links to relevant documentation for the entire public API is provided below for reference:
There are also a few objects defined at the root level itself. These include the following:
- scistanpy.manual_seed(seed: int | integer | None = None)[source]
Sets the seed for global random number generators.
This function sets the seed for both NumPy and PyTorch random number generators to ensure reproducible results across the entire SciStanPy workflow. It updates the global RNG variable and synchronizes PyTorch’s random state.
- Parameters:
seed (Union[custom_types.Integer, None]) – Seed value for random number generation. If None, uses system entropy to generate a random seed.
- Raises:
TypeError – If seed is not an integer type when provided
- Example:
>>> import scistanpy as ssp >>> # Set seed for reproducible results >>> ssp.manual_seed(42) >>> # Now all random operations will be reproducible >>> random_data = ssp.RNG.normal(0, 1, size=100)
- Note:
This function modifies global state and should typically be called once at the beginning of a script or analysis for reproducibility. Note also that it sets the PyTorch global random seed by calling torch.manual_seed, which means that any random processes in PyTorch will also become deterministic.
- scistanpy.RNG: Generator
Global random number generator for SciStanPy.
This generator is used throughout the package to ensure reproducible random number generation. It can be seeded using the manual_seed() function to ensure consistent results across runs.
- Type:
np.random.Generator
- Example:
>>> import scistanpy as ssp >>> # Use the global RNG >>> random_values = ssp.RNG.normal(0, 1, size=10)