Skip to content

Commit c9cd664

Browse files
Catch Rationals
1 parent 3d09301 commit c9cd664

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/vstats.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ vtgkldiv(x, y; dims=:) = vtmapreduce((xᵢ, yᵢ) -> xᵢ * (log(xᵢ) - log(y
181181
# Rénya
182182
_vrenyadivergence(p, q, α::Real, dims) =
183183
vmapreducethen((pᵢ, qᵢ) -> pᵢ^α / qᵢ^-1), +, x -> (1/-1)) * log(x), p, q, dims=dims)
184+
_vrenyadivergence(p, q, α::Rational{T}, dims) where {T} = _vrenyadivergence(p, q, float(α), dims)
184185

185186
function vrenyadivergence(p, q, α::Real; dims=:)
186187
if α 0
@@ -201,6 +202,7 @@ end
201202

202203
_vtrenyadivergence(p, q, α::Real, dims) =
203204
vtmapreducethen((pᵢ, qᵢ) -> pᵢ^α / qᵢ^-1), +, x -> (1/-1)) * log(x), p, q, dims=dims)
205+
_vtrenyadivergence(p, q, α::Rational{T}, dims) where {T} = _vtrenyadivergence(p, q, float(α), dims)
204206

205207
function vtrenyadivergence(p, q, α::Real; dims=:)
206208
if α 0

0 commit comments

Comments
 (0)