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

updating python package to thermal nonEquilibrium #179

Open
ggange opened this issue Oct 14, 2021 · 7 comments
Open

updating python package to thermal nonEquilibrium #179

ggange opened this issue Oct 14, 2021 · 7 comments

Comments

@ggange
Copy link
Contributor

ggange commented Oct 14, 2021

Hello guys,
I am trying to exploit the functionality of the MutationPP python package (got from pip).

I wrote a small script to define a mixture using "ChemNonEqTTv" but, as soon as I tried to setState, I get this error

mix.setState(rho, T, 1)
TypeError: setState(): incompatible function arguments. The following argument types are supported:
1. (self: mutationpp._mutationpp.Mixture, arg0: float, arg1: float, arg2: int) -> None
2. (self: mutationpp._mutationpp.Mixture, arg0: List[float], arg1: float, arg2: int) -> None

Both rho and T are set as lists but the same happens with numpy objects...

After peaking with @BBArrosDias, we think the problem (which I suppose is related to the input arg1 which only allows int) can be solved by modifying pyMixture.cpp adding:

 .def("setState",
       [](Mutation::Mixture &self,
               std::vector<double> rho_i,
               std::vector<double> T,
               const int vars)
      {
           self.setState(rho_i.data(),T.data(),vars);
       },
       "Sets the state of the mixture using the StateModel belonging to "
       "the mixture."
       "The input variables depend on the type of StateModel being used.")

What do you think? How can I then transfer the changes to the actual python package?

Thank you!

@rdbisme
Copy link
Collaborator

rdbisme commented Oct 14, 2021

Ehi @ggange, can you attach the script? Such that I can use it to verify the implementation and maybe add a test.

@BBArrosDias
Copy link
Collaborator

Hi @rubendibattista, I think the point here is to get familiar with changing the package locally and update it.
In your opinion should we do something like this:
https://widdowquinn.github.io/coding/update-pypi-package/

I am also interested in adding more tests, and it would be nice if @ggange does this update so he can get familiar with the package if he needs to add something more in the future.
This issue can also be a reference -- or potentially we could write a small how-to -- for future users.

@ggange
Copy link
Contributor Author

ggange commented Oct 15, 2021

Hi @rubendibattista! indeed, as mentioned by @BBArrosDias, the main concern with it was the update of the python package :) the issue was badly written, my fault!

Anyway I am adding the small script I used (which is actually a modified version of the example Air_11_Equilibrium.py ):

import mutationpp as mpp
import numpy as np

if __name__ == "__main__":
    myMixtureOptions = mpp.MixtureOptions("air_5")
    print("Mixture path:", myMixtureOptions.getSource())
    print("Mixture species:", myMixtureOptions.getSpeciesDescriptor())
    myMixtureOptions.setStateModel("ChemNonEqTTv")
    mix = mpp.Mixture(myMixtureOptions)

    rho = [1]*5
    T   = [1]*2
    # rho = np.ones(5)
    # T = np.ones(2)

    T[0] = 1.
     T[1] = 1.

    mix.setState(rho, T, 1)

@rdbisme
Copy link
Collaborator

rdbisme commented Oct 15, 2021

Ehi @BBArrosDias, I don't understand your question very well, but I'll try to interpolate :).

The package on PyPI is updated automatically via Github actions (here). Basically the package is rebuilt and uploaded automatically when the code is tagged. So there's no need to update the local package, it will be done automatically by the CI system.

So the only thing needed here is to merge your code update, and then tag a new version. Github will take care of the rest.

Also, the package is now still in TestPyPI. Let's test a couple of automatic updates and then we can push it in the mainline PyPI repo.

Does this answer your questions?

@rdbisme
Copy link
Collaborator

rdbisme commented Oct 15, 2021

If your question arises from the fact that you want to develop locally, i.e. you want to modify the C++ code and get the package updated locally to be used in your Python local code, you can try to use editable mode from pip. When you edit your C++ files you' ll probably need to run python setup.py build from the root of the project to recompile your stuff.

@BBArrosDias
Copy link
Collaborator

Ok, you anticipated my question. So we develop locally and then push it to git, and the PyPI package will update automatically.
Is it correct?

@rdbisme
Copy link
Collaborator

rdbisme commented Oct 17, 2021

Yes. Just to be clear: you don't need to upload to PyPi the new package to have it available locally. Building the package correctly in editable mode will give you straight access to the new version. Then, once you push it upstream, we will let all the other users have access to your improvements.

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

No branches or pull requests

3 participants