Skip to content

Commit

Permalink
Patch release for fixing division bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tansongchen committed Nov 26, 2024
1 parent 29b1312 commit 998db88
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TaylorDiff"
uuid = "b36ab563-344f-407b-a36a-4f200bebf99c"
authors = ["Songchen Tan <[email protected]>"]
version = "0.3.0"
version = "0.3.1"

[deps]
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
Expand Down
45 changes: 0 additions & 45 deletions examples/ode.jl

This file was deleted.

4 changes: 3 additions & 1 deletion src/chainrules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function rrule(::typeof(partials), t::TaylorScalar{T, N}) where {N, T}
end

function rrule(::typeof(partials), t::TaylorArray{T, N, A, P}) where {N, T, A, P}
partials_pullback(v̄::NTuple{P, A}) = NoTangent(), TaylorArray(broadcast(zero, v̄[1]), v̄)
function partials_pullback(v̄::NTuple{P, A})
NoTangent(), TaylorArray(broadcast(zero, v̄[1]), v̄)
end
return partials(t), partials_pullback
end

Expand Down
6 changes: 4 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ function process(d, expr)
@match x begin
a_[idx_] => a in magic_names ? Symbol(a, idx) : :($a[begin + $idx])
(a_ = b_) => (push!(known_names, a); :($a = $b))
(a_ += b_) => a in known_names ? :($a += $b) : (push!(known_names, a); :($a = $b))
(a_ -= b_) => a in known_names ? :($a -= $b) : (push!(known_names, a); :($a = -$b))
(a_ += b_) => a in known_names ? :($a += $b) :
(push!(known_names, a); :($a = $b))
(a_ -= b_) => a in known_names ? :($a -= $b) :
(push!(known_names, a); :($a = -$b))
TaylorScalar(v_) => :(TaylorScalar(tuple($([Symbol(v, idx) for idx in 0:d[:P]]...))))
_ => x
end
Expand Down
8 changes: 4 additions & 4 deletions test/primitive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ end
# end
end

@testset "Multi-argument functions" begin
@test derivative(x -> 1 + 1/x, 1.0, Val(1))-1.0 rtol=1e-6
@test derivative(x -> (x+1)/x, 1.0, Val(1))-1.0 rtol=1e-6
@test derivative(x -> x/x, 1.0, Val(1)) 0.0 rtol=1e-6
@testset "Multi-argument functions" begin
@test derivative(x -> 1 + 1 / x, 1.0, Val(1))-1.0 rtol=1e-6
@test derivative(x -> (x + 1) / x, 1.0, Val(1))-1.0 rtol=1e-6
@test derivative(x -> x / x, 1.0, Val(1))0.0 rtol=1e-6
end

@testset "Corner cases" begin
Expand Down

2 comments on commit 998db88

@tansongchen
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 register

Release notes:

Fix error in computing binary division

@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/120231

Tagging

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.3.1 -m "<description of version>" 998db881c199b05f3f7855fa5184ae781957c5f2
git push origin v0.3.1

Please sign in to comment.