Skip to content

Commit

Permalink
fix up docs & details of sig_sampler
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Jul 19, 2024
1 parent ec90e54 commit 09f137c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions neurodsp/sim/multi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Simulation functions that return multiple instances."""

from collections.abc import Sized

import numpy as np

from neurodsp.utils.core import counter
Expand Down Expand Up @@ -43,17 +45,20 @@ def sig_sampler(sim_func, sim_params, return_sim_params=False, n_sims=None):
Whether to yield the simulation parameters as well as the simulated time series.
n_sims : int, optional
Number of simulations to set as the max.
If None, creates an infinite generator.
If None, length is defined by the length of `sim_params`, and could be infinite.
Yields
------
sig : 1d array
Simulated time series.
sample_params : dict
Simulation parameters for the yielded time series.
Only returned if `return_sim_params` is True.
"""

if len(sim_params) and n_sims and n_sims > len(sim_params):
# If `sim_params` has a size, and `n_sims` is defined, check that they are compatible
# To do so, we first check if the iterable has a __len__ attr, and if so check values
if isinstance(sim_params, Sized) and len(sim_params) and n_sims and n_sims > len(sim_params):
msg = 'Cannot simulate the requested number of sims with the given parameters.'
raise ValueError(msg)

Check warning on line 63 in neurodsp/sim/multi.py

View check run for this annotation

Codecov / codecov/patch

neurodsp/sim/multi.py#L62-L63

Added lines #L62 - L63 were not covered by tests

Expand Down

0 comments on commit 09f137c

Please sign in to comment.