Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Views of weights do not work well #561

Closed
oxinabox opened this issue Feb 27, 2020 · 2 comments
Closed

Views of weights do not work well #561

oxinabox opened this issue Feb 27, 2020 · 2 comments

Comments

@oxinabox
Copy link
Contributor

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

@nalimilan
Copy link
Member

For views to be AbstractWeights, we will need not only to override view, but also to allow each AbstractWeights type to wrap any kind of array (including SubArray).

@ParadaCarleton
Copy link
Contributor

Closed as duplicate.

@ParadaCarleton ParadaCarleton closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants