HOME


sh-3ll 1.0
DIR:/usr/local/lib/python3.6/site-packages/xarray/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/xarray/__pycache__/ufuncs.cpython-36.pyc
3

���h��@s�dZddlZddlmZddlmZddl	m
Zddlm
ZddlmZdd	lmZeeeefZejefeZd
d�Zdd
�Zdj�ZxeD]Zee�e�e<q�WdS)arxarray specific universal functions

Handles unary and binary operations for the following types, in ascending
priority order:
- scalars
- numpy.ndarray
- dask.array.Array
- xarray.Variable
- xarray.DataArray
- xarray.Dataset
- xarray.core.groupby.GroupBy

Once NumPy 1.10 comes out with support for overriding ufuncs, this module will
hopefully no longer be necessary.
�N�)�Variable)�Dataset)�	DataArray)�GroupBy)�dask_array_type)�_dask_or_eager_funccCs(x"tt�D]\}}t||�r
|Sq
WdS)Nr���)�	enumerate�_dispatch_order�
isinstance)�obj�priority�cls�r�-/tmp/pip-build-5_djhm0z/xray/xarray/ufuncs.py�_dispatch_prioritys
rcs2��fdd����_tt��j}d�|f�_�S)Ncs�|}t��}t|�dks$t|�dkr:tdt|��f��n�t|�dkrdt|dt�r�|dj��}n`tt|�\}}||kr�t|dt�r�|dj��}n,t|dt�r�|dj�dd�}t	t
|��}|||�}|tkr�td�t|d�t|d�f��|S)N�rz!cannot handle %s arguments for %rrT)Z	reflexivez%%r not implemented for types (%r, %r))
r�len�	TypeErrorr�
_xarray_typesZ	_unary_op�maprZ
_binary_op�tuple�reversed�NotImplemented�type)�args�kwargsZnew_args�f�p1�p2�res)�func�namerrr"(s(
z_create_op.<locals>.funcz�xarray specific variant of numpy.%s. Handles xarray.Dataset, xarray.DataArray, xarray.Variable, numpy.ndarray and dask.array.Array objects with automatic dispatching.

Documentation from numpy:

%s)�__name__�getattr�_np�__doc__)r#�docr)r"r#r�
_create_op&sr)a�logaddexp logaddexp2 conj exp log log2 log10 log1p expm1 sqrt
             square sin cos tan arcsin arccos arctan arctan2 hypot sinh cosh
             tanh arcsinh arccosh arctanh deg2rad rad2deg logical_and
             logical_or logical_xor logical_not maximum minimum fmax fmin
             isreal iscomplex isfinite isinf isnan signbit copysign nextafter
             ldexp fmod floor ceil trunc degrees radians rint fix angle real
             imag fabs sign frexp fmod
             )r'Znumpyr&Z
core.variablerZ	_VariableZcore.datasetrZ_DatasetZcore.dataarrayrZ
_DataArrayZcore.groupbyrZ_GroupByZ
core.pycompatrZ_dask_array_typeZcore.opsrrZndarrayrrr)�split�__all__r#�globalsrrrr�<module>s+