Skip to content

Support pre-allocated array and configurable permutedims? #48

@findmyway

Description

@findmyway

This package is pretty neat and helpful!

Can we add some keyword arguments to the following function to reuse preallocated array and control whether to permute dims or not?

NPZ.jl/src/NPZ.jl

Lines 229 to 240 in 8834d3c

function _npzreadarray(f, hdr::Header{T}) where {T}
toh = hdr.descr
if hdr.fortran_order
@compat x = map(toh, read!(f, Array{T}(undef, hdr.shape)))
else
@compat x = map(toh, read!(f, Array{T}(undef, reverse(hdr.shape))))
if ndims(x) > 1
x = permutedims(x, collect(ndims(x):-1:1))
end
end
ndims(x) == 0 ? x[1] : x
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions