get_method

sherpa.astro.ui.get_method(name: str | None = None) OptMethod

Return an optimization method.

Parameters:

name (str, optional) – If not given, the current method is returned, otherwise it should be one of the names returned by the list_methods function.

Returns:

method – An object representing the optimization method.

Return type:

object

Raises:

sherpa.utils.err.ArgumentErr – If the name argument is not recognized.

See also

get_method_opt

Get the options for the current optimization method.

list_methods

List the supported optimization methods.

set_method

Change the optimization method.

set_method_opt

Change an option of the current optimization method.

Examples

The fields of the object returned by get_method can be used to view or change the method options.

>>> method = ui.get_method()
>>> print(method.name)
levmar
>>> print(method)
name    = levmar
ftol    = 1.19209289551e-07
xtol    = 1.19209289551e-07
gtol    = 1.19209289551e-07
maxfev  = None
epsfcn  = 1.19209289551e-07
factor  = 100.0
verbose = 0
>>> method.maxfev = 5000