MAT.jl icon indicating copy to clipboard operation
MAT.jl copied to clipboard

`file["varname"]` and `file[:varname]` interface?

Open lucasb-eyer opened this issue 11 years ago • 6 comments

I just found myself intuitively expecting that, probably because I'm used to it from scipy io and jsoncpp.

Would you want a PR for that, or is it too non-Julian? (Or is there a caveat which I'm not seeing?)

lucasb-eyer avatar Aug 14 '14 11:08 lucasb-eyer

This seems reasonable to me. It's also possible we might want to use this syntax for an interface that allows incremental reading/writing of datasets, analogous to what HDF5 (and MATLAB's matfile) do, but no one has asked for that yet. @timholy, what do you think?

simonster avatar Aug 14 '14 16:08 simonster

Not sure how that would play together, though. file[:X, 100:200] += 10?

lucasb-eyer avatar Aug 16 '14 17:08 lucasb-eyer

Can we get both without ambiguity?

obj = file["varname"]
X = obj[100:200]

timholy avatar Aug 16 '14 17:08 timholy

My guess was that to achieve this, we need another family of proxy-types for obj which sounds like overkill, but then again, I don't know much of Julia. I also wouldn't be up for the task.

lucasb-eyer avatar Aug 16 '14 17:08 lucasb-eyer

I figure my issues falls into this category. I was hoping I could read MatlabHDF5File files incrementally. We have very large MAT files and was hoping I could just do:

mat = matopen("myfile.mat")
mat.plain["data"][:, :, :, 1]

but get the following error:

ERROR: Dataset indexing (hyperslab) is available only for bits types
Stacktrace:
 [1] _getindex(::HDF5.HDF5Dataset, ::Type{T} where T, ::UnitRange{Int64}, ::Vararg{Union{Int64, Range{Int64}},N} where N) at .julia/v0.6/HDF5/src/HDF5.jl:1682
 [2] getindex(::HDF5.HDF5Dataset, ::UnitRange{Int64}, ::UnitRange{Int64}, ::UnitRange{Int64}, ::Int64, ::Vararg{Int64,N} where N) at .julia/v0.6/HDF5/src/HDF5.jl:1678
 [3] getindex(::HDF5.HDF5Dataset, ::Colon, ::Colon, ::Colon, ::Int64, ::Vararg{Int64,N} where N) at .julia/v0.6/HDF5/src/HDF5.jl:1747

There are no issues reading via matfile. I wish I could just convince our people to just use HDF5 in this case!

jgbos avatar Sep 19 '17 14:09 jgbos

Shoot delving into the issue, this is a reading a matrix of complex numbers

jgbos avatar Sep 19 '17 15:09 jgbos