Skip to content

Commit

Permalink
Add tests for additional small types
Browse files Browse the repository at this point in the history
  • Loading branch information
brenhinkeller committed Jun 20, 2021
1 parent 520e2cb commit a23c680
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/testArrayStats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@

# Summary statistics: dimensional tests, Float64
A = reshape(1:300.,100,3)
@test nansum(A, dims=1) == sum(A, dims=1)
@test nansum(A, dims=2) == sum(A, dims=2)
@test nansum(A, dim=1) == vec(sum(A, dims=1))
@test nansum(A, dim=2) == vec(sum(A, dims=2))
@test nanminimum(A, dim=1) == vec(minimum(A, dims=1))
@test nanminimum(A, dim=2) == vec(minimum(A, dims=2))
@test nanmaximum(A, dim=1) == vec(maximum(A, dims=1))
Expand Down Expand Up @@ -226,6 +226,21 @@
@test nanstd(A, dims=(4,5,6)) std(A, dims=(4,5,6))
@test nanstd(A, dims=(4,5,6)) nanstd(A, dims=(4,5,6), mean=nanmean(A, dims=(4,5,6)))

# A few tests with other types
for T in (Bool, Float16, Float32)
A = rand(T, 100)
@test nansum(A) sum(A)
@test nanmean(A) mean(A)
@test nanstd(A) std(A)
end

for T in (UInt8, UInt16, UInt32, Int8, Int16, Int32)
A = collect(T, 1:100)
@test nansum(A) == 5050
@test nanmean(A) == 50.5
@test nanstd(A) 29.011491975882016
end

# Standardization
@test nanstandardize!(collect(1:10.)) ((1:10) .- mean(1:10)) / std(1:10)
@test nanstandardize(1:10.) ((1:10) .- mean(1:10)) / std(1:10)
Expand Down

2 comments on commit a23c680

@brenhinkeller
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

Release notes:

  • Remove recursive fallback methods for high-dimensional nanmean and nanvar; just use direct loop generation
  • Add direct loop generation methods for nansum
  • Additional test coverage for small numeric types

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/39227

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.5.2 -m "<description of version>" a23c680d3ce4697b2fc770d2d91c536c02108599
git push origin v0.5.2

Please sign in to comment.