Skip to content

Commit db4e40e

Browse files
rofinnnalimilan
andauthored
UnitWeights don't have values to return from dataids (#808)
* Added a few basic UnitWeight tests including calling `dataids` explicitly. * Add explicit dataids special case to pass tests. * Move tests to existing testset * Bump patch release Co-authored-by: Milan Bouchet-Valat <[email protected]>
1 parent 9ff127f commit db4e40e

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "StatsBase"
22
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
33
authors = ["JuliaStats"]
4-
version = "0.33.17"
4+
version = "0.33.18"
55

66
[deps]
77
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"

src/weights.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ length(wv::UnitWeights) = wv.len
304304
size(wv::UnitWeights) = tuple(length(wv))
305305
Base.axes(wv::UnitWeights) = tuple(Base.OneTo(length(wv)))
306306

307+
Base.dataids(::UnitWeights) = ()
307308
Base.convert(::Type{Vector}, wv::UnitWeights{T}) where {T} = ones(T, length(wv))
308309

309310
@propagate_inbounds function Base.getindex(wv::UnitWeights{T}, i::Integer) where T

test/weights.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ end
117117
@test wv != fweights(fill(1.0, 3))
118118
@test wv == uweights(3)
119119
@test wv[[true, false, false]] == uweights(Float64, 1)
120+
@test convert(Vector, wv) == ones(3)
121+
@test !Base.mightalias(wv, uweights(Float64, 3))
122+
@test Base.dataids(wv) == ()
120123
end
121124

122125
## wsum

0 commit comments

Comments
 (0)