Skip to content

Commit

Permalink
constraint xlogx, xlogy args to ::Number
Browse files Browse the repository at this point in the history
  • Loading branch information
cossio committed May 20, 2020
1 parent f51f00e commit 1d70554
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/basicfuns.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ julia> StatsFuns.xlogx(0)
0.0
```
"""
function xlogx(x)
function xlogx(x::Number)
result = x * log(x)
ifelse(iszero(x), zero(result), result)
end
Expand All @@ -26,7 +26,7 @@ julia> StatsFuns.xlogy(0, 0)
0.0
```
"""
function xlogy(x, y)
function xlogy(x::Number, y::Number)
result = x * log(y)
ifelse(iszero(x) && !isnan(y), zero(result), result)
end
Expand Down

0 comments on commit 1d70554

Please sign in to comment.