Can't print slices of orthogonal polynomials
Closed this issue · 0 comments
DanielVandH commented
While the following variables can be defined, printing them to REPL errors:
using ClassicalOrthogonalPolynomials
Chebyshev()[0.3, :] # errors when printing
Jacobi(0.0, 0.0)[0.3, :] # errors when printing
Laguerre(0)[0.3, :] # errors when printing
# etc
with errors like
julia> Chebyshev()[0.3, :]
ℵ₀-element view(::ChebyshevT{Float64}, 0.3, :) with eltype Float64 with indices OneToInf():
ERROR: MethodError: no method matching isassigned(::ChebyshevT{Float64}, ::Float64, ::Int64)
Closest candidates are:
isassigned(::Array, ::Int64...)
@ Base array.jl:266
isassigned(::LinearAlgebra.UnitLowerTriangular, ::Int64, ::Int64)
@ LinearAlgebra C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\LinearAlgebra\src\triangular.jl:226
isassigned(::Base.ReshapedArray{T, N}, ::Int64...) where {T, N}
@ Base reshapedarray.jl:235
...
Stacktrace:
[1] isassigned
@ .\subarray.jl:362 [inlined]
[2] isassigned(::SubArray{Float64, 1, ChebyshevT{Float64}, Tuple{Float64, Base.Slice{InfiniteArrays.OneToInf{Int64}}}, false}, ::Int64, ::Int64)
@ Base .\multidimensional.jl:1575
[3] alignment(io::IOContext{Base.TTY}, X::AbstractVecOrMat, rows::Vector{Int64}, cols::Vector{Int64}, cols_if_complete::Int64, cols_otherwise::Int64, sep::Int64, ncols::Int64)
@ Base .\arrayshow.jl:68
[4] _print_matrix(io::IOContext{Base.TTY}, X::AbstractVecOrMat, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64, rowsA::InfiniteArrays.InfUnitRange{Int64}, colsA::UnitRange{Int64})
@ Base .\arrayshow.jl:207
[5] print_matrix(io::IOContext{Base.TTY}, X::SubArray{Float64, 1, ChebyshevT{Float64}, Tuple{Float64, Base.Slice{InfiniteArrays.OneToInf{Int64}}}, false}, pre::String, sep::String, post::String, hdots::String, vdots::String, ddots::String, hmod::Int64, vmod::Int64)
@ Base .\arrayshow.jl:171
[6] print_matrix
@ .\arrayshow.jl:171 [inlined]
[7] print_array
@ .\arrayshow.jl:358 [inlined]
[8] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, X::SubArray{Float64, 1, ChebyshevT{Float64}, Tuple{Float64, Base.Slice{InfiniteArrays.OneToInf{Int64}}}, false})
@ Base .\arrayshow.jl:399
[9] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
@ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:273
[10] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
@ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:569
[11] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
@ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:259
[12] display(d::REPL.REPLDisplay, x::Any)
@ REPL C:\Users\User\.julia\juliaup\julia-1.10.3+0.x64.w64.mingw32\share\julia\stdlib\v1.10\REPL\src\REPL.jl:278
[13] display(x::Any)
@ Base.Multimedia .\multimedia.jl:340
[14] #invokelatest#2
@ .\essentials.jl:892 [inlined]
[15] invokelatest
@ .\essentials.jl:889 [inlined]
[16] (::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\User\.vscode\extensions\julialang.language-julia-1.79.2\scripts\packages\VSCodeServer\src\eval.jl:237
[17] withpath(f::VSCodeServer.var"#69#74"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
@ VSCodeServer c:\Users\User\.vscode\extensions\julialang.language-julia-1.79.2\scripts\packages\VSCodeServer\src\repl.jl:276
[18] (::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\User\.vscode\extensions\julialang.language-julia-1.79.2\scripts\packages\VSCodeServer\src\eval.jl:179
[19] hideprompt(f::VSCodeServer.var"#68#73"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
@ VSCodeServer c:\Users\User\.vscode\extensions\julialang.language-julia-1.79.2\scripts\packages\VSCodeServer\src\repl.jl:38
[20] (::VSCodeServer.var"#67#72"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\User\.vscode\extensions\julialang.language-julia-1.79.2\scripts\packages\VSCodeServer\src\eval.jl:150
[21] with_logstate(f::Function, logstate::Any)
@ Base.CoreLogging .\logging.jl:515
[22] with_logger
@ .\logging.jl:627 [inlined]
[23] (::VSCodeServer.var"#66#71"{VSCodeServer.ReplRunCodeRequestParams})()
@ VSCodeServer c:\Users\User\.vscode\extensions\julialang.language-julia-1.79.2\scripts\packages\VSCodeServer\src\eval.jl:263
[24] #invokelatest#2
@ .\essentials.jl:892 [inlined]
[25] invokelatest(::Any)
@ Base .\essentials.jl:889
[26] (::VSCodeServer.var"#64#65")()
@ VSCodeServer c:\Users\User\.vscode\extensions\julialang.language-julia-1.79.2\scripts\packages\VSCodeServer\src\eval.jl:34
Judging from the error, would it be reasonable to define
using ClassicalOrthogonalPolynomials: OrthogonalPolynomial
Base.isassigned(P::OrthogonalPolynomial, x, n) = (x ∈ axes(P, 1)) && (n ∈ axes(P, 2))
The printing works with this:
julia> Chebyshev()[0.3, :]' # transposing to reduce vertical space
1×ℵ₀ adjoint(view(::ChebyshevT{Float64}, 0.3, :)) with eltype Float64 with indices Base.OneTo(1)×OneToInf():
1.0 0.3 -0.82 -0.792 0.3448 0.99888 0.254528 -0.846163 -0.762226 0.388828 …
julia> Jacobi(0.0, 0.0)[0.3, :]'
1×ℵ₀ adjoint(view(::Jacobi{Float64}, 0.3, :)) with eltype Float64 with indices Base.OneTo(1)×OneToInf():
1.0 0.3 -0.365 -0.3825 0.0729375 0.345386 0.129181 -0.224073 -0.239075 …
julia> Laguerre(0)[0.3, :]'
1×ℵ₀ adjoint(view(::Laguerre{Float64}, 0.3, :)) with eltype Float64 with indices Base.OneTo(1)×OneToInf():
1.0 0.7 0.445 0.2305 0.0523375 -0.0933327 -0.210058 -0.301106 -0.369481 …