PooledArray.PooledVector causing StackOverflowError in GeoStats when using viz/plot, expected?

I ran into a situation that had me going in circle in that GeoStats viz/plot does not play well with PooledArray.PooledVector of anything(?). Situation was reading in a csv file into a dataframe then using GeoStats viz function. Below I pasted snippets of Point example followed by the plot error. I ran into same issue with PooledArray of Quadrangles. Primary question, is this expected? I can provide a MWE file and accompanying code if useful. My fix, for the record, is setting pool=false for CSV.read to avoid the creation of PooledArray.PooledVector altogether.

julia> df.Rlatlon  #<-- this did not play well with viz/plot
994-element PooledArrays.PooledVector{Meshes.Point{Meshes.𝔼{2}, CoordRefSystems.Cartesian2D{CoordRefSystems.NoDatum, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}}, UInt32, Vector{UInt32}}:
 Point(x: 40.47916666666667 m, y: -105.04166666666666 m)
 Point(x: 46.395833333333336 m, y: 8.958333333333332 m)
 Point(x: 37.145833333333336 m, y: -113.45833333333333 m)...

julia> df.latlon  #<-- this plotted fine
994-element Vector{Meshes.Point{Meshes.𝔼{2}, CoordRefSystems.Cartesian2D{CoordRefSystems.NoDatum, Unitful.Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}}}:
 Point(x: 40.6875 m, y: -104.95833333333333 m)
 Point(x: 50.1875 m, y: 8.375 m)
 Point(x: 41.145833333333336 m, y: -96.20833333333333 m)...

 julia> plot(df.Rlatlon, color=df.SNR)
ERROR: StackOverflowError:
Stacktrace:
  [1] _stable_typeof
    @ ./operators.jl:929 [inlined]
  [2] Base.Fix2(f::typeof(isequal), x::Type)
    @ Base ./operators.jl:1140
  [3] isequal
    @ ./operators.jl:1155 [inlined]
  [4] allequal
    @ ./set.jl:650 [inlined]
  [5] Meshes.GeometrySet(geoms::PooledArrays.PooledVector{Meshes.Point{Meshes.𝔼{…}, CoordRefSystems.Cartesian2D{…}}, UInt32, Vector{UInt32}})
    @ Meshes ~/.julia/packages/Meshes/0ChqX/src/domains/sets.jl:29
  [6] Meshes.GeometrySet(geoms::PooledArrays.PooledVector{Meshes.Point{Meshes.𝔼{…}, CoordRefSystems.Cartesian2D{…}}, UInt32, Vector{UInt32}}) (repeats 74748 times)
    @ Meshes ~/.julia/packages/Meshes/0ChqX/src/domains/sets.jl:35
  [7] convert_arguments(::Type{Plot{Meshes.viz}}, geoms::PooledArrays.PooledVector{Meshes.Point{Meshes.𝔼{…}, CoordRefSystems.Cartesian2D{…}}, UInt32, Vector{UInt32}})
    @ MeshesMakieExt ~/.julia/packages/Meshes/0ChqX/ext/fallbacks.jl:22
  [8] conversion_pipeline(P::Type{…}, used_attrs::Tuple{}, args::Tuple{…}, kw_obs::Observable{…}, args_obs::Tuple{…}, user_attributes::Dict{…}, deregister::Vector{…}, recursion::Int64)
    @ Makie ~/.julia/packages/Makie/ux0Te/src/interfaces.jl:222
  [9] conversion_pipeline(P::Type{…}, used_attrs::Tuple{}, args::Tuple{…}, kw_obs::Observable{…}, args_obs::Tuple{…}, user_attributes::Dict{…}, deregister::Vector{…})
    @ Makie ~/.julia/packages/Makie/ux0Te/src/interfaces.jl:213
 [10] (Plot{Meshes.viz})(user_args::Tuple{PooledArrays.PooledVector{Meshes.Point{…}, UInt32, Vector{…}}}, user_attributes::Dict{Symbol, Any})
    @ Makie ~/.julia/packages/Makie/ux0Te/src/interfaces.jl:273
 [11] _create_plot(F::Function, attributes::Dict{Symbol, Any}, args::PooledArrays.PooledVector{Meshes.Point{…}, UInt32, Vector{…}})
    @ Makie ~/.julia/packages/Makie/ux0Te/src/figureplotting.jl:316
 [12] plot(args::PooledArrays.PooledVector{Meshes.Point{Meshes.𝔼{…}, CoordRefSystems.Cartesian2D{…}}, UInt32, Vector{UInt32}}; kw::@Kwargs{color::Vector{Int64}})
    @ MakieCore ~/.julia/packages/MakieCore/rZ9WV/src/recipes.jl:58
 [13] top-level scope
    @ REPL[25]:1
