o
    g5
                     @   sB   d Z ddlmZ ddlmZ ddlZddlm	Z	 G dd dZ
dS )z5
Unit tests for optimization routines from _root.py.
    )assert_)raisesNrootc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestRootc                 C   s   dd }dd }dD ]T}|dv rq
|dv r|}nd }t |ddg|d	|d
}t |ddg|d|d
}d|||j||jf }t|j| t|j| tt||j t||j k | q
d S )Nc                 S   s&   | \}}t |d d |d d gS N      nparrayzxy r   ]/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/scipy/optimize/tests/test__root.pyfunc      z)TestRoot.test_tol_parameter.<locals>.funcc                 S   s.   | \}}t d|d  dgdd|d  ggS )Nr      r   r
   r   r   r   r   dfunc   s   &z*TestRoot.test_tol_parameter.<locals>.dfunc)hybrlmbroyden1broyden2andersondiagbroydenkrylov)linearmixingexcitingmixing)r   r   皙?g-C6?)jactolmethod      ?z%s: %s vs. %s)r   r   r   successabsmax)selfr   r   r#   r!   sol1sol2msgr   r   r   test_tol_parameter   s"   $zTestRoot.test_tol_parameterc                 C   s2   dd }dD ]}t tjtd|d|id qd S )Nc                 S   s   t | d S Nr   )r&   )r   r   r   r   norm+   s   z$TestRoot.test_tol_norm.<locals>.norm)r   r   r   r   r   r   r   r   tol_norm)r#   options)r   r   
zeros_likezeros)r(   r.   r#   r   r   r   test_tol_norm)   s   zTestRoot.test_tol_normc                 C   s    ddd}t |ddgdd d S )Nr	   c                 S   s&   | \}}t |d d |d | gS r   r
   )r   fr   r   r   r   r   r   ;   r   z=TestRoot.test_minimize_scalar_coerce_args_param.<locals>.funcr    g      ?)args)r	   r   )r(   r   r   r   r   &test_minimize_scalar_coerce_args_param9   s   
z/TestRoot.test_minimize_scalar_coerce_args_paramc                 C   sT   G dd d}| }t t t|ddgdd W d    d S 1 s#w   Y  d S )Nc                   @   s   e Zd Zdd Zdd ZdS )z!TestRoot.test_f_size.<locals>.func                 S   s
   d| _ d S r-   count)r(   r   r   r   __init__E   s   
z*TestRoot.test_f_size.<locals>.fun.__init__c                 S   s   |  j d7  _ | j d s |d d|d |d  d   d }|S |d d|d |d  d   d d|d |d  d  |d  g}|S )Nr	      r   r$   r   g      ?r7   )r(   r   retr   r   r   __call__H   s   
$"z*TestRoot.test_f_size.<locals>.fun.__call__N)__name__
__module____qualname__r9   r<   r   r   r   r   funD   s    r@   g?g        r   )r#   )assert_raises
ValueErrorr   )r(   r@   Fr   r   r   test_f_size@   s
   
"zTestRoot.test_f_sizeN)r=   r>   r?   r,   r3   r6   rD   r   r   r   r   r      s
    r   )__doc__numpy.testingr   pytestr   rA   numpyr   scipy.optimizer   r   r   r   r   r   <module>   s    