diff --git a/README.md b/README.md index abeff623dc316..b84aec36644be 100644 --- a/README.md +++ b/README.md @@ -168,7 +168,9 @@ Currently, the `@compat` macro supports the following syntaxes: Compat provides an unexported `Compat.Filesystem` method that is aliased to `Base.FS` on Julia 0.3 and 0.4 and `Base.Filesystem` on Julia 0.5. -* `mktemp` and `mktempdir` now have variants which take a function as their first argument for automated cleanup. [#9017](https://github.com/JuliaLang/julia/pull/9017) +* `mktemp` and `mktempdir` now have variants which take a function as their first argument for automated cleanup. [#9017](https://github.com/JuliaLang/julia/pull/9017) + +* `cov` and `cor` don't allow keyword arguments anymore. Loading Compat defines compatibility methods for the new API. [#13465](https://github.com/JuliaLang/julia/pull/13465) ## New types diff --git a/src/Compat.jl b/src/Compat.jl index 3b4aac235bfc1..1e9998898f295 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -793,6 +793,20 @@ if VERSION < v"0.4.0-dev+1653" end end +if VERSION < v"0.5.0-dev+679" + import Base: cov, cor + + cov(x::AbstractVector, corrected::Bool) = cov(x, corrected=corrected) + cov(X::AbstractMatrix, vardim::Integer) = cov(X, vardim=vardim) + cov(X::AbstractMatrix, vardim::Integer, corrected::Bool) = cov(X, vardim=vardim, corrected=corrected) + cov(x::AbstractVector, y::AbstractVector, corrected::Bool) = cov(x, y, corrected=corrected) + cov(X::AbstractMatrix, Y::AbstractMatrix, vardim::Integer) = cov(X, Y, vardim=vardim) + cov(X::AbstractMatrix, Y::AbstractMatrix, vardim::Integer, corrected::Bool) = cov(X, Y, vardim=vardim, corrected=corrected) + + cor(X::AbstractMatrix, vardim::Integer) = cor(X, vardim=vardim) + cor(X::AbstractMatrix, Y::AbstractMatrix, vardim::Integer) = cor(X, Y, vardim=vardim) +end + if VERSION < v"0.5.0-dev+2228" const readstring = readall export readstring diff --git a/test/runtests.jl b/test/runtests.jl index d6dc12bb6d0f8..0cb9b31127095 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -827,3 +827,20 @@ end @test issymmetric([1 2 3; 2 2 3; 3 3 2]) @test !issymmetric([1 3 3; 2 2 3; 3 3 2]) + +let X = randn(10,2), Y = randn(10,2), x = randn(10), y = randn(10) + for b in (true, false) + if VERSION < v"0.5.0-dev+679" + @test cov(x, b) == cov(x, corrected=b) + end + for d in (1, 2) + @test size(cov(X, d), 1) == 8*d - 6 + @test size(cov(X, d, b), 1) == 8*d - 6 + @test size(cov(X, Y, d), 1) == 8*d - 6 + @test size(cov(X, Y, d, b), 1) == 8*d - 6 + + @test size(cor(X, d), 1) == 8*d - 6 + @test size(cor(X, Y, d), 1) == 8*d - 6 + end + end +end