Skip to content

Commit

Permalink
Use something instead of coalesce
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters committed May 31, 2018
1 parent 8659f37 commit b19ec13
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/base.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# This file contains code formerly part of Julia. License is MIT: https://julialang.org/license

if VERSION < v"0.7.0-DEV.5278"
const something = Base.coalesce
end

# deprecations from base/deprecated.jl
@deprecate varm(A::AbstractArray, m::AbstractArray, dims; kwargs...) varm(A, m; kwargs..., dims=dims)
@deprecate var(A::AbstractArray, dims; kwargs...) var(A; kwargs..., dims=dims)
Expand Down Expand Up @@ -164,10 +168,10 @@ The mean `mean` over the region may be provided.
var(A::AbstractArray; corrected::Bool=true, mean=nothing, dims=:) = _var(A, corrected, mean, dims)

_var(A::AbstractArray, corrected::Bool, mean, dims) =
varm(A, coalesce(mean, Base.mean(A, dims=dims)); corrected=corrected, dims=dims)
varm(A, something(mean, Base.mean(A, dims=dims)); corrected=corrected, dims=dims)

_var(A::AbstractArray, corrected::Bool, mean, ::Colon) =
real(varm(A, coalesce(mean, Base.mean(A)); corrected=corrected))
real(varm(A, something(mean, Base.mean(A)); corrected=corrected))

varm(iterable, m; corrected::Bool=true) = _var(iterable, corrected, m)

Expand Down

0 comments on commit b19ec13

Please sign in to comment.