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

Add 'PairIJ Coeffs' section to the list of sections in LAMMPS parser #3959

Merged
merged 17 commits into from
Jan 6, 2023

Conversation

mglagolev
Copy link
Contributor

When called with "pair ij" option, the write_data command in LAMMPS writes a data file with a 'PairIJ Coeffs' section, as stated https://docs.lammps.org/write_data.html
Absence of this section in the SECTIONS list of LAMMPSParser.py can lead to an error.
This fix ensures correct processing of LAMMPS data files with a 'PairIJ Coeffs' section.

Changes made in this Pull Request:

'PairIJ Coeffs' added to the list of sections in LAMMPSParser.py

… This ensures correct processing of LAMMPS data files
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hello there first time contributor! Welcome to the MDAnalysis community! We ask that all contributors abide by our Code of Conduct and that first time contributors introduce themselves on the developer mailing list so we can get to know you. You can learn more about participating here. Please also add yourself to package/AUTHORS as part of this PR.

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Base: 93.49% // Head: 93.49% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (d8fc45a) compared to base (d67b4f1).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3959   +/-   ##
========================================
  Coverage    93.49%   93.49%           
========================================
  Files          190      190           
  Lines        24963    24963           
  Branches      3527     3527           
========================================
+ Hits         23338    23340    +2     
+ Misses        1102     1101    -1     
+ Partials       523      522    -1     
Impacted Files Coverage Δ
package/MDAnalysis/topology/LAMMPSParser.py 95.81% <ø> (+0.83%) ⬆️
package/MDAnalysis/visualization/streamlines_3D.py 70.49% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mglagolev
Copy link
Contributor Author

This should actually solve the issue #3336

@hmacdope
Copy link
Member

Hi @mglagolev thanks for the contribution!

Would you be able to add a test with a small example test file to show the issue is resolved.

You will also need to update CHANGELOG, and add yourself to AUTHORS.

I would also ask you to possibly introduce yourself on the developer mailing list to welcome you to the community and have a means of contacting you. :)

@mglagolev
Copy link
Contributor Author

@hmacdope Thank you for the suggestions! I pushed the changes to AUTHORS and CHANGELOG to my branch, shall I do anything else? This is my first pull request ever.
Shall I add the test file and test script to my branch also? If so, where shall I put it?

@mglagolev
Copy link
Contributor Author

Added a datafile and a reading script to testsuite/MDAnalysisTests/topology

Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

A good start :) See my comments. Ping me if unsure of anything.

@@ -0,0 +1,17 @@
#!/usr/bin/env python3
Copy link
Member

Choose a reason for hiding this comment

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

This can become part of the other LAMMPS Topology tests in test_lammpsdata.py it doesn't need its own file.

import MDAnalysis as mda


PAIRIJ_COEFFS_DATA = "PR3959_test.data"
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be added as a datafile see datafiles.py on how to do that.

@@ -0,0 +1,3228 @@
LAMMPS data file via write_data, version 23 Jun 2022, timestep = 1000
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be moved to data and added to datafiles.py.

This reverts commit 383423f.

The test needs to be integrated into the test_lammpsdata.py
instead of a separate script, and the sample datafile needs
to be placed in the appropriate directory.
@mglagolev
Copy link
Contributor Author

@hmacdope Thank you for your guiding! I tried to replicate what I saw in test_lammpsdata.py, and committed to the branch. When I run the test:

cd testsuite/MDAnalysisTests
pytest --disable-pytest-warnings

It shows errors in some other modules, but not topology.
However, I'm not sure that I've done everything correctly and the testing actually takes place.

I'm also wondering, shall my datafile state the number of impropers and charges, because these are mentioned as expected_attrs in LammpsBase.

@mglagolev mglagolev requested a review from hmacdope December 22, 2022 17:10
@hmacdope
Copy link
Member

hmacdope commented Dec 23, 2022

@hmacdope Thank you for your guiding! I tried to replicate what I saw in test_lammpsdata.py, and committed to the branch. When I run the test:

well done on getting the test files sorted out!

cd testsuite/MDAnalysisTests pytest --disable-pytest-warnings

It shows errors in some other modules, but not topology. However, I'm not sure that I've done everything correctly and the testing actually takes place.

  1. The errors are coming from the issue with the density code, histogramdd normed argument replaced by density #3976 will fix it in due time so no need to worry about it yet.

You have imported the file but the testing is not yet taking place as you need to have asserts, but you have a good start

I will review to show you how to make the testing work

EDIT: Looks like the testing is working, sorry I didn't see that it was being done in the base class.

