Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle PermutedDimsArray #240

Open
tiemvanderdeure opened this issue Mar 7, 2025 · 2 comments
Open

Handle PermutedDimsArray #240

tiemvanderdeure opened this issue Mar 7, 2025 · 2 comments

Comments

@tiemvanderdeure
Copy link
Contributor

The chunks of a PermutedDimsArray of a chunked array is not chunked - this is really annoying for Rasters in particular, because the @d macro internally uses PermutedDimsArray

using Rasters, NCDatasets
import Rasters.DiskArrays: eachchunk
A = Rasters.create(
    "myraster.nc", Float64, (X(1:1000), Y(1:1000)); 
    force = true, chunks = (128, 128)
)

Aperm = @d A (Y, X)
eachchunk(Aperm) # 1×1 DiskArrays.GridChunks
eachchunk(A) # 8x8 DiskArrays.GridChunks

Or a more minimal example

using DiskArrays
chunkedA = DiskArrays.TestTypes.ChunkedDiskArray(rand(100,100), (10, 10))
PermutedDimsArray(chunkedA, (2,1)) |> eachchunk
1×1 DiskArrays.GridChunks{2, Tuple{DiskArrays.RegularChunks, DiskArrays.RegularChunks}}:
 (1:100, 1:100)

I'm not entirely sure how this should work - probably we need to get the chunks of the parent and then apply the same permutation, right?

@tiemvanderdeure
Copy link
Contributor Author

Okay, silly of me, I just found out about PermutedDiskArray and this old issue #42 - but we probably need to handle this in Rasters.

@rafaqz
Copy link
Collaborator

rafaqz commented Mar 7, 2025

No its a real issue - Julia base needs a function rather than a constructor for PermutedDimsArray so we can return what we like, or DiskArrays.jl needs to lower its standards and do what DD does and just return something else from PermutedDimsArray constructor.

Rasters already has a bunch of special casing for isdisk and PermutedDimsArray because the fast path for memory is PermutedDimsArray but for disk arrays its permutedims.

I've pushed for both fixes but got nowhere concrete so far. Maybe chime in on my Base.lazypermutedims issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants