unfoldtoolbox / UnfoldMakie.jl

Plotting tools for Unfold.jl based on Makie.jl and AlgebraOfGraphics.jl
MIT License
15 stars 7 forks source link

Observables being deepcopied #167

Closed vladdez closed 2 months ago

vladdez commented 2 months ago

Passing observable string throws an error when used with show_sortval

obs = Observable(data)
chan_i = Observable(1)
sort_val = Observable(evts_e.Δlatency)
str = @lift("ERP image: channel " * string($chan_i))
f = plot_erpimage(times, dat_e; sortvalues = sort_val, show_sortval = true, axis = (; title = str))
str[] = 5

on the line sub_config2 = deepcopy(config)

 [1052] deepcopy_internal(x::Any, stackdict::IdDict{Any, Any})
      @ Base ./deepcopy.jl:76
 [1053] deepcopy_internal(x::Any, stackdict::IdDict{Any, Any})
      @ Base ./deepcopy.jl:65
 [1054] deepcopy
      @ ./deepcopy.jl:26 [inlined]
 [1055] plot_erpimage!(f::Figure, times::Observable{…}, data::Observable{…}; sortvalues::Observable{…}, sortindex::Observable{…}, erpblur::Observable{…}, meanplot::Bool, show_sortval::Bool, kwargs::@Kwargs{…})

It seems it doesn't like Observables being deepcopied. Any ideas how to solve it?

behinger commented 2 months ago

I guess it doesnt make much sense to deepcopy an observable, because you'd break the realtionship to the original observable?

why/where exactly do we deepcopy the config?

vladdez commented 2 months ago

https://github.com/unfoldtoolbox/UnfoldMakie.jl/blob/760c9437c92f4f042bb1137df5cf1853a3b6504b/src/plot_erpimage.jl#L117

behinger commented 2 months ago

Why not generate a new config there and fill in the kwargs again?

vladdez commented 2 months ago

solved in #166