Skip to content

Commit 05b4aa5

Browse files
authored
More explicit error and deprecation warnings
1 parent 9d6807b commit 05b4aa5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/scalarstats.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ Elements with probability 0 or 1 add 0 to the entropy.
534534
"""
535535
function entropy(p)
536536
if isempty(p)
537-
throw(ArgumentError("empty collections of probabilities are not supported"))
537+
throw(ArgumentError("empty collections are not supported since they do not " *
538+
"represent proper probability distributions"))
538539
end
539540
return -sum(xlogx, p)
540541
end
@@ -595,7 +596,8 @@ function crossentropy(p::AbstractArray{<:Real}, q::AbstractArray{<:Real})
595596
# handle empty collections
596597
if isempty(p)
597598
Base.depwarn(
598-
"support for empty collections of probabilities will be removed",
599+
"support for empty collections will be removed since they do not " *
600+
"represent proper probability distributions",
599601
:crossentropy,
600602
)
601603
# return zero for empty arrays
@@ -625,7 +627,8 @@ function kldivergence(p::AbstractArray{<:Real}, q::AbstractArray{<:Real})
625627
# handle empty collections
626628
if isempty(p)
627629
Base.depwarn(
628-
"support for empty collections of probabilities will be removed",
630+
"support for empty collections will be removed since they do not "*
631+
"represent proper probability distributions",
629632
:kldivergence,
630633
)
631634
# return zero for empty arrays

0 commit comments

Comments
 (0)