From b878e54a57ddb51fba7996e81a9fbe1c8a02ece9 Mon Sep 17 00:00:00 2001 From: Simeon David Schaub Date: Thu, 28 Oct 2021 01:57:23 -0400 Subject: [PATCH 1/2] Revert "Merge pull request #495 from JuliaDiff/mz/error" This reverts commit a724bbb1beb75281bdfe576bde2ff98b1c507013, reversing changes made to bde316600b2644af05f2ad4d6e81ae47c85151ca. --- src/tangent_types/tangent.jl | 17 ----------------- test/tangent_types/tangent.jl | 22 +--------------------- 2 files changed, 1 insertion(+), 38 deletions(-) diff --git a/src/tangent_types/tangent.jl b/src/tangent_types/tangent.jl index ec7c64448..bb91e431e 100644 --- a/src/tangent_types/tangent.jl +++ b/src/tangent_types/tangent.jl @@ -25,18 +25,6 @@ struct Tangent{P,T} <: AbstractTangent # Note: If T is a Tuple/Dict, then P is also a Tuple/Dict # (but potentially a different one, as it doesn't contain differentials) backing::T - - function Tangent{P,T}(backing) where {P,T} - if P <: Tuple - T <: Tuple || _backing_error(P, T, Tuple) - elseif P <: AbstractDict - T <: AbstractDict || _backing_error(P, T, AbstractDict) - elseif P === Any # can be anything - else # Any other struct (including NamedTuple) - T <: NamedTuple || _backing_error(P, T, NamedTuple) - end - return new(backing) - end end function Tangent{P}(; kwargs...) where {P} @@ -57,11 +45,6 @@ function Tangent{P}(d::Dict) where {P<:Dict} return Tangent{P,typeof(d)}(d) end -function _backing_error(P, G, E) - msg = "Tangent for the primal $P should be backed by a $E type, not by $G." - return throw(ArgumentError(msg)) -end - function Base.:(==)(a::Tangent{P,T}, b::Tangent{P,T}) where {P,T} return backing(a) == backing(b) end diff --git a/test/tangent_types/tangent.jl b/test/tangent_types/tangent.jl index 1e6b27878..9fcb227a1 100644 --- a/test/tangent_types/tangent.jl +++ b/test/tangent_types/tangent.jl @@ -23,26 +23,6 @@ end @test typeof(Tangent{Tuple{}}()) == Tangent{Tuple{},Tuple{}} end - @testset "constructor" begin - t = (1.0, 2.0) - nt = (x=1, y=2.0) - d = Dict(:x => 1.0, :y => 2.0) - vals = [1, 2] - - @test_throws ArgumentError Tangent{typeof(t),typeof(nt)}(nt) - @test_throws ArgumentError Tangent{typeof(t),typeof(d)}(d) - - @test_throws ArgumentError Tangent{typeof(d),typeof(nt)}(nt) - @test_throws ArgumentError Tangent{typeof(d),typeof(t)}(t) - - @test_throws ArgumentError Tangent{typeof(nt),typeof(vals)}(vals) - @test_throws ArgumentError Tangent{typeof(nt),typeof(d)}(d) - @test_throws ArgumentError Tangent{typeof(nt),typeof(t)}(t) - - @test_throws ArgumentError Tangent{Foo,typeof(d)}(d) - @test_throws ArgumentError Tangent{Foo,typeof(t)}(t) - end - @testset "==" begin @test Tangent{Foo}(; x=0.1, y=2.5) == Tangent{Foo}(; x=0.1, y=2.5) @test Tangent{Foo}(; x=0.1, y=2.5) == Tangent{Foo}(; y=2.5, x=0.1) @@ -134,7 +114,7 @@ end @test_throws MethodError reverse(Tangent{Foo}(; x=1.0, y=2.0)) d = Dict(:x => 1, :y => 2.0) - cdict = Tangent{typeof(d),typeof(d)}(d) + cdict = Tangent{Foo,typeof(d)}(d) @test_throws MethodError reverse(Tangent{Foo}()) end From 4f7a28939a07a23ec568548c31c2b21a3cb8e4ce Mon Sep 17 00:00:00 2001 From: Simeon David Schaub Date: Thu, 28 Oct 2021 02:02:36 -0400 Subject: [PATCH 2/2] bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 4b0a35e4a..c94d6c4dc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "ChainRulesCore" uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" -version = "1.11.0" +version = "1.11.1" [deps] Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"