Skip to content

iris.cube.Cube.lazy_data method results in wrong chunk array type for masked arrays #5800

@bouweandela

Description

@bouweandela

🐛 Bug Report

How To Reproduce

Steps to reproduce the behaviour:

Run the following code

import numpy as np
import iris.cube

In [1]: iris.cube.Cube(np.ma.array([1, 2], mask=[True, False])).lazy_data()
Out[1]: dask.array<array, shape=(2,), dtype=int64, chunksize=(2,), chunktype=numpy.ndarray>

Note that chunktype is numpy.ndarray, while the data type is actually a masked array. This causes problems when inspecting the content of the Dask array with dask.array.utils.meta_from_array, because that will return the wrong chunk type shown above.

Expected behaviour

import numpy as np
import iris.cube

In [1]: iris.cube.Cube(np.ma.array([1, 2], mask=[True, False])).lazy_data()
Out[1]: dask.array<array, shape=(2,), dtype=int64, chunksize=(2,), chunktype=numpy.MaskedArray>

Environment

  • OS & Version: 23.10
  • Iris Version: 3.9.0.dev15

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions