Skip to content

Commit

Permalink
use upstream fcollect (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericphanson authored Oct 20, 2021
1 parent aaa94fd commit 9f2903f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LegolasFlux"
uuid = "eb5f792d-d1b1-4535-bae3-d5649ec7daa4"
authors = ["Beacon Biosignals, Inc."]
version = "0.1.2"
version = "0.1.3"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand All @@ -12,7 +12,7 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
[compat]
Arrow = "1"
Flux = "0.12"
Functors = "0.2.1"
Functors = "0.2.6"
Legolas = "0.1, 0.2"
Tables = "1"
julia = "1.5"
Expand Down
15 changes: 1 addition & 14 deletions src/functors.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
# Modified version of `fcollect` to use an `IdSet` cache so that
# distinct arrays whose values happen to be duplicates are each kept.
# <https://github.com/FluxML/Functors.jl/issues/16>
function fcollect2(x; output=[], cache=IdSet(), exclude=_ -> 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

"""
fetch_weights(m) -> Vector{Array}
Expand All @@ -22,7 +9,7 @@ custom types.
Note that this function does not copy the results, so that e.g. mutating
`fetch_weights(m)[1]` modifies the model.
"""
fetch_weights(m) = filter(is_numeric_array, fcollect2(m))
fetch_weights(m) = filter(is_numeric_array, fcollect(m))
is_numeric_array(x) = false
is_numeric_array(x::Array{<:Number}) = true
is_numeric_array(x::Array) = all(x -> x isa Number || is_numeric_array(x), x)
Expand Down

2 comments on commit 9f2903f

@ericphanson
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/47101

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.3 -m "<description of version>" 9f2903f3bcc5848bc8df45e1f9a411f6fbbab68e
git push origin v0.1.3

Please sign in to comment.