U
    Cvf                     @  sr   d dl mZ d dlZd dlZd dlZd dlZe	dZ
ejdd Zdddd	Zddd
dZddddZdS )    )annotationsNZcupyc                  C  s   t jd tjdddd} t dt j | jjd d  }d	d
|	dd  }|dt j
|jd  }|d	 dt j
|jd  }td|fd|fd| dddgd}t|jj|j_t|jj|j_|S )zConstruct the example DataSet from the Toy weather data example.

    https://docs.xarray.dev/en/stable/examples/weather-data.html

    Here we construct the DataSet exactly as shown in the example and then
    convert the numpy arrays to cupy.

    {   z
2000-01-01z
2001-12-31time)name   g     v@gQ?
            )r   location)tmintmaxZIAINZIL)nprandomseedpdZ
date_rangesinpiZ	dayofyearvaluesZreshapeZrandnsizexrZDatasetcpZasarrayr   datar   )timesZannual_cyclebaseZtmin_valuesZtmax_valuesZds r   :/tmp/pip-unpacked-wheel-h316xyqg/xarray/tests/test_cupy.pytoy_weather_data   s    
 r   None)returnc                   C  s   t stdS )zCheck the import worked.N)r   AssertionErrorr   r   r   r   test_cupy_import,   s    r#   c                 C  s.   | d dk dd}t|jtjs*tdS )z<Perform some operations and check the data stays on the GPU.r   r   z
time.monthr   N)groupbyZmean
isinstancer   r   ndarrayr"   )r   freezer   r   r   test_check_data_stays_on_gpu1   s    r(   c                  C  sF   ddl m}  td}| |dk d| }|s2tt|tjsBtd S )Nr   )wherer   r
   )Zxarray.core.duck_array_opsr)   r   zerosallr"   r%   r&   )r)   r   outputr   r   r   
test_where7   s
    
r-   )
__future__r   Znumpyr   Zpandasr   ZpytestZxarrayr   Zimportorskipr   Zfixturer   r#   r(   r-   r   r   r   r   <module>   s   

