Skip to content
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

fcollect won't keep repeated arrays that are == but distinct #16

Closed
ericphanson opened this issue Jul 7, 2021 · 1 comment · Fixed by #25
Closed

fcollect won't keep repeated arrays that are == but distinct #16

ericphanson opened this issue Jul 7, 2021 · 1 comment · Fixed by #25

Comments

@ericphanson
Copy link
Contributor

See beacon-biosignals/LegolasFlux.jl#4 (comment) and the alternate implementation

function fcollect2(x; output = [], cache = Base.IdSet(), exclude = v -> false)
    x in cache && return output
    if !exclude(x)
      push!(cache, x)
      push!(output, x)
      foreach(y -> fcollect2(y; cache = cache, output=output, exclude = exclude), Functors.children(x))
    end
    return output
end
@ericphanson ericphanson changed the title fcollect won't keep repeated arrays that are == by distinct fcollect won't keep repeated arrays that are == but distinct Jul 9, 2021
@DhairyaLGandhi
Copy link
Member

A pr would be great with a small mwe from beacon-biosignals/LegolasFlux.jl#4 (comment) @ericphanson !

ericphanson added a commit to ericphanson/Functors.jl that referenced this issue Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants