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

Add to_vec(::Thunk) #173

Merged
merged 4 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
env:
JULIA_PKG_SERVER: ""
- run: |
julia --project=docs -e '
using Documenter: doctest
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FiniteDifferences"
uuid = "26cc04aa-876d-5657-8c51-4c34ba976000"
version = "0.12.12"
version = "0.12.13"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand All @@ -11,7 +11,7 @@ Richardson = "708f8203-808e-40c0-ba2d-98a6953ed40d"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
ChainRulesCore = "0.9.44, 0.10"
ChainRulesCore = "0.10.3"
Richardson = "1.2"
StaticArrays = "0.12, 1.0"
julia = "1"
Expand Down
16 changes: 8 additions & 8 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[ChainRulesCore]]
deps = ["Compat", "LinearAlgebra", "SparseArrays"]
git-tree-sha1 = "b391f22252b8754f4440de1f37ece49d8a7314bb"
git-tree-sha1 = "8b31cc69cbc38c5c826aaa1c890c694be3622d99"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "0.9.44"
version = "0.10.3"

[[Compat]]
deps = ["Base64", "Dates", "DelimitedFiles", "Distributed", "InteractiveUtils", "LibGit2", "Libdl", "LinearAlgebra", "Markdown", "Mmap", "Pkg", "Printf", "REPL", "Random", "SHA", "Serialization", "SharedArrays", "Sockets", "SparseArrays", "Statistics", "Test", "UUIDs", "Unicode"]
Expand All @@ -34,10 +34,10 @@ deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"

[[DocStringExtensions]]
deps = ["LibGit2", "Markdown", "Pkg", "Test"]
git-tree-sha1 = "9d4f64f79012636741cf01133158a54b24924c32"
deps = ["LibGit2"]
git-tree-sha1 = "a32185f5428d3986f47c2ab78b1f216d5e6cc96f"
uuid = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
version = "0.8.4"
version = "0.8.5"

[[Documenter]]
deps = ["Base64", "Dates", "DocStringExtensions", "IOCapture", "InteractiveUtils", "JSON", "LibGit2", "Logging", "Markdown", "REPL", "Test", "Unicode"]
Expand All @@ -53,7 +53,7 @@ uuid = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
deps = ["ChainRulesCore", "LinearAlgebra", "Printf", "Random", "Richardson", "StaticArrays"]
path = ".."
uuid = "26cc04aa-876d-5657-8c51-4c34ba976000"
version = "0.12.7"
version = "0.12.13"

[[IOCapture]]
deps = ["Logging"]
Expand Down Expand Up @@ -161,9 +161,9 @@ uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[[StaticArrays]]
deps = ["LinearAlgebra", "Random", "Statistics"]
git-tree-sha1 = "c635017268fd51ed944ec429bcc4ad010bcea900"
git-tree-sha1 = "42378d3bab8b4f57aa1ca443821b752850592668"
uuid = "90137ffa-7385-5640-81b9-e52037218182"
version = "1.2.0"
version = "1.2.2"

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
Expand Down
6 changes: 6 additions & 0 deletions src/to_vec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,9 @@ function FiniteDifferences.to_vec(x::AbstractZero)
end
return Bool[], AbstractZero_from_vec
end

function FiniteDifferences.to_vec(t::Thunk)
v, back = to_vec(unthunk(t))
Thunk_from_vec = v -> @thunk(back(v))
return v, Thunk_from_vec
end
4 changes: 4 additions & 0 deletions test/to_vec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ end
test_to_vec(ZeroTangent())
test_to_vec(NoTangent())
end

@testset "Thunks" begin
test_to_vec(@thunk(3.2+4.3))
end
end

@testset "FillVector" begin
Expand Down