Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Statistics] fix type determination in corm #32271

Merged
merged 5 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stdlib/Statistics/src/Statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -645,8 +645,8 @@ function corm(x::AbstractVector, mx, y::AbstractVector, my)

@inbounds begin
# Initialize the accumulators
xx = zero(sqrt(abs2(x[1])))
yy = zero(sqrt(abs2(y[1])))
xx = zero(sqrt(abs2(one(x[1]))))
yy = zero(sqrt(abs2(one(y[1]))))
xy = zero(x[1] * y[1]')

@simd for i in eachindex(x, y)
Expand Down
2 changes: 2 additions & 0 deletions stdlib/Statistics/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ end
@test cor(repeat(1:17, 1, 17))[2] <= 1.0
@test cor(1:17, 1:17) <= 1.0
@test cor(1:17, 18:34) <= 1.0
@test cor(Any[1, 2], Any[1, 2]) == 1.0
@test isnan(cor([0], Int8[81]))
let tmp = range(1, stop=85, length=100)
tmp2 = Vector(tmp)
@test cor(tmp, tmp) <= 1.0
Expand Down