Skip to content
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

Force the returned solution object to stay as ODESolution #6

Merged
merged 1 commit into from May 13, 2023

Conversation

hwpang
Copy link
Contributor

@hwpang hwpang commented May 12, 2023

ReactionMechanismSimulator.threadedsensitivities is supposed to return either an ODESolution object, or a dictionary containing ODESolution as values, but they both get converted to list of lists when we use it through pyrms.

Fixing the case that returns an ODESolution object is easier, I use the solution mentioned in JuliaPy/PyCall.jl#460.
Fixing the case that returns a dictionary of ODESolution objects is trickier. I had to force the Main.get to not convert the value into list of lists.

@hwpang hwpang requested a review from mjohnson541 May 12, 2023 20:55
sol = _threadedsensitivities(react)
return sol

ReactionMechanismSimulator.threadedsensitivities = pythreadedsensitivities
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does pythreadedsensitivities get defined anywhere? Also is it possible to move this up with pygetfluxdiagram?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this, the function was supposed to be pythreadedsensitivities. I also move this up with pygetfluxdiagram

@hwpang
Copy link
Contributor Author

hwpang commented May 12, 2023

Do we not have tests for pyrms?

@mjohnson541
Copy link
Contributor

There is a test, but it ran off travis so I think it might not work now.

pyrms/rms.py Outdated
# Allow us the get the solution object in the julia wrapped object without
# it being converted into list of lists
get = Main.pyfunctionret(Main.get, Main.Any, Main.PyAny, Main.PyAny, Main.PyAny)
def pythreadedsensitivities(react, inds=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these be fed the keyword arguments the original function can?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hwpang
Copy link
Contributor Author

hwpang commented May 13, 2023

Passing in the keyword arguments as Dict{Symbol,Float64} is tricky.
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.

I had to change something in RMS to get the type right, see ReactionMechanismGenerator/ReactionMechanismSimulator.jl#212.

Copy link
Contributor

@mjohnson541 mjohnson541 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Can you squash as appropriate?

@hwpang
Copy link
Contributor Author

hwpang commented May 13, 2023

@mjohnson541 All squashed!

@hwpang hwpang requested a review from mjohnson541 May 13, 2023 21:29
@mjohnson541 mjohnson541 merged commit affac68 into main May 13, 2023
@mjohnson541 mjohnson541 deleted the hwpang-patch-1 branch May 13, 2023 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants