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

Add is_polar() utility for classifying polar space groups #176

Merged
merged 6 commits into from
Aug 25, 2022
Merged

Conversation

JBGreisman
Copy link
Member

Aligning maps of isomorphous structures can benefit from classifying polar space groups. This is useful for distinguishing which cases have a discrete set of alternative origins vs. continuous alternatives (see #174).

This PR implements a reciprocalspaceship.utils.is_polar() utility function that classifies a space group as polar. This function is tested against the 530 spacegroup settings in sgtbx.

@JBGreisman JBGreisman requested a review from kmdalton August 24, 2022 16:37
Copy link
Member

@kmdalton kmdalton left a comment

Choose a reason for hiding this comment

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

I think this looks very good. I don't see anything objectionable except that I found the test really hard to understand. I think that is on me not understanding pytest that well, but maybe you can spruce up the docstring to help others understand it in the future.



@pytest.fixture(params=sgtbx_polar_classification())
def polar_by_xhm(request):
Copy link
Member

Choose a reason for hiding this comment

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

admittedly, i do not understand fixtures all that well, but i found this file surprisingly difficult to read. i think this might be helped by adding

Parameters
---------------
request : ??????

to the docstring.

Copy link
Member Author

Choose a reason for hiding this comment

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

technically speaking, the request is of type _pytest.fixture.SubRequest. I'll update this docstring to be more descriptive of what is going on rather than explicit about the types of things. The gist of this pair of functions is that sgtbx_polar_classification() yields an iterable. The polar_by_xhm fixture then packages that in a more convenient form such that the test function is provided a tuple of (str, bool) that is parametrized over all entries in the iterable.

This recipe for building pytest fixtures is pretty prevalent in our conftest.py files.

@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2022

Codecov Report

Merging #176 (baaea46) into main (379bd9e) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #176   +/-   ##
=======================================
  Coverage   98.31%   98.31%           
=======================================
  Files          44       44           
  Lines        1718     1724    +6     
=======================================
+ Hits         1689     1695    +6     
  Misses         29       29           
Flag Coverage Δ
unittests 98.31% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
reciprocalspaceship/utils/__init__.py 100.00% <100.00%> (ø)
reciprocalspaceship/utils/asu.py 100.00% <100.00%> (ø)
reciprocalspaceship/utils/phases.py 100.00% <100.00%> (ø)
reciprocalspaceship/utils/symmetry.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@JBGreisman JBGreisman requested a review from kmdalton August 24, 2022 21:43
Copy link
Member

@kmdalton kmdalton left a comment

Choose a reason for hiding this comment

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

I still find this hard to understand, but I am not going to hold you responsible for pytest's API choices.

@JBGreisman JBGreisman merged commit f634ed1 into main Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants