Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ability to iterate on axis elements #142

Closed
tlnagy opened this issue Aug 3, 2018 · 3 comments
Closed

Add ability to iterate on axis elements #142

tlnagy opened this issue Aug 3, 2018 · 3 comments

Comments

@tlnagy
Copy link

tlnagy commented Aug 3, 2018

It would be great to have the ability to do the following:

Main> a = AxisArray(randn(10,10,5), :x, :y, :time);

Main> timeaxis(a)
AxisArrays.Axis{:time,Base.OneTo{Int64}}(Base.OneTo(5))

Main> for timepoint in timeaxis(a)
          println(timepoint)
       end
ERROR: MethodError: no method matching start(::AxisArrays.Axis{:time,Base.OneTo{Int64}})
Closest candidates are:
  start(::SimpleVector) at essentials.jl:258
  start(::Base.MethodList) at reflection.jl:560
  start(::ExponentialBackOff) at error.jl:107
  ...
Stacktrace:
 [1] anonymous at ./<missing>:?
 [2] eval(::Module, ::Any) at ./boot.jl:235

That would be the most intuitive method for me to iterate over slices along an axis.

My current solution is way uglier and more fragile

for timepoint in 1:size(exp_img)[axisdim(exp_img, Axis{:time}())]
    println(timepoint)
end
@tlnagy
Copy link
Author

tlnagy commented Sep 10, 2018

Thoughts @Evizero @timholy?

@Evizero
Copy link
Member

Evizero commented Sep 10, 2018

Sorry but I am not that involved with AxisArrays

@tlnagy
Copy link
Author

tlnagy commented Sep 7, 2019

I think this was resolved by #160

@tlnagy tlnagy closed this as completed Sep 7, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants