Skip to content

Commit

Permalink
change the mutable default arguments into None
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengzl18 committed Nov 5, 2023
1 parent 5963c45 commit 56cf268
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cyipopt/scipy_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,9 +386,9 @@ def minimize_ipopt(fun,
tol=None,
callback=None,
options=None,
mult_g=[],
mult_x_L=[],
mult_x_U=[],):
mult_g=None,
mult_x_L=None,
mult_x_U=None,):
"""
Minimization using Ipopt with an interface like
:py:func:`scipy.optimize.minimize`.
Expand Down Expand Up @@ -630,6 +630,9 @@ def minimize_ipopt(fun,
msg = 'Invalid option for IPOPT: {0}: {1} (Original message: "{2}")'
raise TypeError(msg.format(option, value, e))

mult_g = [] if mult_g is None else mult_g
mult_x_L = [] if mult_x_L is None else mult_x_L
mult_x_U = [] if mult_x_U is None else mult_x_U
_dual_initial_guess_validation("mult_g", mult_g, len(cl))
_dual_initial_guess_validation("mult_x_L", mult_x_L, len(lb))
_dual_initial_guess_validation("mult_x_U", mult_x_U, len(ub))
Expand Down

0 comments on commit 56cf268

Please sign in to comment.