ThummeTo / FMIImport.jl

FMIImport.jl implements the import functionalities of the FMI-standard (fmi-standard.org) for the Julia programming language. FMIImport.jl provides the foundation for the Julia packages FMI.jl and FMIFlux.jl.
MIT License
18 stars 17 forks source link

Type stability for StringToValueReference #109

Open CasBex opened 10 months ago

CasBex commented 10 months ago

fmi2StringToValueReference has a type instability where it can return either a UInt32 or a Nothing type result. This gives some impracticalities when for example broadcasting where you can get either a Vector{UInt32} or a Vector{Union{Nothing,UInt32}} depending on the input. This pull-request fixes that by returning typemax(UInt32) (= 4.3e9) by default. (If your model has more than 4.3e9 inputs then this will fail, but I don't think this edge case is realistic)

ThummeTo commented 3 months ago

Thanks for noticing, we will do a complete check with DispatchDoctor.jl in all libraries.

Some FMUs (e.g. Dymola) start counting at higher values... returning 0 could be a better option (value refs must be greater than 0).