-
Notifications
You must be signed in to change notification settings - Fork 658
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
Writes compressed output of given format #2221
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #2221 +/- ##
===========================================
- Coverage 90.71% 89.57% -1.15%
===========================================
Files 15 158 +143
Lines 1982 19686 +17704
Branches 0 2769 +2769
===========================================
+ Hits 1798 17633 +15835
- Misses 184 1458 +1274
- Partials 0 595 +595
Continue to review full report at Codecov.
|
Not sure why codecov is failing |
I guess the test is already written for this in Class
|
Thank you for your contribution! Codecov complains because you added code which is not tested. You need to add a test that calls From what I see, your change would indeed allow to write a gziped file. Though, as you noticed, @richardjgowers, it seems you wrote the lines around mdanalysis/package/MDAnalysis/core/groups.py Line 3086 in 04056e3
get_writer_for deal with it?
|
@jbarnoud, ohh ok, I'll add such a test. from what I understood
|
@Fenil3510 The format discovery logic has to exist, indeed. My point is that it is already implemented in The user should still be able to ask for a specific format by providing the |
Oh, I get it @jbarnoud you are right. |
This is what I had in mind. But, you are breaking the |
@jbarnoud yes that makes sense. Currently when the user has given argument The issue then will be that if neither |
Look at the signature of
It takes an optional format. The guessing is only done if that format is not explicitly provided.
This is good practice because, if the user tells the function to do something, then the function should do what the user asked. What you did in your last commit is to disregard an explicit format that the user may have passed with the In the ideal scenario for
|
Ok, @jbarnoud I understand what you say but my confusion is in |
|
Ok, thanks for the clarification about |
@jbarnoud a doubt, if the user writes |
As a general rule, it is very frustrating for users when a software tries to outsmart them. Indeed, the example you give presents a contradiction, but the request is clear: the user wants to write a GRO file named "filename.pdb.gz"; therefore it is what we should generate. |
I would have thought that you couldn't compress the file frame by frame, but instead you'd need to see the entire file before compressing. It would be useful to see a test that writes a |
Noted @jbarnoud, thanks |
Ok @richardjgowers . I'll write the test as suggested. |
@jbarnoud @richardjgowers I've made a fix. But this is by no means robust. There will be a bit of an issue in the compression part. How would the user indicate that a compressed format is needed? This would be via extraction |
The build is failing as |
I haven't reviewed the code but I note that although the tests pass now, the coverage is still low. Do you still have to write tests? |
@orbeckst, yes haven't added the tests yet. Will do as soon as changes are reviewed. There are some issues that need to be addressed that I've mentioned in the previous comments before tests be written. |
I'm sorry, will follow it. I'm writing tests. |
Tests were written as per this and from what I understood. Are any other tests expected? |
I got a weird failure in PR MDAnalysis#2231 in Travis job https://travis-ci.com/MDAnalysis/mdanalysis/jobs/189553940 : Exception occurred: File "/home/travis/miniconda/envs/test/lib/python3.5/site-packages/sphinx/ext/napoleon/docstring.py", line 703, in _parse_raises_section m = self._name_rgx.match(_type).groupdict() AttributeError: 'NoneType' object has no attribute 'groupdict' and the docs build find locally (under Python 3.6)
The failure of the doc build https://travis-ci.com/MDAnalysis/mdanalysis/jobs/189731062 is not your fault, I just had the same thing in PR #2231 . Maybe my patch there will fix this. If you haven't added your name yet to AUTHORS then do that, too. Also add an entry to CHANGELOG. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding tests. See comments (formatting, tests for capitalized extensions). Also add yoursel to AUTHORS and and entry to CHANGELOG.
@@ -326,7 +326,7 @@ def __init__(self, filename, convert_units=None, n_atoms=None, **kwargs): | |||
w.write(u.atoms) | |||
|
|||
""" | |||
self.filename = util.filename(filename, ext='gro') | |||
self.filename = util.filename(filename, ext='gro', keep = True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8; no space around =
in args.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we also restricting the number of characters per line to 80/79 as per pep8?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the Style Guide: yes, we try to keep within 79 characters. (Not all our code rigorously adheres to it, but that's what we're striving for)
package/MDAnalysis/core/groups.py
Outdated
@@ -3054,8 +3054,7 @@ def write(self, filename=None, file_format="PDB", | |||
if filename is None: | |||
trjname, ext = os.path.splitext(os.path.basename(trj.filename)) | |||
filename = filenamefmt.format(trjname=trjname, frame=trj.frame) | |||
filename = util.filename(filename, ext=file_format.lower(), keep=True) | |||
|
|||
filename = util.filename(filename, ext= file_format or 'PDB', keep=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test that you can omit .lower()
??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like file_format or 'PDB'
. Better be explicit so that only None
really gets defaulted:
file_format if file_format is not None else 'PDB'
@@ -167,7 +167,27 @@ def test_write_frame_none(self, u, tmpdir, extension): | |||
u.atoms.positions[None, ...], new_positions, decimal=2 | |||
) | |||
|
|||
@pytest.mark.parametrize('extension', ('xtc', 'dcd', 'pdb', 'xyz')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se should capitalized extensions, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I don't understand. Should I capitalize all the extensions?. I've used the parameters from the previous test already written.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a test for a capitalized extension 'PDB'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, clearly I should proof-read what I am typing... yes, test for capitalized extensions was what I was looking for.
@jbarnoud can you please also have a quick peek? Thanks. |
fixed 2'-hydroxyl dihedral calculation
…o Fenil3510-develop
I merged the latest develop into your branch, which should fix the doc build failure (via 4f8dc17). |
oops, I killed travis #2233 ... fixing (so that the tests ACTUALLY run) |
* pin the version of sphinx used in Travis doc builds until upstream issues are resolved in version 2.0
…2233 fix travis file (tab -> space)
Would need to commit again for Travis to build? As I see it is fixed now. |
Merged develop to get the travis fix from PR #2234. |
Congratulations @Fenil3510 to your first commit. Thank you for your effort. |
@Fenil3510 I sent you a GitHub invite so that you can be part of @MDAnalysis/contributors. |
Happy to be a part of the team! |
Update of AUTHORS and CHANGELOG with inferred author contributions. * Removed duplicate mattwthompson in 0.20.0 changelog entry.: mattwthompson was placed twice by accident, this removes this duplication. * Addition of missing authors. An retrospective analysis of the authors found via `git shortlog -s -n --email --branches="develop"` found several commits by authors which were not present in the `AUTHORS.md` file. - Zhenbo Li: commited via PR: Started tests for gnm. #803 and Make Travis run tests on OSX. #771, - Jenna M. Swarthout via PR Update CoC according to suggestions from current CoC committee #4289 and Point to new reporting form link (owned by [email protected]) #4298, - Bradley Dice via PR Fix GSD Windows compatibility #2384 , - David Minh via PR #2668 There seemed to be no indications in the above mentioned PRs that the author did not want to be in the authors file, it looks like it was just forgotten. * Addition of missing entries from the changelog Continued cross referencing of the git shortlog output but also accounting for the changelog identified several individuals that had not been included in the changelog entries for the release they contributed under. They were added to the relevant entry of the changelog based on the merge commit date. Please note that for Tone Bengsten, we a) had no github handle (so they were assigned @tbengtsen), and b) no specific commit. Given we know that this individual was including alongside the encore merge, they were assigned to the 0.16.0 release. * Update CHANGELOG * PR #1218 * PR #1284 and #1408 * PR #4109 * based on git history * PRs #803 and #771 (author addition, changelog addition) * PR #2255 and #2221 * PR #1225 * PR #4289 and #4298 * PR #4031 * PR #4085 * PR #3635 * PR #2356 * PR #2559 * No GH handle - Encore author addition @tbengtsen * PR #4184 * PR #2614 * PR #2219 * PR #2384 * PR #2668 * Add missing entry for Jenna Thanks to @fiona-naughton for helping out with digging into this data :) Co-authored-by: Fiona Naughton <[email protected]> Co-authored-by: Oliver Beckstein <[email protected]>
Fixes #2216
Changes made in this Pull Request:
file_format
argument overfilename
inget_writer_for
.ag.write(filename.writer.gz)
PR Checklist