You could use AbstractPlutoDingetjes
Hi @pepijndevos !
We have a new package, https://github.com/JuliaPluto/AbstractPlutoDingetjes.jl, which gives one feature that would be interesting for this app: https://docs.juliahub.com/AbstractPlutoDingetjes/UHbnu/1.1.2/#AbstractPlutoDingetjes.Bonds.transform_value-Tuple{Any,%20Any}
It allows you to transform the value that you get from JS before assigning it to the Julia variable. For example, it allows us to do this:
https://user-images.githubusercontent.com/6933510/145571622-b3514fe2-d9ba-4104-a8f8-66cd3aae6001.mov
The bound variable is a Julia function, even though JS has no "julia functions". The code for this is the example snippet in the docs for transform_value
What use do you see for this library? It's interesting but... not sure where I'd use it :thinking:
Sorry I forgot to write the point that i wanted to make :)
You currently use the widget like so:
@bind data MosaicWidget("plutocircuit")
nl = split(data, "\n")
res = begin
NgSpice.load_netlist(nl)
NgSpice.cmd("ac dec 10 1 10meg")
vecs = NgSpice.listcurvecs()
Dict(map(x->x=>NgSpice.getvec(x)[3], vecs))
end
plot(real(res["frequency"]), abs.(res["out"]); xaxis=:log, yaxis=:log)
and anyone who wants to use the widget needs to copy this code.
Instead, you could put this transformation inside a method, inside this package:
function AbstractPlutoDingetjes.Bonds.transform_value(mw::MosaicWidget, data)
nl = split(data, "\n")
NgSpice.load_netlist(nl)
NgSpice.cmd("ac dec 10 1 10meg")
vecs = NgSpice.listcurvecs()
return Dict(map(x->x=>NgSpice.getvec(x)[3], vecs))
end
so that people can use the result directly:
@bind res MosaicWidget("plutocircuit")
plot(real(res["frequency"]), abs.(res["out"]); xaxis=:log, yaxis=:log)
Aha!
That's actually pretty cool.
Now only problem is I've removed the client side netlist API from the latest release so to upgrade this widget to the latest version I'd need to port the Python netlist API to Julia.