Skip to content

Modified the ArkaneSpecies.update_xyz_string() method - #1714

Merged
mliu49 merged 1 commit into
py3from
arkane_species_xyz
Aug 29, 2019
Merged

Modified the ArkaneSpecies.update_xyz_string() method#1714
mliu49 merged 1 commit into
py3from
arkane_species_xyz

Conversation

@alongd

@alongd alongd commented Aug 29, 2019

Copy link
Copy Markdown
Member

Now outputs a standardized form of the xyz
Test extended accordingly

Addresses issue 1 reported in #1713

I think this PR should be merged into the py3 branch before #1713, since it doesn't break Py2 compatibility.

@alongd
alongd requested a review from mliu49 August 29, 2019 03:31
@codecov

codecov Bot commented Aug 29, 2019

Copy link
Copy Markdown

Codecov Report

Merging #1714 into py3 will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##              py3    #1714   +/-   ##
=======================================
  Coverage   41.41%   41.41%           
=======================================
  Files         167      167           
  Lines       30118    30118           
  Branches     6421     6421           
=======================================
  Hits        12473    12473           
  Misses      16685    16685           
  Partials      960      960

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 50e6ae4...fdf0a48. Read the comment docs.

Comment thread arkane/common.py Outdated
xyz_list.append(str(len(self.conformer.number.value_si)))
xyz_list.append(self.label)
for number in self.conformer.number.value_si:
elements.append(getElement(int(number)).symbol)

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.

Is this for loop necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sorry, it's a left-over from a different version of this block

Comment thread arkane/common.py Outdated
elements.append(getElement(int(number)).symbol)
for number, coordinate in zip(self.conformer.number.value_si, self.conformer.coordinates.value_si):
element_symbol = getElement(int(number)).symbol
row = element_symbol + ' ' * (4 - len(element_symbol))

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.

You can use string formatting here: row = '{0:4}'.format(element_symbol)

Note that strings are left aligned by default while numbers are right aligned by default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks!

Comment thread arkane/common.py Outdated
for c in coordinate:
row += '{0:14.8f}'.format(c * 1e10) # convert m to Angstrom
xyz_list.append(row)
return os.linesep.join(xyz_list)

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 you should use linesep here. File writing should automatically take care of line endings (at least in Python 3): https://docs.python.org/3/library/os.html#os.linesep

Comment thread arkane/common.py Outdated
element_symbol = getElement(int(number)).symbol
row = element_symbol + ' ' * (4 - len(element_symbol))
for c in coordinate:
row += '{0:14.8f}'.format(c * 1e10) # convert m to Angstrom

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.

Another option (although it might be a bit harder to read):
row += '{0:14.8f}{1:14.8f}{2:14.8f}'.format(*(coordinate * 1e10).tolist())

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nice!

@alongd

alongd commented Aug 29, 2019

Copy link
Copy Markdown
Member Author

Something's messed up with the coverage report. I don't think this small PR bumped the coverage by 3%...

Now outputs a standardized form of the xyz, also compatible with Py3
Test extended accordingly

@alongd alongd left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the comments! Corrected and squashed

Comment thread arkane/common.py Outdated
xyz_list.append(str(len(self.conformer.number.value_si)))
xyz_list.append(self.label)
for number in self.conformer.number.value_si:
elements.append(getElement(int(number)).symbol)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

sorry, it's a left-over from a different version of this block

Comment thread arkane/common.py Outdated
elements.append(getElement(int(number)).symbol)
for number, coordinate in zip(self.conformer.number.value_si, self.conformer.coordinates.value_si):
element_symbol = getElement(int(number)).symbol
row = element_symbol + ' ' * (4 - len(element_symbol))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

thanks!

Comment thread arkane/common.py Outdated
element_symbol = getElement(int(number)).symbol
row = element_symbol + ' ' * (4 - len(element_symbol))
for c in coordinate:
row += '{0:14.8f}'.format(c * 1e10) # convert m to Angstrom

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

nice!

@alongd
alongd force-pushed the arkane_species_xyz branch from 59e0701 to fdf0a48 Compare August 29, 2019 14:51
@mliu49
mliu49 merged commit af9dc41 into py3 Aug 29, 2019
@mliu49
mliu49 deleted the arkane_species_xyz branch August 29, 2019 16:51
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.

2 participants