Correlation matrices divide each column by the unit, so they are by definition dimensionless. However, the oneunit function is used here.
I can't think of an example where this would work. This won't work with Unitful.jl, because the covariance matrix can only have a single unit; if you try to use cor2cov! the type will change, because it has to be unitless.
X = randn(10,3) .*u"m"
julia> cov(X)
3×3 Matrix{Quantity{Float64, 𝐋^2, Unitful.FreeUnits{(m^2,), 𝐋^2, nothing}}}:
1.09164 m^2 0.289683 m^2 -0.139717 m^2
0.289683 m^2 0.481522 m^2 -0.150258 m^2
-0.139717 m^2 -0.150258 m^2 1.2722 m^2
julia> cor(X)
ERROR: DimensionError: m^2 and 0.3995548704289101 are not dimensionally compatible.
I can't see this working for Dates either. The oneunit function should be switched to the one function, because the diagonals of correlation matrices are multiplicative identities. If the return type of one(S[i]) cannot be converted to the element type of the covariance matrix S, there's no way to produce the correlation matrix through in-place modification of S anyway. It's best to just construct a new matrix using the element type of one(S[i]).
Correlation matrices divide each column by the unit, so they are by definition dimensionless. However, the
oneunitfunction is used here.Statistics.jl/src/Statistics.jl
Line 652 in ad4a0cd
I can't think of an example where this would work. This won't work with Unitful.jl, because the covariance matrix can only have a single unit; if you try to use
cor2cov!the type will change, because it has to be unitless.I can't see this working for Dates either. The
oneunitfunction should be switched to theonefunction, because the diagonals of correlation matrices are multiplicative identities. If the return type ofone(S[i])cannot be converted to the element type of the covariance matrixS, there's no way to produce the correlation matrix through in-place modification ofSanyway. It's best to just construct a new matrix using the element type ofone(S[i]).