You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I report you a strange behaviour I observe when trying to rename a dask.array data field.
In the following script, I want to delete the default data name ('map_data_frame...') in the colormap when plotting.
when uncommenting the COMMENT-2 : it's ok
But when uncommenting the COMMENT-1 (this only one), I generate the following error message : ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (4,) and requested shape (1,10,10)
strange, isn't it ?
Patrick
import numpy as np
from PIL import Image
from dask_image.imread import imread
import xarray as xr
import matplotlib.pyplot as plt
for i in range(10):
arr = i * np.ones((10, 10))
img = Image.fromarray(arr)
img.save(f'img_{i}.tif')
darr = imread('*.tif')
# darr.name = None # COMMENT-1
x = y = z = np.arange(10)
xarr = xr.DataArray(darr, coords=[('z', z), ('y', y), ('x', x)])
# xarr.name = None # COMMENT-2
print(xarr.name)
xarr.to_netcdf("test.nc")
xarr.isel(x=5).plot()
plt.show()
I tham wondering why you are trying to set the name of the dask.array. It seems like the dask.array.name is a special property that is expected to have certain features. Changing the name of the array will have unintended consequences.
That being said, there is probably something we can do in dask to protect people from inadvertently setting the name to something invalid.
As explained above, colormap with label named '_map_read_frame-ca2cc3dd7ed112e69d4a351f0b358663' was not very relevant in my case.
I tried First to change this by renaming the dask.array.name (associated to the previous label) And I found really strange that changing the name engendered such a misbehaviour.
On my mind, this shouldn't - like what is obtained when doing xarray.name renaming.
Dask.array.name should be 'just' a name (used for labelling for instance) and it shouldn't be responsible of this : ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (4,) and requested shape (1,10,10)
But this is just my opinion :)
In dask.array name is not user-facing in the way that it is in xarray.DataArray. If you want to control the name that shows up on your plot, you should change the name on the xarray object like you do in COMMENT-2.
@jsignell , I have seen the discussion you had with @mrocklin (and your PR).
That was the aim of my issue.... so I can close it.
Thanks for all.
Patrick
Activity
jsignell commentedon Feb 12, 2021
I tham wondering why you are trying to set the name of the dask.array. It seems like the dask.array.name is a special property that is expected to have certain features. Changing the name of the array will have unintended consequences.
That being said, there is probably something we can do in dask to protect people from inadvertently setting the name to something invalid.
patquem commentedon Feb 15, 2021
Hello @jsignell ,
As explained above, colormap with label named '_map_read_frame-ca2cc3dd7ed112e69d4a351f0b358663' was not very relevant in my case.
I tried First to change this by renaming the dask.array.name (associated to the previous label) And I found really strange that changing the name engendered such a misbehaviour.
On my mind, this shouldn't - like what is obtained when doing xarray.name renaming.
Dask.array.name should be 'just' a name (used for labelling for instance) and it shouldn't be responsible of this :
ValueError: operands could not be broadcast together with remapped shapes [original->remapped]: (4,) and requested shape (1,10,10)
But this is just my opinion :)
Patrick
jsignell commentedon Feb 15, 2021
In dask.array
nameis not user-facing in the way that it is in xarray.DataArray. If you want to control the name that shows up on your plot, you should change the name on the xarray object like you do in COMMENT-2.patquem commentedon Feb 17, 2021
@jsignell , I have seen the discussion you had with @mrocklin (and your PR).
That was the aim of my issue.... so I can close it.
Thanks for all.
Patrick