-
Notifications
You must be signed in to change notification settings - Fork 744
[WIP] DCD Cython Changes #1155
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
[WIP] DCD Cython Changes #1155
Conversation
|
| class DCDWriteHeaderTest(TestCase): | ||
|
|
||
| def setUp(self): | ||
| self.dcdfile = DCDFile(DCD) |
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.
Maybe open a new file here instead of writing to the test file.
kain88-de
left a comment
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.
Looks good as a first draft. We need some error checks though to not accidentally overwrite files.
|
|
||
| @run_in_tempdir() | ||
| def test_write_header(self): | ||
| self.dcdfile._write_header() |
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.
This should raise an error since the dcd isn't opened in write mode
| self.current_frame = frame | ||
|
|
||
| def _write_header(self): | ||
| if not self.is_open: |
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.
This should also check that the dcd is opened in write mode.
|
@tylerjereddy thanks for working on this. I'm currently more focused on getting 0.16.0 out and preparing things for GSoC |
|
Yeah, the idea is that I'm probably going to do most stuff incorrectly on the first try here, but I can at least catalyze the process / discussion/ get feedback & edge us closer to use of MDA with python 3. |
|
| assert_equal(self.dcdfile.n_atoms, 3341) | ||
|
|
||
| @raises(IOError) | ||
| @raises(RuntimeError) |
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 think in the xdr wrapper I changed everything to raise an IO error. I think that would be a good idea here to.
| from . import memory | ||
| from . import MMTF | ||
| from . import null | ||
|
|
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.
If you add these imports back in, more tests should start passing (or failing with better messages)
a1b78e1 to
077527d
Compare
Will be good to have things in a state where python 2 & 3 produce matching results for |
Are there tests for |
Yes it does still use the old dcd module for the DCDReader. This is because the new reader is currently a stand alone module. This style has advantages for the development. Rebasing against develop is easy since there can be almost no merge-conflicts. When I test the new libdcd functions it's easy to compare against the current DCDReader using the same python2 session. I've done that because developing libdcd is taking much longer then actually hooking it up to the reader in mdanalysis later, that should then be simple.
I'm surprised by that. You shouldn't have had any merge conflicts since this branch contains almost exclusively new files.
Yes that should be the first goal before we replace _dcdmodule in this branch. |
@jbarnoud Are you saying you previously fixed the way that the Bisecting in python 3.5 is proving harder than I thought... other confounding issues keep cropping up with the setup / build process. |
|
MDAnalysisTests.util could not import on python 3, not because of mock but because of __builtin__. I fixed that without breaking the tests. But now I realize that there is no test for block_import so I am not sure I fixed it on python 3. If I actually fixed it, it is in 2f57649. Le 16 janv. 2017 4:26 AM, Tyler Reddy <notifications@github.com> a écrit :
Are there tests for block_import? I thought I fixed its python 3 compatibility because I did not break anything by touching it.
@jbarnoud Are you saying you previously fixed the way that the mock module was imported for block_import to work with both python 2 & 3?
Bisecting in python 3.5 is proving harder than I thought... other confounding issues keep cropping up with the setup / build process.
—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.
|
|
There's no tests for block_import, maybe we should have a few tests for our test fixtures? Anyway, I ran the following in a python 3 environment and it worked (in that it blocked the import) so I think block_import has been fixed for py3 from MDAnalysisTests import block_import
@block_import('numpy')
def try_this():
import numpy as np
return np.zeros(3)WRT mock, we're still installing this even in the py3 install, which isn't a real problem as I think it's identical, but it does mean that we can do either @tylerjereddy I didn't realise that the DCDFile wasn't coupled to the DCDReader yet, so you can not import it if it makes things easier. |
|
I activated the _dcdmodule build again. This should help with travis |
|
With respect to the |
|
Also, there's no regression -- the git log shows that I noted a single test failure in October of last year, so that is just being carried over rather than being introduced by some other change. So, just need to fix it rather than bisect / hunt. |
|
Also, likely thanks to the changes from @kain88-de, I'm now seeing the exact same unit test results for |
|
How confident are we that 596 printf("Starting to print unit cell in C\n");
597 int i;
598 for (i=0;i < (sizeof (unitcell));i++) {
599 printf("unitcell element from C code: %lf\n",unitcell[i]);
600 }
601 printf("Finished printing unit cell in C\n");
602 return DCD_SUCCESS;
603 } I get: (two extra elements -- so I'm probably over-iterating in C for whatever reason?) And the Cython-captured result looks like this: There appears to be some stochastic component to the result having values that hover around 0 / floating point stuff going on? But overall, it looks like the values are basically just zeroes and that never changes. The unit test expected result from |
|
Look into the old python code. There was some unit-cell handling in there as well. I wanted to keep it at the python level since unit-cell handling seems to be different for some dcd formats. |
|
DCD unit cells are different in NAMD DCD vs newer CHARMM DCD. I patched the CHARMM DCD unit cell recognition into the Python code but ideally that gets handled at the C/Cython level. See #187 . |
|
|
| alpha = unitcell[4]; | ||
| beta = unitcell[3]; | ||
| gamma = unitcell[1]; | ||
| } |
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.
my original idea was that we leave out these things out of this library. If we have this in here it will make it difficult to write DCD files for CHARM or NAMD 2.5 separately. This is because that code standardizes the unitcell we receive from a DCD file so in writing the same standard should be accepted. Then when writing a DCD we need to add a flag what unit-cell format should be written (complicating this code) and adopting to changes in the unitcell handling will mean we have to change this file and add more options. This goes against my original goal of having this wrapper as simple as possible and dealing with program specific DCD file logic in the python mda layer.
But I'm not to familiar with the DCD file landscape or CHARM/NAMD if NAMD=2.5 isn't used anymore and other programs using DCD use the same standard for unitcell's I'm OK leaving this in the cython layer. We then have to document that NAMD 2.5 is supported for only for reading.
If we decide to leave this in libdcd I would prefer the code to be in the pyx file.
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.
We could simply read out the 6 numbers and then have the reader figure it out in the beginning and then use one conversion function in the layer that converts to/from dimensions. This would make the C/pyx code fairly clean: we really just read what's there.
I don't know how to autodetect without actually reading the first frame, though.
I also don't know if there's a significant speed penalty for moving the asin() etc out of the C layer into Python – probably not, compared to reading the rest, but one potential consideration.
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.
This code shouldn't be here and it doesn't have any affect either. read_dcdsubstep doesn't update the unitcell array at all. Only read_dcdstep does.
See libmdaxdr the required arguments should be added to the write function |
|
@tylerjereddy box dimension handling still seems to be broken. From our original DCD tests the dimension checks are failing. |
Unitcells are not handled uniformly. We take a [A, B, C, alpha, beta, gamma] and return the same as well.
4f8d216 to
0a655ac
Compare
|
@tylerjereddy I finally fixed all unit cell handling. It is now consistent between read and write. I also removed all special handling from the C files. Now it's just hooking the new libdcd up to our readers / writers and some clean up. |
|
OK I did the hookup of the reader and writer. Our normal unit tests pass. |
|
@kain88-de Ok, thanks. Presumably the old / new tests can be combined in a sensible way if you've not done that already. I might try to get the one property-based test I added to pass as well, since that presumably doesn't pass yet (it will have to check for a truncated return string, etc.). We'll have to see how long that takes, but my experience is that these are very fast too. |
I first only checked our old tests. The new style tests of trajectory readers I did in the morning.
Before you start. Please write down the encoding and symbols that we should support in the Remarks. Right now you restricted the code to printable ascii. As I see in hypothesis it will try though to generate a large portion of the unicode including non printable control characters. Personally I would stick with ASCII seeing how old DCD files are. I'm not super set on control characters. I think some of our own files actually have them and we currently just ignore them but that needs to be checked. |
|
@kain88-de Currently, when I try to build off your latest commit I get: Presumably |
|
Ok, patched |
… ASCII REMARKS section strings.
|
|
I'll aim to rebase against develop in a few hours unless someone has an objection to that--I think it makes sense to have the CI running automatically again now that we're getting closer? |
|
@tylerjereddy yep. I can find some time this weekend to give this a review with some fresh eyes. |
|
@richardjgowers I'm not quite done finalizing the API of libdcd. I essentially would like to move all unitcell post processing into MDAnalysis and have libdcd read the vanilla data. Also writing the header will be made explicit. |
|
@tylerjereddy can you upload your rebase? |
|
@kain88-de I'm actually having some strange issues with the rebase command: This happens on two computers where I've already set my git config for user name and email. I suspect this relates to me working on a few new / different machines after my relocation, with various credential settings. Maybe another core dev can see if they reproduce this issue when rebasing against the latest develop on their machine? |
|
@tylerjereddy yeah your wrong identity setting is a problem for the rebase. But there is another problem as well. A month ago or so you merged develop into this branch. This makes rebasing hard. I can try to remove it but that has to wait until later today. |
|
rebase done in #1372 I'll leave this branch here in case I made a mistake. I don't think so though. |
Related to #929 -- I'm working in a separate branch descending from the original but rebased against develop. We can deal with merging stuff etc. later.
The changes introduced so far finally allow the DCD unit tests to run again on my machine, although there is a new failure for one of them for some reason. Trying to figure this out & slowly chip away at writing DCDs. Focusing on py2 at the moment.