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

Reverse recipes should be in reverse order #1829

Merged
merged 1 commit into from
Dec 4, 2019

Conversation

mazeau
Copy link
Contributor

@mazeau mazeau commented Nov 23, 2019

This is a duplicate of PR #1827, but only contains the relevant commits.

I found that when generating reverse templates, the action list would go in the same order as the forward, and this would cause issues when making and breaking multiple bonds.

    ['CHANGE_BOND', '*1', 1, '*2'],
    ['CHANGE_BOND', '*2', -1, '*3'],
    ['BREAK_BOND', '*2', 1, '*3'],
    ['FORM_BOND', '*3', 1, '*4'],
    ['CHANGE_BOND', '*3', 1, '*4']

This change fixes this template's reverse recipe.

@@ -258,6 +258,7 @@ def get_reverse(self):
other.add_action(['GAIN_PAIR', action[1], action[2]])
elif action[0] == 'GAIN_PAIR':
other.add_action(['LOSE_PAIR', action[1], action[2]])
other.actions = reversed(other.actions) # Play the reverse recipe in the reverse order
Copy link
Contributor

Choose a reason for hiding this comment

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

reversed returns an iterator. Do we expect any issues with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't think that would cause any issues. I'm able to run it perfectly fine. Maybe @rwest feels differently?

Copy link
Member

Choose a reason for hiding this comment

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

Hard to anticipate, but might as well try other.actions = list(reversed(other.actions)).

Then should (rebase and) look into why the unit tests failed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I have a better suggestion: use reversed directly on the for loop, for action in reversed(self.actions)

@mliu49
Copy link
Contributor

mliu49 commented Nov 26, 2019

The failing unit tests are all related to reaction generation:

======================================================================
ERROR: test_reaction_degeneracy_independent_of_generatereactions_direction
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/ReactionMechanismGenerator/RMG-Py/rmgpy/data/kinetics/kineticsTest.py", line 565, in test_reaction_degeneracy_independent_of_generatereactions_direction
    self.assertEqual(forward_reactions[0].degeneracy, reverse_reactions[0].degeneracy,
IndexError: list index out of range
======================================================================
FAIL: Test that the ``react_all`` function works in serial
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/ReactionMechanismGenerator/RMG-Py/rmgpy/rmg/reactTest.py", line 124, in test_react_all
    self.assertEqual(len(flat_rxn_list), 44)
AssertionError: 25 != 44
======================================================================
FAIL: Test that the ``react_all`` function works in parallel using Python multiprocessing
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/ReactionMechanismGenerator/RMG-Py/rmgpy/rmg/reactTest.py", line 149, in test_react_all_parallel
    self.assertEqual(len(flat_rxn_list), 44)
AssertionError: 25 != 44

I don't have any intuition for why this change would have these effects, so you would need to do some debugging.

@codecov
Copy link

codecov bot commented Dec 3, 2019

Codecov Report

Merging #1829 into master will decrease coverage by 1.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1829      +/-   ##
==========================================
- Coverage   43.98%   42.89%   -1.09%     
==========================================
  Files          83       83              
  Lines       21581    21565      -16     
  Branches     5653     5652       -1     
==========================================
- Hits         9492     9251     -241     
- Misses      11043    11290     +247     
+ Partials     1046     1024      -22
Impacted Files Coverage Δ
rmgpy/data/kinetics/family.py 48.35% <100%> (ø) ⬆️
rmgpy/qm/molecule.py 24.77% <0%> (-55.41%) ⬇️
rmgpy/qm/mopac.py 27.05% <0%> (-42.95%) ⬇️
rmgpy/qm/qmdata.py 55.88% <0%> (-29.42%) ⬇️
rmgpy/qm/main.py 50% <0%> (-15.33%) ⬇️
rmgpy/data/solvation.py 63.78% <0%> (-1.34%) ⬇️

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 a87d79f...de77c4b. Read the comment docs.

Recipes that decrement THEN break a bond, when reversed
must create THEN increment the bond, not increment
then create. i.e. the recipe steps must be played backwards
in order.

reversing the loop, suggested by mliu49.
@rwest
Copy link
Member

rwest commented Dec 3, 2019

I can't imagine why this change would cause a

======================================================================
5124FAIL: A general test for a PDep job in Arkane
5125----------------------------------------------------------------------
5126Traceback (most recent call last):
5127  File "/home/travis/build/ReactionMechanismGenerator/RMG-Py/arkane/pdepTest.py", line 107, in test_pdep_job
5128    self.assertAlmostEquals(rxn.kinetics.get_rate_coefficient(1000.0, 1.0), 88.88253229631246)
5129AssertionError: 88.9961408998604 != 88.88253229631246 within 7 places (0.11360860354794511 difference)

that was showing up in Travis, so I've triggered a new travis build, in case it's something weird or random.

@mliu49
Copy link
Contributor

mliu49 commented Dec 3, 2019

It seems that a lot of new builds are failing due to that. It's discussed somewhat in #1682, but we were not able to reach a conclusion. It is possible that this new wave of failures is caused by a new version of some dependency, but the idea that math could change (by 0.1!) is quite odd.

Copy link
Contributor

@mliu49 mliu49 left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@mliu49 mliu49 merged commit b691b45 into ReactionMechanismGenerator:master Dec 4, 2019
@mazeau mazeau deleted the recipe branch December 4, 2019 18:52
@mliu49 mliu49 mentioned this pull request Dec 16, 2019
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.

3 participants