-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Description
The last example in the readme:
B = AxisArray(randn(100,100,100), :x, :y, :z)
Itotal = sumz = 0.0
for iter in eachindex(B) # traverses in storage order for cache efficiency
I = B[iter] # intensity in a single voxel
Itotal += I
sumz += I * iter[axisdim(B, Axis{:z})] # axisdim "looks up" the z dimension
end
meanz = sumz/Itotaldoesn't work under Julia 0.6. It gives a bounds error:
ERROR: BoundsError
Stacktrace:
[1] getindex(::Int64, ::Int64) at ./number.jl:38
[2] macro expansion at ./REPL[4]:4 [inlined]
[3] anonymous at ./<missing>:?
I believe this is due to eachindex returning a single value instead of a tuple. This is likely because it is using fast linear indexing instead of Cartesian indexing. What would the updated version of this code look like? @timholy
Metadata
Metadata
Assignees
Labels
No labels