-
Notifications
You must be signed in to change notification settings - Fork 143
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 CartesianRange indexing #442
Conversation
function setindex!{N}(dset::HDF5Dataset, val, cr::CartesianRange{CartesianIndex{N}}) | ||
# transfer to unit range | ||
ur = map((x,y)->x:y, cr.start.I, cr.stop.I) | ||
@show ur |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why @show ur
here ?
This functionality seems useful although I am not so sure that the implementation is optimal. I wonder if anyone else has any comments |
@@ -710,6 +710,12 @@ function h5read(filename, name::String, indices::Tuple{Vararg{Union{Range{Int},I | |||
dat | |||
end | |||
|
|||
function h5read{N}(filename, name::String, cr::CartesianRange{CartesianIndex{N}}) | |||
# transfer to unit range | |||
ur = map((x,y)->x:y, cr.start.I, cr.stop.I) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use first(cr)
and last(cr)
than cr.start.I
and cr.stop.I
; in 0.7, the representation of CartesianRange has changed. Indeed, in 0.7 this can just be ur = cr.indices
.
dset = f["main"] | ||
# setindex of cartesian range | ||
dset[CartesianRange((3:5,))] = [4:6;] | ||
@test dset[CartesianRange((3:5,))] == [4:6;] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests should cover a case with more than one dimension. Also, why is the correct answer not [3:5;]
as you would get with a normal range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because on line 14 he rewrites elements 3:5 to 4:6 (which is testing setindex!)
addressed review in #459 (review) |
CartesianRange is widely used to handle ranges, adding support of CartesianRange to index the arrays inside dataset could make some implementation easier.
These functions were moved from BigArrays.jl
seung-lab/BigArrays.jl#21