rs-station / reciprocalspaceship

Tools for exploring reciprocal space
https://rs-station.github.io/reciprocalspaceship/
MIT License
28 stars 12 forks source link

Add `rs.utils.polar_axes()` for classifying which cell axes permit continuous origin shifts #177

Closed JBGreisman closed 2 years ago

JBGreisman commented 2 years ago

Based on the routine implemented in is_polar(), it's also possible to return which of the cell axes in a given spacegroup are polar (permit continuous origin shifts). This is implemented here as rs.utils.polar_axes() with the following call signature:

polar_axes(spacegroup) --> List(3) of bools

For example:

import reciprocalspaceship as rs
print(rs.utils.polar_axes("P 1"))         # [True, True, True]
print(rs.utils.polar_axes("P 1 21 1"))    # [False, True, False]
print(rs.utils.polar_axes("P 21 21 21"))  # [False, False, False]

One implementation decision was to only support hexagonal Bravais lattices for the relevant "R 3" trigonal space groups. This decision is made so that it is clear that the function returns polar axes corresponding to the a, b, and c-axes, and not the a', b', c' corresponding to the rhombohedral setting. The supported hexagonal case is the reference setting for these spacegroups, so I think this is a reasonable design choice. To avoid confusion, a ValueError is raised when such space groups are given with a rhombohedral setting.

The code is tested against all applicable spacegroup settings in sgtbx using the is_allowed_origin_shift() method.

codecov-commenter commented 2 years ago

Codecov Report

Merging #177 (00b7943) into main (f634ed1) will increase coverage by 0.00%. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #177   +/-   ##
=======================================
  Coverage   98.31%   98.32%           
=======================================
  Files          44       44           
  Lines        1724     1731    +7     
=======================================
+ Hits         1695     1702    +7     
  Misses         29       29           
Flag Coverage Δ
unittests 98.32% <100.00%> (+<0.01%) :arrow_up:

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/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.