o
    ʩZhB'                     @  s  d dl mZ d dlmZmZmZmZmZ er*ddlm	Z	m
Z
mZmZmZ d dlmZ ddlmZ d dlZdd	 Zdddd
dRddZ		dSddddTddZddddUd!d"ZddddVd$d%Z	dWd ddd&dXd,d-ZdYd/d0ZddddZd2d3Zdddd[d4d5Zddd6d7d\d;d<Zd=d>d]dCdDZddddUdEdFZddddVdGdHZ d dId^dJdKZ!d dId^dLdMZ"ddddUdNdOZ#ddddVdPdQZ$dS )_    )annotations)TYPE_CHECKINGListOptionalTupleUnion   )ArrayDeviceDtypeNestedSequenceSupportsBufferProtocol)Sequence)_all_dtypesNc                 C  s$   dt  D ]	}| |u r d S qtd)NNz)dtype must be one of the supported dtypes)r   
ValueError)dtyped r   Z/var/www/html/lang_env/lib/python3.10/site-packages/numpy/array_api/_creation_functions.py_check_valid_dtype   s
   r   )r   devicecopyobjZUnion[Array, bool, int, float, NestedSequence[bool | int | float], SupportsBufferProtocol]r   Optional[Dtype]r   Optional[Device]r   #Optional[Union[bool, np._CopyMode]]returnr	   c               C  s   ddl m} t| |dvrtd||dtjjfv r!tdt| |rG|dur1| j	|kr1d}|dtjj
fv rE|tj| jd|d	S | S |du r\t| tr\| d
ksX| dk r\tdtj| |d}||S )z~
    Array API compatible wrapper for :py:func:`np.asarray <numpy.asarray>`.

    See its docstring for more information.
    r   r	   cpuNUnsupported device Fz!copy=False is not yet implementedNT)r   r   l            l         z&Integer out of bounds for array dtypesr   )_array_objectr	   r   r   npZ	_CopyModeZ	IF_NEEDEDNotImplementedError
isinstancer   ZALWAYS_newarray_arrayintOverflowErrorasarray)r   r   r   r   r	   resr   r   r   r-      s    
"
r-   )r   r   stopOptional[Union[int, float]]stepUnion[int, float]startc               C  B   ddl m} t| |dvrtd||tj| |||dS )z|
    Array API compatible wrapper for :py:func:`np.arange <numpy.arange>`.

    See its docstring for more information.
    r   r   r    r"   )r/   r1   r   )r$   r	   r   r   r(   r%   arange)r3   r/   r1   r   r   r	   r   r   r   r5   K   
   r5   shapeUnion[int, Tuple[int, ...]]c                C  >   ddl m} t| |dvrtd||tj| |dS )zz
    Array API compatible wrapper for :py:func:`np.empty <numpy.empty>`.

    See its docstring for more information.
    r   r   r    r"   r#   )r$   r	   r   r   r(   r%   emptyr7   r   r   r	   r   r   r   r:   a   
   r:   xc               C  @   ddl m} t| |dvrtd||tj| j|dS )z
    Array API compatible wrapper for :py:func:`np.empty_like <numpy.empty_like>`.

    See its docstring for more information.
    r   r   r    r"   r#   )r$   r	   r   r   r(   r%   
empty_liker*   r=   r   r   r	   r   r   r   r?   t   
   r?   )kr   r   n_rowsr+   n_colsOptional[int]rB   c               C  r4   )zv
    Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.

    See its docstring for more information.
    r   r   r    r"   )MrB   r   )r$   r	   r   r   r(   r%   eye)rC   rD   rB   r   r   r	   r   r   r   rG      r6   rG   objectc                C  s   ddl m} |t| S )Nr   r   )r$   r	   r(   r%   from_dlpack)r=   r	   r   r   r   rI      s   rI   
fill_valuec                C  sp   ddl m} t| |dvrtd|t||r"|jdkr"|j}tj| ||d}|j	t
vr3td||S )zx
    Array API compatible wrapper for :py:func:`np.full <numpy.full>`.

    See its docstring for more information.
    r   r   r    r"   r   r#   zInvalid input to full)r$   r	   r   r   r'   ndimr*   r%   fullr   r   	TypeErrorr(   )r7   rJ   r   r   r	   r.   r   r   r   rL      s   

