a
    hÝEbC'  ã                	   @  s:  d dl mZ d dlmZmZmZmZmZ erTd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
œddddddœdd„ZdKdddœdddddddœdd„Zdddœdddddœdd„Zdddœdddddœdd„ZdLd ddd œd!d"d!dddd#œd$d%„Zd&dd'œd(d)„Zdddœdddddd*œd+d,„Zdddœdddddd-œd.d/„Zddd0d1œd!ddddd2dd3œd4d5„Zd6d7œdd8d9d:œd;d<„Zdddœdddddœd=d>„Zdddœdddddœd?d@„Z d dAœdd!ddBœdCdD„Z!d dAœdd!ddBœdEdF„Z"dddœdddddœdGdH„Z#dddœdddddœdIdJ„Z$dS )Mé    )Ú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ƒ‚d S )N)Nz)dtype must be one of the supported dtypes)r   Ú
ValueError)ÚdtypeÚd© r   úc/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/numpy/array_api/_creation_functions.pyÚ_check_valid_dtype   s    r   )r   ÚdeviceÚcopyzZUnion[Array, bool, int, float, NestedSequence[bool | int | float], SupportsBufferProtocol]zOptional[Dtype]zOptional[Device]z#Optional[Union[bool, np._CopyMode]]r	   )Úobjr   r   r   Úreturnc               C  sÐ   ddl m} t|ƒ |dvr*td|›�ƒ‚|dtjjfv rBtdƒ‚t| |ƒrŽ|durb| j	|krbd}|dtjj
fv rŠ| tj| jd|d	�¡S | S |du r¸t| tƒr¸| d
ks°| 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   zOptional[Union[int, float]]zUnion[int, float])ÚstopÚstepÚstartr   r   r   c               C  sB   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*   r+   r   )r   r	   r   r   r#   r    Úarange)r,   r*   r+   r   r   r	   r   r   r   r-   K   s
    r-   zUnion[int, Tuple[int, ...]])Úshaper   r   r   c                C  s>   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©r.   r   r   r	   r   r   r   r/   a   s
    r/   )Úxr   r   r   c               C  s@   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%   ©r1   r   r   r	   r   r   r   r2   t   s
    r2   )Úkr   r   r&   zOptional[int])Ún_rowsÚn_colsr4   r   r   r   c               C  sB   ddl m} t|ƒ |dvr*td|›�ƒ‚| tj| |||d�¡S )zv
    Array API compatible wrapper for :py:func:`np.eye <numpy.eye>`.

    See its docstring for more information.
    r   r   r   r   )ÚMr4   r   )r   r	   r   r   r#   r    Úeye)r5   r6   r4   r   r   r	   r   r   r   r8   „   s
    r8   Úobject)r1   r   c                C  s   ddl m} | t | ¡¡S )Nr   r   )r   r	   r#   r    Z_from_dlpack)r1   r	   r   r   r   Úfrom_dlpackš   s    r:   )r.   Ú
fill_valuer   r   r   c                C  sp   ddl m} t|ƒ |dvr*td|›�ƒ‚t||ƒrD|jdkrD|j}tj| ||d�}|j	t
vrft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#   )r.   r;   r   r   r	   r)   r   r   r   r=       s    
r=   )r;   r1   r   r   r   c               C  sX   ddl m} t|ƒ |dvr*td|›�ƒ‚tj| j||d�}|jtvrNt	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   r>   r#   )r1   r;   r   r   r	   r)   r   r   r   r?   »   s    
r?   T)r   r   ÚendpointÚbool)Únumr,   r*   r   r   r@   r   c            	   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   r@   )r   r	   r   r   r#   r    Úlinspace)r,   r*   rB   r   r   r@   r	   r   r   r   rC   Õ   s
    rC   Zxy)ÚindexingÚstrzList[Array])ÚarraysrD   r   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#   )rH   r$   r   r   r   Ú
<listcomp>ú   s   ÿzmeshgrid.<locals>.<listcomp>c                 S  s   g | ]
}|j ‘qS r   )r%   rG   r   r   r   rL   ü   rK   rD   )r   r	   Úlenr   r    Úmeshgrid)rD   rF   r   r   r   rN   ì   s    
þrN   c                C  s>   ddl m} t|ƒ |dvr*td|›�ƒ‚| tj| |d�¡S )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    Úonesr0   r   r   r   rO      s
    rO   c               C  s@   ddl m} t|ƒ |dvr*td|›�ƒ‚| tj| j|d�¡S )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%   r3   r   r   r   rP     s
    rP   ©r4   )r1   r4   r   c               C  s4   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 trilrQ   )r   r	   r<   r   r#   r    Útrilr%   ©r1   r4   r	   r   r   r   rS   #  s    
rS   c               C  s4   ddl m} | jdk rtdƒ‚| tj| j|d�¡S )zx
    Array API compatible wrapper for :py:func:`np.triu <numpy.triu>`.

    See its docstring for more information.
    r   r   rR   z)x must be at least 2-dimensional for triurQ   )r   r	   r<   r   r#   r    Útriur%   rT   r   r   r   rU   1  s    
rU   c                C  s>   ddl m} t|ƒ |dvr*td|›�ƒ‚| tj| |d�¡S )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    Úzerosr0   r   r   r   rV   ?  s
    rV   c               C  s@   ddl m} t|ƒ |dvr*td|›�ƒ‚| tj| j|d�¡S )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%   r3   r   r   r   rW   R  s
    rW   )Nr   )N)%Ú
__future__r   Útypingr   r   r   r   r   Z_typingr	   r
   r   r   r   Úcollections.abcr   Z_dtypesr   Únumpyr    r   r(   r-   r/   r2   r8   r:   r=   r?   rC   rN   rO   rP   rS   rU   rV   rW   r   r   r   r   Ú<module>   sh   ó/  üùüÿ þù
û ú øüÿüÿ