Genie Discord forum
![Author Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Hi, I've been testing an app that requires ComplexF64 data and noticed that this triggers
InexactError
when the reactive variable is a complex value. Here's an example:
@genietools
@app begin
@out this_triggers_InexactError = ComplexF64(1.0 +1.0im)
@onchange isready begin
@show this_triggers_InexactError
end
end
function ui()
"{{this_triggers_InexactError}}"
end
@page("/", ui)
Server.isrunning() || Server.up()```
when I run Genie.loadapp(), it errors with:
julia> ┌ Error: 2023-10-27 09:54:30 InexactError: Float64(1.0 + 1.0im) │ Stacktrace: │ 1 Real │ @ ./complex.jl:44 inlined │ 2 #construct#1 │ @ ~/.julia/packages/StructTypes/AK4aM/src/StructTypes.jl:327 inlined │ 3 construct │ @ ~/.julia/packages/StructTypes/AK4aM/src/StructTypes.jl:327 inlined │ 4 write(::StructTypes.NumberType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::ComplexF64; kw::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) │ @ JSON3 ~/.julia/packages/JSON3/L8Yfy/src/write.jl:266 │ 5 write(::StructTypes.NumberType, buf::Vector{UInt8}, pos::Int64, len::Int64, x::ComplexF64) │ @ JSON3 ~/.julia/packages/JSON3/L8Yfy/src/write.jl:251 ...
The error message seems to imply that Genie only supports Float64 not ComplexF64?
![Author Avatar](https://cdn.discordapp.com/embed/avatars/2.png)
Changed the channel name: Can reactive variables be ComplexF64?
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
Thanks for the MWE! It made debugging this much easier.
Indeed, it seems that Complex type cannot be serialized and sent to the browser. You can define your own renderer as
Stipple.render(x::ComplexF64) = Dict(:re => x.im, :im => x.re)
so that ComplexF64
types are displayed in the browser. I've opened a new issue about adding support for this type to Stipple.jl
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
I've released an alpha version of the Package StippleMathjs https://github.com/GenieFramework/StippleMathjs
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
It's not yet registered so installation is a bit different. But you find all in the Readme or you try the demo at https://github.com/GenieFramework/StippleDemos/tree/master/AdvancedExamples/StippleMathjsDemo
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
@hhaensel those push and deps macros, where are they defined? I'd never seen them before and I can't seem to use them in my REPL
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
ReactiveTools
![Author Avatar](https://cdn.discordapp.com/avatars/960642755799941150/8454099b3f43462890d75bc9c4cd572d.png?size=512)
@Pere could you get it to work. StippleMathks is meanwhile registered 🙂
![Author Avatar](https://cdn.discordapp.com/avatars/743412727464067154/bc30abeb49653e9978c0f7c90f4486a8.png?size=512)
@hhaensel I just tried it installing from the registry and it worked! looks great 😄