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

MethodErrors when expanding in Fourier()[:, range] with non-UnitRange range #235

Open
DanielVandH opened this issue Mar 6, 2025 · 1 comment

Comments

@DanielVandH
Copy link
Member

DanielVandH commented Mar 6, 2025

(jl_RPqcPu) pkg> st
Status `C:\Users\djv23\AppData\Local\Temp\jl_RPqcPu\Project.toml`
  [b30e2e7b] ClassicalOrthogonalPolynomials v0.15.1
julia> using ClassicalOrthogonalPolynomials

julia> expand(Fourier(), sin) # fine
Fourier{Float64}() * [-5.819717467793159e-18, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0    ]

julia> expand(Fourier()[:, 1:3], sin) # fine
Fourier{Float64}() * [7.401486830834377e-17, 0.9999999999999998, -7.401486830834377e-17, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0    ]

julia> expand(Fourier()[:, 1:2:3], sin) # not fine
ERROR: MethodError: no method matching zero(::Type{Matrix{Int64}})
The function `zero` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  zero(::Type{Union{}}, Any...)
   @ Base number.jl:310
  zero(::Type{Infinities.Infinity})
   @ Infinities C:\Users\djv23\.julia\packages\Infinities\r9wt7\src\Infinities.jl:46
  zero(::Type{Dates.Date})
   @ Dates C:\Users\djv23\.julia\juliaup\julia-1.11.3+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Dates\src\types.jl:459
  ...

