Skip to content

dask.array renaming creates ValueError #7209

@patquem

Description

@patquem

Hello,

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions