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

Remove ts from writers #2754

Merged
merged 13 commits into from
Jun 15, 2020
Merged

Conversation

IAlibay
Copy link
Member

@IAlibay IAlibay commented Jun 14, 2020

Towards #2739

Changes made in this Pull Request:

  • Removed deprecated use of timestep from writers.
  • Removed Writer.write_next_timestep
  • Removes support for passing atoms to XYZWriter (code paths here no longer worked since we removed support for Timestep).
  • Partial py2 removals for coordinates (rest to follow in a separate PR).
  • Mostly aligned error checking for using Timestep on writers.

To do:

  • Fix broken tests (chainreader, netcdf, lammps, trz, xdr, xyz currently failing).
  • Add checks for raising TypeError on calling with timestep?

PR Checklist

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

@@ -57,4 +57,9 @@ def __init__(self, filename, **kwargs):
pass

def _write_next_frame(self, obj):
try:
Copy link
Member Author

Choose a reason for hiding this comment

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

I went ahead and added this check to the null writer. My understanding is that the null writer should behave like all other writers, so it should complain if we pass it a Timestep. Thoughts anyone?

@richardjgowers
Copy link
Member

richardjgowers commented Jun 14, 2020 via email

@IAlibay IAlibay marked this pull request as ready for review June 14, 2020 15:23
@codecov
Copy link

codecov bot commented Jun 14, 2020

Codecov Report

Merging #2754 into develop will increase coverage by 0.01%.
The diff coverage is 93.27%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2754      +/-   ##
===========================================
+ Coverage    91.17%   91.19%   +0.01%     
===========================================
  Files          176      176              
  Lines        23798    23767      -31     
  Branches      3134     3118      -16     
===========================================
- Hits         21699    21674      -25     
+ Misses        1476     1473       -3     
+ Partials       623      620       -3     
Impacted Files Coverage Δ
package/MDAnalysis/coordinates/CRD.py 79.20% <71.42%> (-0.60%) ⬇️
package/MDAnalysis/coordinates/TRZ.py 83.58% <78.57%> (+1.46%) ⬆️
package/MDAnalysis/coordinates/base.py 93.67% <85.71%> (+0.10%) ⬆️
package/MDAnalysis/coordinates/GRO.py 93.95% <92.30%> (-1.50%) ⬇️
package/MDAnalysis/coordinates/DCD.py 97.20% <100.00%> (-0.06%) ⬇️
package/MDAnalysis/coordinates/FHIAIMS.py 93.75% <100.00%> (-1.94%) ⬇️
package/MDAnalysis/coordinates/MOL2.py 94.48% <100.00%> (+0.17%) ⬆️
package/MDAnalysis/coordinates/NAMDBIN.py 100.00% <100.00%> (ø)
package/MDAnalysis/coordinates/PDBQT.py 84.53% <100.00%> (+0.66%) ⬆️
package/MDAnalysis/coordinates/PQR.py 91.95% <100.00%> (+0.18%) ⬆️
... and 12 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 085ac0f...b1f5dc9. Read the comment docs.

Copy link
Member

@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.

A few comments but looking good

@@ -357,31 +353,24 @@ def write(self, obj):
*resName* and *atomName* are truncated to a maximum of 5 characters
.. versionchanged:: 0.16.0
`frame` kwarg has been removed
.. deprecated:: 1.0.0
Copy link
Member

Choose a reason for hiding this comment

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

I think we’re meant to keep the old tag and just keep appending new stuff

Copy link
Member Author

Choose a reason for hiding this comment

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

This came up before in: #2494 (comment) and I think the idea at the time was to remove deprecation notices since they get replaced by the versionchanged.

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 glad that you have a good memory @IAlibay !

I added a section under Writing Documentation: Documenting changes to capture what I believe is our current consensus. It's up for discussion, of course.

@lilyminium I know that the User Guide copied most of the wiki style guide so I created PR MDAnalysis/UserGuide#76 with these changes.

ts = ag
else:
try:
ts = ag.ts
Copy link
Member

Choose a reason for hiding this comment

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

Constructing an AtomGroup timestep ain’t free, so maybe use ag.positions to grab the positions etc

Copy link
Member Author

Choose a reason for hiding this comment

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

So from a quick look, I think DCD, TRJ, TRR, TRZ, XTC, XYZ, and chemfiles all do something similar. In the interest of not making this PR too hard to follow, would you be ok if I opened an issue for this and dealt with it in a separate PR?

@@ -307,7 +307,12 @@ def encode_block(self, obj):
obj : AtomGroup or Universe
"""
# Issue 2717
obj = obj.atoms
try:
obj = obj.atoms
Copy link
Member

Choose a reason for hiding this comment

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

I’d hope stuff is type checked by this point

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately this is the failure point if you pass a Timestep object to the MOL2Writer. I could move it up to _write_next_frame if you think it's more appropriate?

"""
# TODO 2.0: Remove Timestep logic
if isinstance(obj, base.Timestep):
Copy link
Member

Choose a reason for hiding this comment

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

Same here, put a type check in base.Write

@orbeckst orbeckst added the remove-2.0 deprecated in 1.0 and to be removed in 2.0 label Jun 15, 2020
@fiona-naughton fiona-naughton added Component-Writers deprecation Deprecated functionality to give advance warning for API changes. labels Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component-Writers deprecation Deprecated functionality to give advance warning for API changes. maintainability remove-2.0 deprecated in 1.0 and to be removed in 2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants