U
    Cvf6                  	   @  s  d Z ddlmZ ddlZddlZddlmZmZm	Z	m
Z
mZ ddlmZmZ ddlmZmZmZ ddlmZmZ ddlmZ G d	d
 d
ZG dd deeeeeeZG dd deee
ZG dd deeeeZG dd deeZG dd dee	ZG dd deZdS )z8Base classes implementing arithmetic for xarray objects.    )annotationsN)DataArrayGroupByOpsMixinDataArrayOpsMixinDatasetGroupByOpsMixinDatasetOpsMixinVariableOpsMixin)ImplementsArrayReduceImplementsDatasetReduce)IncludeCumMethodsIncludeNumpySameMethodsIncludeReduceMethods)OPTIONS_get_keep_attrs)is_duck_arrayc                   @  s,   e Zd ZdZdZejeje	e
fZdd ZdS )SupportsArithmeticzpBase class for xarray types that support arithmetic.

    Used by Dataset, DataArray, Variable and GroupBy.
     c           
      O  s   ddl m} |dd}|| D ]&}t|s t|| jtf s t  S q |jd k	r`t	d
||dkrxt	d
||tdd	 |D rt	d
td  }}	||f|d|j d|j ||	tj|dtdddS )Nr   )apply_ufuncoutr   z{} not supported: xarray objects do not directly implement generalized ufuncs. Instead, use xarray.apply_ufunc or explicitly convert to xarray objects to NumPy arrays (e.g., with `.values`).__call__z{} method for ufunc {} is not implemented on xarray objects, which currently only support the __call__ method. As an alternative, consider explicitly converting xarray objects to NumPy arrays (e.g., with `.values`).c                 s  s   | ]}t |tV  qd S )N)
isinstancer   ).0or   r   :/tmp/pip-unpacked-wheel-h316xyqg/xarray/core/arithmetic.py	<genexpr>J   s     z5SupportsArithmetic.__array_ufunc__.<locals>.<genexpr>zxarray objects are not yet supported in the `out` argument for ufuncs. As an alternative, consider explicitly converting xarray objects to NumPy arrays (e.g., with `.values`).Zarithmetic_join)r   allowedT)default)Zinput_core_dimsZoutput_core_dimsjoindataset_joinZdataset_fill_valuekwargsZdaskZ
keep_attrs)Zxarray.core.computationr   getr   r   _HANDLED_TYPESr   NotImplemented	signatureNotImplementedErrorformatanyr   ZninZnoutnpnanr   )
selfZufuncmethodinputsr   r   r   xr   r   r   r   r   __array_ufunc__.   sP    
 


 z"SupportsArithmetic.__array_ufunc__N)__name__
__module____qualname____doc__	__slots__r&   ZgenericnumbersNumberbytesstrr    r,   r   r   r   r   r      s   r   c                   @  s   e Zd ZdZdZdS )VariableArithmeticr   2   Nr-   r.   r/   r1   Z__array_priority__r   r   r   r   r6   d   s   r6   c                   @  s   e Zd ZdZdZdS )DatasetArithmeticr   r7   Nr8   r   r   r   r   r9   q   s   r9   c                   @  s   e Zd ZdZdZdS )DataArrayArithmeticr   <   Nr8   r   r   r   r   r:   z   s   r:   c                   @  s   e Zd ZdZdS )DataArrayGroupbyArithmeticr   Nr-   r.   r/   r1   r   r   r   r   r<      s   r<   c                   @  s   e Zd ZdZdS )DatasetGroupbyArithmeticr   Nr=   r   r   r   r   r>      s   r>   c                   @  s   e Zd ZdZdS )CoarsenArithmeticr   Nr=   r   r   r   r   r?      s   r?   )r0   
__future__r   r2   Znumpyr&   Zxarray.core._typed_opsr   r   r   r   r   Zxarray.core.commonr   r	   Zxarray.core.opsr
   r   r   Zxarray.core.optionsr   r   Zxarray.core.pycompatr   r   r6   r9   r:   r<   r>   r?   r   r   r   r   <module>   sJ   J

	


