Skip to content

Commit 5a539ac

Browse files
committed
tests: Fix tests for older Julia
Also a couple of clarity fixes
1 parent 1f1d180 commit 5a539ac

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/mutualinfo.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ in the denominator is computed. It can be one of:
5555
"""
5656
function mutualinfo(a, b; method::Union{Nothing, Symbol} = nothing, normed::Union{Nothing, Bool} = nothing, kwargs...)
5757
# Disallow `method` and `normed` to be used together
58-
if isnothing(method)
59-
isnothing(normed) || Base.depwarn("`normed` kwarg is deprecated, please use `method=:normalized` instead of `normed=true`, and `method=:classic` instead of `normed=false'", :mutualinfo)
60-
method = if isnothing(normed) || normed
58+
if method === nothing
59+
(normed === nothing) || Base.depwarn("`normed` kwarg is deprecated, please use `method=:normalized` instead of `normed=true`, and `method=:classic` instead of `normed=false'", :mutualinfo)
60+
method = if (normed === nothing) || normed
6161
:normalized
6262
else
6363
:classic
6464
end
6565
else
66-
isnothing(normed) || throw(ArgumentError("`normed` kwarg is not compatible with `method` kwarg"))
66+
(normed === nothing) || throw(ArgumentError("`normed` kwarg is not compatible with `method` kwarg"))
6767
end
68-
# Little hack to ensure the correct error is thrown
68+
# Little hack to ensure the invalid kwargs error is thrown
6969
if method === :adjusted && length(kwargs) >= 1 && :aggregate keys(kwargs)
7070
method = :classic
7171
end

test/mutualinfo.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,17 @@ using Clustering
2727
@test mutualinfo(a1, a2; method=:adjusted, aggregate=:max) 0.3437 atol=1.0e-4
2828
@test mutualinfo(a1, a2; method=:adjusted, aggregate=:min) 0.4348 atol=1.0e-4
2929

30-
# test errors
31-
@test_throws "ArgumentError: `normed` kwarg is not compatible with `method` kwarg" mutualinfo(a1, a2; method=:adjusfted, normed=false)
32-
@test_throws "ArgumentError: mutualinfo(): `method=:adjusfted` is not supported" mutualinfo(a1, a2; method=:adjusfted, aggregate=:min)
33-
@test_throws "ArgumentError: mutualinfo(): unsupported kwargs used." mutualinfo(a1, a2; method=:adjusted, notaggregate=:min)
34-
@test_throws "ArgumentError: mutualinfo(): unsupported kwargs used." mutualinfo(a1, a2; method=:classic, notaggregate=:min)
30+
# test errors. More precise tests on Julia 1.8+ when supported
3531

32+
if VERSION >= v"1.8"
33+
@test_throws "ArgumentError: `normed` kwarg is not compatible with `method` kwarg" mutualinfo(a1, a2; method=:adjusted, normed=false)
34+
@test_throws "ArgumentError: mutualinfo(): `method=:adjusfted` is not supported" mutualinfo(a1, a2; method=:adjusfted, aggregate=:min)
35+
@test_throws "ArgumentError: mutualinfo(): unsupported kwargs used." mutualinfo(a1, a2; method=:adjusted, notaggregate=:min)
36+
@test_throws "ArgumentError: mutualinfo(): unsupported kwargs used." mutualinfo(a1, a2; method=:classic, notaggregate=:min)
37+
else
38+
@test_throws ArgumentError mutualinfo(a1, a2; method=:adjusted, normed=false)
39+
@test_throws ArgumentError mutualinfo(a1, a2; method=:adjusfted, aggregate=:min)
40+
@test_throws ArgumentError mutualinfo(a1, a2; method=:adjusted, notaggregate=:min)
41+
@test_throws ArgumentError mutualinfo(a1, a2; method=:classic, notaggregate=:min)
42+
end
3643
end

0 commit comments

Comments
 (0)