Skip to content

Commit

Permalink
Merge pull request #636 from JuliaDiff/ox/zero_getprop
Browse files Browse the repository at this point in the history
Define getproperty on AbstractZeroTangents
  • Loading branch information
oxinabox authored Oct 13, 2023
2 parents ef8905b + 5066406 commit efc2f86
Show file tree
Hide file tree
Showing 3 changed files with 6 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 = "ChainRulesCore"
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
version = "1.16.0"
version = "1.17.0"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
2 changes: 2 additions & 0 deletions src/tangent_types/abstract_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Base.convert(::Type{T}, x::AbstractZero) where {T<:Number} = zero(T)
(::Type{Complex})(x::Real, y::AbstractZero) = Complex(x, false)

Base.getindex(z::AbstractZero, args...) = z
Base.getproperty(z::AbstractZero, name::Symbol) = z


Base.view(z::AbstractZero, ind...) = z
Base.sum(z::AbstractZero; dims=:) = z
Expand Down
3 changes: 3 additions & 0 deletions test/tangent_types/abstract_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
@test z[1:3] === z
@test z[1, 2] === z
@test getindex(z) === z

@test z.foo === z

@test first(z) === z
@test last(z) === z
Expand Down Expand Up @@ -134,6 +136,7 @@
@test dne[1:3] === dne
@test dne[1, 2] === dne
@test getindex(dne) === dne
@test dne.foo === dne
end

@testset "ambiguities" begin
Expand Down

2 comments on commit efc2f86

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

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 v1.17.0 -m "<description of version>" efc2f86016b1279a0a4ecaaf0ca65178a60d13db
git push origin v1.17.0

Please sign in to comment.