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

collect fails to work for all finite iterators #12009

Closed
simonbyrne opened this issue Jul 4, 2015 · 3 comments
Closed

collect fails to work for all finite iterators #12009

simonbyrne opened this issue Jul 4, 2015 · 3 comments

Comments

@simonbyrne
Copy link
Contributor

julia> collect(enumerate(Filter(x -> x>0, randn(10))))
ERROR: MethodError: `length` has no method matching length(::Filter{Function,Array{Float64,1}})
 in collect at array.jl:269
 in collect at array.jl:283

Rather than call applicable, maybe it would be better to use try/catch?

@stevengj
Copy link
Member

stevengj commented Jul 6, 2015

Probably ... the performance overhead of the try/catch seems unlikely to be an issue here, since I doubt collect will be a inner-loop function.

@KristofferC
Copy link
Member

This seems to work now:

julia> collect(enumerate(Iterators.Filter(x -> x>0, randn(10))))
4-element Array{Tuple{Int64,Float64},1}:
 (1,0.0895511)
 (2,1.58289)  
 (3,0.35398)  
 (4,0.496553) 

@tkelman
Copy link
Contributor

tkelman commented Jan 22, 2017

and is it tested? don't close things that aren't

@tkelman tkelman added the needs tests Unit tests are required for this change label Jan 22, 2017
KristofferC added a commit that referenced this issue Jan 22, 2017
KristofferC added a commit that referenced this issue Jan 22, 2017
@tkelman tkelman removed the needs tests Unit tests are required for this change label Jan 22, 2017
JeffBezanson pushed a commit that referenced this issue Jan 23, 2017
# 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

4 participants