-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add unit tests for reaction methods #85
Conversation
There seems to be some problem with the pipeline... |
@jngrad it seems related again with EESI and espresso 4.2.2, could you take a look? |
This is a harmless EESSI warning. The execution continued and failed while running pylint: values were stored in variables that are never read. The usual way if discarded unwanted values from a function that returns a tuple is to store the values into placeholder |
Oh, I am sorry for the misleading comment. I am travelling and I checked this too quick, Thanks @jngrad. Could you please fix it @davidbbeyer ? I will check this PR more throughly soon. |
Thanks @jngrad and @pm-blanco, now it is working |
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.
@davidbbeyer The test look good to me, but you forgot to commit your changes to the Makefile
, where you have probably added your new unit tests.
There are a few lines of code on those functions that are not currently covered by the new unit tests, most of them related with the use_exclusion_radius_per_type
feature and other corner cases (I list them below). You can check the coverage locally following the guidelines in our wiki (this is what I did).
- In
setup_cpH
, line 2751, we should test a case withuse_exclusion_radius_per_type
. - In
setup_cpH
, lines 2765-2766, just for completion a test case with a pka_set with particles not defined pyMBE (it should produce a warning) - In
setup_gcmc
, line 2800, again , we should test a case withuse_exclusion_radius_per_type
. - In
setup_gcmc
, lines 2821 and 2823, we should test cases with ions with the wrong charge to make sure that a value error is raised. You can checktestsuite/setup_salt_ions_unit_tests.py
line 236 for examples where errors are unit tested. - In
setup_grxmc_reactions
, line 2872, case withuse_exclusion_radius_per_type
. - In
setup_grxmc_reactions
, lines 2901-2907 cases with ions of the wrong charge. - In
setup_grxmc_reactions
, lines 2993-2994 test case with a pka_set with particles not defined pyMBE (it should produce a warning) - In
setup_grxmc_unified
, line 3076 test a case withuse_exclusion_radius_per_type
. - In
setup_grxmc_unified
, lines 3100-3102 cases with ions of the wrong charge. - In
setup_grxmc_unified
, lines 3121-3122 case with a pka_set with particles not defined pyMBE (it should produce a warning)
@pm-blanco I have implemented all of your suggestions and checked that the various functions for setting up the reactions have full coverage now. Also, while implementing the additional test, I realized that the function |
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.
Thank you @davidbbeyer, it looks very good to me. Again, it proves how important is to check even the corner cases 😄
I have added unit tests for the various functions that set up the reaction methods (
pymbe_library.setup_cpH()
,pymbe_library.setup_gcmc()
,pymbe_library.setup_grxmc_reactions()
,pymbe_library.setup_grxmc_unified()
). In all cases, the unit test consists of setting up the corresponding reactions for a system containing a weak acid and base in espresso and explicitly checking that the number of reactions is correct. Furthermore, the values of the equilibrium constants of the reactions are checked to see if they are correct.Additionally, I have also added a unit test that checks if the function
pymbe_library.determine_reservoir_concentrations()
returns the correct reservoir concentrations for an ideal system. The predictions are checked over a wide range of pH-values and salt concentrations by directly comparing it to the values obtained by a calculation independent from pyMBE.