JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

Fix `Bonds.possible_values(::MultiSelect)` #260

Closed Pangoraw closed 11 months ago

Pangoraw commented 1 year ago

subarrays should take an indexable Vector as input, not any generator.

github-actions[bot] commented 1 year ago

Try this Pull Request!

Open Julia and type:

  julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/JuliaPluto/PlutoUI.jl", rev="ms_possible_values")
julia> using PlutoUI

Or run this code in your browser: Run with binder

fonsp commented 1 year ago

ooh what does this fix again?

the precomputed plutosliderswrrver has a second issue that this is a lazy object (on purpose) but pss does not work with that yet. i started working on it but still need to finish it

Pangoraw commented 1 year ago

This fixes the generator which currently fails to generate possible values:

julia> PlutoUI.BuiltinsNotebook.Bonds.possible_values(MultiSelect([1, 2, 3])) |> collect
ERROR: MethodError: no method matching getindex(::Base.Generator{UnitRange{Int64}, PlutoUI.BuiltinsNotebook.var"#48#52"}, ::Vector{Bool})
Stacktrace:
 [1] (::PlutoUI.BuiltinsNotebook.var"#33#34"{Base.Generator{UnitRange{Int64}, PlutoUI.BuiltinsNotebook.var"#48#52"}})(I::Tuple{Bool, Bool, Bool})
   @ PlutoUI.BuiltinsNotebook ./none:0
 [2] iterate
   @ ./generator.jl:47 [inlined]
 [3] collect
   @ ./array.jl:782 [inlined]
 [4] |>(x::Base.Generator{Vector{Tuple{Bool, Bool, Bool}}, PlutoUI.BuiltinsNotebook.var"#33#34"{Base.Generator{UnitRange{Int64}, PlutoUI.BuiltinsNotebook.var"#48#52"}}}, f::typeof(collect))
   @ Base ./operators.jl:907
 [5] top-level scope
   @ REPL[8]:1

The output of possible_values(::MultiSelect) is still a generator but it can now be collected as shown in tests.