Skip to content

Views of weights do not work well #561

Closed as not planned
Closed as not planned
@oxinabox

Description

@oxinabox

Views of weights are not <:AbstractWeight
They are only <:AbstractVector

This messes with some dispatches.

For example:

julia> w = eweights(20,0.3);

julia> mean(1:10, w[1:10])
7.957353087579495

julia> mean(1:10, @view w[1:10])
ERROR: MethodError: objects of type UnitRange{Int64} are not callable

julia> mean_and_std(1:10, @view w[1:10])
ERROR: MethodError: no method matching mean_and_std(::UnitRange{Int64}, ::SubArray{Float64,1,Weights{Float64,Float64,Array{Float64,1}},Tuple{UnitRange{Int64}},false})

Work-around is to use:
AnalyticWeights(@view w[1:10])

A possible solution is to overload the functions the create views and make then return subtypes of AbstractWeight

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions