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

Fix a few bugs and add tests: KineticsModel and uncertainty handling. #1705

Merged
merged 7 commits into from
Sep 30, 2019

Conversation

rwest
Copy link
Member

@rwest rwest commented Aug 23, 2019

Motivation or Problem

Issue #1703 describes a problem whereby SurfaceArrhenius objects can't be copied with deepcopy (meaning they can't be loaded in a kinetics family, or pretty much used for anything).
It was due to the new uncertainty attribute being left out of the __repr__ or __reduce__ methods.
While fixing and debugging, and adding unit tests, I caught some other bugs.
The KineticsModel had some errors, also in the __repr__ method, and the logic behind the isIdenticalTo() was broken and it'd return False when it should be True (which was causing the new unit tests I wrote for the surface kinetics module to fail).

Description of Changes

Added some unit tests that initially failed, and then fixed the bugs that they demonstrated.

Testing

It was test-driven development. A test I wrote to isolate one bug in fact led to finding two more.
Tested locally. Running Travis now. Test coverage around these modules is still pretty low, and even when lines of code are executed, the logic is not always being tested that the lines of code do the right thing. But improving that situation should wait until after Py3!

@codecov
Copy link

codecov bot commented Sep 27, 2019

Codecov Report

Merging #1705 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1705   +/-   ##
=======================================
  Coverage   32.61%   32.61%           
=======================================
  Files          87       87           
  Lines       26102    26102           
  Branches     6869     6869           
=======================================
  Hits         8514     8514           
+ Misses      16629    16618   -11     
- Partials      959      970   +11
Impacted Files Coverage Δ
rmgpy/data/statmech.py 42.2% <0%> (ø) ⬆️
rmgpy/rmg/pdep.py 12.21% <0%> (ø) ⬆️
rmgpy/reaction.py 0% <0%> (ø) ⬆️
rmgpy/data/kinetics/family.py 48.28% <0%> (ø) ⬆️
rmgpy/yml.py 15.71% <0%> (ø) ⬆️
rmgpy/data/kinetics/database.py 50.61% <0%> (ø) ⬆️
rmgpy/rmg/input.py 34.34% <0%> (ø) ⬆️
rmgpy/molecule/molecule.py 0% <0%> (ø) ⬆️
rmgpy/statmech/ndTorsions.py 59.78% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67f7508...893602e. Read the comment docs.

@mliu49 mliu49 force-pushed the catfix branch 2 times, most recently from e37e29d to 1cd2cd6 Compare September 27, 2019 19:21
@mliu49
Copy link
Contributor

mliu49 commented Sep 27, 2019

I went ahead and rebased this on top of master. I also incorporated futurization and RMG 3 changes into the relevant commits. I think this looks good, but perhaps we should have a second reviewer?

@rwest
Copy link
Member Author

rwest commented Sep 27, 2019

Thanks for rebasing, Max. A quick glance looks good to me (I have no time for a thorough review).

@xiaoruiDong
Copy link
Contributor

Thanks for the contribution, Dr. West. Thanks for the rebasing, Max. I went through the codes and they looked good to me. I ran the RMG-test and all tests related to this PR passed. I also implemented PEP-8 formatting to this PR to be consistent with other RMG code.

@xiaoruiDong
Copy link
Contributor

Corrections for namespace has been made. Sorry for my ignorant.

rwest and others added 7 commits September 29, 2019 18:22
So far just StickingCoefficient and SurfaceArrhenius.
Doesn't test everything.
Doesn't pass.
Can we pickle and unpickle, reconstruct from __repr__,
and does the isIdenticalTo method work?

(The answer to the last two is currently No)
First, the Tmin and Tmax were being printed for Pmin and Pmax,
and the Pmin was being printed as the comment.

Second, the uncertainty was not being reported.
This method just checks that Tmin and Tmax are equal.
But if they were equal, it used to return False.

Now it returns False if one or other is None, or they're
different. Note, however, that because the Quantity.equals
method defaults to a 1% tolerance, that's 20K difference
needed at 2000K.
@mliu49
Copy link
Contributor

mliu49 commented Sep 30, 2019

@xiaoruiDong, could you take a final look and approve? I added another commit fixing an issue with Chebyshev.is_identical_to which was uncovered by the fix to KineticsModel.is_identical_to.

Copy link
Contributor

@xiaoruiDong xiaoruiDong left a comment

Choose a reason for hiding this comment

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

It looks good. Thanks, Max.

@mliu49 mliu49 merged commit ce53e34 into master Sep 30, 2019
@mliu49 mliu49 deleted the catfix branch September 30, 2019 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants