From f2967dd8485a41a8e9c9038e104f84e1e42135f9 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 26 Nov 2020 14:37:11 +0000 Subject: [PATCH 1/4] remove unreachable code --- pymc3/sampling.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pymc3/sampling.py b/pymc3/sampling.py index 4d03674e6d..cd441ed826 100644 --- a/pymc3/sampling.py +++ b/pymc3/sampling.py @@ -130,8 +130,6 @@ def instantiate_steppers(_model, steps, selected_steps, step_kwargs=None): used_keys = set() for step_class, vars in selected_steps.items(): - if len(vars) == 0: - continue args = step_kwargs.get(step_class.name, {}) used_keys.add(step_class.name) step = step_class(vars=vars, **args) From 032b9e7db2d7c88e4b2d8e3c506ad3aba21c7706 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 26 Nov 2020 20:19:27 +0000 Subject: [PATCH 2/4] clarify docs, invert guard --- pymc3/sampling.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pymc3/sampling.py b/pymc3/sampling.py index cd441ed826..1e6992295e 100644 --- a/pymc3/sampling.py +++ b/pymc3/sampling.py @@ -113,27 +113,29 @@ def instantiate_steppers(_model, steps, selected_steps, step_kwargs=None): A fully-specified model object; legacy argument -- ignored steps : step function or vector of step functions One or more step functions that have been assigned to some subset of - the model's parameters. Defaults to None (no assigned variables). + the model's parameters. selected_steps : dictionary of step methods and variables - The step methods and the variables that have were assigned to them. + The step methods and the (possibly zero) variables that have were assigned to them. step_kwargs : dict Parameters for the samplers. Keys are the lower case names of - the step method, values a dict of arguments. + the step method, values a dict of arguments. Defaults to None. Returns ------- - methods : list - List of step methods associated with the model's variables. + methods : list or step + List of step methods associated with the model's variables, or step method + if there is only one. """ if step_kwargs is None: step_kwargs = {} used_keys = set() for step_class, vars in selected_steps.items(): - args = step_kwargs.get(step_class.name, {}) - used_keys.add(step_class.name) - step = step_class(vars=vars, **args) - steps.append(step) + if vars: + args = step_kwargs.get(step_class.name, {}) + used_keys.add(step_class.name) + step = step_class(vars=vars, **args) + steps.append(step) unused_args = set(step_kwargs).difference(used_keys) if unused_args: From ed705143033ba539ef792c67111f6b2171a890c3 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 26 Nov 2020 20:20:46 +0000 Subject: [PATCH 3/4] clarify that steps is a sequence --- pymc3/sampling.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymc3/sampling.py b/pymc3/sampling.py index 1e6992295e..137a77bf80 100644 --- a/pymc3/sampling.py +++ b/pymc3/sampling.py @@ -111,7 +111,7 @@ def instantiate_steppers(_model, steps, selected_steps, step_kwargs=None): ---------- model : Model object A fully-specified model object; legacy argument -- ignored - steps : step function or vector of step functions + steps : sequence of step functions One or more step functions that have been assigned to some subset of the model's parameters. selected_steps : dictionary of step methods and variables From 6ab2c4ff537637e3d7962e3f810feafdd61dc8f7 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 27 Nov 2020 10:15:20 +0000 Subject: [PATCH 4/4] :memo: update docstring --- pymc3/sampling.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pymc3/sampling.py b/pymc3/sampling.py index 137a77bf80..b7a77a0722 100644 --- a/pymc3/sampling.py +++ b/pymc3/sampling.py @@ -111,11 +111,11 @@ def instantiate_steppers(_model, steps, selected_steps, step_kwargs=None): ---------- model : Model object A fully-specified model object; legacy argument -- ignored - steps : sequence of step functions - One or more step functions that have been assigned to some subset of + steps : list + A list of zero or more step function instances that have been assigned to some subset of the model's parameters. - selected_steps : dictionary of step methods and variables - The step methods and the (possibly zero) variables that have were assigned to them. + selected_steps : dict + A dictionary that maps a step method class to a list of zero or more model variables. step_kwargs : dict Parameters for the samplers. Keys are the lower case names of the step method, values a dict of arguments. Defaults to None.