Skip to content

Commit

Permalink
[Statistics] fix type determination in corm (#32271)
Browse files Browse the repository at this point in the history
* [Statistics] fix type determination in corm

* remove obsolete typeof

* use first element(s) for type initialization

* add test for inhomogeneous data and for overflow

* fix test with NaN
  • Loading branch information
dkarrasch authored and andreasnoack committed Jul 24, 2019
1 parent e6a897e commit a8a567e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

4 comments on commit a8a567e

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

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

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.