-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert Dict{Any,Any} to Dict{Symbol,Float64} for pyrms compatibility + formatting #212
Conversation
Codecov Report
@@ Coverage Diff @@
## main #212 +/- ##
==========================================
- Coverage 49.83% 49.81% -0.03%
==========================================
Files 31 31
Lines 7900 7904 +4
==========================================
Hits 3937 3937
- Misses 3963 3967 +4
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
src/ThreadedSensitivities.jl
Outdated
# Convert Dict{Any,Any} to Dict{Symbol, Float64} | ||
# Needed for pyrms compatability | ||
# Python string gets converted to String and runs into expected Symbol, got a value of type String error | ||
if odekwargs isa Dict{Any,Any} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I don't think these kwargs are all symbols mapped to floats so if someone tries to turn on an option that isn't a float I think this will crash
- Can we instead do this the julian way and write a Dict{Any,Any} specific method that just converts the dictionary to Dict{Symbol,Any} and then calls the main method (which I think would need made specific to Dict{Symbol,T})?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I fixed it. I remove the Float64() and the type of the new dictionary should be inferred automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using convert
to convert Dict{Any,Any}
to Dict{Symbol,Any}
, but it doesn't work.
ERROR: MethodError: Cannot `convert` an object of type String to an object of type Symbol
Closest candidates are:
convert(::Type{T}, ::T) where T at Base.jl:61
Symbol(::String) at boot.jl:489
Symbol(::AbstractString) at strings/basic.jl:228
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wait I misunderstood what you meant. I will fix it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, but can you squash?
allow nonfloat64 value Julian style Allow different typing for odekwargs and senskwargs
@mjohnson541 Squashed the commits related to dictionary typing! |
This is needed for pyrms compatability, see ReactionMechanismGenerator/pyrms#6.
Python string gets converted to String and runs into "expected Symbol, got a value of type String" error.
I tried the trick mentioned in JuliaPy/pyjulia#156, but when the symbol is contained in a dictionary, it still gets converted to a String during python to Julia conversion.