Skip to content

Commit

Permalink
Drop compat for corrected kw arg to cov from #401
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed Oct 1, 2019
1 parent 30575ee commit 642878f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 45 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ Currently, the `@compat` macro supports the following syntaxes:
* `Base.rtoldefault` how takes a third parameter `atol`.
The two argument form is deprecated in favor of the three arguments form with `atol=0`.

* The `corrected` optional argument of `cov` becomes a keyword argument of `Compat.Statistics.cov` ([#21709]).

* `isequal`, `==` and `in` have one argument "curried" forms. For example `isequal(x)`
returns a function that compares its arguments to `x` using `isequal` ([#26436]).

Expand Down
29 changes: 0 additions & 29 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,6 @@ end

include("compatmacro.jl")

if VERSION < v"0.7.0-DEV.755"
# This is a hack to only add keyword signature that won't work on all julia versions.
# However, since we really only need to support a few (0.5, 0.6 and early 0.7) versions
# this should be good enough.
# TODO add deprecation warning to switch to StatsBase
let Tf = typeof(Base.cov), Tkw = Core.Core.kwftype(Tf)
@eval begin
@inline function _get_corrected(kws)
corrected = true
nkw = length(kws) >> 1
for i in 1:nkw
if kws[i * 2 - 1] !== :corrected
Base.kwerr(kws)
end
corrected = kws[i * 2]
end
return corrected::Bool
end
(::$Tkw)(kws::Vector{Any}, ::$Tf, x::AbstractVector) = Base.cov(x, _get_corrected(kws))
(::$Tkw)(kws::Vector{Any}, ::$Tf, X::AbstractVector, Y::AbstractVector) =
Base.cov(X, Y, _get_corrected(kws))
(::$Tkw)(kws::Vector{Any}, ::$Tf, x::AbstractMatrix, vardim::Int) =
Base.cov(x, vardim, _get_corrected(kws))
(::$Tkw)(kws::Vector{Any}, ::$Tf, X::AbstractVecOrMat, Y::AbstractVecOrMat,
vardim::Int) = Base.cov(X, Y, vardim, _get_corrected(kws))
end
end
end

# 0.7.0-DEV.1415
@static if !isdefined(Base, :adjoint)
const adjoint = ctranspose
Expand Down
14 changes: 0 additions & 14 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,6 @@ end
@test isa(Base.rtoldefault(Float64, Float64, 0), Float64)
@test Base.rtoldefault(Float64, Float64, 1.0) === 0.0

# 0.7
if VERSION < v"0.7.0-DEV.5238"
# Test the extended cov if cov is part of Base. In the future, this will be dealt with
# in StatsBase
@test cov([1 2; 3 4], 1, corrected=true) == fill(2.0, 2, 2)
@test cov([1 2; 3 4], 1, corrected=false) == fill(1.0, 2, 2)
@test cov([1 2; 3 4], [0 4; 8 9], 1, corrected=true) == [8.0 5.0; 8.0 5.0]
@test cov([1 2; 3 4], [0 4; 8 9], 1, corrected=false) == [4.0 2.5; 4.0 2.5]
@test cov([1, 2], corrected=true) === 0.5
@test cov([1, 2], corrected=false) === 0.25
@test cov([1, 2], [0, 10], corrected=true) === 5.0
@test cov([1, 2], [0, 10], corrected=false) === 2.5
end

# 0.7
module Test23876
using Compat
Expand Down

0 comments on commit 642878f

Please sign in to comment.