U
    #c                  	   @  s   d Z ddlmZ ddlZddlZddlmZ ddlZddlZ	ddl
mZ G dd dZG dd	 d	Zejjejd
k ddejde	je	je	je	je	jgG dd dZejjejd
kddddddZdS )z
This file tests the generic aspects of ArrayMethod.  At the time of writing
this is private API, but when added, public API may be added here.
    )annotationsN)Any)_get_castingimplc                   @  sd   e Zd ZeeedeedZej	
dddddeddffedd	ffgd
d Zd	S )TestResolveDescriptorsdfargsTN)NNN)NNTNc              	   C  s&   t t | jj|  W 5 Q R X d S r
   )pytestraises	TypeErrormethodZ_resolve_descriptors)selfr    r   E/tmp/pip-unpacked-wheel-b2rbor69/numpy/core/tests/test_arraymethod.pytest_invalid_arguments   s    	z-TestResolveDescriptors.test_invalid_arguments)__name__
__module____qualname__get_castingimpltypenpdtyper   r   markparametrizer   r   r   r   r   r      s   r   c                   @  s   e Zd ZeeedeedZej	
ddgdefdefdefdefed	ed	ffefejd	d
dejd	ddffefejdddejdddffefejd	ddejdddffefejdddejdddffefg	dd ZdS )TestSimpleStridedCallr   r   r   errorr	   )r
   r   r      z>d)r   z<f)   r!      s    x00 x00 x00 x00 x00 x00s    x00 x00 x00c              	   C  s&   t | | jj|  W 5 Q R X d S r
   )r   r   r   Z_simple_strided_call)r   r   r   r   r   r   r   -   s    z,TestSimpleStridedCall.test_invalid_argumentsN)r   r   r   r   r   r   r   r   r   r   r   r   ZarangeZones
ValueErrorZ
frombufferr   r   r   r   r   r   &   s.   r   )r    	   zRequires python 3.9)reasonclsc                   @  s@   e Zd ZdddddZejdeddddd	d
dZdS )TestClassGetItemztype[np.ndarray]None)r&   returnc                 C  s.   |t t f }t|tjst|j|ks*tdS )z!Test `ndarray.__class_getitem__`.N)r   
isinstancetypesZGenericAliasAssertionError
__origin__)r   r&   aliasr   r   r   test_class_getitemH   s    z#TestClassGetItem.test_class_getitemarg_lenr"   int)r&   r0   r)   c              	   C  s^   t f| }|dkr || sZtn:d|dkr.dnd d}tjt|d ||  W 5 Q R X d S )N)   r!   zToo r   fewmanyz
 argumentsmatch)r   r,   r   r   r   )r   r&   r0   Zarg_tupr6   r   r   r   test_subscript_tupN   s    
z#TestClassGetItem.test_subscript_tupN)	r   r   r   r/   r   r   r   ranger7   r   r   r   r   r'   C   s   r'   zRequires python 3.8r(   )r)   c               	   C  s0   d} t jt| d tjttf  W 5 Q R X d S )Nz(Type subscription requires python >= 3.9r5   )r   r   r   r   ndarrayr   r5   r   r   r   test_class_getitem_38Y   s    r:   )__doc__
__future__r   sysr+   typingr   r   Znumpyr   Znumpy.core._multiarray_umathr   r   r   r   r   Zskipifversion_infor   r9   ZrecarrayZ	chararrayZmatrixZmemmapr'   r:   r   r   r   r   <module>   s"    