jkrumbiegel / GridLayoutBase.jl

MIT License
4 stars 13 forks source link

`InexactError` when adding `LAxis` to layout #5

Closed timholy closed 3 years ago

timholy commented 3 years ago

I'm showing this error on 1.6, but I get it on 1.5 too. Any ideas where to fix? I spent about 15 minutes looking at it but alignedbboxobservable! and align_to_bbox! are not tiny functions.

The demo essentially comes from the docs, http://makie.juliaplots.org/stable/makielayout/tutorial.html.

julia> import AbstractPlotting

julia> using AbstractPlotting.MakieLayout

julia> scene, layout = layoutscene(30, resolution=(800,800))
(Scene (800px, 800px):
  0 Plots
  0 Child Scenes, GridLayout[1, 1] (0 children))

julia> ax = layout[1,1] = LAxis(scene, title="");
ERROR: InexactError: trunc(Int64, NaN)
Stacktrace:
  [1] trunc
    @ ./float.jl:689 [inlined]
  [2] round
    @ ./float.jl:367 [inlined]
  [3] macro expansion
    @ ~/.julia/packages/StaticArrays/l7lu2/src/broadcast.jl:125 [inlined]
  [4] _broadcast
    @ ~/.julia/packages/StaticArrays/l7lu2/src/broadcast.jl:99 [inlined]
  [5] copy
    @ ~/.julia/packages/StaticArrays/l7lu2/src/broadcast.jl:26 [inlined]
  [6] materialize
    @ ./broadcast.jl:837 [inlined]
  [7] round_to_IRect2D(r::GeometryBasics.HyperRectangle{2, Float32})
    @ AbstractPlotting.MakieLayout ~/.julia/packages/AbstractPlotting/xb5Wp/src/makielayout/helpers.jl:7
  [8] (::AbstractPlotting.MakieLayout.var"#7#8"{Observables.Observable{GeometryBasics.HyperRectangle{2, Int64}}})(bbox::GeometryBasics.HyperRectangle{2, Float32}, limits::GeometryBasics.HyperRectangle{2, Float32}, aspect::Nothing)
    @ AbstractPlotting.MakieLayout ~/.julia/packages/AbstractPlotting/xb5Wp/src/makielayout/helpers.jl:53
  [9] (::Observables.OnUpdate{AbstractPlotting.MakieLayout.var"#7#8"{Observables.Observable{GeometryBasics.HyperRectangle{2, Int64}}}, Tuple{Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, Observables.Observable{Any}}})(#unused#::GeometryBasics.HyperRectangle{2, Float32})
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:293
 [10] setindex!(observable::Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, val::GeometryBasics.HyperRectangle{2, Float32}; notify::Observables.var"#9#11")
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:205
 [11] setindex!
    @ ~/.julia/packages/Observables/A7I8T/src/Observables.jl:201 [inlined]
 [12] (::GridLayoutBase.var"#129#130"{Observables.Observable{Tuple{Any, Any}}, Observables.Observable{Tuple{Union{Nothing, Float32}, Union{Nothing, Float32}}}, Observables.Observable{Any}, Observables.Observable{GridLayoutBase.RectSides{Float32}}, Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}})(sbbox::GeometryBasics.HyperRectangle{2, Float32}, al::Tuple{Symbol, Symbol}, rsize::Tuple{Nothing, Nothing})
    @ GridLayoutBase ~/.julia/packages/GridLayoutBase/IXgjC/src/layoutobservables.jl:279
 [13] (::Observables.OnUpdate{GridLayoutBase.var"#129#130"{Observables.Observable{Tuple{Any, Any}}, Observables.Observable{Tuple{Union{Nothing, Float32}, Union{Nothing, Float32}}}, Observables.Observable{Any}, Observables.Observable{GridLayoutBase.RectSides{Float32}}, Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}}, Tuple{Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, Observables.Observable{Any}, Observables.Observable{Tuple{Union{Nothing, Float32}, Union{Nothing, Float32}}}}})(#unused#::GeometryBasics.HyperRectangle{2, Float32})
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:293
 [14] setindex!(observable::Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, val::GeometryBasics.HyperRectangle{2, Float32}; notify::Observables.var"#9#11")
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:205
 [15] setindex!(observable::Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, val::GeometryBasics.HyperRectangle{2, Float32})
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:201
 [16] align_to_bbox!(gl::GridLayout, suggestedbbox::GeometryBasics.HyperRectangle{2, Float32})
    @ GridLayoutBase ~/.julia/packages/GridLayoutBase/IXgjC/src/gridlayout.jl:781
 [17] (::GridLayoutBase.var"#10#12"{GridLayout})(cbb::GeometryBasics.HyperRectangle{2, Float32})
    @ GridLayoutBase ~/.julia/packages/GridLayoutBase/IXgjC/src/gridlayout.jl:54
 [18] #invokelatest#2
    @ ./essentials.jl:709 [inlined]
 [19] invokelatest
    @ ./essentials.jl:708 [inlined]
 [20] setindex!(observable::Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, val::GeometryBasics.HyperRectangle{2, Float32}; notify::Observables.var"#9#11")
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:207
 [21] setindex!
    @ ~/.julia/packages/Observables/A7I8T/src/Observables.jl:201 [inlined]
 [22] (::GridLayoutBase.var"#129#130"{Observables.Observable{Tuple{Any, Any}}, Observables.Observable{Tuple{Union{Nothing, Float32}, Union{Nothing, Float32}}}, Observables.Observable{GridLayoutBase.AlignMode}, Observables.Observable{GridLayoutBase.RectSides{Float32}}, Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}})(sbbox::GeometryBasics.HyperRectangle{2, Float32}, al::Tuple{Symbol, Symbol}, rsize::Tuple{Nothing, Nothing})
    @ GridLayoutBase ~/.julia/packages/GridLayoutBase/IXgjC/src/layoutobservables.jl:279
 [23] (::Observables.OnUpdate{GridLayoutBase.var"#129#130"{Observables.Observable{Tuple{Any, Any}}, Observables.Observable{Tuple{Union{Nothing, Float32}, Union{Nothing, Float32}}}, Observables.Observable{GridLayoutBase.AlignMode}, Observables.Observable{GridLayoutBase.RectSides{Float32}}, Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}}, Tuple{Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, Observables.Observable{Any}, Observables.Observable{Tuple{Union{Nothing, Float32}, Union{Nothing, Float32}}}}})(#unused#::GeometryBasics.HyperRectangle{2, Float32})
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:293
 [24] setindex!(observable::Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, val::GeometryBasics.HyperRectangle{2, Float32}; notify::Observables.var"#9#11")
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:205
 [25] setindex!(observable::Observables.Observable{GeometryBasics.HyperRectangle{2, Float32}}, val::GeometryBasics.HyperRectangle{2, Float32})
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:201
 [26] (::GridLayoutBase.var"#11#13"{GridLayout})(u::Bool)
    @ GridLayoutBase ~/.julia/packages/GridLayoutBase/IXgjC/src/gridlayout.jl:72
 [27] #invokelatest#2
    @ ./essentials.jl:709 [inlined]
 [28] invokelatest
    @ ./essentials.jl:708 [inlined]
 [29] setindex!(observable::Observables.Observable{Bool}, val::Bool; notify::Observables.var"#9#11")
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:207
 [30] setindex!(observable::Observables.Observable{Bool}, val::Bool)
    @ Observables ~/.julia/packages/Observables/A7I8T/src/Observables.jl:201
 [31] add_to_gridlayout!(g::GridLayout, gc::GridLayoutBase.GridContent{GridLayout, LAxis})
    @ GridLayoutBase ~/.julia/packages/GridLayoutBase/IXgjC/src/gridlayout.jl:160
 [32] add_content!(g::GridLayout, content::LAxis, rows::Int64, cols::Int64, side::GridLayoutBase.Inner)
    @ GridLayoutBase ~/.julia/packages/GridLayoutBase/IXgjC/src/gridlayout.jl:1218
 [33] setindex!
    @ ~/.julia/packages/GridLayoutBase/IXgjC/src/gridlayout.jl:1115 [inlined]
 [34] top-level scope
    @ REPL[4]:1

Package versions:

(@v1.6) pkg> st
Status `~/.julia/environments/v1.6/Project.toml`
  [537997a7] AbstractPlotting v0.12.15
  [1520ce14] AbstractTrees v0.3.3
  [39de3d68] AxisArrays v0.4.3
  [6e4b80f9] BenchmarkTools v0.5.0
  [bcf9a6e7] BugReporting v0.1.3
  [336ed68f] CSV v0.7.7
  [13f3f980] CairoMakie v0.3.3
  [aafaddc9] CatIndices v0.2.1
  [da1fd8a2] CodeTracking v1.0.4
  [3da002f7] ColorTypes v0.10.9
  [c3611d14] ColorVectorSpace v0.8.6
  [5ae59095] Colors v0.12.4 `~/.julia/dev/Colors`
  [861a8166] Combinatorics v1.0.2
  [ed09eef8] ComputationalResources v0.3.2
  [d38c429a] Contour v0.5.5
  [150eb455] CoordinateTransformations v0.6.0
  [a2441757] Coverage v1.1.1
  [f68482b8] Cthulhu v1.2.2
  [a93c6f00] DataFrames v0.21.8
  [864edb3b] DataStructures v0.18.7
  [31a5f54b] Debugger v0.6.6
  [5a34b05b] DebuggingUtilities v1.0.0
  [163ba53b] DiffResults v1.0.2
  [e30172f5] Documenter v0.25.2
  [997ab1e6] DocumenterMarkdown v0.2.0
  [35a29f4d] DocumenterTools v0.1.7
  [d872a56f] ElectronDisplay v1.0.0
  [340492b5] EndpointRanges v0.2.0
  [97e2ac4a] EponymTuples v0.2.2
  [7876af07] Example v0.5.3
  [c87230d0] FFMPEG v0.4.0
  [4f61f5a4] FFTViews v0.3.1
  [7a1cc6ca] FFTW v1.2.4
  [597c7b4e] FakeCells v0.2.0
  [5789e2e9] FileIO v1.4.3
  [48062228] FilePathsBase v0.6.2
  [53c48c17] FixedPointNumbers v0.8.4
  [08572546] FlameGraphs v0.2.4
  [587475ba] Flux v0.11.1
  [f6369f11] ForwardDiff v0.10.12
  [e9467ef8] GLMakie v0.1.13
  [28b8d3ca] GR v0.52.0
  [14197337] GenericLinearAlgebra v0.2.4
  [5c1252a2] GeometryBasics v0.3.3
  [a2bd30eb] Graphics v1.0.2
  [3955a311] GridLayoutBase v0.3.7
  [42e2da0e] Grisu v1.0.0
  [4c0ca9eb] Gtk v1.1.5
  [cd3eb016] HTTP v0.8.19
  [1baab800] HybridArrays v0.3.8
  [47d2ed2b] Hyperscript v0.0.3 `~/.julia/dev/Hyperscript`
  [7073ff75] IJulia v1.21.4
  [2803e5a7] ImageAxes v0.6.7
  [f332f351] ImageContrastAdjustment v0.3.5
  [a09fc81d] ImageCore v0.8.17 `~/.julia/dev/ImageCore`
  [51556ac3] ImageDistances v0.2.8
  [4381153b] ImageDraw v0.2.3
  [6a3955dd] ImageFiltering v0.6.16
  [82e4d734] ImageIO v0.3.0
  [d8c32880] ImageInTerminal v0.4.5
  [6218d12a] ImageMagick v1.1.6
  [bc367c6b] ImageMetadata v0.9.4
  [787d08f9] ImageMorphology v0.2.9
  [2996bd0c] ImageQualityIndexes v0.2.0
  [80713f31] ImageSegmentation v1.4.7
  [4e3cecfd] ImageShow v0.2.3
  [02fcd773] ImageTransformations v0.8.6
  [86fae568] ImageView v0.10.11
  [916415d5] Images v0.22.5 `~/.julia/dev/Images`
  [9b13fd28] IndirectArrays v0.5.1
  [a98d9a8b] Interpolations v0.12.10
  [d1acc4aa] IntervalArithmetic v0.17.5
  [8197267c] IntervalSets v0.5.1
  [4138dd39] JLD v0.10.0
  [033835bb] JLD2 v0.2.4
  [4076af6c] JuMP v0.21.5
  [aa1ae85d] JuliaInterpreter v0.8.1
  [89398ba2] LocalRegistry v0.3.0
  [bdcacae8] LoopVectorization v0.8.26
  [6f1432cf] LoweredCodeUtils v1.2.4
  [2fda8390] LsqFit v0.11.0
  [1914dd2f] MacroTools v0.5.5
  [ee78f7c6] Makie v0.11.1
  [dbb5928d] MappedArrays v0.2.2
  [2b713a72] MergePairwise v0.1.0
  [7269a6da] MeshIO v0.4.3
  [85b6ec6f] MethodAnalysis v0.4.2
  [e94cdb99] MosaicViews v0.2.3
  [0ec0bfde] MzCore v0.1.0 `~/.julia/dev/MzCore`
  [5043a3e8] MzPlots v0.1.0 `~/.julia/dev/MzPlots`
  [cb69de98] MzXML v0.1.0 `~/.julia/dev/MzXML`
  [6ef6ca0d] NMF v0.4.1
  [510215fc] Observables v0.3.2
  [6fe1bfb0] OffsetArrays v1.3.1
  [429524aa] Optim v1.2.0
  [bac558e1] OrderedCollections v1.3.1
  [f57f5aa1] PNGFiles v0.3.1
  [5432bcbf] PaddedViews v0.5.6
  [65888b18] ParameterizedFunctions v5.6.0
  [d96e819e] Parameters v0.12.1
  [32113eaa] PkgBenchmark v0.2.10
  [14b8a8f1] PkgTemplates v0.7.11
  [995b91a9] PlotUtils v1.0.7
  [91a5bcdd] Plots v1.6.12
  [c46f51b8] ProfileView v0.6.7
  [92933f4c] ProgressMeter v1.4.0
  [438e738f] PyCall v1.92.1
  [d330b81b] PyPlot v2.9.0
  [189a3867] Reexport v0.2.0
  [324d217c] ReferenceTests v0.9.2
  [3c0dd727] RegisterMismatch v0.3.0
  [ac24ea0c] RegisterQD v0.2.0
  [0f4576a4] RegistryCompatTools v0.1.0 `~/.julia/dev/RegistryCompatTools`
  [ae029012] Requires v1.0.3
  [295af30f] Revise v3.1.5
  [d5f540fe] RoundingIntegers v0.2.0
  [fdea26ae] SIMD v3.1.0
  [992d4aef] Showoff v0.3.2
  [aa65fe97] SnoopCompile v2.1.1
  [e2b509da] SnoopCompileCore v2.1.1
  [90137ffa] StaticArrays v0.12.4
  [fd094767] Suppressor v0.2.0
  [48a634ad] Tensors v1.4.3
  [5e47fb64] TestImages v1.2.3
  [cd6f60fb] TileTrees v0.3.2
  [23bcbbb2] TiledFactorizations v0.1.0
  [3a884ed6] UnPack v1.0.2
  [1986cc42] Unitful v1.4.1
  [276b4fcb] WGLMakie v0.2.9
  [b77e0a4c] InteractiveUtils
  [cf7118a7] UUIDs
timholy commented 3 years ago

The problem turns out to stem from me supplying an empty string as the default title. Debugging output in AbstractPlotting's laxis.jl, compute_protrusions, yields

title = ""
titlegap = 10.0f0
titlet = Text{...}
boundingbox(titlet) = GeometryBasics.HyperRectangle{3, Float32}(Float32[NaN, NaN, NaN], Float32[NaN, NaN, NaN])

I can fix this in AbstractPlotting with

diff --git a/src/makielayout/lobjects/laxis.jl b/src/makielayout/lobjects/laxis.jl
index 2643bba..bc22d72 100644
--- a/src/makielayout/lobjects/laxis.jl
+++ b/src/makielayout/lobjects/laxis.jl
@@ -265,7 +265,9 @@ function LAxis(parent::Scene; bbox = nothing, kwargs...)
         else
             boundingbox(titlet).widths[2] + titlegap
         end
-        top += titlespace
+        if isfinite(titlespace)
+            top += titlespace
+        end

         if yaxisposition == :left
             left = yaxisprotrusion

but I am unsure of whether this is the right fix. And it doesn't fix all errors, later I get

ERROR: ArgumentError: reducing over an empty collection is not allowed
Stacktrace:
  [1] _empty_reduce_error()
    @ Base ./reduce.jl:299
  [2] mapreduce_empty(f::Function, op::Function, T::Type)
    @ Base ./reduce.jl:342
  [3] reduce_empty(op::Base.MappingRF{AbstractPlotting.var"#557#571"{Float64}, typeof(max)}, #unused#::Type{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}})
    @ Base ./reduce.jl:329
  [4] reduce_empty_iter
    @ ./reduce.jl:355 [inlined]
  [5] mapreduce_empty_iter(f::Function, op::Function, itr::Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}}, ItrEltype::Base.HasEltype)
    @ Base ./reduce.jl:351
  [6] _mapreduce(f::AbstractPlotting.var"#557#571"{Float64}, op::typeof(max), #unused#::IndexLinear, A::Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}})
    @ Base ./reduce.jl:400
  [7] _mapreduce_dim
    @ ./reducedim.jl:318 [inlined]
  [8] #mapreduce#656
    @ ./reducedim.jl:310 [inlined]
  [9] mapreduce
    @ ./reducedim.jl:310 [inlined]
 [10] #_maximum#674
    @ ./reducedim.jl:875 [inlined]
 [11] _maximum
    @ ./reducedim.jl:875 [inlined]
 [12] #maximum#672
    @ ./reducedim.jl:871 [inlined]
 [13] maximum
    @ ./reducedim.jl:871 [inlined]
 [14] #556
    @ ~/.julia/dev/AbstractPlotting/src/layouting/layouting.jl:111 [inlined]
 [15] iterate
    @ ./generator.jl:47 [inlined]
 [16] _collect(c::Vector{Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}}}, itr::Base.Generator{Vector{Vector{Tuple{Char, FreeTypeAbstraction.FTFont, Float32}}}, AbstractPlotting.var"#556#570"{Float64}}, #unused#::Base.EltypeUnknown, isz::Base.HasShape{1})
    @ Base ./array.jl:699
 [17] collect_similar
    @ ./array.jl:628 [inlined]
 [18] map
    @ ./abstractarray.jl:2238 [inlined]
 [19] glyph_positions(str::String, font_per_char::Base.Generator{String, AbstractPlotting.var"#544#545"{FreeTypeAbstraction.FTFont}}, fontscale_px::Base.Generator{String, AbstractPlotting.var"#542#543"{Float32}}, halign::Float32, valign::Float32, lineheight_factor::Float64, justification::Float64)
    @ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/layouting/layouting.jl:110
 [20] layout_text(string::String, startpos::GeometryBasics.Point{2, Float32}, textsize::Float32, font::FreeTypeAbstraction.FTFont, align::GeometryBasics.Vec{2, Float32}, rotation::AbstractPlotting.Quaternionf0, model::StaticArrays.SMatrix{4, 4, Float32, 16}, justification::Float64, lineheight::Float64)
    @ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/layouting/layouting.jl:55
 [21] to_gl_text(string::String, startpos::GeometryBasics.Point{2, Float32}, textsize::Float32, font::FreeTypeAbstraction.FTFont, aoffsetvec::GeometryBasics.Vec{2, Float32}, rot::AbstractPlotting.Quaternionf0, model::StaticArrays.SMatrix{4, 4, Float32, 16}, j::Float64, l::Float64)
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:268
 [22] (::GLMakie.var"#106#111"{Text{...}})(str::String, pos::GeometryBasics.Point{2, Float32}, tsize::Float32, font::FreeTypeAbstraction.FTFont, align::GeometryBasics.Vec{2, Float32}, rotation::AbstractPlotting.Quaternionf0, model::StaticArrays.SMatrix{4, 4, Float32, 16}, j::Float64, l::Float64)
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:288
 [23] lift(::Function, ::Observables.Observable{String}, ::Observables.Observable{GeometryBasics.Point{2, Float32}}, ::Vararg{Any, N} where N)
    @ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/interaction/nodes.jl:15
 [24] (::GLMakie.var"#105#110"{Text{...}})(gl_attributes::Dict{Symbol, Any})
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:285
 [25] (::GLMakie.var"#69#75"{GLMakie.var"#105#110"{Text{...}}, GLMakie.Screen, AbstractPlotting.Scene, Text{...}})()
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:75
 [26] get!(default::GLMakie.var"#69#75"{GLMakie.var"#105#110"{Text{...}}, GLMakie.Screen, AbstractPlotting.Scene, Text{...}}, h::Dict{UInt64, GLMakie.GLAbstraction.RenderObject}, key::UInt64)
    @ Base ./dict.jl:465
 [27] cached_robj!(robj_func::GLMakie.var"#105#110"{Text{...}}, screen::GLMakie.Screen, scene::AbstractPlotting.Scene, x::Text{...})
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:51
 [28] draw_atomic(screen::GLMakie.Screen, scene::AbstractPlotting.Scene, x::Text{...})
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:282
 [29] insert!(screen::GLMakie.Screen, scene::AbstractPlotting.Scene, x::AbstractPlotting.Combined)
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/drawing_primitives.jl:172
 [30] insertplots!(screen::GLMakie.Screen, scene::AbstractPlotting.Scene)
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/screen.jl:54
 [31] backend_display(screen::GLMakie.Screen, scene::AbstractPlotting.Scene)
    @ GLMakie ~/.julia/packages/GLMakie/Pway1/src/screen.jl:124
 [32] backend_display
    @ ~/.julia/packages/GLMakie/Pway1/src/gl_backend.jl:59 [inlined]
 [33] display(d::AbstractPlotting.PlotDisplay, scene::AbstractPlotting.Scene)
    @ AbstractPlotting ~/.julia/dev/AbstractPlotting/src/display.jl:45
 [34] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
 [35] #invokelatest#2
    @ ./essentials.jl:709 [inlined]
 [36] invokelatest
    @ ./essentials.jl:708 [inlined]
 [37] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:246
 [38] (::REPL.var"#40#41"{REPL.LineEditREPL, Tuple{AbstractPlotting.Scene, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:230
 [39] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:461
 [40] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:228
 [41] (::REPL.var"#do_respond#61"{Bool, Bool, REPL.var"#72#82"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:797
 [42] #invokelatest#2
    @ ./essentials.jl:709 [inlined]
 [43] invokelatest
    @ ./essentials.jl:708 [inlined]
 [44] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/LineEdit.jl:2435
 [45] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/src/julia-master/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:1124
 [46] (::REPL.var"#44#49"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:395
jkrumbiegel commented 3 years ago

I think the base problem is that AbstractPlotting can't deal with certain empty plot types, one of them being text. It's a more annoying problem to fix than it looks like on the surface and because most graphs don't need empty plots it hasn't been dealt with carefully. I've made a couple issues about it over the last year.. That MakieLayout fails when text has an ill defined size is only one side effect

timholy commented 3 years ago

What about making boundingbox return something of zero size in this case? Anything wrong with that?

jkrumbiegel commented 3 years ago

There is a case to be made that an empty string should have a height but not a width, because the height reserved for a string depends not on the characters but font and fontsize. So I think this needs to be fixed at the string object (I have other fixes for strings still waiting in PRs that need GLMakie fixes first..) The other error you saw stems from later assumptions that strings are never empty, these also need to be fixed. It's also the reason why you get errors if you don't have any ticks on one dimension (I think the annotations or linesegments are not allowed to be empty).

@SimonDanisch this would be another good starting point for lower-level fixes, I think the AbstractPlotting specific broadcast mechanism needs to have its logic fixed to deal with zero element arguments.

jkrumbiegel commented 3 years ago

fixed in https://github.com/JuliaPlots/AbstractPlotting.jl/pull/530

timholy commented 3 years ago

Thanks so much!