o
    h                     @   sN   d dl Z d dlZd dlmZ d dlmZ edg dddgZG dd	 d	ZdS )
    N)assert_equal)_make_tuple_bunchResult)xyzwbetac                   @   sz  e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zejd%d&d'gd(gfd)d*gd+gfd)d'gd,gfgd-d. Zejd%d)g d/d+gfd)d'd(gd(d+gfgd0d1 Zejd%d)d2gd+gfd)d'gd3gfgd4d5 Zejd%d)d6gd+gfd)d'gd7gfd8d'gd+gfgd9d: Zd;d< Zd=S )>TestMakeTupleBunchc                 C   s   t dddddd| _d S )N         c         ?r   r   r   r   r	   )r   resultself r   O/var/www/vscode/kcb/lib/python3.10/site-packages/scipy/_lib/tests/test_bunch.pysetup_method   s   zTestMakeTupleBunch.setup_methodc                 C   sJ   t | jjd t | jjd t | jjd t | jjd t | jjd d S )Nr   r   r   r   r   )r   r   r   r   r   r   r	   r   r   r   r   test_attribute_access   s
   z(TestMakeTupleBunch.test_attribute_accessc                 C   s~   t | jd d t | jd d t | jd d t | jd d tjtdd | jd  W d    d S 1 s8w   Y  d S )Nr   r   r   r   zindex out of rangematch)r   r   pytestraises
IndexErrorr   r   r   r   test_indexing   s   "z TestMakeTupleBunch.test_indexingc                 C   s,   | j \}}}t|||fd t| j d d S Nr   r   r   )r   r   )r   x0y0z0r   r   r   test_unpacking%   s   z!TestMakeTupleBunch.test_unpackingc                 C   sD   t | jdd  d t | jd d d d t | jd d d d d S )Nr   )r   r   r   )r   r   r   )r   r   r   )r   r   r   r   r   r   
test_slice*   s   zTestMakeTupleBunch.test_slicec                 C   s   t t| jd d S )Nr   )r   lenr   r   r   r   r   test_len/   s   zTestMakeTupleBunch.test_lenc                 C   s   t | j}t|d d S )Nz%Result(x=1, y=2, z=3, w=99, beta=0.5))reprr   r   )r   sr   r   r   	test_repr2   s   
zTestMakeTupleBunch.test_reprc                 C   s   t t| jtd d S r   )r   hashr   r   r   r   r   	test_hash6   s   zTestMakeTupleBunch.test_hashc                 C   sx   t | j}t |}t|tsJ t|j| jj t|j| jj t|j	| jj	 t|j
| jj
 t|j| jj d S )N)pickledumpsr   loads
isinstancer   r   r   r   r   r   r	   )r   r)   objr   r   r   test_pickle9   s   
zTestMakeTupleBunch.test_picklec                 C   s<   t jtdd d| j_W d    d S 1 sw   Y  d S )Nzcan't set attributer   r   )r   r   AttributeErrorr   r   r   r   r   r   test_read_only_existingC   s   
"z*TestMakeTupleBunch.test_read_only_existingc                 C   s   d| j _| j jdksJ d S )Nzlattice of coincidence)r   plate_of_shrimpr   r   r   r   test_read_only_newG   s   z%TestMakeTupleBunch.test_read_only_newc                 C   sD   t jtdd tddddd W d    d S 1 sw   Y  d S )Nmissingr   r   r   r         ?)r   r   r   r	   r   r   	TypeErrorr   r   r   r   r   "test_constructor_missing_parameterK   s   "z5TestMakeTupleBunch.test_constructor_missing_parameterc              	   C   sH   t jtdd tddddddd	 W d    d S 1 sw   Y  d S )
N
unexpectedr   r   r   r   {   r8   i  )r   r   r   r   r	   foor9   r   r   r   r   $test_constructor_incorrect_parameterP   s   "z7TestMakeTupleBunch.test_constructor_incorrect_parameterc                 C   s"   d}t tj| t | jj| d S )Nzscipy._lib.tests.test_bunch)r   r   
__module__r   )r   mr   r   r   test_moduleU   s   zTestMakeTupleBunch.test_modulec                 C   s|   t dddddd}t ddd	d
dd}t|jd t|jd t|d d  d t|jd
 t|jd t|d d  d d S )Nr   r   r   r   g        r            r   g      ?r    )rC   rD   rE   )r   r   r   r	   )r   result1result2r   r   r   test_extra_fields_per_instanceZ   s   z1TestMakeTupleBunch.test_extra_fields_per_instancec                 C   sH   t dddg}|ddd}t|jd t|jd t|}t|d d S )NSquarewidthheightr   r   )rJ   rK   zSquare(width=1, height=2))r   r   rJ   rK   r(   )r   rI   sqr)   r   r   r   "test_extra_field_names_is_optionalm   s   z5TestMakeTupleBunch.test_extra_field_names_is_optionalc                 C   s>   t dddg}|ddd}t|tsJ t|d tsJ d S )NTupabr   r   )rO   rP   )r   )r   r0   tuple)r   rN   tur   r   r   test_tuple_likeu   s   z"TestMakeTupleBunch.test_tuple_likec                 C   sD   d}t ddgddg|d}|ddd	d
}t|j| t|j| d S )Nzsome.module.nameFoor   rO   rP   )moduler   ic  q   )r   rO   rP   )r   r   r@   )r   rA   rT   r>   r   r   r   test_explicit_module{   s
   z'TestMakeTupleBunch.test_explicit_moduleargs123rO   rP   rT   z-3r   z+-*/c                 C   <   t jtdd t|  W d    d S 1 sw   Y  d S )Nidentifiersr   r   r   
ValueErrorr   r   rX   r   r   r   test_identifiers_not_allowed      
"z/TestMakeTupleBunch.test_identifiers_not_allowed)rO   rP   rO   c                 C   rZ   )N	Duplicater   r\   r^   r   r   r   test_repeated_field_names      
"z,TestMakeTupleBunch.test_repeated_field_names_a_xc                 C   rZ   )N
underscorer   r\   r^   r   r   r   #test_leading_underscore_not_allowed   rc   z6TestMakeTupleBunch.test_leading_underscore_not_alloweddeforandc                 C   rZ   )Nkeywordr   r\   r^   r   r   r   "test_keyword_not_allowed_in_fields   r`   z5TestMakeTupleBunch.test_keyword_not_allowed_in_fieldsc                 C   sD   t jtdd tdg ddg W d    d S 1 sw   Y  d S )Nzat least one namer   QwertyrO   rP   r\   r   r   r   r   %test_at_least_one_field_name_required   s   "z8TestMakeTupleBunch.test_at_least_one_field_name_requiredN)__name__r@   __qualname__r   r   r   r$   r%   r'   r*   r,   r2   r4   r6   r;   r?   rB   rH   rM   rS   rW   r   markparametrizer_   rb   rg   rl   rn   r   r   r   r   r
      sL    




r
   )r   r-   numpy.testingr   scipy._lib._bunchr   r   r
   r   r   r   r   <module>   s    