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

Add support for reading H5T_ARRAY #55

Closed
wants to merge 1 commit into from
Closed

Add support for reading H5T_ARRAY #55

wants to merge 1 commit into from

Conversation

timholy
Copy link
Member

@timholy timholy commented Nov 20, 2013

This gets us partway to fixing #50. @simonster , if you have time to review, I would greatly value your opinion. The most "controversial" aspect of this is that I decided to abandon my previous attempts to read fixed-size arrays by encoding the dimensions within an "instance" and instead decided to create a stub-type for each fixed-size array (with the dimensions encoded as parameters, e.g., FixedArray3{Float64, 3, 5, 7} would correspond to Array{Float64,3} of size (3,5,7). The stub types don't actually allocate any memory.

The reason I went with the type-based approach is because the whole infrastructure around hdf5_to_julia_eltype etc is built on types rather than instances, and arrays-of-fixedarrays (as in the example file I added to readremote) seemed ugly if implemented with instances.

But see if you agree.

@simonster
Copy link
Member

I'll look at this more closely later, but generally I think it's better if we can avoid dynamically generating types. One possibility is to use:

immutable Dim{N} end
immutable FixedArray{T,N<:(Dim...)} end

Then we have:

param{N}(::Type{Dim{N}}) = N
size{T,D}(::Type{FixedArray{T,D}}) = map(param, D)::(Int...)

size(FixedArray{Float64,(Dim{3},Dim{4},Dim{7})}) == (3,4,7)

There might even be a way to avoid the Dim type, but I don't see it ATM.

@timholy
Copy link
Member Author

timholy commented Nov 20, 2013

Very interesting. I tried the same thing without the Dim wrapper, and got this:

julia> immutable FixedArray2{T,N<:(Int...)} end

julia> F = FixedArray2{Float64,(3,4,2)}
ERROR: type: apply_type: in FixedArray2, expected Type{T<:Top}, got (Int64,Int64,Int64)

I should have thought to do the wrapper. Nice work!

I completely agree that it's better to avoid dynamically-generating types. I don't think you have to review this in detail, I'll generate a version based on your suggestion.

@timholy timholy closed this Nov 20, 2013
@timholy
Copy link
Member Author

timholy commented Nov 20, 2013

CC @JeffBezanson in case he's interested in the tuple-of-types vs tuple-of-integers 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

Successfully merging this pull request may close these issues.

2 participants