Skip to content

Commit

Permalink
fix new test on 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aplavin committed May 16, 2024
1 parent 588ac75 commit 8ca1d97
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions test/weights.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
using StatsBase
using LinearAlgebra, Random, SparseArrays, Test


# minimal custom weights type for tests below
struct MyWeights <: AbstractWeights{Float64, Float64, Vector{Float64}}
values::Vector{Float64}
sum::Float64
end
MyWeights(values) = MyWeights(values, sum(values))


@testset "StatsBase.Weights" begin
weight_funcs = (weights, aweights, fweights, pweights)

Expand Down Expand Up @@ -611,12 +620,6 @@ end
end

@testset "custom weight types" begin
struct MyWeights <: AbstractWeights{Float64, Float64, Vector{Float64}}
values::Vector{Float64}
sum::Float64
end
MyWeights(values) = MyWeights(values, sum(values))

@test mean([1, 2, 3], MyWeights([1, 4, 10])) 2.6
@test mean([1, 2, 3], MyWeights([NaN, 4, 10])) |> isnan
@test mode([1, 2, 3], MyWeights([1, 4, 10])) == 3
Expand Down

0 comments on commit 8ca1d97

Please sign in to comment.