Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit

Permalink
Fix WeightVec deprecation from StatsBase 0.15 (#254)
Browse files Browse the repository at this point in the history
* Fix WeightVec deprecation from StatsBase 0.15

* enable travis on 0.6 for master
  • Loading branch information
tkelman authored and ararslan committed May 28, 2017
1 parent c27e356 commit 1cd77da
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: julia
julia:
# - 0.6
- 0.6
- nightly
os:
- linux
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
julia 0.6.0-pre
Compat 0.8.6
StatsBase 0.14.0
StatsBase 0.15.0
Reexport
SpecialFunctions
4 changes: 2 additions & 2 deletions src/extras.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function StatsBase.addcounts!{T,U}(cm::Dict{U,Int}, x::AbstractDataArray{T})
return cm
end

function StatsBase.addcounts!{T,U,W}(cm::Dict{U,W}, x::AbstractDataArray{T}, wv::WeightVec{W})
function StatsBase.addcounts!{T,U,W}(cm::Dict{U,W}, x::AbstractDataArray{T}, wv::Weights{W})
n = length(x)
length(wv) == n || raise_dimerror()
w = values(wv)
Expand All @@ -23,7 +23,7 @@ function StatsBase.countmap{T}(x::AbstractDataArray{T})
addcounts!(Dict{Union{T, NAtype}, Int}(), x)
end

function StatsBase.countmap{T,W}(x::AbstractDataArray{T}, wv::WeightVec{W})
function StatsBase.countmap{T,W}(x::AbstractDataArray{T}, wv::Weights{W})
addcounts!(Dict{Union{T, NAtype}, W}(), x, wv)
end

Expand Down
4 changes: 2 additions & 2 deletions src/reduce.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Base.std(A::DataArray; corrected::Bool=true, mean=nothing, skipna::Bool=false) =

## weighted mean

function Base.mean(a::DataArray, w::WeightVec; skipna::Bool=false)
function Base.mean(a::DataArray, w::Weights; skipna::Bool=false)
if skipna
v = a .* w.values
sum(v; skipna=true) / sum(DataArray(w.values, v.na); skipna=true)
Expand All @@ -184,7 +184,7 @@ function Base.mean(a::DataArray, w::WeightVec; skipna::Bool=false)
end
end

function Base.mean{W,V<:DataArray}(a::DataArray, w::WeightVec{W,V}; skipna::Bool=false)
function Base.mean{W,V<:DataArray}(a::DataArray, w::Weights{W,V}; skipna::Bool=false)
if skipna
v = a .* w.values
sum(v; skipna=true) / sum(DataArray(w.values.data, v.na); skipna=true)
Expand Down

0 comments on commit 1cd77da

Please sign in to comment.