Skip to content

Commit

Permalink
Add example to reverse-lookup ITA number for HM symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
lan496 committed Feb 26, 2025
1 parent f1eace0 commit f379100
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/ci-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ jobs:
set -e
uv pip install --system --no-index --find-links dist moyopy
uv pip install --system moyopy[interface]
python moyopy/examples/basic.py
python moyopy/examples/space_group_type.py
python moyopy/examples/pymatgen_structure.py
find moyopy/examples -name "*.py" | xargs -I {} python {}
linux:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ A fast and robust crystal symmetry finder, written in Rust.
<figcaption><a href="bench/mp/analysis.ipynb">Several times faster symmetry detection than Spglib for Materials Project dataset</a></figcaption>
</figure>

- Rust support available via [crates.io](https://crates.io/crates/moyo)
- Python support available via [PyPI](https://pypi.org/project/moyopy/)
- Rust support available via [crates.io](https://crates.io/crates/moyo): [Docs](https://docs.rs/moyo/latest/moyo/)
- Python support available via [PyPI](https://pypi.org/project/moyopy/): [Docs](https://spglib.github.io/moyo/python/)

## Interfaces

Expand Down
5 changes: 5 additions & 0 deletions moyopy/docs/examples/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ You can access the space-group classification information using {py:class}`moyop

```{literalinclude} ../../examples/space_group_type.py
```

You can reverse-lookup an ITA space group number from a Hermann-Mauguin symbol by looping over {py:class}`moyopy.SpaceGroupType`.

```{literalinclude} ../../examples/hm_to_number.py
```
12 changes: 12 additions & 0 deletions moyopy/examples/hm_to_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ruff: noqa: E501
from moyopy import SpaceGroupType

map_hm_short_to_number = {
# SpaceGroupType(number).hm_short is separated by a space like "F m -3 m"
SpaceGroupType(number).hm_short.replace(" ", ""): number
for number in range(1, 230 + 1)
}

print(map_hm_short_to_number.get("Fm-3m")) # -> 225
print(map_hm_short_to_number.get("P6_3/m")) # -> 176
print(map_hm_short_to_number.get("Fmmm")) # -> 69

0 comments on commit f379100

Please sign in to comment.