Skip to content

fix masses and charge bug in HOOMD-XML parser#2889

Merged
orbeckst merged 12 commits intoMDAnalysis:developfrom
CalCraven:update_xml_parser
Aug 12, 2020
Merged

fix masses and charge bug in HOOMD-XML parser#2889
orbeckst merged 12 commits intoMDAnalysis:developfrom
CalCraven:update_xml_parser

Conversation

@CalCraven
Copy link
Contributor

@CalCraven CalCraven commented Aug 7, 2020

Fixes #2888

Changes made in this Pull Request:

  • Fix the HoomdXMLParser.py so that it properly reads in masses and charges instead of overriding all of those values with 0.0.

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@pep8speaks
Copy link

pep8speaks commented Aug 7, 2020

Hello @CalCraven! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 572:80: E501 line too long (82 > 79 characters)
Line 814:80: E501 line too long (87 > 79 characters)

Line 43:80: E501 line too long (83 > 79 characters)
Line 45:80: E501 line too long (87 > 79 characters)
Line 51:80: E501 line too long (88 > 79 characters)
Line 62:80: E501 line too long (80 > 79 characters)
Line 74:80: E501 line too long (82 > 79 characters)
Line 154:1: W391 blank line at end of file

Comment last updated at 2020-08-12 16:24:27 UTC

@codecov
Copy link

codecov bot commented Aug 7, 2020

Codecov Report

Merging #2889 into develop will increase coverage by 5.63%.
The diff coverage is 92.59%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2889      +/-   ##
===========================================
+ Coverage    87.20%   92.83%   +5.63%     
===========================================
  Files          167      187      +20     
  Lines        21744    24520    +2776     
  Branches      3186     3192       +6     
===========================================
+ Hits         18961    22764    +3803     
+ Misses        2258     1710     -548     
+ Partials       525       46     -479     
Impacted Files Coverage Δ
package/MDAnalysis/transformations/rotate.py 100.00% <ø> (ø)
package/MDAnalysis/topology/HoomdXMLParser.py 85.10% <50.00%> (+2.12%) ⬆️
package/MDAnalysis/coordinates/H5MD.py 94.55% <100.00%> (+70.41%) ⬆️
package/MDAnalysis/topology/tpr/obj.py 96.96% <0.00%> (-3.04%) ⬇️
package/MDAnalysis/core/topology.py 100.00% <0.00%> (ø)
package/MDAnalysis/analysis/polymer.py 100.00% <0.00%> (ø)
package/MDAnalysis/coordinates/MMTF.py 100.00% <0.00%> (ø)
package/MDAnalysis/coordinates/NAMDBIN.py 100.00% <0.00%> (ø)
lib/__init__.py 100.00% <0.00%> (ø)
transformations/__init__.py 100.00% <0.00%> (ø)
... and 118 more

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 3ea6e43...17a07f4. Read the comment docs.

@orbeckst orbeckst changed the title fix masses and charge bug fix masses and charge bug in HOOMD-XML parser Aug 7, 2020
Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

Thank you for pinpointing the error and providing a solution. This looks pretty good but before merging please address the following

@orbeckst orbeckst self-assigned this Aug 7, 2020
try:
val = configuration.find(attrname)
vals = [mapper(el) for el in val.text.strip().split()]
vals = [mapper(el) for el in val.text.strip().split('\n')]

Choose a reason for hiding this comment

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

Wow that fixed it? What was wrong with splitting on any white space? I thought the problem was not doing .split()[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.

That wasn't the issue. The issued ended up being with the plural vs singular terms for mass and charge being called at the wrong time.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

looking good.. please see comments

@orbeckst
Copy link
Member

Btw, the errors in your tests are due to #2890 .

@orbeckst
Copy link
Member

Your tests fail because you need to import assert_almost_equal.

@orbeckst
Copy link
Member

See https://travis-ci.com/github/MDAnalysis/mdanalysis/jobs/370755668#L2255-L2257

    def test_read_charges(self, top):
>       assert_almost_equal(top.charges.values, 0.0)
E       NameError: name 'assert_almost_equal' is not defined
testsuite/MDAnalysisTests/topology/test_hoomdxml.py:82: NameError

RMeli and others added 4 commits August 11, 2020 17:57
* Fixes MDAnalysis#2901
* Changes made in this Pull Request:
    - Added call to rotateby (instead of rotate)
    - Removed () from atom group
* fix MDAnalysis#2890 
* added H5PYPicklable class (works in serial but not with driver="mpio" and MPI comm)
* mock h5py so that the docs build even in the absence of h5py
* tests (anything related to mpi is excluded from coverage)
* update CHANGELOG
- import assert_almost_equal
- removed asserts that were not needed (and used deprecated constructs)
@orbeckst
Copy link
Member

I fixed the test and merged the develop branch. If all the tests pass I will approve and merge.

@orbeckst orbeckst added this to the 1.0.x milestone Aug 12, 2020
@orbeckst orbeckst merged commit 01bbf3c into MDAnalysis:develop Aug 12, 2020
@orbeckst
Copy link
Member

Thank you for your fix @CalCraven , I also sent you an invitation to the MDAnaysis/contributors.

orbeckst pushed a commit that referenced this pull request Aug 12, 2020
* Fixes #2888
* Fix the HoomdXMLParser.py so that it properly reads in masses and charges instead of overriding all of those values with 0.0.
* add tests
* update CHANGELOG
* update AUTHORS

Cherry-picked from  01bbf3c
@CalCraven
Copy link
Contributor Author

Thanks for getting that to the finish line @orbeckst. This was my first PR so it was good to get that figured out.

@CalCraven CalCraven deleted the update_xml_parser branch August 13, 2020 16:11
@orbeckst
Copy link
Member

Sure, I hope you'll contribute more!

PicoCentauri pushed a commit to PicoCentauri/mdanalysis that referenced this pull request Mar 30, 2021
* Fixes MDAnalysis#2888
* Fix the HoomdXMLParser.py so that it properly reads in masses and charges instead of overriding all of those values with 0.0.
* add tests
* update CHANGELOG
* update AUTHORS
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.

HoomdXML parser won't read in mass and charges

7 participants