@@ -165,20 +165,24 @@ using InverseFunctions: FunctionWithInverse
165165unwrap (f) = f
166166unwrap (f:: FunctionWithInverse ) = f. f
167167
168-
169168fcomp (f, g) = fchain (g, f)
170169fcomp (:: typeof (identity), g) = g
171170fcomp (f, :: typeof (identity)) = f
172171fcomp (:: typeof (identity), :: typeof (identity)) = identity
173172
173+ near_neg_inf (:: Type{T} ) where {T<: Real } = T (- 1E38 ) # Still fits into Float32
174+
175+ isneginf (x) = isinf (x) && x < zero (x)
176+ isposinf (x) = isinf (x) && x > zero (x)
174177
175- near_neg_inf (:: Type{T} ) where T<: Real = T (- 1E38 ) # Still fits into Float32
178+ _isneginf_pullback (:: Any ) = (NoTangent (), ZeroTangent ())
179+ ChainRulesCore. rrule (:: typeof (isneginf), x) = isneginf (x), _logdensityof_rt_pullback
176180
177- isneginf (x ) = isinf (x) && x < 0
178- isposinf ( x) = isinf (x) && x > 0
181+ _isposinf_pullback ( :: Any ) = ( NoTangent (), ZeroTangent ())
182+ ChainRulesCore . rrule ( :: typeof (isposinf), x) = isposinf (x), _isposinf_pullback
179183
180- isapproxzero (x:: T ) where T<: Real = x ≈ zero (T)
184+ isapproxzero (x:: T ) where { T<: Real } = x ≈ zero (T)
181185isapproxzero (A:: AbstractArray ) = all (isapproxzero, A)
182186
183- isapproxone (x:: T ) where T<: Real = x ≈ one (T)
187+ isapproxone (x:: T ) where { T<: Real } = x ≈ one (T)
184188isapproxone (A:: AbstractArray ) = all (isapproxone, A)
0 commit comments