<p dir="auto">My issue is about optimize.shgo. It gives an unexpected TypeError.</p>
<p dir="auto">When running the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from scipy.optimize import rosen, rosen_der, rosen_hess
bounds = [(0,1.6), (0, 1.6), (0, 1.4), (0, 1.4), (0, 1.4)]
result = scipy.optimize.shgo(rosen, bounds, options={'jac':rosen_der,'hess':rosen_hess})"><pre class="notranslate"><code class="notranslate">from scipy.optimize import rosen, rosen_der, rosen_hess
bounds = [(0,1.6), (0, 1.6), (0, 1.4), (0, 1.4), (0, 1.4)]
result = scipy.optimize.shgo(rosen, bounds, options={'jac':rosen_der,'hess':rosen_hess})
</code></pre></div>
<p dir="auto">I get</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TypeError: _minimize_slsqp() got multiple values for argument 'jac'"><pre class="notranslate"><code class="notranslate">TypeError: _minimize_slsqp() got multiple values for argument 'jac'
</code></pre></div>
<p dir="auto">I believe that <code class="notranslate">jac</code> is correctly specified here (see <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.shgo.html#scipy.optimize.shgo" rel="nofollow">this documentation</a>). Did I make a mistake or is there a bug here?</p>
<h4 dir="auto">Scipy/Numpy/Python version information:</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="1.6.0 1.20.0 sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)"><pre class="notranslate"><code class="notranslate">1.6.0 1.20.0 sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)
</code></pre></div>
<p dir="auto">The shgo implementation seems to be unable to handle the gradient calculation option where the gradient is directly returned alongside the objective value by the objective function (as indicated by using <code class="notranslate">'jac': True</code>).<br>
I think the minimal working example below demonstrates the issue quite well.</p>
<p dir="auto">It works fine when passing a separate Callable that calculates the gradient for <code class="notranslate">'jac'</code></p>
<h4 dir="auto">Reproducing code example:</h4>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="from scipy.optimize import shgo

def func(x):
    return np.sum(np.power(x, 2)), 2 * x

shgo(
    func, 
    bounds=[[-1,1], [1,2], [-1,1], [1,2], [0,3]],  
    n=100, iters=5, 
    sampling_method=&quot;sobol&quot;, 
    minimizer_kwargs={'method': 'SLSQP', 'jac': True}
)"><pre class="notranslate"><code class="notranslate">from scipy.optimize import shgo

def func(x):
    return np.sum(np.power(x, 2)), 2 * x

shgo(
    func, 
    bounds=[[-1,1], [1,2], [-1,1], [1,2], [0,3]],  
    n=100, iters=5, 
    sampling_method="sobol", 
    minimizer_kwargs={'method': 'SLSQP', 'jac': True}
)
</code></pre></div>
<h4 dir="auto">Error message:</h4>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;&lt;input&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py&quot;, line 421, in shgo
    shc.construct_complex()
  File &quot;/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py&quot;, line 726, in construct_complex
    self.iterate()
  File &quot;/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py&quot;, line 869, in iterate
    self.iterate_complex()
  File &quot;/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py&quot;, line 906, in iterate_delaunay
    self.sampled_surface(infty_cons_sampl=self.infty_cons_sampl)
  File &quot;/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py&quot;, line 1236, in sampled_surface
    self.fun_ref()
  File &quot;/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py&quot;, line 1447, in fun_ref
    self.F[i] = self.func(self.C[i, :], *self.args)
ValueError: setting an array element with a sequence."><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "&lt;input&gt;", line 1, in &lt;module&gt;
  File "/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py", line 421, in shgo
    shc.construct_complex()
  File "/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py", line 726, in construct_complex
    self.iterate()
  File "/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py", line 869, in iterate
    self.iterate_complex()
  File "/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py", line 906, in iterate_delaunay
    self.sampled_surface(infty_cons_sampl=self.infty_cons_sampl)
  File "/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py", line 1236, in sampled_surface
    self.fun_ref()
  File "/home/david/anaconda3/envs/bachelor-project/lib/python3.8/site-packages/scipy/optimize/_shgo.py", line 1447, in fun_ref
    self.F[i] = self.func(self.C[i, :], *self.args)
ValueError: setting an array element with a sequence.
</code></pre></div>
<h4 dir="auto">Scipy/Numpy/Python version information:</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="scipy: 1.6.0 
numpy: 1.19.2 
sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)"><pre class="notranslate"><code class="notranslate">scipy: 1.6.0 
numpy: 1.19.2 
sys.version_info(major=3, minor=8, micro=5, releaselevel='final', serial=0)
</code></pre></div>
<p dir="auto">--&gt;</p>