Repository: scipy/scipy

Issue:
scipy.optimize.fmin_bfgs documentation needs updating
The [documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fmin_bfgs.html) mentions that with `retall=True` the return will include OptimizationResults.  When run, the code behaves differently:

```python
>>> fmin_bfgs(rosen, (0,0,0), retall=True)
(array([ 0.99999732,  0.99999462,  0.99998923]),
 [array([0, 0, 0]),
  array([  2.09501851e-02,   2.09501695e-02,  -1.56091044e-08]),
  array([ 0.2208026 ,  0.02729313,  0.00397084]),
  array([  2.22555523e-01,   2.74968004e-02,   7.03149370e-05]),
  array([ 0.26073342,  0.04075589,  0.00224016]),
  array([ 0.28984301,  0.0620206 ,  0.00309347]),
  array([ 0.35581717,  0.10877849,  0.00813283]),
  array([ 0.47681982,  0.20921535,  0.0273798 ]),
  array([ 0.56861512,  0.3390795 ,  0.07684598]),
  array([ 0.62532321,  0.38169266,  0.10536257]),
  array([ 0.63119477,  0.38675609,  0.13325103]),
  array([ 0.69081077,  0.46481491,  0.20935697]),
  array([ 0.77348053,  0.58905893,  0.32507236]),
  array([ 0.78850168,  0.64107791,  0.40566935]),
  array([ 0.84831148,  0.72244888,  0.50368372]),
  array([ 0.86901568,  0.74032163,  0.54986425]),
  array([ 0.89104549,  0.78482893,  0.60777836]),
  array([ 0.89768663,  0.81220331,  0.65403176]),
  array([ 0.93326622,  0.87168118,  0.74614417]),
  array([ 0.93770033,  0.87661227,  0.76369004]),
  array([ 0.95761356,  0.91412639,  0.83338952]),
  array([ 0.97915317,  0.95810126,  0.91504748]),
  array([ 0.98712875,  0.97587607,  0.95270796]),
  array([ 0.99535325,  0.99129005,  0.9819492 ]),
  array([ 0.99917515,  0.99819472,  0.99610454]),
  array([ 0.99966018,  0.99924902,  0.9984712 ]),
  array([ 1.00003947,  1.00007811,  1.00014926]),
  array([ 0.99999531,  0.99999088,  0.99998279]),
  array([ 0.99999732,  0.99999462,  0.99998923])])
```
The return is a tuple where the first element is the accepted value of `x` and the second is the history as numpy arrays, not OptimizationResults.
scipy.optimize.fmin_bfgs documentation needs updating
The [documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fmin_bfgs.html) mentions that with `retall=True` the return will include OptimizationResults.  When run, the code behaves differently:

```python
>>> fmin_bfgs(rosen, (0,0,0), retall=True)
(array([ 0.99999732,  0.99999462,  0.99998923]),
 [array([0, 0, 0]),
  array([  2.09501851e-02,   2.09501695e-02,  -1.56091044e-08]),
  array([ 0.2208026 ,  0.02729313,  0.00397084]),
  array([  2.22555523e-01,   2.74968004e-02,   7.03149370e-05]),
  array([ 0.26073342,  0.04075589,  0.00224016]),
  array([ 0.28984301,  0.0620206 ,  0.00309347]),
  array([ 0.35581717,  0.10877849,  0.00813283]),
  array([ 0.47681982,  0.20921535,  0.0273798 ]),
  array([ 0.56861512,  0.3390795 ,  0.07684598]),
  array([ 0.62532321,  0.38169266,  0.10536257]),
  array([ 0.63119477,  0.38675609,  0.13325103]),
  array([ 0.69081077,  0.46481491,  0.20935697]),
  array([ 0.77348053,  0.58905893,  0.32507236]),
  array([ 0.78850168,  0.64107791,  0.40566935]),
  array([ 0.84831148,  0.72244888,  0.50368372]),
  array([ 0.86901568,  0.74032163,  0.54986425]),
  array([ 0.89104549,  0.78482893,  0.60777836]),
  array([ 0.89768663,  0.81220331,  0.65403176]),
  array([ 0.93326622,  0.87168118,  0.74614417]),
  array([ 0.93770033,  0.87661227,  0.76369004]),
  array([ 0.95761356,  0.91412639,  0.83338952]),
  array([ 0.97915317,  0.95810126,  0.91504748]),
  array([ 0.98712875,  0.97587607,  0.95270796]),
  array([ 0.99535325,  0.99129005,  0.9819492 ]),
  array([ 0.99917515,  0.99819472,  0.99610454]),
  array([ 0.99966018,  0.99924902,  0.9984712 ]),
  array([ 1.00003947,  1.00007811,  1.00014926]),
  array([ 0.99999531,  0.99999088,  0.99998279]),
  array([ 0.99999732,  0.99999462,  0.99998923])])
```
The return is a tuple where the first element is the accepted value of `x` and the second is the history as numpy arrays, not OptimizationResults.


Discussion:
This is bug 2/3 extracted from #8373 
This is bug 2/3 extracted from #8373 

Resolving patch:
diff --git a/scipy/optimize/optimize.py b/scipy/optimize/optimize.py
--- a/scipy/optimize/optimize.py
+++ b/scipy/optimize/optimize.py
@@ -880,7 +880,7 @@ def fmin_bfgs(f, x0, fprime=None, args=(), gtol=1e-5, norm=Inf,
         1 : Maximum number of iterations exceeded.
         2 : Gradient and/or function calls not changing.
     allvecs  :  list
-        `OptimizeResult` at each iteration.  Only returned if retall is True.
+        The value of xopt at each iteration.  Only returned if retall is True.
 
     See also
     --------


Test patch: