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

BUG: Fixes #1795 sphzone selection regression #1818

Closed
wants to merge 2 commits into from

Conversation

tylerjereddy
Copy link
Member

Fixes #1795

Supersedes attempted fix in #1806 based on feedback from @richardjgowers. The corresponding unit test now only crudely checks for regression of sphzone behavior as it relates to the reported issue, rather than making any claims about the geometric correctness of the selection.

I verified that the script I used for git bisecting the regression is happy with this fix & that the regression test (modified from the original unit test) does fail alongside the bisection script without the application of the fix used in this PR.

We'll see what the CI says. More detailed & correct handling of pbc & wrapping issues are delayed to future efforts, as discussed in the linked issue / PR above.

* sphzone selections adjusted to address
Issue #1795

* corresponding unit test modified to
prevent regression only; proper handling
of pbc and wrapping matters is delayed
for now
@tylerjereddy
Copy link
Member Author

Looks like the new test fails in Python 2.7 but not 3.6; will have to investigate.

@tylerjereddy
Copy link
Member Author

This is related to zip() but actually isn't repaired by using the six.moves.zip. I basically need a way to feed in parametrized arguments from subclassed test objects -- wasn't working when I tried to to do this early -- maybe I'll have another go tonight.

Basically, there are two test classes that inherit from BaseDistanceSelection, and the expected values are different in each case -- is there a straightforward way to feed in different values of the same Python object from the subclassed test scenarios to the parametrization decoration in test_spherical_zone?

This basically means that

 549     @pytest.mark.parametrize('input_val, expected',
 550                              list(zip(methods,
 551                                       sphzone_expected)))
 552     def test_spherical_zone(self, u, input_val, expected):

Should have different values of sphzone_expected (a list of 4 integer values) in different subclassed test cases -- should that be trivial? I feel like it should be, but actually a number of attempts failed!

@richardjgowers
Copy link
Member

@tylerjereddy I don't think that's easily fixed. You could just redefine the test in each subclass

@@ -602,12 +588,38 @@ def test_cyzone(self, u, meth, periodic):

assert ref == set(result.indices)

@pytest.mark.parametrize('input_val, expected',
zip(BaseDistanceSelection.methods,
[25, 31, 33, 25]))
Copy link
Member

Choose a reason for hiding this comment

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

So this means that kdtree and non-kdtree are returning a different result for periodic=True

Copy link
Member Author

Choose a reason for hiding this comment

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

Does that mean more changes are needed or we need to think about this a bit more?

@tylerjereddy
Copy link
Member Author

Ok, I've redefined the pertinent test in each subclass with appropriate expected values. Locally, the tests now pass in Python 2.7 & 3.6 -- we'll see what the CI says.

The code duplication is perhaps a little ugly, but prettier solutions were proving problematic (and time consuming). A fixture or something probably could be used for concision.

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.

I'm looking into this myself, I think this fix is fine, but I want to double check it

@orbeckst
Copy link
Member

@tylerjereddy I think you will have to look at the merge. This might also kick appveyor to actually run the tests.

@tylerjereddy
Copy link
Member Author

@orbeckst Noted / put reminder on my calendar to take a look soon-ish

@tylerjereddy
Copy link
Member Author

tylerjereddy commented Sep 3, 2018

The test file has been refactored pretty substantially, AttributeError: type object 'BaseDistanceSelection' has no attribute 'methods'

I think there have been a lot distance-based operation changes lately -- has the linked issue been confirmed on latest develop branch? I'll have to check that next I guess.

@richardjgowers
Copy link
Member

#1795 is now fixed

@RMeli RMeli deleted the issue_1795_pbc_removal branch December 23, 2023 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

different results of select_atoms in 0.17.0 and 0.16.2
3 participants