Open lkursell opened 7 years ago
I dont understand this issue - the SyntaxError
is an expected part of python. If you specify positional arguments after a keyword argument you get errors. The solution to the 'defined parameters outside' is to remove the keyword sinks
. For example:
alpha1 = .1
alpha2 = .1
beta = 10
burnins = 100
delay = 1
restarts = 1
draws_per_restart = 1
cluster = c
create_feature_tables = True
# This will fail because a keyword argument occurs before a positional argument.
gibbs(sources, sinks=None, alpha1, alpha2, beta, restart,
draws_per_restart, burnin, delay, cluster, create_feature_tables)
# This would not fail because no keyword argument precedes a positional argument.
sinks = None
gibbs(sources, sinks, alpha1, alpha2, beta, restart,
draws_per_restart, burnin, delay, cluster, create_feature_tables)
# or, if you like
gibbs(sources, None, alpha1, alpha2, beta, restart,
draws_per_restart, burnin, delay, cluster, create_feature_tables)
As I sent to @nscott1 offline.
def f(a,b,c,d,e):
return a+b+c+d+e
# won't work because we are specifying at least one positional argument after
# the keyword args
e = 5
f(a=1, b=2, c=3, d=4, e)
a = 1
e = 5
f(a, b=2, c=3, d=4, e)
# will work because the last positional argument occurs before a keyword argument
a = 1
b = 2
f(a, b, c=3, d=4, e=5)
In the
gibbs
argument:Code If a user defined the parameters outside of the
gibbs()
call, and then passed insinks=None
, they could get a positional argument, which can be confusing. Using the leave-one-out function therefore requires the user to use**kwargs
or specify the parameters within the function.