File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ Base.:+(a::Tangent{P}, b::P) where {P} = b + a
147147# We intentionally do not define, `Base.*(::Tangent, ::Tangent)` as that is not meaningful
148148# In general one doesn't have to represent multiplications of 2 differentials
149149# Only of a differential and a scaling factor (generally `Real`)
150- for T in (:Any ,)
150+ for T in (:Number ,)
151151 @eval Base.:* (s:: $T , tangent:: Tangent ) = map (x -> s * x, tangent)
152152 @eval Base.:* (tangent:: Tangent , s:: $T ) = map (x -> x * s, tangent)
153153end
Original file line number Diff line number Diff line change 9191 @test getproperty (Tangent {NT} (; b= (@thunk 2.0 ^ 2 )), 2 ) == 4.0
9292
9393 # TODO : uncomment this once https://github.com/JuliaLang/julia/issues/35516
94- @test_broken haskey (Tangent {Tuple{Float64}} (2.0 ), 1 ) == true
94+ if VERSION >= v " 1.8-"
95+ @test haskey (Tangent {Tuple{Float64}} (2.0 ), 1 ) == true
96+ else
97+ @test_broken haskey (Tangent {Tuple{Float64}} (2.0 ), 1 ) == true
98+ end
9599 @test_broken hasproperty (Tangent {Tuple{Float64}} (2.0 ), 2 ) == false
96100
97101 @test length (Tangent {Foo} (; x= 2.5 )) == 1
331335 d = Tangent {Dict} (Dict (4 => 3.0 ))
332336 two_d = Tangent {Dict} (Dict (4 => 2 * 3.0 ))
333337 @test 2 * d == two_d == d * 2
338+
339+ @test_throws MethodError [1 , 2 ] * Tangent {Foo} (; y= 1.5 , x= 2.5 )
340+ @test_throws MethodError [1 , 2 ] * d
341+ @test_throws MethodError Tangent {Foo} (; y= 1.5 , x= 2.5 ) * @thunk [1 2 ; 3 4 ]
334342 end
335343
336344 @testset " show" begin
You can’t perform that action at this time.
0 commit comments