Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #209 from invenia/ox/ambifil
Browse files Browse the repository at this point in the history
Fix ambiguity in fill
  • Loading branch information
oxinabox committed Aug 17, 2021
2 parents eadaaaf + 16fffeb commit f5adedb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Nabla"
uuid = "49c96f43-aa6d-5a04-a506-44c7070ebe78"
version = "0.13.1"
version = "0.13.2"

[deps]
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
Expand Down
4 changes: 4 additions & 0 deletions src/Nabla.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ module Nabla
# Sensitivities via ChainRules
include("sensitivities/chainrules.jl")

# Overloads we added to solve ambiguitities (probably caused by ChainRules)
include("sensitivities/ambiguity_resolution.jl")


# Sensitivities for the basics.
include("sensitivities/indexing.jl")
include("sensitivities/scalar.jl")
Expand Down
7 changes: 7 additions & 0 deletions src/sensitivities/ambiguity_resolution.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function Base.fill(val::Node, dims::Vararg{Union{Integer,AbstractUnitRange}})
return invoke(fill, Tuple{Node, Vararg{Any}}, val, dims...)
end

function Base.fill(val::Node, dims::Tuple{Vararg{Integer}})
return invoke(fill, Tuple{Node, Vararg{Any}}, val, dims)
end
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ end
@testset "Sensitivities" begin
include("finite_differencing.jl")

include("sensitivities/ambiguity_resolution.jl")
# Test sensitivities for the basics.
include("sensitivities/indexing.jl")
include("sensitivities/scalar.jl")
Expand Down
9 changes: 9 additions & 0 deletions test/sensitivities/ambiguity_resolution.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@testset "Ambiguity Resolution" begin
@testset "fill" begin
k = fill(Leaf(Tape(), 1.2), 3, 4)
@test k.pullback !== nothing

x = fill(Leaf(Tape(), 1.2), (3, 4))
@test x.pullback !== nothing
end
end

2 comments on commit f5adedb

@oxinabox
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/43043

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.13.2 -m "<description of version>" f5adedb5632d0ec9b887709e0c0391286d386603
git push origin v0.13.2

Please sign in to comment.