-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
filter doesn't work on generators #37146
Comments
Note that julia> f = (i for i = 1:10 if i % 2 == 0)
Base.Generator{Base.Iterators.Filter{var"#33#34",UnitRange{Int64}},typeof(identity)}(identity, Base.Iterators.Filter{var"#33#34",UnitRange{Int64}}(var"#33#34"(), 1:10)) |
Perhaps there should be a method |
One thing that came up from a slack discussion with @mcabbott, @dpsanders, @SaschaMann and others, and @bramtayl mentioning it in the above PR as well: Though not everyone agreed(?), it seems questionable to automatically The current issue would also be fixed by simply exporting Similar issues could be fixed for |
Seems like the origin of the separation of eager/lazy is #18839:
I don't know if the separation has since been debated and agreed upon conclusively, but I think the current issue highlights the problem with this separation rather well: Base |
I think the issue with iterators is that they are...messy from a type standpoint. They inherit some traits from their parents and not others. |
The story is: iterators preserve traits that they preserve. |
Right; |
The
filter
function cannot be used on generators:This is surprising because
map
works, and the documentation of bothmap
andfilter
say they work on "collections".Apparently it used to work, see examples mentioned in #18866 .
In support of the view that the current behavior is confusing, some problems reported by users on Discourse:
https://discourse.julialang.org/t/creating-an-array-of-tuples-why-doesnt-filter-work-on-a-zip/28173
https://discourse.julialang.org/t/filter-doesnt-work-on-grouped-dataframe/27322
https://discourse.julialang.org/t/filter-of-skipmissing-fails/21249
https://discourse.julialang.org/t/what-is-the-correct-way-to-ignore-some-files-directories-in-walkdir/26780
https://discourse.julialang.org/t/jump-filtering-the-output-of-jump-value-x/25391
(And my own use case: filtering the output of
eachline
.)The text was updated successfully, but these errors were encountered: