Skip to content

Add kwarg to index TPRParser from 0 or 1#3152

Merged
jbarnoud merged 6 commits intoMDAnalysis:developfrom
lilyminium:fix-2364
Mar 15, 2021
Merged

Add kwarg to index TPRParser from 0 or 1#3152
jbarnoud merged 6 commits intoMDAnalysis:developfrom
lilyminium:fix-2364

Conversation

@lilyminium
Copy link
Member

@lilyminium lilyminium commented Mar 13, 2021

Fixes #2364

Changes made in this Pull Request:

  • Added keyword argument to index TPRParser from 0 or 1
  • Set the default to index from 1, changing the default behaviour

This is easily undoable. I read the discussion in #2364 as supporting both including a kwarg and a warning. If that is not consensus, please let me know. I'll update CHANGELOG once we have this nailed down :-)

PR Checklist

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

@pep8speaks
Copy link

pep8speaks commented Mar 13, 2021

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

Line 151:80: E501 line too long (85 > 79 characters)

Comment last updated at 2021-03-14 17:05:53 UTC

@codecov
Copy link

codecov bot commented Mar 13, 2021

Codecov Report

Merging #3152 (76f6cdf) into develop (cadf5b9) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3152   +/-   ##
========================================
  Coverage    92.68%   92.68%           
========================================
  Files          168      168           
  Lines        22677    22679    +2     
  Branches      3212     3213    +1     
========================================
+ Hits         21018    21020    +2     
  Misses        1611     1611           
  Partials        48       48           
Impacted Files Coverage Δ
package/MDAnalysis/topology/TPRParser.py 95.16% <100.00%> (ø)
package/MDAnalysis/topology/tpr/utils.py 96.98% <100.00%> (+0.01%) ⬆️

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 cadf5b9...76f6cdf. Read the comment docs.

Copy link
Contributor

@jbarnoud jbarnoud left a comment

Choose a reason for hiding this comment

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

Looks good to me. I am not sure the deprecation message is very clear, though. I would phrase the message to say that from version 2.0, resid will start at 1 rather than 0.

Copy link
Contributor

@jbarnoud jbarnoud left a comment

Choose a reason for hiding this comment

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

I just realized it is missing an entry in the changelog and a "versionchanged".

@lilyminium
Copy link
Member Author

Thanks @jbarnoud, I've updated CHANGELOG now. I also realised this PR is to develop, so I removed the deprecation warning and changed the default. #3153 is the "first" addition of this to master with the deprecation warning and the status quo default of tpr_resid_from_one=False.

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! I was first confused by the PR description but then saw that this is one against develop.

I have minor improvements and one bigger discussion point regarding the default value inside the low-level TPR reader code.



def do_mtop(data, fver):
def do_mtop(data, fver, tpr_resid_from_one=True):
Copy link
Member

Choose a reason for hiding this comment

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

I feel the default should remain False because that is what the TPR actually contains. IMHO the TPR functions themselves could/should stay as faithful to the original format as possible. Assume someone wrote their own TPR parser with our functions. With the new default you break their code needlessly, with the old defaults nothing changes and our own parser just makes the well-documented choice to index from 1.

Copy link
Member

Choose a reason for hiding this comment

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

I can be convinced otherwise (ie to let default True stand) but wanted to discuss this point first before approving.

Copy link
Member Author

Choose a reason for hiding this comment

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

Others may want to chime in (maybe the most knowledgeable, @jbarnoud) but I agree with your argument.

Copy link
Member

Choose a reason for hiding this comment

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

I am going to approve because it looks sensible from my point but let @jbarnoud also say something before merging.

Copy link
Contributor

Choose a reason for hiding this comment

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

TPR indeed index from 0, but it is a bit moot because you do not read a TPR directly. Instead, you end up reading your gro and ITP files to make sense of your TPR so consistency there seems the right thing to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

My previous objection was that it would break the existing code, but the deprecation in 1.1.0 should be enough.

@orbeckst
Copy link
Member

@lilyminium the issue description is not correct, is it?

Set the default to index from 0, i.e. status quo

This PR (against develop) does change the default indexing to 1-based.

@orbeckst
Copy link
Member

Note that anything referring to 1.0.2 should become 1.1.0 (see comment on #3153 ).

@orbeckst
Copy link
Member

@jbarnoud any last comments? Otherwise I'll merge tomorrow.

orbeckst pushed a commit that referenced this pull request Mar 14, 2021
- Fixes #2364
- Master version of #3152.
- Changes made in this Pull Request:
    - Add `tpr_resid_from_one` keyword to TPRParser
    - Set default to `False`, keeping current status quo
    - Emits a warning for `tpr_resid_from_one=False` indicating that default behaviour will change in 2.0
- add tests
- update CHANGELOG
@IAlibay IAlibay added this to the 2.0 milestone Mar 14, 2021
@jbarnoud jbarnoud merged commit 6282385 into MDAnalysis:develop Mar 15, 2021
PicoCentauri pushed a commit to PicoCentauri/mdanalysis that referenced this pull request Mar 30, 2021
* add kwarg

* change default to True for 2.0

* fix tests to index resids from 0 again

* Update package/CHANGELOG

Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>

* change default arg for TPR utilities and remove warnings

* updated to 1.1.0

Co-authored-by: Oliver Beckstein <orbeckst@gmail.com>
@IAlibay IAlibay added the defect label Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TPRParser should not index from 0

5 participants