Stacktrace:
  [1] getindex_value
    @ C:\Users\djv23\.julia\packages\FillArrays\lVl4c\src\FillArrays.jl:321 [inlined]
  [2] broadcasted(::Base.Broadcast.DefaultArrayStyle{2}, op::typeof(identity), r::FillArrays.Zeros{Matrix{…}, 2, Tuple{…}})
    @ FillArrays C:\Users\djv23\.julia\packages\FillArrays\lVl4c\src\fillbroadcast.jl:79
  [3] broadcasted
    @ .\broadcast.jl:1325 [inlined]
  [4] cache_filldata!(::LazyArrays.CachedArray{…}, ::UnitRange{…}, ::Base.OneTo{…})
    @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\cache.jl:230
  [5] resizedata!(::ArrayLayouts.DenseColumnMajor, ::ArrayLayouts.ZerosLayout, ::LazyArrays.CachedArray{…}, ::Int64, ::Int64)
    @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\cache.jl:270
  [6] resizedata!(::LazyArrays.CachedArray{Matrix{…}, 2, Matrix{…}, FillArrays.Zeros{…}}, ::Int64, ::Int64)
    @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\cache.jl:221
  [7] setindex!
    @ C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\cache.jl:85 [inlined]
  [8] _setindex!
    @ .\abstractarray.jl:1448 [inlined]
  [9] setindex!
    @ .\abstractarray.jl:1413 [inlined]
 [10] collect_to_with_first!(dest::LazyArrays.CachedArray{…}, v1::Matrix{…}, itr::Base.Generator{…}, st::Tuple{…})
    @ Base .\array.jl:826
 [11] collect(itr::Base.Generator{Base.Iterators.ProductIterator{Tuple{…}}, BlockArrays.var"#26#29"{Matrix{…}, Tuple{…}}})
    @ Base .\array.jl:801
 [12] map(f::Function, A::Base.Iterators.ProductIterator{Tuple{BlockArrays.BlockRange{…}, BlockArrays.BlockRange{…}}})
    @ Base .\abstractarray.jl:3399
 [13] initialized_blocks_BlockArray(::Type{Matrix{…}}, baxes::Tuple{BlockArrays.BlockedOneTo{…}, Base.OneTo{…}})
    @ BlockArrays C:\Users\djv23\.julia\packages\BlockArrays\8VbzB\src\blockarray.jl:190
 [14] BlockArray
    @ C:\Users\djv23\.julia\packages\BlockArrays\8VbzB\src\blockarray.jl:201 [inlined]
 [15] similar
    @ C:\Users\djv23\.julia\packages\BlockArrays\8VbzB\src\blockarray.jl:440 [inlined]
 [16] similar(a::LinearAlgebra.Diagonal{Int64, FillArrays.Ones{…}}, dims::Tuple{BlockArrays.BlockedOneTo{…}, Base.OneTo{…}})
    @ Base .\abstractarray.jl:822
 [17] _unsafe_getindex(::IndexCartesian, ::LinearAlgebra.Diagonal{…}, ::Base.Slice{…}, ::StepRange{…})
    @ Base .\multidimensional.jl:927
 [18] _getindex
    @ .\multidimensional.jl:915 [inlined]
 [19] getindex
    @ .\abstractarray.jl:1312 [inlined]
 [20] arguments(::LazyArrays.ApplyLayout{typeof(*)}, V::QuasiArrays.SubQuasiArray{Float64, 2, Fourier{…}, Tuple{…}, false})
    @ ContinuumArrays C:\Users\djv23\.julia\packages\ContinuumArrays\0WcPp\src\bases\bases.jl:639
 [21] arguments(::ContinuumArrays.SubBasisLayout, A::QuasiArrays.SubQuasiArray{Float64, 2, Fourier{…}, Tuple{…}, false})
    @ ContinuumArrays C:\Users\djv23\.julia\packages\ContinuumArrays\0WcPp\src\bases\bases.jl:617
 [22] arguments(a::QuasiArrays.SubQuasiArray{Float64, 2, Fourier{Float64}, Tuple{Inclusion{…}, StepRange{…}}, false})
    @ QuasiArrays C:\Users\djv23\.julia\packages\QuasiArrays\hFvLm\src\lazyquasiarrays.jl:226
 [23] _mul_arguments
    @ C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\linalg\mul.jl:136 [inlined]
 [24] _mul_arguments(::ContinuumArrays.SubBasisLayout, A::QuasiArrays.SubQuasiArray{Float64, 2, Fourier{…}, Tuple{…}, false})
    @ ContinuumArrays C:\Users\djv23\.julia\packages\ContinuumArrays\0WcPp\src\bases\bases.jl:616
 [25] _mul_arguments
    @ C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\linalg\mul.jl:139 [inlined]
 [26] _flatten
    @ C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\linalg\mul.jl:147 [inlined]
 [27] simplify
    @ C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\linalg\mul.jl:345 [inlined]
 [28] simplify(M::ArrayLayouts.Mul{…})
    @ LazyArrays C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\linalg\mul.jl:355
 [29] copy
    @ C:\Users\djv23\.julia\packages\LazyArrays\ltmzk\src\linalg\mul.jl:360 [inlined]
 [30] materialize
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\B2wRU\src\mul.jl:137 [inlined]
 [31] mul
    @ C:\Users\djv23\.julia\packages\ArrayLayouts\B2wRU\src\mul.jl:138 [inlined]
 [32] *(A::QuasiArrays.SubQuasiArray{Float64, 2, Fourier{…}, Tuple{…}, false}, B::Vector{Float64})
    @ QuasiArrays C:\Users\djv23\.julia\packages\QuasiArrays\hFvLm\src\matmul.jl:25
 [33] expand(A::QuasiArrays.SubQuasiArray{Float64, 2, Fourier{…}, Tuple{…}, false}, f::Function)
    @ ContinuumArrays C:\Users\djv23\.julia\packages\ContinuumArrays\0WcPp\src\bases\bases.jl:348
 [34] top-level scope
    @ REPL[17]:1
Some type information was truncated. Use `show(err)` to see complete types.
@DanielVandH
Copy link
Member Author

DanielVandH commented Mar 6, 2025

This seems to be fixed if using the method proposed in JuliaApproximation/HarmonicOrthogonalPolynomials.jl#87 (comment) (proposed to fix piracy, not an issue like this). Maybe that method should be added somewhere to fix both this and JuliaApproximation/HarmonicOrthogonalPolynomials.jl#87. (Doesn't fix #236 though, not sure what the deal is there.)

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

1 participant