Skip to content

renamed 'pbc' kwarg to 'wrap' for Group methods#2857

Merged
jbarnoud merged 11 commits intodevelopfrom
pbc_to_wrap
Mar 6, 2022
Merged

renamed 'pbc' kwarg to 'wrap' for Group methods#2857
jbarnoud merged 11 commits intodevelopfrom
pbc_to_wrap

Conversation

@richardjgowers
Copy link
Copy Markdown
Member

@richardjgowers richardjgowers commented Jul 19, 2020

Related to issue #1760 in particular @orbeckst here

Changes made in this Pull Request:

  • pbc kwarg changed to wrap for Group methods

The pbc kwarg for center_of_mass has been confusing people for a while, it's not clear if this wraps (ie forcing atoms to inside the unit cell) or unwrap (ie makes bonds whole, possibly putting atoms outside the unit cell).

The pbc option will still work for now but raise a deprecation warning

PR Checklist

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

@pep8speaks
Copy link
Copy Markdown

pep8speaks commented Jul 19, 2020

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

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

Line 1578:80: E501 line too long (80 > 79 characters)
Line 1581:80: E501 line too long (80 > 79 characters)
Line 1591:80: E501 line too long (84 > 79 characters)
Line 1596:80: E501 line too long (102 > 79 characters)
Line 1601:80: E501 line too long (101 > 79 characters)
Line 1602:80: E501 line too long (115 > 79 characters)
Line 1604:80: E501 line too long (101 > 79 characters)
Line 1608:80: E501 line too long (93 > 79 characters)

Line 1555:80: E501 line too long (89 > 79 characters)
Line 1567:80: E501 line too long (87 > 79 characters)

Comment last updated at 2022-03-05 16:25:15 UTC

"""Raises ValueError when both 'wrap' and 'unwrap' are set to True"""
@functools.wraps(function)
def wrapped(group, *args, **kwargs):
if kwargs.get('compound') == 'group':
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.

Here we used to allow pbc and unwrap if compound wasn't group, this slipped through review here: https://github.com/MDAnalysis/mdanalysis/pull/2275/files#r296183096

For sanity's sake, I'm saying that if you want a combination of wrapping/unwrapping you need to do multiple calls

@richardjgowers
Copy link
Copy Markdown
Member Author

I'm also not sure what we should target for the pbc deprecation. It's not overly urgent we just need to nudge people away from using center_of_mass(pbc=True) but it's not going to break anything to leave the undocumented option

@codecov
Copy link
Copy Markdown

codecov bot commented Jul 19, 2020

Codecov Report

Merging #2857 (bf4bfd7) into develop (db0c3d3) will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2857      +/-   ##
===========================================
+ Coverage    94.06%   94.11%   +0.05%     
===========================================
  Files          176      190      +14     
  Lines        23294    24656    +1362     
  Branches      3305     3309       +4     
===========================================
+ Hits         21911    23206    +1295     
- Misses        1337     1404      +67     
  Partials        46       46              
Impacted Files Coverage Δ
package/MDAnalysis/transformations/rotate.py 100.00% <ø> (ø)
package/MDAnalysis/transformations/translate.py 95.74% <ø> (ø)
package/MDAnalysis/core/groups.py 98.58% <100.00%> (+0.01%) ⬆️
package/MDAnalysis/core/topologyattrs.py 96.63% <100.00%> (+0.01%) ⬆️
package/MDAnalysis/converters/OpenMM.py 97.22% <0.00%> (-0.12%) ⬇️
package/MDAnalysis/units.py 100.00% <0.00%> (ø)
package/MDAnalysis/lib/c_distances.pyx 100.00% <0.00%> (ø)
package/MDAnalysis/converters/OpenMMParser.py 100.00% <0.00%> (ø)
package/MDAnalysis/lib/c_distances_openmp.pyx 100.00% <0.00%> (ø)
MDAnalysisTests/lib/__init__.py 100.00% <0.00%> (ø)
... and 14 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 db0c3d3...bf4bfd7. Read the comment docs.

@jbarnoud
Copy link
Copy Markdown
Contributor

jbarnoud commented Jul 19, 2020

Just throwing #2299 and #2305 here for reference.

@functools.wraps(function)
def wrapped(group, *args, **kwargs):
if kwargs.get('pbc', None) is not None:
warnings.warn("Use 'wrap' kwarg not 'pbc'", DeprecationWarning)
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.

The tone sounds a bit harsh, maybe.

@orbeckst
Copy link
Copy Markdown
Member

If you split the PR into two:

  1. deprecations (against master), to go into 1.0.1
  2. this PR where you don't bother with deprecations

@richardjgowers
Copy link
Copy Markdown
Member Author

@orbeckst the deprecations are in this PR, pbc=True still works but issues a warning. This doesn't need backporting.

@orbeckst
Copy link
Copy Markdown
Member

I thought you wanted to get rid of pbc=True for 2.0. You can if you put the deprecations into 1.0.1.

Otherwise the next time you can get rid of them is 3.0.

Copy link
Copy Markdown
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.

Could you please make this a PR against 1.0 (master) to go into 1.0.1?

Then make a second PR against develop where you remove the deprecated functionality. I'd rather remove stuff for 2.0 than let it sit until 3.0. We have a good opportunity for proper cleanup here, and we're already spending user-goodwill so I'd make it count.

@orbeckst orbeckst self-assigned this Jul 29, 2020
@IAlibay IAlibay mentioned this pull request Jan 24, 2021
@IAlibay
Copy link
Copy Markdown
Member

IAlibay commented Apr 6, 2021

What's the status of this? I'm making a finalised list of the 2.0 milestones. I've included it for now.

@IAlibay IAlibay added this to the 2.0 milestone Apr 6, 2021
@orbeckst
Copy link
Copy Markdown
Member

orbeckst commented Apr 6, 2021

I think my review comment still stands: if anything is removed in 2.0, it needs to be deprecated in 1.x

@IAlibay IAlibay requested a review from mnmelo April 26, 2021 19:59
@orbeckst
Copy link
Copy Markdown
Member

My opinion remains that

  • the pbc kwarg for should be deprecated in 1.1 (and we allow wrap as a synonym as in this PR)
  • we replace pbc with wrap in 2.0

Alternatively, we go ahead with the PR as it stands and allow wrap and pbc as synonyms for 2.x.

Given that @richardjgowers and I seem to be of different opinion how to move forward, it would be useful to have some other devs offer opinions.

@IAlibay
Copy link
Copy Markdown
Member

IAlibay commented Apr 27, 2021

My opinion remains that

  • the pbc kwarg for should be deprecated in 1.1 (and we allow wrap as a synonym as in this PR)
  • we replace pbc with wrap in 2.0

Alternatively, we go ahead with the PR as it stands and allow wrap and pbc as synonyms for 2.x.

Given that @richardjgowers and I seem to be of different opinion how to move forward, it would be useful to have some other devs offer opinions.

Whilst I agree that deprecating in 1.1 would be cleaner. I think at this point we just need to complete #3242 and cut a release. Probably going with synonyms and then deprecating so that we can remove in 3.0 would be our best option.

Copy link
Copy Markdown
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.

I am swayed by @IAlibay, let's deprecate pbc for removal in 3.0.

  • documentation
  • please also fix the benchmarks in benchmarks/benchmarks/ag_methods.py

@orbeckst
Copy link
Copy Markdown
Member

@IAlibay this one was not on 2.0.0 milestone. It does not have to be because we'll deprecate for 3.0 but because unwrapping is something that we might want for the workshop (?), I thought I mention it.

@IAlibay
Copy link
Copy Markdown
Member

IAlibay commented May 11, 2021

@IAlibay this one was not on 2.0.0 milestone. It does not have to be because we'll deprecate for 3.0 but because unwrapping is something that we might want for the workshop (?), I thought I mention it.

Yeah that's why I originally added it to the 2.0 milestone last month. I don't mind either way, we just need to have enough developer time to get it done. How much work is left to deal with here?

@IAlibay
Copy link
Copy Markdown
Member

IAlibay commented Aug 17, 2021

@orbeckst are we good moving this to the 2.1 milestone?

@orbeckst
Copy link
Copy Markdown
Member

sure, move it

@orbeckst orbeckst modified the milestones: 2.0, 2.1.0 Aug 17, 2021
@orbeckst
Copy link
Copy Markdown
Member

Going through the comments, there doesn't seem to be an enormous amount of work to do, except that all the conflicts need to be resolved.

@jbarnoud
Copy link
Copy Markdown
Contributor

jbarnoud commented Feb 4, 2022

@richardjgowers do you want to give the final touches on that PR? If you don't have time, I should be able to take care of it next week.

richardjgowers and others added 3 commits February 10, 2022 18:03
Rename a missed variable and remove calls that use both wrap and unwrap.
This commit does not pass the tests because some of them rely on both
wrap and unwrap in the same call. This will be fixed in a subsequent commit.
@jbarnoud
Copy link
Copy Markdown
Contributor

jbarnoud commented Feb 15, 2022

I rebased the changes and fixed the conflicts. The tests are broken, though, because some tests have been introduced that rely on both unwrap and warp being used on the same call. I need to fix that. Some other tests may need fixing.

TODO:

  • fix broken tests
  • change version in the deprecation notices
  • mention version 3.0 in the deprecation warning

topologyobjects.Bond.length still has a pdb argument. This commit
reflects this.
@richardjgowers
Copy link
Copy Markdown
Member Author

@jbarnoud yes there are some things which have both unwrap and wrap. I think the idea was to first unwrap to calculate e.g. a CoM, then wrap these results back inside. I think this is extremely confusing as it's not clear which of wrap/unwrap is first see #2857 (comment)

@jbarnoud
Copy link
Copy Markdown
Contributor

@richardjgowers Indeed. Removing ambiguity is a good thing. My main issue with the broken tests is that it is not clear if they are meant to test the wrap and the unwrap.

@jbarnoud
Copy link
Copy Markdown
Contributor

jbarnoud commented Mar 3, 2022

@orbeckst Assuming the tests pass, it should be good to go. Since there is a deprecation, it would be good to have it in 2.1.0 that @IAlibay hopes to push soon.

Testing deprecated arguments lead to false positives in pylint. This
commit ignores the specific warning on the problematic lines.
@jbarnoud jbarnoud mentioned this pull request Mar 4, 2022
5 tasks
Copy link
Copy Markdown
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.

I had a quick look and as far as I can tell there are still a few minor documentation issues left.
EDIT: see my earlier comments.
EDIT 2: Some that say "out of date" are still valid, they just had some other changes nearby. I resolved everything that was clearly done. Please look at anything that's not been resolved and then please resolve it yourself — either because you fixed it or because you consider it out of scope or already done. Thanks.

@orbeckst
Copy link
Copy Markdown
Member

orbeckst commented Mar 5, 2022

I am doing the doc updates.

orbeckst added 2 commits March 4, 2022 18:09
- versionchanged for pbc -> wrap everywhere
- fixed format of older versionchanged markup
- added missing docs for moment_of_inertia()
  and replaced kwargs with explicit keyword arguments
- removed superfluous kwargs from shape_parameter()
@orbeckst
Copy link
Copy Markdown
Member

orbeckst commented Mar 5, 2022

I hope the tests pass now. I am approving now because I might not be able to get to it later during the day and in principle at least everything is there. Another pair of 👀 would be good before merging.

@orbeckst orbeckst force-pushed the pbc_to_wrap branch 2 times, most recently from d76d3b7 to 75420b6 Compare March 5, 2022 16:24
Copy link
Copy Markdown
Member Author

@richardjgowers richardjgowers left a comment

Choose a reason for hiding this comment

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

Lgtm!

@jbarnoud jbarnoud merged commit 8835ab7 into develop Mar 6, 2022
@jbarnoud jbarnoud deleted the pbc_to_wrap branch March 6, 2022 14:31
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.

6 participants