Skip to content

get(slider::RangeSlider) unnecessarily (?) returns an array instead of a rangeΒ #130

@ForceBru

Description

@ForceBru

I've just attempted to put the result of a RangeSlider into the title of my plot, but it immediately crashed Pluto:

@bind time_frame RangeSlider(1:length(moving_res.range), right=100, show_value=true)

scatter(
	view(moving_res.M, :, time_frame)', view(moving_res.Ξ£, :, time_frame)',
	marker_z=moving_res.range[time_frame],
	markerstrokewidth=0, markersize=2, markeralpha=.6,
	title="Clusters over time ($time_frame)",
	label="", xlabel="Means", ylabel="Standard deviations",
	c=:deep,
	fmt=:png
)

I expected the title to become something like "Clusters over time (1:100)". However, Pluto crashed with this error:

β”Œ Error: Update notebook failed
β”‚   πŸ™‹.body["updates"] =
β”‚    1-element Vector{Dict{Any, Any}}:
β”‚     Dict("value" => Dict{Any, Any}("value" => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10  …  91, 92, 93, 94, 95, 96, 97, 98, 99, 100], "is_first_value" => true), "op" => "add", "path" => ["bonds", "time_frame"])
β”‚   exception =
β”‚    Distributed.ProcessExitedException(12)
β”‚    Stacktrace:
β”‚      [1] worker_from_id(pg::Distributed.ProcessGroup, i::Int64)
β”‚        @ Distributed /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/cluster.jl:1084
β”‚      [2] worker_from_id
β”‚        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/cluster.jl:1081 [inlined]
β”‚      [3] #remotecall_fetch#146
β”‚        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:421 [inlined]
β”‚      [4] remotecall_fetch
β”‚        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/remotecall.jl:421 [inlined]
β”‚      [5] remotecall_eval
β”‚        @ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.7/Distributed/src/macros.jl:246 [inlined]
β”‚      [6] eval_fetch_in_workspace(session_notebook::Tuple{Pluto.ServerSession, Pluto.Notebook}, expr::Expr)
β”‚        @ Pluto.WorkspaceManager ~/.julia/packages/Pluto/HmZoH/src/evaluation/WorkspaceManager.jl:294
β”‚      [7] (::Pluto.var"#190#193"{Pluto.ServerSession, Pluto.Notebook})(bound_sym::Symbol)
β”‚        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/evaluation/RunBonds.jl:25
β”‚      [8] filter(f::Pluto.var"#190#193"{Pluto.ServerSession, Pluto.Notebook}, a::Vector{Symbol})
β”‚        @ Base ./array.jl:2448
β”‚      [9] set_bond_values_reactive(; session::Pluto.ServerSession, notebook::Pluto.Notebook, bound_sym_names::Vector{Symbol}, is_first_value::Nothing, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:run_async,), Tuple{Bool}}})
β”‚        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/evaluation/RunBonds.jl:6
β”‚     [10] response_update_notebook(πŸ™‹::Pluto.ClientRequest)
β”‚        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/Dynamic.jl:315
β”‚     [11] process_ws_message(session::Pluto.ServerSession, parentbody::Dict{Any, Any}, clientstream::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β”‚        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/WebServer.jl:340
β”‚     [12] (::Pluto.var"#302#312"{Pluto.ServerSession, Base.RefValue{Function}})(clientstream::HTTP.WebSockets.WebSocket{HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β”‚        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/WebServer.jl:153
β”‚     [13] upgrade(f::Pluto.var"#302#312"{Pluto.ServerSession, Base.RefValue{Function}}, http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}; binary::Bool)
β”‚        @ HTTP.WebSockets ~/.julia/packages/HTTP/D0FSE/src/WebSockets.jl:160
β”‚     [14] upgrade
β”‚        @ ~/.julia/packages/HTTP/D0FSE/src/WebSockets.jl:142 [inlined]
β”‚     [15] (::Pluto.var"#301#311"{Pluto.ServerSession, Base.RefValue{Function}, HTTP.Handlers.Router{Symbol("##281")}})(http::HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}})
β”‚        @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/WebServer.jl:135
β”‚     [16] handle
β”‚        @ ~/.julia/packages/HTTP/D0FSE/src/Handlers.jl:270 [inlined]
β”‚     [17] #4
β”‚        @ ~/.julia/packages/HTTP/D0FSE/src/Handlers.jl:346 [inlined]
β”‚     [18] macro expansion
β”‚        @ ~/.julia/packages/HTTP/D0FSE/src/Servers.jl:413 [inlined]
β”‚     [19] (::HTTP.Servers.var"#13#14"{HTTP.Handlers.var"#4#5"{HTTP.Handlers.StreamHandlerFunction{Pluto.var"#301#311"{Pluto.ServerSession, Base.RefValue{Function}, HTTP.Handlers.Router{Symbol("##281")}}}}, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}, HTTP.Servers.Server{Nothing, Sockets.TCPServer}, HTTP.Streams.Stream{HTTP.Messages.Request, HTTP.ConnectionPool.Transaction{Sockets.TCPSocket}}})()
β”‚        @ HTTP.Servers ./task.jl:411
β”” @ Pluto ~/.julia/packages/Pluto/HmZoH/src/webserver/Dynamic.jl:325

I looked at the code of the RangeSlider and was very surprised by get(slider::RangeSlider) returning an array, while, given that the UI element is called RangeSlider, I expected to get a range:

https://github.com/fonsp/PlutoUI.jl/blob/a107c6aa010dff1ab9574874143007786fa86451/src/RangeSlider.jl#L64

Indeed, "$the_range" is a big string in my case, so I guess there were problems displaying it...


Wouldn't it make sense to return a range instead of an array, like get(slider::RangeSlider) = slider.left:step(slider.range):slider.right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs Pluto.jl featureCan't be done right now because something is missing from Pluto.jl itself

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions