Skip to content

Commit f2c86a4

Browse files
agriyakhetarpalBradyPlanden
authored andcommitted
Don't be too strict with func_args longer than symbol.children
1 parent 313dd7f commit f2c86a4

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/pybamm/parameters/parameter_values.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,12 +866,21 @@ def _process_function_parameter(self, symbol):
866866
else:
867867
new_children.append(self.process_symbol(child))
868868

869-
# Get the expression and inputs for the function
869+
# Get the expression and inputs for the function.
870+
# func_args may include arguments that were not explicitly wired up
871+
# in this FunctionParameter (e.g., kwargs with default values). After
872+
# serialisation/deserialisation, we only recover the children that were
873+
# actually connected.
874+
#
875+
# Using strict=True here therefore raises a ValueError when there are
876+
# more args than children. We allow func_args to be longer than
877+
# symbol.children and only build the mapping for the args for which we
878+
# actually have children.
870879
expression = function_parameter.child
871880
inputs = {
872881
arg: child
873882
for arg, child in zip(
874-
function_parameter.func_args, symbol.children, strict=True
883+
function_parameter.func_args, symbol.children, strict=False
875884
)
876885
}
877886

0 commit comments

Comments
 (0)