I'm also wondering, shall my datafile state the number of impropers and charges, because these are mentioned as expected_attrs in LammpsBase.

Lets see what happens when we add testing.

@hmacdope
Copy link
Member

To test only your module go to MDAnalysistests/topology/ and run pytests test_lammpsdata.py

package/CHANGELOG Show resolved Hide resolved
@mglagolev
Copy link
Contributor Author

To test only your module go to MDAnalysistests/topology/ and run pytests test_lammpsdata.py

Done that.
My file understandably fails on test_expected_attributes: AssertionError: Missing expected attribute: charges
What shall I do? Create a different file with a different LAMMPS atom_style, which will include charges?

@mglagolev mglagolev requested a review from hmacdope December 23, 2022 21:56
@@ -0,0 +1,3228 @@
LAMMPS data file via write_data, version 23 Jun 2022, timestep = 1000
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to gzip or bzip2 this? i.e. is this something we support (I know we do for PDBs and similar, so I assume it should work here too?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@IAlibay I'm sorry, I'm lost a little bit. How can I help at this point?

Copy link
Member

Choose a reason for hiding this comment

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

Compress the file(s) with bzip2 and store it as testsuite/MDAnalysisTests/data/lammps/pairij_coeffs.data.bz2. MDAnalysis will just read it the compressed file and we use up less space in the package and on disk.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you! Recommitted with a zipped file.

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

I'm going to make that last one blocking, I'll unblock if it turns out to not be feasible.

@mglagolev
Copy link
Contributor Author

Thank you all, I've reverted the previous commit and recommitted with a zipped file.

@mglagolev mglagolev requested review from IAlibay and removed request for hmacdope and IAlibay December 25, 2022 21:51
@mglagolev mglagolev requested review from IAlibay and hmacdope and removed request for IAlibay December 27, 2022 10:52
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Couple things from my side of things, thanks for bzipping that datafile.

@mglagolev mglagolev requested review from IAlibay and hmacdope and removed request for hmacdope and IAlibay December 28, 2022 17:17
@hmacdope
Copy link
Member

hmacdope commented Jan 3, 2023

@mglagolev If you could fix the failing tests and the merge conflicts, we can move forward from there.
:)

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Just the one quick thing from me.

@@ -13,11 +13,14 @@ The rules for this file:
* release numbers follow "Semantic Versioning" http://semver.org

------------------------------------------------------------------------------
??/??/?? IAlibay, pgbarletta

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Please don't add the extra line here (we try to keep the format of this file reasonably strict to make life easier on releases).

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Thanks!

@mglagolev
Copy link
Contributor Author

@IAlibay @hmacdope
It seems that everything should be fine now, except for the darker lint test. But I thought maybe I should comply with the style already used in test_lammpsdata.py.
Thank you all for your big help with this small commit!

@orbeckst
Copy link
Member

orbeckst commented Jan 4, 2023

Thank you for your contribution @mglagolev !

Thank you all for your big help with this small commit!

Yes, as you can see, when working on software that's used by a few thousand researchers, there's a lot more to do for maintaining quality than just to add a few lines of code and hoping it will be fine. We do all this reviewing and insisting on tests with the goal to keep MDAnalysis a useful and maintainable piece of software for the foreseeable future.

"""Tests the reading of lammps .data topology file with a
PairIJ Coeffs section
"""

Copy link
Member

@IAlibay IAlibay Jan 4, 2023

Choose a reason for hiding this comment

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

Suggested change

No worries about the darker linting, as long as it's not breaching PEP8 it ends up just black trying to enforce its style.

That being said the above "whitespace on an empty line" is a PEP8 violation (I suspect the suggested edit here won't work well, essentially the empty line is fine, but it can't have any whitespaces on it)

Sorry about this, as @orbeckst explains re: keeping maintenance costs down, we end up requiring a lot of weird formatting rules that do tend to be rather unfriendly to new contributors :(

@mglagolev
Copy link
Contributor Author

@orbeckst @IAlibay @hmacdope
I absolutely understand that this rigorousness is essential, and I'm very grateful for your immense work on this project.
Thanks for sort of onboarding me. I hope that I can contribute more in the future.

@IAlibay IAlibay requested a review from hmacdope January 5, 2023 20:24
Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

Fantastic work @mglagolev! Thanks for the contribution 😄 Many LAMMPS users will appreciate this one I'm sure. 👍

@hmacdope hmacdope merged commit 08cf96f into MDAnalysis:develop Jan 6, 2023
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.

4 participants