Skip to content

Update RMG-database scripts and notebooks to Python 3#364

Merged
mliu49 merged 4 commits into
masterfrom
rmg2to3scripts
Dec 4, 2019
Merged

Update RMG-database scripts and notebooks to Python 3#364
mliu49 merged 4 commits into
masterfrom
rmg2to3scripts

Conversation

@ajocher

@ajocher ajocher commented Oct 15, 2019

Copy link
Copy Markdown
Contributor

This pull request addresses "Update RMG-database scripts and notebooks" in ReactionMechanismGenerator/RMG-Py#1726.

In addition, RMG-Java related scripts and unnecessary scripts are deleted as discussed in #363.

generateFilterArrheniusFits.ipynb is updated but can only be finalized once from rmgpy/data/kinetics/database.py has 'filter_limit_fits' updated (currently not in master and Python 3).

Errors related to drawing a molecule are fixed in ReactionMechanismGenerator/RMG-Py#1735.

The documentation is updated in ReactionMechanismGenerator/RMG-Py#1767.

@mliu49 mliu49 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I made a couple quick comments about imports which are not necessary since we aren't aiming for compatibility with both Python 2 and Python 3.

Comment thread scripts/evansPolanyi.py Outdated
Comment on lines +7 to +12
from __future__ import division
from __future__ import print_function

from builtins import zip
from builtins import range
from past.utils import old_div

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we're going for Python 3 compatibility only, we don't need these compatibility measures.

  • __future__ imports are not necessary since we are using Python 3 only
  • For division, we should use the built-in / operator instead of importing old_div.
  • We can use zip and range from the default Python 3 libraries instead of the builtins module, so these imports are not necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread scripts/importChemkinLibrary.py Outdated
from rmgpy.chemkin import loadChemkinFile, getSpeciesIdentifier

from builtins import str
from builtins import range

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These imports are also not necessary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread scripts/process_family_images.py Outdated
to
<policy domain="coder" rights="read|write" pattern="EPS" />
"""
from __future__ import print_function

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't need this import.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@mliu49 mliu49 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I made a couple more minor comments. I think once you fix those, you can squash and rebase.

"\n",
" # Find key and value of max rate coefficient\n",
" key_max_rate = max(mydict.iteritems(), key=operator.itemgetter(1))[0]\n",
" key_max_rate = max(iter(mydict.items()), key=operator.itemgetter(1))[0]\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could you change this to just max(mydict.items(), ...?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

to
<policy domain="coder" rights="read|write" pattern="EPS" />
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this change is necessary if there are no other changes to this file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This commit is removed.

"reaction_dict = {}\n",
"for library_name in libraries:\n",
" kinetic_library = database.kinetics.libraries[library_name]\n",
" for index, entry in iter(kinetic_library.entries.items()):\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This can also be kinetics_library.entries.items() without iter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

" for index, entry in kineticLibrary.entries.iteritems():\n",
"for library_name in libraries:\n",
" kinetic_library = database.kinetics.libraries[library_name]\n",
" for index, entry in iter(kinetic_library.entries.items()):\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same thing here with iter.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ajocher

ajocher commented Dec 3, 2019

Copy link
Copy Markdown
Contributor Author

Thanks for the comments! I squashed and rebased.

@mliu49
mliu49 merged commit e409c4b into master Dec 4, 2019
@mliu49
mliu49 deleted the rmg2to3scripts branch December 4, 2019 17:06
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.

2 participants