-
Notifications
You must be signed in to change notification settings - Fork 663
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
distopia 0.3.0 compatibility changes #4734
base: develop
Are you sure you want to change the base?
Conversation
Hello @hmacdope! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2025-01-06 18:00:18 UTC |
Linter Bot Results:Hi @hmacdope! Thanks for making this PR. We linted your code and found the following: Some issues were found with the formatting of your code.
Please have a look at the Please note: The |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4734 +/- ##
===========================================
- Coverage 93.66% 93.62% -0.04%
===========================================
Files 177 189 +12
Lines 21796 22918 +1122
Branches 3067 3079 +12
===========================================
+ Hits 20415 21457 +1042
- Misses 929 1007 +78
- Partials 452 454 +2 ☔ View full report in Codecov by Sentry. |
@orbeckst @richardjgowers this is ready for a first look over. The failing tests are for a 180 degree dihedral where numpy returns np.pi and distopia returns -np.pi (equivalent in polar coordinates). Are we ok to change the test to account for this? There are also options for changing in distopia but at the cost of a lot of performance improvement. |
I'd be ok with changing tests but adding a note to docs. |
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 am not sure if the tests are actually run — if we can confirm that they run then I have no blockers.
ALso updated CHANGELOG, please.
FYI, upstream distopia 0.3.0 release is currently breaking all tests, see #4739 . |
Co-authored-by: Oliver Beckstein <[email protected]>
@@ -946,6 +939,19 @@ def test_bonds(self, box, backend, dtype, pos, request): | |||
assert_almost_equal(dists_pbc[3], 3.46410072, self.prec, | |||
err_msg="PBC check #w with box") | |||
|
|||
@pytest.mark.parametrize("dtype", (np.float32, np.float64)) | |||
@pytest.mark.parametrize("backend", distopia_conditional_backend()) | |||
def test_results_inplace_all_backends(self, backend, dtype,): |
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.
Problematic test here.
# distopia requires that all the input arrays are the same type, | ||
# while MDAnalysis allows for mixed types, this should be changed | ||
# pre 0.3.0 release see issue #3707 | ||
distances = distances.astype(np.float32) |
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 may create a copy.
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.
With the astype
required for distopia you may be creating a copy so that the top-level in-place operation is not actually in-place anymore. ... I think.
if backend == 'distopia': | ||
# mda expects the result to be in float64, so we need to convert it back | ||
# to float64, change for 3.0, see #3707 | ||
distances = distances.astype(np.float64) |
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 may create a copy.
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.
You may have to instead put the numbers back into the original array to make in-place work.
result[:] = distances
...
return result
or something of that kind.
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 used this strategy
@hmacdope did you look further into the copy vs in-place issue? |
@orbeckst I'll try get back to this over holidays, sorry for delay. |
Ok! I think getting this one working will be important for a MDA paper. |
@hmacdope I resolved the merge conflicts but please double-check that I didn't miss anything. |
…s into distopia_0.3.0_compat
@orbeckst this is probably ready for another look. |
def test_selfdist(self, S_mol, box, tri_vec_box, backend): | ||
S_mol1, S_mol2 = S_mol | ||
R_coords = distances.transform_StoR(S_mol1, box, backend=backend) | ||
R_coords = distances.transform_StoR(S_mol1, box, backend="serial") |
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.
Why hard-code serial here instead of using backend
?
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.
Should the comment below apply to the R_coords
line?
Maybe add a short 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.
Quick first look (sorry for brevity), see minor comments and below:
- Could you please also make PEP8 happy?
- Coverage?
def test_selfdist(self, S_mol, box, tri_vec_box, backend): | ||
S_mol1, S_mol2 = S_mol | ||
R_coords = distances.transform_StoR(S_mol1, box, backend=backend) | ||
R_coords = distances.transform_StoR(S_mol1, box, backend="serial") |
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.
Should the comment below apply to the R_coords
line?
Maybe add a short comment.
@@ -948,7 +961,7 @@ def test_selfdist(self, S_mol, box, tri_vec_box, backend): | |||
) | |||
|
|||
# Do it again for input 2 (has wider separation in points) | |||
R_coords = distances.transform_StoR(S_mol2, box, backend=backend) | |||
R_coords = distances.transform_StoR(S_mol2, box, backend="serial") |
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.
Same questions as above – explain why backend="serial"
Test implementation of distopia-0.3.0 distances API.
Changes made in this Pull Request:
PR Checklist
Developers certificate of origin
📚 Documentation preview 📚: https://mdanalysis--4734.org.readthedocs.build/en/4734/