Skip to content

Commit

Permalink
Combine definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion authored Sep 25, 2023
1 parent 7fcb8b7 commit f2421a4
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/weights.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ isempty(wv::AbstractWeights) = isempty(wv.values)
size(wv::AbstractWeights) = size(wv.values)
Base.axes(wv::AbstractWeights) = Base.axes(wv.values)

# https://github.com/JuliaLang/julia/pull/43354
if VERSION >= v"1.8.0-DEV.1494" # 98e60ffb11ee431e462b092b48a31a1204bd263d
Base.allequal(wv::AbstractWeights) = allequal(wv.values)
end
Base.allunique(wv::AbstractWeights) = allunique(wv.values)

Base.IndexStyle(::Type{<:AbstractWeights{S,T,V}}) where {S,T,V} = IndexStyle(V)

Base.dataids(wv::AbstractWeights) = Base.dataids(wv.values)
Expand Down Expand Up @@ -319,12 +313,6 @@ length(wv::UnitWeights) = wv.len
size(wv::UnitWeights) = tuple(length(wv))
Base.axes(wv::UnitWeights) = tuple(Base.OneTo(length(wv)))

# https://github.com/JuliaLang/julia/pull/43354
if VERSION >= v"1.8.0-DEV.1494" # 98e60ffb11ee431e462b092b48a31a1204bd263d
Base.allequal(::UnitWeights) = true
end
Base.allunique(wv::UnitWeights) = length(wv) <= 1

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

Expand Down Expand Up @@ -397,6 +385,14 @@ Base.:(==)(x::UnitWeights, y::UnitWeights) = (x.len == y.len)
Base.isequal(x::AbstractWeights, y::AbstractWeights) = false
Base.:(==)(x::AbstractWeights, y::AbstractWeights) = false

# https://github.com/JuliaLang/julia/pull/43354
if VERSION >= v"1.8.0-DEV.1494" # 98e60ffb11ee431e462b092b48a31a1204bd263d
Base.allequal(wv::AbstractWeights) = allequal(wv.values)
Base.allequal(::UnitWeights) = true
end
Base.allunique(wv::AbstractWeights) = allunique(wv.values)
Base.allunique(wv::UnitWeights) = length(wv) <= 1

##### Weighted sum #####

## weighted sum over vectors
Expand Down

0 comments on commit f2421a4

Please sign in to comment.