← Back
Editing: test_optimize.cpython-311.pyc
� d�c�� � � � d Z ddlZddlZddlZddlmZmZmZm Z m Z mZmZ ddl Z ddl mZ ddlmZ ddlmZmZ ddlmZmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlm Z m!Z! dd l"m#Z#m$Z$ d� Z% G d� d� � Z& G d� de&� � Z'd� Z(d� Z)d� Z*d� Z+d� Z,d� Z-d� Z.d� Z/d� Z0 G d� de'� � Z1 G d� de'� � Z2 G d � d!e'� � Z3 G d"� d#e'� � Z4 G d$� d%e&� � Z5e j6 �7 d&g d'�� � d(� � � Z8 G d)� d*� � Z9 G d+� d,� � Z:d-� Z; G d.� d/� � Z<d0� Z=d1� Z>d2� Z?d3� Z@ G d4� d5� � ZAd6� ZBd7� ZCd8� ZDd9d:gZEd;d<gZFd=ZGd>� ZH G d?� d@� � ZIdA� ZJdB� ZKdC� ZLdD� ZM G dE� dF� � ZNdG� ZO G dH� dI� � ZPdJ� ZQ G dK� dL� � ZRe jS dM� � � ZTdN� ZUdO� ZVdP� ZWdQ� ZXdR� ZY eY� � ZZe j6 �[ dS� � e j6 �7 d&eZdT � � e j6 �7 dUeZdU � � e j6 �7 dVeZdW � � e j6 �7 dXeZdX � � e j6 �7 dYeZdZ � � d[� � � � � � � � � � � � � Z\e j6 �7 d&eZdT � � d\� � � Z]d]� Z^d^� Z_d_� Z`d`� Za G da� db� � Zbdc� Zcdd� ZddS )ez� Unit tests for optimization routines from optimize.py Authors: Ed Schofield, Nov 2005 Andrew Straw, April 2008 To run it in its simplest form:: nosetests test_optimize.py � N)�assert_allclose�assert_equal�assert_almost_equal�assert_no_warnings�assert_warns�assert_array_less�suppress_warnings)�raises)�optimize)�Bounds�NonlinearConstraint)�MINIMIZE_METHODS�MINIMIZE_SCALAR_METHODS)�LINPROG_METHODS)�ROOT_METHODS)�ROOT_SCALAR_METHODS)�QUADRATIC_ASSIGNMENT_METHODS)�ScalarFunction� FD_METHODS)� MemoizeJac�show_optionsc �v � d� } d� }t j dg� � }t j | ||� � }t |d� � t j | ||dd�� � }t |d� � t j | ||d� � � }t |d� � t j | ||ddd� � � }t |d� � t t j | ||d� � � dz � � }|dk sJ �t t j | ||ddd� � � dz � � }|dk sJ �d � }d� }t j ddd� � }t j |||dd�� � }t |d� � t t t j |||dd�� � t j t t t dd�� � }|dk sJ �d S )Nc �8 � ddt j | � � z z S �N� ��np�exp��xs �D/usr/lib/python3/dist-packages/scipy/optimize/tests/test_optimize.py�expitztest_check_grad.<locals>.expit% s � ��A����r� � �N�#�#� c �d � t j | � � dt j | � � z dz z S �Nr � r r s r! � der_expitz"test_check_grad.<locals>.der_expit( s* � ��v�q�b�z�z�Q�������^�a�/�/�/r# � �?r �random�� )� direction�seed���ư>)�epsilon)r. r+ r, 皙�����?�H�����z>c �T � | t j | � � z � � � S �N)r �sin�sumr s r! �x_sinxztest_check_grad.<locals>.x_sinx@ s � ��"�&��)�)�� � �"�"�"r# c �Z � t j | � � | t j | � � z z S r2 �r r3 �cosr s r! � der_x_sinxz#test_check_grad.<locals>.der_x_sinxC s! � ��v�a�y�y�1�R�V�A�Y�Y�;�&�&r# r&