Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin committed Apr 20, 2024
1 parent cc11ea9 commit 517afa6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ end
@test isnan(median(Any[NaN,0.0,1.0]))
@test isequal(median([NaN 0.0; 1.2 4.5], dims=2), reshape([NaN; 2.85], 2, 1))

# the specific NaN value is propagated from the input
@test median([NaN]) === NaN
@test median([0.0,NaN]) === NaN
@test median([0.0,NaN,NaN]) === NaN
@test median([-NaN]) === -NaN
@test median([0.0,-NaN]) === -NaN
@test median([0.0,-NaN,-NaN]) === -NaN

@test ismissing(median([1, missing]))
@test ismissing(median([1, 2, missing]))
@test ismissing(median([NaN, 2.0, missing]))
Expand Down Expand Up @@ -112,6 +120,14 @@ end
@test isnan(mean([0.0,NaN]))
@test isnan(mean([NaN,0.0]))

# the specific NaN value is propagated from the input
@test mean([NaN]) === NaN
@test mean([0.0,NaN]) === NaN
@test mean([0.0,NaN,NaN]) === NaN
@test mean([-NaN]) === -NaN
@test mean([0.0,-NaN]) === -NaN
@test mean([0.0,-NaN,-NaN]) === -NaN

@test isnan(mean([0.,Inf,-Inf]))
@test isnan(mean([1.,-1.,Inf,-Inf]))
@test isnan(mean([-Inf,Inf]))
Expand Down

0 comments on commit 517afa6

Please sign in to comment.