@@ -135,21 +135,26 @@ end
135135 end
136136
137137 @test isnan (logsubexp (Inf , Inf ))
138- @test isnan (logsubexp (- Inf , - Inf ))
138+ @test logsubexp (- Inf , - Inf ) ≡ - Inf
139+ @test logsubexp (Inf , - Inf ) ≡ Inf
140+ @test logsubexp (- Inf , Inf ) ≡ Inf
139141 @test logsubexp (Inf , 9.0 ) ≡ Inf
142+ @test logsubexp (9.0 , Inf ) ≡ Inf
140143 @test logsubexp (- Inf , 9.0 ) ≡ 9.0
144+ @test logsubexp (9.0 , - Inf ) ≡ 9.0
141145 @test logsubexp (1f2 , 1f2 ) ≡ - Inf32
142146 @test logsubexp (0 , 0 ) ≡ - Inf
143147 @test logsubexp (3 , 2 ) ≈ 2.541324854612918108978
144148
145149 # NaN propagation
146- @test isnan (logaddexp (NaN , 9.0 ))
147- @test isnan (logaddexp (NaN , Inf ))
148- @test isnan (logaddexp (NaN , - Inf ))
149-
150- @test isnan (logsubexp (NaN , 9.0 ))
151- @test isnan (logsubexp (NaN , Inf ))
152- @test isnan (logsubexp (NaN , - Inf ))
150+ for f in (logaddexp, logsubexp)
151+ @test isnan (f (NaN , 9.0 ))
152+ @test isnan (f (NaN , Inf ))
153+ @test isnan (f (NaN , - Inf ))
154+ @test isnan (f (9.0 , NaN ))
155+ @test isnan (f (Inf , NaN ))
156+ @test isnan (f (- Inf , NaN ))
157+ end
153158
154159 @test isnan (logsumexp ([NaN , 9.0 ]))
155160 @test isnan (logsumexp ([NaN , Inf ]))
205210 s = softmax (x)
206211 @test s ≈ r
207212 @test eltype (s) === Float64
208-
213+
209214 # non-standard indices: #12
210215 x = OffsetArray (1 : 3 , - 2 : 0 )
211216 s = softmax (x)
0 commit comments