File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -147,7 +147,7 @@ Base.:+(a::Tangent{P}, b::P) where {P} = b + a
147
147
# We intentionally do not define, `Base.*(::Tangent, ::Tangent)` as that is not meaningful
148
148
# In general one doesn't have to represent multiplications of 2 differentials
149
149
# Only of a differential and a scaling factor (generally `Real`)
150
- for T in (:Any ,)
150
+ for T in (:Number ,)
151
151
@eval Base.:* (s:: $T , tangent:: Tangent ) = map (x -> s * x, tangent)
152
152
@eval Base.:* (tangent:: Tangent , s:: $T ) = map (x -> x * s, tangent)
153
153
end
Original file line number Diff line number Diff line change 91
91
@test getproperty (Tangent {NT} (; b= (@thunk 2.0 ^ 2 )), 2 ) == 4.0
92
92
93
93
# 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
95
99
@test_broken hasproperty (Tangent {Tuple{Float64}} (2.0 ), 2 ) == false
96
100
97
101
@test length (Tangent {Foo} (; x= 2.5 )) == 1
331
335
d = Tangent {Dict} (Dict (4 => 3.0 ))
332
336
two_d = Tangent {Dict} (Dict (4 => 2 * 3.0 ))
333
337
@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 ]
334
342
end
335
343
336
344
@testset " show" begin
You can’t perform that action at this time.
0 commit comments