rL   c               C  sX   ddl m} t| |dvrtd|tj| j||d}|jtvr't	d|
|S )z
    Array API compatible wrapper for :py:func:`np.full_like <numpy.full_like>`.

    See its docstring for more information.
    r   r   r    r"   r#   zInvalid input to full_like)r$   r	   r   r   r%   	full_liker*   r   r   rM   r(   )r=   rJ   r   r   r	   r.   r   r   r   rN      s   

rN   T)r   r   endpointnumrO   boolc            	   C  sD   ddl m} t| |dvrtd||tj| ||||dS )z
    Array API compatible wrapper for :py:func:`np.linspace <numpy.linspace>`.

    See its docstring for more information.
    r   r   r    r"   )r   rO   )r$   r	   r   r   r(   r%   linspace)r3   r/   rP   r   r   rO   r	   r   r   r   rR      s
   rR   Zxy)indexingarraysrS   strList[Array]c                   sR   ddl m  tdd |D dkrtd fddtjdd |D d	| iD S )
z
    Array API compatible wrapper for :py:func:`np.meshgrid <numpy.meshgrid>`.

    See its docstring for more information.
    r   r   c                 S  s   h | ]}|j qS r   r#   .0ar   r   r   	<setcomp>       zmeshgrid.<locals>.<setcomp>z,meshgrid inputs must all have the same dtypec                   s   g | ]}  |qS r   )r(   )rX   r)   r   r   r   
<listcomp>   s    zmeshgrid.<locals>.<listcomp>c                 S  s   g | ]}|j qS r   )r*   rW   r   r   r   r\      r[   rS   )r$   r	   lenr   r%   meshgrid)rS   rT   r   r   r   r^      s   
r^   c                C  r9   )zx
    Array API compatible wrapper for :py:func:`np.ones <numpy.ones>`.

    See its docstring for more information.
    r   r   r    r"   r#   )r$   r	   r   r   r(   r%   onesr;   r   r   r   r_      r<   r_   c               C  r>   )z
    Array API compatible wrapper for :py:func:`np.ones_like <numpy.ones_like>`.

    See its docstring for more information.
    r   r   r    r"   r#   )r$   r	   r   r   r(   r%   	ones_liker*   r@   r   r   r   r`     rA   r`   rB   c               C  4   ddl m} | jdk rtd|tj| j|dS )zx
    Array API compatible wrapper for :py:func:`np.tril <numpy.tril>`.

    See its docstring for more information.
    r   r      z)x must be at least 2-dimensional for trilra   )r$   r	   rK   r   r(   r%   trilr*   r=   rB   r	   r   r   r   rd   #     
rd   c               C  rb   )zx
    Array API compatible wrapper for :py:func:`np.triu <numpy.triu>`.

    See its docstring for more information.
    r   r   rc   z)x must be at least 2-dimensional for triura   )r$   r	   rK   r   r(   r%   triur*   re   r   r   r   rg   1  rf   rg   c                C  r9   )zz
    Array API compatible wrapper for :py:func:`np.zeros <numpy.zeros>`.

    See its docstring for more information.
    r   r   r    r"   r#   )r$   r	   r   r   r(   r%   zerosr;   r   r   r   rh   ?  r<   rh   c               C  r>   )z
    Array API compatible wrapper for :py:func:`np.zeros_like <numpy.zeros_like>`.

    See its docstring for more information.
    r   r   r    r"   r#   )r$   r	   r   r   r(   r%   
zeros_liker*   r@   r   r   r   ri   R  rA   ri   )
r   r   r   r   r   r   r   r   r   r	   )Nr   )r/   r0   r1   r2   r3   r2   r   r   r   r   r   r	   )r7   r8   r   r   r   r   r   r	   )r=   r	   r   r   r   r   r   r	   r   )rC   r+   rD   rE   rB   r+   r   r   r   r   r   r	   )r=   rH   r   r	   )
r7   r8   rJ   r2   r   r   r   r   r   r	   )
rJ   r2   r=   r	   r   r   r   r   r   r	   )rP   r+   r3   r2   r/   r2   r   r   r   r   rO   rQ   r   r	   )rT   r	   rS   rU   r   rV   )r=   r	   rB   r+   r   r	   )%
__future__r   typingr   r   r   r   r   Z_typingr	   r
   r   r   r   collections.abcr   Z_dtypesr   numpyr%   r   r-   r5   r:   r?   rG   rI   rL   rN   rR   r^   r_   r`   rd   rg   rh   ri   r   r   r   r   <module>   sj    /

  