U
    Cvf¬	  ã                   @  sÌ   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
mZ d dlZd dlmZ d dlmZmZ eejfZerŠe	d Ze
ee d	f ZG d
d„ dƒZdddœdd„Zdddœdd„Zdd„ Zdd„ ZdS )é    )Úannotations)Úimport_module)Ú
ModuleType)ÚTYPE_CHECKINGÚAnyÚLiteralÚTupleÚTypeN)ÚVersion)Úis_duck_arrayÚmodule_available)ÚdaskÚpintÚcupyÚsparse.c                   @  sB   e Zd ZU dZded< ded< ded< ded	< d
ddœdd„ZdS )ÚDuckArrayModulezß
    Solely for internal isinstance and version checks.

    Motivated by having to only import pint when required (as pint currently imports xarray)
    https://github.com/pydata/xarray/pull/5561#discussion_r664815718
    zModuleType | NoneÚmoduler
   ÚversionÚDuckArrayTypesÚtypeÚboolÚ	availableÚModTypeÚNone©ÚmodÚreturnc                 C  s°   d }zft |ƒ}t|jƒ}|dkr.t dƒjf}n:|dkr@|jf}n(|dkrR|jf}n|dkrd|jf}nt‚W n$ tk
rŽ   d }tdƒ}d}Y nX || _	|| _
|| _|d k	| _d S )Nr   z
dask.arrayr   r   r   z0.0.0© )r   r
   Ú__version__ÚArrayZQuantityZndarrayZSparseArrayÚNotImplementedErrorÚImportErrorr   r   r   r   )Úselfr   Zduck_array_moduleZduck_array_versionZduck_array_typer   r   ú8/tmp/pip-unpacked-wheel-h316xyqg/xarray/core/pycompat.pyÚ__init__    s*    




zDuckArrayModule.__init__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú__annotations__r$   r   r   r   r#   r      s   
r   r   r   r   c                 C  s
   t | ƒjS )z3Quick wrapper to get the array class of the module.)r   r   ©r   r   r   r#   Ú
array_type>   s    r+   r
   c                 C  s
   t | ƒjS )z/Quick wrapper to get the version of the module.)r   r   r*   r   r   r#   Úmod_versionC   s    r,   c                 C  s    t dƒrddlm} || ƒS dS )Nr   r   )Úis_dask_collectionF)r   Z	dask.baser-   )Úxr-   r   r   r#   r-   H   s    r-   c                 C  s   t | ƒot| ƒS )N)r   r-   )r.   r   r   r#   Úis_duck_dask_arrayP   s    r/   )Ú
__future__r   Ú	importlibr   Útypesr   Útypingr   r   r   r   r	   ZnumpyÚnpZpackaging.versionr
   Zxarray.core.utilsr   r   ÚintÚintegerÚinteger_typesr   r   r   r+   r,   r-   r/   r   r   r   r#   Ú<module>   s   
+