MAT.jl
MAT.jl copied to clipboard
`file["varname"]` and `file[:varname]` interface?
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?)
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?
Not sure how that would play together, though. file[:X, 100:200] += 10?
Can we get both without ambiguity?
obj = file["varname"]
X = obj[100:200]
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.
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!
Shoot delving into the issue, this is a reading a matrix of complex numbers