Some type information was truncated. Use `show(err)` to see complete types.

@diadora77 in theory the viz recipe (that gets called when you pass a vector of Meshes.jl geometries) supports any type of vector. The stacktrace in the error message indicates that the error is coming from the GeometrySet constructor with PooledVector.

What happens when you try to convert the pooled vector into a geometry set? Can you please try GeometrySet(df.Rlatlon)?

We are probably hitting this generic constructor for iterators:

which creates the infinite loop and overflow.

Looks like the same error…

julia> plot(GeometrySet(df.Rlatlon), color= df.SNR)
ERROR: StackOverflowError:
Stacktrace:
 [1] _stable_typeof
   @ ./operators.jl:929 [inlined]
 [2] Base.Fix2(f::typeof(isequal), x::Type)
   @ Base ./operators.jl:1140
 [3] isequal
   @ ./operators.jl:1155 [inlined]
 [4] allequal
   @ ./set.jl:650 [inlined]
 [5] GeometrySet(geoms::PooledArrays.PooledVector{Meshes.Point{𝔼{2}, Cartesian2D{NoDatum, Quantity{…}}}, UInt32, Vector{UInt32}})
   @ Meshes ~/.julia/packages/Meshes/0ChqX/src/domains/sets.jl:29
 [6] GeometrySet(geoms::PooledArrays.PooledVector{Meshes.Point{𝔼{2}, Cartesian2D{NoDatum, Quantity{…}}}, UInt32, Vector{UInt32}}) (repeats 74760 times)
   @ Meshes ~/.julia/packages/Meshes/0ChqX/src/domains/sets.jl:35
 [7] top-level scope
   @ REPL[155]:1
Some type information was truncated. Use show(err) to see complete types.

In case you just wanted the GeometrySet(df.Rlatlon)

julia> GeometrySet(df.Rlatlon)
ERROR: StackOverflowError:
Stacktrace:
 [1] _stable_typeof
   @ ./operators.jl:929 [inlined]
 [2] Base.Fix2(f::typeof(isequal), x::Type)
   @ Base ./operators.jl:1140
 [3] isequal
   @ ./operators.jl:1155 [inlined]
 [4] allequal
   @ ./set.jl:650 [inlined]
 [5] GeometrySet(geoms::PooledArrays.PooledVector{Meshes.Point{𝔼{2}, Cartesian2D{NoDatum, Quantity{…}}}, UInt32, Vector{UInt32}})
   @ Meshes ~/.julia/packages/Meshes/0ChqX/src/domains/sets.jl:29
 [6] GeometrySet(geoms::PooledArrays.PooledVector{Meshes.Point{𝔼{2}, Cartesian2D{NoDatum, Quantity{…}}}, UInt32, Vector{UInt32}}) (repeats 74760 times)
   @ Meshes ~/.julia/packages/Meshes/0ChqX/src/domains/sets.jl:35
 [7] top-level scope
   @ REPL[156]:1
Some type information was truncated. Use show(err) to see complete types.

Yes, the error is caused by the GeometrySet constructor. Could you please open an issue on GitHub with a MWE that doesn’t involve viz nor plot?

Sure, I’ll get something posted tomorrow. Thanks for the sanity check.

1 Like

Thank you @diadora77 for considering opening the issue.

Done, issue opened.

1 Like