Skip to content

Commit 636f0f1

Browse files
authored
Merge pull request #42 from JuliaDiff/npr/rename-dne-doesnotexit
Rename `DNE` -> `DoesNotExist`
2 parents 2130ed8 + efb9c19 commit 636f0f1

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

src/ChainRulesCore.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ export frule, rrule
55
export wirtinger_conjugate, wirtinger_primal, refine_differential
66
export @scalar_rule, @thunk
77
export extern, cast, store!
8-
export Wirtinger, Zero, One, DNE, Thunk, InplaceableThunk
8+
export Wirtinger, Zero, One, DoesNotExist, Thunk, InplaceableThunk
99
export NO_FIELDS
1010

1111
include("differentials.jl")
1212
include("differential_arithmetic.jl")
1313
include("operations.jl")
1414
include("rules.jl")
1515
include("rule_definition_tools.jl")
16+
17+
Base.@deprecate_binding DNE DoesNotExist
18+
1619
end # module

src/differential_arithmetic.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ subtypes, as we know the full set that might be encountered.
77
Thus we can avoid any ambiguities.
88
99
Notice:
10-
The precidence goes: (:Wirtinger, :Zero, :DNE, :One, :AbstractThunk, :Any)
10+
The precidence goes: (:Wirtinger, :Zero, :DoesNotExist, :One, :AbstractThunk, :Any)
1111
Thus each of the @eval loops creating definitions of + and *
1212
defines the combination this type with all types of lower precidence.
1313
This means each eval loops is 1 item smaller than the previous.
@@ -36,7 +36,7 @@ function Base.:+(a::Wirtinger, b::Wirtinger)
3636
return Wirtinger(+(a.primal, b.primal), a.conjugate + b.conjugate)
3737
end
3838

39-
for T in (:Zero, :DNE, :One, :AbstractThunk, :Any)
39+
for T in (:Zero, :DoesNotExist, :One, :AbstractThunk, :Any)
4040
@eval Base.:+(a::Wirtinger, b::$T) = a + Wirtinger(b, Zero())
4141
@eval Base.:+(a::$T, b::Wirtinger) = Wirtinger(a, Zero()) + b
4242

@@ -47,7 +47,7 @@ end
4747

4848
Base.:+(::Zero, b::Zero) = Zero()
4949
Base.:*(::Zero, ::Zero) = Zero()
50-
for T in (:DNE, :One, :AbstractThunk, :Any)
50+
for T in (:DoesNotExist, :One, :AbstractThunk, :Any)
5151
@eval Base.:+(::Zero, b::$T) = b
5252
@eval Base.:+(a::$T, ::Zero) = a
5353

@@ -56,14 +56,14 @@ for T in (:DNE, :One, :AbstractThunk, :Any)
5656
end
5757

5858

59-
Base.:+(::DNE, ::DNE) = DNE()
60-
Base.:*(::DNE, ::DNE) = DNE()
59+
Base.:+(::DoesNotExist, ::DoesNotExist) = DoesNotExist()
60+
Base.:*(::DoesNotExist, ::DoesNotExist) = DoesNotExist()
6161
for T in (:One, :AbstractThunk, :Any)
62-
@eval Base.:+(::DNE, b::$T) = b
63-
@eval Base.:+(a::$T, ::DNE) = a
62+
@eval Base.:+(::DoesNotExist, b::$T) = b
63+
@eval Base.:+(a::$T, ::DoesNotExist) = a
6464

65-
@eval Base.:*(::DNE, ::$T) = DNE()
66-
@eval Base.:*(::$T, ::DNE) = DNE()
65+
@eval Base.:*(::DoesNotExist, ::$T) = DoesNotExist()
66+
@eval Base.:*(::$T, ::DoesNotExist) = DoesNotExist()
6767
end
6868

6969

src/differentials.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,26 +106,26 @@ Base.iterate(::Zero, ::Any) = nothing
106106

107107

108108
#####
109-
##### `DNE`
109+
##### `DoesNotExist`
110110
#####
111111

112112
"""
113-
DNE()
113+
DoesNotExist()
114114
115115
This differential indicates that the derivative Does Not Exist (D.N.E).
116116
This is not the cast that it is not implemented, but rather that it mathematically
117117
is not defined.
118118
"""
119-
struct DNE <: AbstractDifferential end
119+
struct DoesNotExist <: AbstractDifferential end
120120

121-
function extern(x::DNE)
121+
function extern(x::DoesNotExist)
122122
throw(ArgumentError("Derivative does not exit. Cannot be converted to an external type."))
123123
end
124124

125-
Base.Broadcast.broadcastable(::DNE) = Ref(DNE())
125+
Base.Broadcast.broadcastable(::DoesNotExist) = Ref(DoesNotExist())
126126

127-
Base.iterate(x::DNE) = (x, nothing)
128-
Base.iterate(::DNE, ::Any) = nothing
127+
Base.iterate(x::DoesNotExist) = (x, nothing)
128+
Base.iterate(::DoesNotExist, ::Any) = nothing
129129

130130
#####
131131
##### `One`
@@ -270,7 +270,7 @@ Constant for the reverse-mode derivative with respect to a structure that has no
270270
The most notable use for this is for the reverse-mode derivative with respect to the
271271
function itself, when that function is not a closure.
272272
"""
273-
const NO_FIELDS = DNE()
273+
const NO_FIELDS = DoesNotExist()
274274

275275
"""
276276
refine_differential(𝒟::Type, der)

test/differentials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
@test refine_differential(typeof([1.2]), Wirtinger(2,2)) == 4
105105

106106
# For most differentials, in most domains, this does nothing
107-
for der in (DNE(), @thunk(23), @thunk(Wirtinger(2,2)), [1 2], One(), Zero(), 0.0)
107+
for der in (DoesNotExist(), @thunk(23), @thunk(Wirtinger(2,2)), [1 2], One(), Zero(), 0.0)
108108
for 𝒟 in typeof.((1.0 + 1im, [1.0 + 1im], 1.2, [1.2]))
109109
@test refine_differential(𝒟, der) === der
110110
end

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ using ChainRulesCore
44
using LinearAlgebra: Diagonal
55
using ChainRulesCore: extern, accumulate, accumulate!, store!, @scalar_rule,
66
Wirtinger, wirtinger_primal, wirtinger_conjugate,
7-
Zero, One, DNE, Thunk
7+
Zero, One, DoesNotExist, Thunk
88
using Base.Broadcast: broadcastable
99

1010
@testset "ChainRulesCore" begin

0 commit comments

Comments
 (0)