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

Adding Appending Functionality method to WriterBase #3863

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

yuxuanzhuang
Copy link
Contributor

Fixes #3861

Changes made in this Pull Request:

  • add new SingleFrameWriterBase
  • add new flag append for appending trajectory to WriterBase
  • add a check for the number of frames written by WriterBase.
  • make sure write is not overwritten by Writers (they only modified _write_next_frame)

TODO:

  • add tests for writers that are not covered by BaseWriterTest

PR Checklist

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

@yuxuanzhuang yuxuanzhuang marked this pull request as draft October 14, 2022 13:44
@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Base: 94.31% // Head: 94.34% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (523a46f) compared to base (35248e8).
Patch coverage: 95.50% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3863      +/-   ##
===========================================
+ Coverage    94.31%   94.34%   +0.03%     
===========================================
  Files          193      193              
  Lines        25024    25068      +44     
  Branches      3374     3376       +2     
===========================================
+ Hits         23601    23651      +50     
+ Misses        1374     1368       -6     
  Partials        49       49              
Impacted Files Coverage Δ
package/MDAnalysis/coordinates/XYZ.py 92.05% <75.00%> (-0.76%) ⬇️
package/MDAnalysis/coordinates/PDB.py 95.62% <78.57%> (+0.48%) ⬆️
package/MDAnalysis/coordinates/CRD.py 93.20% <100.00%> (+1.04%) ⬆️
package/MDAnalysis/coordinates/DCD.py 100.00% <100.00%> (ø)
package/MDAnalysis/coordinates/FHIAIMS.py 95.09% <100.00%> (ø)
package/MDAnalysis/coordinates/GRO.py 96.66% <100.00%> (ø)
package/MDAnalysis/coordinates/H5MD.py 97.60% <100.00%> (-0.01%) ⬇️
package/MDAnalysis/coordinates/MOL2.py 97.67% <100.00%> (ø)
package/MDAnalysis/coordinates/NAMDBIN.py 100.00% <100.00%> (ø)
package/MDAnalysis/coordinates/PDBQT.py 87.75% <100.00%> (+0.12%) ⬆️
... and 12 more

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.

Comment on lines +1602 to +1604
append: bool (optional)
If ``True``, append to an existing file. If ``False``, overwrite
the file. Default is ``False``.
Copy link
Member

Choose a reason for hiding this comment

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

Document that this option only exists for API compatibility and will raise an issue

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.

ChemFiles treatment needs fixing. I think append = append or 'a' in mode might work

Comment on lines 311 to 314
)
self.filename = filename
self.n_atoms = n_atoms
super().__init__(filename, n_atoms, append)
if mode != "a" and mode != "w":
raise IOError("Expected 'a' or 'w' as mode in ChemfilesWriter")
Copy link
Member

Choose a reason for hiding this comment

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

ChemFiles is possibly using 'a' for append mode here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's up for discussion but my idea is to focus this PR on only adding general API to WriterBase and leave specific implementations to other PRs (in a batch for similar Writers) so it doesn't get messy :)

Also after this PR is merged, the current API for mode=a (if anyone is really using it) should not break.

Copy link
Member

Choose a reason for hiding this comment

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

I support @yuxuanzhuang's approach here, keep it simple to make sure we can merge quickly.

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.

Adding Appending Functionality to Writers
3 participants