o
    1ήc                     @   sp   d Z ddlZddlZddlZejjjZejjjZG dd dZ	G dd dZ
ejdg dG d	d
 d
ZdS )zQ
Tests of the ._exceptions module. Primarily for exercising the __str__ methods.
    Nc                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestArrayMemoryErrorc                 C   s6   t dttj}tt|}|j|jksJ dS )z, Test that _ArrayMemoryError can be pickled   N)_ArrayMemoryErrornpdtypeuint8pickleloadsdumps_total_size)selferrorres r   H/tmp/pip-target-vg8gfxp4/lib/python/numpy/core/tests/test__exceptions.pytest_pickling   s   z"TestArrayMemoryError.test_picklingc                 C   s   t dttj}t| d S )Nr   )r   r   r   r   strr   er   r   r   test_str   s   zTestArrayMemoryError.test_strc                 C   s>  t j}d}|ddksJ |ddksJ |ddksJ ||dks%J ||d dks/J |d	| d
ks9J |td| dksEJ |td| dksQJ |td| dks]J ||| dksgJ |t|| | d dkswJ ||| | | | | dksJ ||| | | | | d dksJ dS )z Test e._size_to_string    r   z0 bytes   z1 bytesr   z
1023 bytesz1.00 KiB
   z10.0 KiBg33333;@z999. KiBg33333@z	1023. KiBg     @z1.00 MiBgH.?z1.00 GiBz1.00 EiBi@ z123456. EiBN)r   _size_to_stringint)r   fKir   r   r   test__size_to_string   s    $,z)TestArrayMemoryError.test__size_to_stringc                 C   sH   t dttj}|jdksJ t dttjdf}|jdks"J dS )z Test e._total_size )r   r   )         r   N)r   r   r   r   r   uint64r   r   r   r   test__total_size/   s   z%TestArrayMemoryError.test__total_sizeN)__name__
__module____qualname__r   r   r   r#   r   r   r   r   r      s
    r   c                   @   s   e Zd Zdd ZdS )TestUFuncNoLoopErrorc                 C   s   t ttts
J dS )z, Test that _UFuncNoLoopError can be pickled N)
isinstancer	   r   _UFuncNoLoopErrorbytes)r   r   r   r   r   9   s   z"TestUFuncNoLoopError.test_picklingN)r$   r%   r&   r   r   r   r   r   r'   8   s    r'   args))r   r   N)r   r   test_prefix)ztest messagec                   @   s   e Zd Zdd Zdd ZdS )TestAxisErrorc                 C   s`   t j| }t|dkr|jdu sJ |jdu sJ dS |^}}}|j|ks'J |j|ks.J dS )zValidate attribute types.r   N)r   	AxisErrorlenaxisndim)r   r+   excr0   r1   _r   r   r   	test_attrD   s   

zTestAxisError.test_attrc                 C   s`   t j| }tt|}t|t|u sJ dD ]}t||}t||}||ks-J |qdS )z%Test that `AxisError` can be pickled.)r0   r1   r+   N)r   r.   r	   r
   r   typegetattr)r   r+   r2   exc2nameattr1attr2r   r   r   r   O   s   


zTestAxisError.test_picklingN)r$   r%   r&   r4   r   r   r   r   r   r-   >   s    r-   )__doc__r	   pytestnumpyr   core_exceptionsr   r)   r   r'   markparametrizer-   r   r   r   r   <module>   s    

+