rafaqz / Stencils.jl

Static Stencil mapping for Julia
Other
8 stars 1 forks source link

Error when showing Stencil within a type #46

Open asinghvi17 opened 5 months ago

asinghvi17 commented 5 months ago

It looks like show tries to use array shows, which fail because stencil[1] isa eltype(stencil) is false.


Pycnophylactic(20.0, [ERROR: TypeError: in typeassert, expected Float64, got a value of type Nothing
Stacktrace:
  [1] getindex
    @ ~/.julia/packages/Stencils/elhCe/src/stencil.jl:135 [inlined]
  [2] isassigned(A::Kernel{1, 2, 5, Float64, Nothing, Cross{1, 2, 5, Nothing}, Vector{Float64}}, i::Int64)
    @ Base ./multidimensional.jl:1578
  [3] show_delim_array(io::IOContext{Base.TTY}, itr::Kernel{1, 2, 5, Float64, Nothing, Cross{1, 2, 5, Nothing}, Vector{Float64}}, op::Char, delim::String, cl::Char, delim_one::Bool, i1::Int64, l::Int64)
    @ Base ./show.jl:1342
  [4] show_delim_array
    @ ./show.jl:1335 [inlined]
  [5] show_vector(io::IOContext{Base.TTY}, v::Kernel{1, 2, 5, Float64, Nothing, Cross{1, 2, 5, Nothing}, Vector{Float64}}, opn::Char, cls::Char)
    @ Base ./arrayshow.jl:530
  [6] show_vector
    @ ./arrayshow.jl:515 [inlined]
  [7] show(io::IOContext{Base.TTY}, X::Kernel{1, 2, 5, Float64, Nothing, Cross{1, 2, 5, Nothing}, Vector{Float64}})
    @ Base ./arrayshow.jl:486
  [8] _show_default(io::IOContext{Base.TTY}, x::Any)
    @ Base ./show.jl:479
  [9] show_default
    @ ./show.jl:462 [inlined]
 [10] show
    @ ./show.jl:457 [inlined]
 [11] show(io::IOContext{Base.TTY}, ::MIME{Symbol("text/plain")}, x::Pycnophylactic)

This should be solvable in my case pretty easily, but not sure what the general solution should be.

rafaqz commented 5 months ago

Just needs a custom show?

asinghvi17 commented 5 months ago

The type yes, but stencils probably also need a show(io, stencil) definition for this I think?

rafaqz commented 5 months ago

Yeah thats what I meant, we need show(io, ::Strencil).

But maybe it shouldn't work like that at all, the empty Stencil having the eltype of what it will be later is kind of weird.