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 1186949971,I_kwDOAMm_X85Gv2tT,6427,Inverting Datasets or DataArrays with dask float data throws wrong ValueError instead of TypeError,7178572,open,0,,,5,2022-03-30T20:26:02Z,2022-03-31T23:42:30Z,,NONE,,,,"### What happened? Inverting (\_\_invert\_\_) a DataArray or Dataset containing dask float data throws a `ValueError` with a message about the dimensions not matching the data. This should throw a TypeError with a message indicating an unsupported type for that operation. ### What did you expect to happen? I expected a TypeError with a relevant message about the type (shown below), not a ValueError with a misleading message. ```python import xarray as xr import dask.array as da data = da.from_array([1.0]) x = xr.DataArray(data) ~x Traceback (most recent call last): File """", line 1, in File ""/home/USEr/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/_typed_ops.py"", line 329, in __invert__ return self._unary_op(operator.invert) File ""/home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 3078, in _unary_op da = self.__array_wrap__(f(self.variable.data, *args, **kwargs)) TypeError: ufunc 'invert' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe'' ``` ### Minimal Complete Verifiable Example ```Python import xarray as xr import dask.array as da data = da.from_array([1.0]) x = xr.DataArray(data) ~x ``` ### Relevant log output ```Python Traceback (most recent call last): File """", line 1, in File ""/home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/_typed_ops.py"", line 329, in __invert__ return self._unary_op(operator.invert) File ""/home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 3078, in _unary_op da = self.__array_wrap__(f(self.variable.data, *args, **kwargs)) File ""/home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/dataarray.py"", line 3057, in __array_wrap__ new_var = self.variable.__array_wrap__(obj, context) File ""/home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/variable.py"", line 2444, in __array_wrap__ return Variable(self.dims, obj) File ""/home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/variable.py"", line 305, in __init__ self._dims = self._parse_dimensions(dims) File ""/home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/xarray/core/variable.py"", line 573, in _parse_dimensions raise ValueError( ValueError: dimensions ('dim_0',) must have the same length as the number of data dimensions, ndim=0 ``` ### Anything else we need to know? _No response_ ### Environment /home/USER/anaconda3/envs/rstools/lib/python3.8/site-packages/_distutils_hack/__init__.py:30: UserWarning: Setuptools is replacing distutils. warnings.warn(""Setuptools is replacing distutils."") INSTALLED VERSIONS ------------------ commit: None python: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10) [GCC 10.3.0] python-bits: 64 OS: Linux OS-release: 5.13.0-35-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: None libnetcdf: None xarray: 2022.3.0 pandas: 1.4.1 numpy: 1.21.5 scipy: 1.8.0 netCDF4: None pydap: None h5netcdf: None h5py: None Nio: None zarr: None cftime: None nc_time_axis: None PseudoNetCDF: None rasterio: 1.2.10 cfgrib: None iris: None bottleneck: None dask: 2022.03.0 distributed: 2022.3.0 matplotlib: 3.5.1 cartopy: None seaborn: None numbagg: None fsspec: 2022.02.0 cupy: None pint: None sparse: None setuptools: 61.2.0 pip: 22.0.4 conda: None pytest: 7.1.1 IPython: 8.2.0 sphinx: None","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6427/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue