Skip to content

When is transpose not lazy? #2576

@djhoese

Description

@djhoese

Code Sample, a copy-pastable example if possible

import xarray as xr
import dask.array as da 
from dask.diagnostics import ProgressBar
a = xr.DataArray(da.zeros((3, 5, 5), chunks=(1, 2, 2)), dims=('bands', 'y', 'x'))

with ProgressBar():
    b = a.transpose('y', 'x', 'bands')
# dask does not show a progress bar due to no computation

with ProgressBar():
    b = a.transpose('y', 'x', 'bands')
    b.compute()
# dask computes the array (since we told it to) and we see a progress bar

Question

The documentation for transpose says that it is not lazy. Is this only in certain situations? By not lazy does it mean that when the data is computed that the transpose task will require all data to be loaded at once (one large chunk) or does it mean that the transpose operation will immediately compute the transposed array? My test above does not seem to compute the data when transpose is called.

Or is the documentation just outdated?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions