Repository: scipy/scipy

Issue:
Documentation of 'hybr' and 'lm' inconsistent in optimize.root
'lm':
http://docs.scipy.org/doc/scipy/reference/optimize.root-lm.html#optimize-root-lm

options contain `func` which I guess is redundant since `fun` is already in the signature of `root()`.
The user really should not be allowed to specify both `fun` and `func`

'hybr':
http://docs.scipy.org/doc/scipy/reference/optimize.root-hybr.html#optimize-root-hybr

same thing applies here, and here the documentation talks about a parameter `fprime`
https://github.com/scipy/scipy/blob/master/scipy/optimize/minpack.py#L176

which is not visible in the signature in the documentation (another name for the Jacobian callback `jac`).

EDIT: furthermore, `hybr` has an undocumented option `full_output`



Discussion:
The `full_output` option for `'hybr'` was fixed in gh-5373. The other things look straightforward, adding easy-fix label.

do we only need to edit the "func" to "fun" at all the places it is used in the optimize.root.py file.

Being a newbie would be good to start to contribute  to this project.

So which files are to be changed here?

If you see the text in the html docs, you can search for that:

```
$ grin "Solve for least squares with Levenberg-Marquardt"
./scipy/optimize/_root.py:
  216 :     Solve for least squares with Levenberg-Marquardt
```

I got the same page, but I couldn't find how the documentation is generating this function definition:

`scipy.optimize.root(fun, x0, args=(), method='lm', jac=None, tol=None, callback=None, 
options={'col_deriv': 0, 'diag': None, 'factor': 100, 'gtol': 0.0, 'eps': 0.0, 'func': None, 'maxiter': 0, 'xtol': 1.49012e-08, 'ftol': 1.49012e-08})`

cf https://github.com/scipy/scipy/blob/master/doc/source/scipyoptdoc.py

Internal solver parameters (such as func probably) should be changed to add a prefix `_`  in the `_minimize_*` functions so that they don't appear in the documentation.

Or more precisely, it should be fixed just by renaming `func` -> `fun` in the `_root_lm` function.


Resolving patch:
diff --git a/scipy/optimize/_root.py b/scipy/optimize/_root.py
--- a/scipy/optimize/_root.py
+++ b/scipy/optimize/_root.py
@@ -208,7 +208,7 @@ def _warn_jac_unused(jac, method):
              RuntimeWarning)
 
 
-def _root_leastsq(func, x0, args=(), jac=None,
+def _root_leastsq(fun, x0, args=(), jac=None,
                   col_deriv=0, xtol=1.49012e-08, ftol=1.49012e-08,
                   gtol=0.0, maxiter=0, eps=0.0, factor=100, diag=None,
                   **unknown_options):
@@ -243,7 +243,7 @@ def _root_leastsq(func, x0, args=(), jac=None,
     """
 
     _check_unknown_options(unknown_options)
-    x, cov_x, info, msg, ier = leastsq(func, x0, args=args, Dfun=jac,
+    x, cov_x, info, msg, ier = leastsq(fun, x0, args=args, Dfun=jac,
                                        full_output=True,
                                        col_deriv=col_deriv, xtol=xtol,
                                        ftol=ftol, gtol=gtol,
@@ -256,7 +256,7 @@ def _root_leastsq(func, x0, args=(), jac=None,
     return sol
 
 
-def _root_nonlin_solve(func, x0, args=(), jac=None,
+def _root_nonlin_solve(fun, x0, args=(), jac=None,
                        _callback=None, _method=None,
                        nit=None, disp=False, maxiter=None,
                        ftol=None, fatol=None, xtol=None, xatol=None,
@@ -284,12 +284,12 @@ def _root_nonlin_solve(func, x0, args=(), jac=None,
     if args:
         if jac:
             def f(x):
-                return func(x, *args)[0]
+                return fun(x, *args)[0]
         else:
             def f(x):
-                return func(x, *args)
+                return fun(x, *args)
     else:
-        f = func
+        f = fun
 
     x, info = nonlin.nonlin_solve(f, x0, jacobian=jacobian(**jac_options),
                                   iter=nit, verbose=verbose,


Test patch: