optimize.tests.test_minpack

Unit tests for optimization routines from minpack.py.

Module Contents

Classes

ReturnShape(self,shape) This class exists to create a callable that does not have a ‘__name__’ attribute.
TestFSolve()
TestRootHybr()
TestRootLM()
TestLeastSq()
TestCurveFit()
TestFixedPoint()

Functions

dummy_func(x,shape) A function that returns an array of ones of the given shape.
pressure_network(flow_rates,Qtot,k) Evaluate non-linear equation system representing
pressure_network_jacobian(flow_rates,Qtot,k) Return the jacobian of the equation system F(flow_rates)
pressure_network_fun_and_grad(flow_rates,Qtot,k)
class ReturnShape(shape)

This class exists to create a callable that does not have a ‘__name__’ attribute.

__init__ takes the argument ‘shape’, which should be a tuple of ints. When an instance it called with a single argument ‘x’, it returns numpy.ones(shape).

__init__(shape)
__call__(x)
dummy_func(x, shape)

A function that returns an array of ones of the given shape. x is ignored.

pressure_network(flow_rates, Qtot, k)

Evaluate non-linear equation system representing the pressures and flows in a system of n parallel pipes:

f_i = P_i - P_0, for i = 1..n
f_0 = sum(Q_i) - Qtot

Where Q_i is the flow rate in pipe i and P_i the pressure in that pipe. Pressure is modeled as a P=kQ**2 where k is a valve coefficient and Q is the flow rate.

flow_rates : float
A 1D array of n flow rates [kg/s].
k : float
A 1D array of n valve coefficients [1/kg m].
Qtot : float
A scalar, the total input flow rate [kg/s].
F : float
A 1D array, F[i] == f_i.
pressure_network_jacobian(flow_rates, Qtot, k)

Return the jacobian of the equation system F(flow_rates) computed by pressure_network with respect to flow_rates. See pressure_network for the detailed description of parrameters.

jac : float
n by n matrix df_i/dQ_i where n = len(flow_rates) and f_i and Q_i are described in the doc for pressure_network
pressure_network_fun_and_grad(flow_rates, Qtot, k)
class TestFSolve
test_pressure_network_no_gradient()
test_pressure_network_with_gradient()
test_wrong_shape_func_callable()
test_wrong_shape_func_function()
test_wrong_shape_fprime_callable()
test_wrong_shape_fprime_function()
test_float32()
class TestRootHybr
test_pressure_network_no_gradient()
test_pressure_network_with_gradient()
test_pressure_network_with_gradient_combined()
class TestRootLM
test_pressure_network_no_gradient()
class TestLeastSq
setup_method()
residuals(p, y, x)
test_basic()
test_full_output()
test_input_untouched()
test_wrong_shape_func_callable()
test_wrong_shape_func_function()
test_wrong_shape_Dfun_callable()
test_wrong_shape_Dfun_function()
test_float32()
class TestCurveFit
setup_method()
test_one_argument()
test_two_argument()
test_func_is_classmethod()
test_regression_2639()
test_pcov()
test_array_like()
test_indeterminate_covariance()
test_NaN_handling()
test_method_argument()
test_bounds()
test_bounds_p0()
test_jac()
test_maxfev_and_bounds()
test_curvefit_simplecovariance()
test_curvefit_covariance()
class TestFixedPoint
test_scalar_trivial()
test_scalar_basic1()
test_scalar_basic2()
test_array_trivial()
test_array_basic1()
test_array_basic2()
test_lambertw()
test_no_acceleration()