Skip to content

Commit

Permalink
add docstring examples
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Aug 17, 2024
1 parent 12d4c6d commit e2770f5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion neurodsp/sim/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def create_updater(update, component=None):
-------
callable
Updater function which can update specified parameter in simulation parameters.
Examples
--------
Create an updater callable for a specified parameter:
>>> upd = create_updater('exponent')
Create an updater callable for a specified parameter within a specified component:
>>> upd = create_updater('exponent', 'sim_powerlaw')
"""

if component is not None:
Expand Down Expand Up @@ -175,7 +183,7 @@ def _reset_yielder(self):
## PARAM SAMPLERS

def create_sampler(values, probs=None, n_samples=None):
"""Create a generator to sample from a parameter range.
"""Create a generator to sample from a set of parameters.
Parameters
----------
Expand All @@ -192,6 +200,16 @@ def create_sampler(values, probs=None, n_samples=None):
------
generator
Generator to sample parameter values from.
Examples
--------
Create a generator to sample parameter values from, for a specified number of samples:
>>> sampler = create_sampler([-2, -1, 0], n_samples=5)
Create a generator to sampler parameter values from, with specified probability:
>>> sampler = create_sampler([9, 10, 11], probs=[0.25, 0.5, 0.25])
"""

# Check that length of values is same as length of probs, if provided
Expand Down

0 comments on commit e2770f5

Please sign in to comment.