Skip to content

Commit

Permalink
Fixes some chain rules stuff. Fixes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
jonniedie committed Mar 26, 2021
1 parent 277a1c4 commit 8a8c7ba
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ComponentArrays"
uuid = "b0b7db55-cfe3-40fc-9ded-d10e2dbeff66"
authors = ["Jonnie Diegelman <[email protected]>"]
version = "0.9.2"
version = "0.9.3"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
1 change: 0 additions & 1 deletion src/ComponentArrays.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module ComponentArrays

using ArrayInterface
# using ChainRulesCore
using LinearAlgebra
using Requires

Expand Down
14 changes: 2 additions & 12 deletions src/if_required/chainrulescore.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
using ChainRulesCore: NO_FIELDS

# ChainRulesCore.frule(Δ, ::typeof(getproperty), x::ComponentArray, s::Symbol) = frule((_, Δ), getproperty, x, Val(s))
# function ChainRulesCore.frule(Δ, ::typeof(getproperty), x::ComponentArray, ::Val{s}) where s
# zero_x = zero(x)
# setproperty!(zero_x, s, Δ)
# return getproperty(x, s), zero_x
# end
ChainRulesCore.rrule(::typeof(getproperty), x::ComponentArray, ::Val{s}) where s = ChainRulesCore.rrule(getproperty, x, s)
function ChainRulesCore.rrule(::typeof(getproperty), x::ComponentArray, s::Symbol)
function getproperty_adjoint(Δ)
Expand All @@ -17,8 +9,6 @@ function ChainRulesCore.rrule(::typeof(getproperty), x::ComponentArray, s::Symbo
return getproperty(x, s), getproperty_adjoint
end

ChainRulesCore.rrule(::typeof(getdata), x::ComponentArray) = getdata(x), Δ->ComponentArray(Δ, getaxes(x))

ChainRulesCore.rrule(::Type{ComponentArray}, data, axes) = ComponentArray(data, axes), Δ->(NO_FIELDS, getdata(Δ), getaxes(Δ))
ChainRulesCore.rrule(::typeof(getdata), x::ComponentArray) = getdata(x), Δ->(ChainRulesCore.NO_FIELDS, ComponentArray(Δ, getaxes(x)))

ChainRulesCore.rrule(::Type{ComponentArray}, data, axes) = ComponentArray(data, axes), Δ->(getdata(Δ), getaxes(Δ))
ChainRulesCore.rrule(::Type{ComponentArray}, data, axes) = ComponentArray(data, axes), Δ->(ChainRulesCore.NO_FIELDS, getdata(Δ), getaxes(Δ))

2 comments on commit 8a8c7ba

@jonniedie
Copy link
Collaborator 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/32893

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.9.3 -m "<description of version>" 8a8c7ba627ba0248a2c7a1de50e99d884345369a
git push origin v0.9.3

Please sign in to comment.