Skip to content

Commit

Permalink
UnitWeights don't have values to return from dataids (#808)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
rofinn and nalimilan committed Jun 28, 2022
1 parent 9ff127f commit db4e40e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "StatsBase"
uuid = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
authors = ["JuliaStats"]
version = "0.33.17"
version = "0.33.18"

[deps]
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
Expand Down
1 change: 1 addition & 0 deletions src/weights.jl
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ length(wv::UnitWeights) = wv.len
size(wv::UnitWeights) = tuple(length(wv))
Base.axes(wv::UnitWeights) = tuple(Base.OneTo(length(wv)))

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

@propagate_inbounds function Base.getindex(wv::UnitWeights{T}, i::Integer) where T
Expand Down
3 changes: 3 additions & 0 deletions test/weights.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ end
@test wv != fweights(fill(1.0, 3))
@test wv == uweights(3)
@test wv[[true, false, false]] == uweights(Float64, 1)
@test convert(Vector, wv) == ones(3)
@test !Base.mightalias(wv, uweights(Float64, 3))
@test Base.dataids(wv) == ()
end

## wsum
Expand Down

2 comments on commit db4e40e

@rofinn
Copy link
Member Author

@rofinn rofinn commented on db4e40e Jun 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/63278

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.33.18 -m "<description of version>" db4e40e3ad84f55627441599d6e40e9c6768ef4c
git push origin v0.33.18

Please sign in to comment.