home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 608974755

This data as json

id node_id number title user state locked assignee milestone comments created_at updated_at closed_at author_association active_lock_reason draft pull_request body reactions performed_via_github_app state_reason repo type
608974755 MDU6SXNzdWU2MDg5NzQ3NTU= 4015 apply_ufunc gives wrong dtype with dask=parallelized and vectorized=True 13190237 closed 0     2 2020-04-29T11:17:48Z 2020-08-19T06:57:56Z 2020-08-19T06:57:56Z CONTRIBUTOR      

Applying a function to a data array with dtype = complex returns one with dtype = float. It seems to work before commit 17b70caa6eafa062fd31e7f39334b3de922ff422.

MCVE Code Sample

```python import numpy as np import xarray as xr

def func(x): return np.sum(x ** 2)

da = xr.DataArray(np.arange(234).reshape(2,3,4)) da = da + 1j * da da = da.chunk(dict(dim_1=1))

da2 = xr.apply_ufunc( func, da, vectorize=True, dask="parallelized", output_dtypes=[da.dtype], )

assert da2.dtype == da.dtype, "wrong dtype" ```

Expected Output

da and da2 should both have the same dtype=complex.

Problem Description

To me it seems to me that the kwarg meta=None somehow causes dask to allocate a float array and ignore the dtype kwargs (which seems to be carried through correctly down to dask.array.blockwise.blockwise()) . I'm not familiar with the apply_ufing and the dask code, so I can't tell on which end the bug sits.

Versions

Output of <tt>xr.show_versions()</tt> INSTALLED VERSIONS ------------------ commit: None python: 3.8.2 (default, Apr 8 2020, 14:31:25) [GCC 9.3.0] python-bits: 64 OS: Linux OS-release: 5.6.5-arch3-1 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: de_DE.utf8 LOCALE: de_DE.UTF-8 libhdf5: 1.10.5 libnetcdf: 4.7.3 xarray: 0.15.2.dev47+g33a66d63 pandas: 1.0.3 numpy: 1.18.3 scipy: 1.4.1 netCDF4: 1.5.3 pydap: None h5netcdf: 0.7.4 h5py: 2.10.0 Nio: None zarr: None cftime: 1.1.1.2 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.3.2 dask: 2.12.0 distributed: 2.14.0 matplotlib: 3.2.1 cartopy: 0.17.0 seaborn: 0.10.0 numbagg: None pint: None setuptools: 46.1.3 pip: 20.0.2 conda: None pytest: 5.4.1 IPython: 7.13.0 sphinx: 3.0.2
{
    "url": "https://api.github.com/repos/pydata/xarray/issues/4015/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 2 rows from issue in issue_comments
Powered by Datasette · Queries took 0.633ms · About: xarray-datasette