Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw functions with flexible number of parameters #75

Merged
merged 13 commits into from
Jul 25, 2024

Conversation

twallema
Copy link
Owner

  • I have checked to ensure there aren't other open Pull Requests for the same update/change
  • I have updated the documentation accordingly.

Describe your fixes/additions/changes

Old

Draw functions with two mandatory inputs: parameters and samples, even if samples wasn't used,

def draw_function(parameters, samples):
    parameters['alpha'] = np.random.uniform(low=0, high=5)
    return parameters

out = model.sim(121, N=10, draw_function=draw_function, samples={}, processes=10)

New

Only parameters is mandatory,

def draw_function(parameters):
    parameters['alpha'] = np.random.uniform(low=0, high=5)
    return parameters

out = model.sim(121, N=10, draw_function=draw_function, processes=10)

But users can add any number of arguments, and need to supply them to the sim() function with the argument draw_function_kwargs (type dict, keys are names of extra args),

def draw_function(parameters, low, high):
    parameters['alpha'] = np.random.uniform(low=low, high=high)
    return parameters

out = model.sim(121, N=10, draw_function=draw_function, draw_function_kwargs={'low': 0, 'high:5}, processes=10)

@RitaVazVerstraeten Check any draw functions in your code if using them.

@twallema twallema merged commit 237940a into master Jul 25, 2024
3 checks passed
@twallema twallema deleted the draw-functions-with-flexible-number-of-parameters branch July 25, 2024 14:45
@twallema twallema mentioned this pull request Oct 9, 2024
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant