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

BugFix: Don't overwrite self.mol if self.mol_from_xyz is None #106

Merged
merged 2 commits into from
Mar 28, 2019

Conversation

oscarwumit
Copy link
Contributor

@oscarwumit oscarwumit commented Mar 26, 2019

Temporary fix. Need to troubleshoot why self.mol_from_xyz is None
i.e. why it does not parse xyz as expected

@oscarwumit oscarwumit requested a review from alongd March 26, 2019 20:00
@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #106 into master will decrease coverage by 9.1%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
- Coverage    40.6%   31.49%   -9.11%     
==========================================
  Files          22       22              
  Lines        5221     5226       +5     
  Branches     1353     1357       +4     
==========================================
- Hits         2120     1646     -474     
- Misses       2759     3271     +512     
+ Partials      342      309      -33
Impacted Files Coverage Δ
arc/species/species.py 35.15% <0%> (-23.25%) ⬇️
arc/species/converter.py 24.78% <0%> (-47.01%) ⬇️
arc/species/xyz_to_2d.py 16.61% <0%> (-22.16%) ⬇️
arc/scheduler.py 14.44% <0%> (-5.06%) ⬇️
arc/reaction.py 38.58% <0%> (-3.55%) ⬇️
arc/main.py 40.36% <0%> (-1.68%) ⬇️
arc/job/job.py 20.95% <0%> (-1.11%) ⬇️

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 4e1638b...4c4dce8. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #106 into master will increase coverage by 0.01%.
The diff coverage is 39.13%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage    40.6%   40.62%   +0.01%     
==========================================
  Files          22       22              
  Lines        5221     5226       +5     
  Branches     1353     1357       +4     
==========================================
+ Hits         2120     2123       +3     
+ Misses       2759     2758       -1     
- Partials      342      345       +3
Impacted Files Coverage Δ
arc/species/species.py 58.4% <39.13%> (ø) ⬆️
arc/reaction.py 42.12% <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 4e1638b...f9e42b2. Read the comment docs.

@@ -827,6 +830,8 @@ def mol_from_xyz(self, xyz=None):
'Got xyz:\n{0}\n\nwhich corresponds to {1}\n{2}\n\nand: {3}\n{4}'.format(
xyz, self.mol.toSMILES(), self.mol.toAdjacencyList(),
original_mol.toSMILES(), original_mol.toAdjacencyList()))
if self.mol is None:
self.mol = original_mol # todo: Atom order will not be correct, need fix
else:
self.mol = molecules_from_xyz(xyz, multiplicity=self.multiplicity, charge=self.charge)[1]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alongd What if after the else statement, molecules_from_xyz gives None. In this case, it seems that we will still have a problem of self.mol = None. How should we resolve that?

Copy link
Member

Choose a reason for hiding this comment

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

If this condition is true, then this means that self.mol is None to begin with, and molecules_from_xyz is our last resort. If it doesn't work, the user is expected to give some 2D representation. When we do it in an automated fashion, we have an RMG Species object, so it shouldn't be a problem

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 see.

Copy link
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Thanks! please see comments

else:
# parameters were entered directly, not via an RMG:Species object

# parameters were entered directly, not via an RMG:Species object
Copy link
Member

Choose a reason for hiding this comment

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

This comment should be removed, since the code here refers to all cases now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.

self.charge = charge
if self.mol is None:
if adjlist:
Copy link
Member

Choose a reason for hiding this comment

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

Let's add mol before adjList, inchi and SMILES (it can also be directly given)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't we already have self.mol = mol in the init? See line 118, species.py @alongd

Copy link
Member

Choose a reason for hiding this comment

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

good point

@@ -827,6 +830,8 @@ def mol_from_xyz(self, xyz=None):
'Got xyz:\n{0}\n\nwhich corresponds to {1}\n{2}\n\nand: {3}\n{4}'.format(
xyz, self.mol.toSMILES(), self.mol.toAdjacencyList(),
original_mol.toSMILES(), original_mol.toAdjacencyList()))
if self.mol is None:
self.mol = original_mol # todo: Atom order will not be correct, need fix
else:
self.mol = molecules_from_xyz(xyz, multiplicity=self.multiplicity, charge=self.charge)[1]
Copy link
Member

Choose a reason for hiding this comment

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

If this condition is true, then this means that self.mol is None to begin with, and molecules_from_xyz is our last resort. If it doesn't work, the user is expected to give some 2D representation. When we do it in an automated fashion, we have an RMG Species object, so it shouldn't be a problem

@alongd
Copy link
Member

alongd commented Mar 27, 2019

Thanks for your contribution!
Regarding the commit message, I prefer to have a BugFix in the beginning, this capitalization is easier to spot when briefly looking at a bunch of commits. Also, in the commit message, please replace = None with is None.

@oscarwumit oscarwumit changed the title bug fix: avoid overwriting self.mol if self.mol_from_xyz = None BugFix: avoid overwriting self.mol if self.mol_from_xyz is None Mar 27, 2019
@oscarwumit oscarwumit changed the title BugFix: avoid overwriting self.mol if self.mol_from_xyz is None BugFix: avoid overwrite self.mol if self.mol_from_xyz is None Mar 27, 2019
@oscarwumit oscarwumit changed the title BugFix: avoid overwrite self.mol if self.mol_from_xyz is None BugFix: Don't overwrite self.mol if self.mol_from_xyz is None Mar 27, 2019
@oscarwumit
Copy link
Contributor Author

@alongd Many thanks for your review. I have changed the commit message. Please let me what do you think of the self.mol = mol in the init.

@alongd
Copy link
Member

alongd commented Mar 27, 2019

Could you change the commit message (not the PR title)?

Temporary fix. Need to troubleshoot why self.mol_from_xyz is None
i.e. why it does not parse xyz as expected
@oscarwumit
Copy link
Contributor Author

@alongd I updated the commit message and also rebased.

elif smiles:
self.mol = Molecule(SMILES=smiles)
if not self.is_ts and self.mol is None and self.generate_thermo:
logging.warn('No structure (SMILES, adjList, RMG:Species, or RMG:Molecule) was given for species'
Copy link
Member

Choose a reason for hiding this comment

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

Please change logging.warn (which will be deprecated soon) to logging.warning

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 just made another commit to replace all logging.warn to logging.warning in species.py. I also changed the code to conform to PEP 8.

@alongd
Copy link
Member

alongd commented Mar 27, 2019

I added another small comment.
Also, the commit massage says "temp, need to see why we don't get the correct xyz...", so please open an issue and give the details of the species we saw the bug for, so we'll remember to deal with it.

Also modified code to conform PEP 8 style guide
@oscarwumit
Copy link
Contributor Author

Many thanks for the comment. I opened an issue addressing our problem here.

Copy link
Member

@alongd alongd left a comment

Choose a reason for hiding this comment

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

Thanks!!

@alongd alongd merged commit 8b5db7a into master Mar 28, 2019
@alongd alongd deleted the fix_parsing_molecule branch March 28, 2019 02:02
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.

None yet

2 participants