Skip to content

Commit

Permalink
Merge pull request #53 from spglib/refactor-stub
Browse files Browse the repository at this point in the history
Separate stub files
  • Loading branch information
lan496 authored Jan 23, 2025
2 parents 7e09d05 + a5481e3 commit 00e72cc
Show file tree
Hide file tree
Showing 11 changed files with 339 additions and 298 deletions.
22 changes: 22 additions & 0 deletions .github/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
changelog:
categories:
- title: 🛠 Breaking Changes
labels:
- Semver-Major
- breaking-changes
- title: 🎉 New Features
labels:
- Semver-Minor
- enhancement
- title: ⚠️ Deprecation
labels:
- deprecation
- title: 🐞 Bug fixes
labels:
- bug
- title: 📔 Documentation
labels:
- documentation
- title: Other changes
labels:
- '*'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ lcov.info
!**/assets/*.json
.env
*.png
*.cif

docs/note/

Expand Down
25 changes: 25 additions & 0 deletions moyopy/python/moyopy/_base.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
class Cell:
def __init__(
self,
basis: list[list[float]],
positions: list[list[float]],
numbers: list[int],
): ...
@property
def basis(self) -> list[list[float]]: ...
@property
def positions(self) -> list[list[float]]: ...
@property
def numbers(self) -> list[int]: ...
def serialize_json(self) -> str: ...
@classmethod
def deserialize_json(cls, json_str: str) -> Cell: ...

class Operations:
@property
def rotations(self) -> list[list[list[float]]]: ...
@property
def translations(self) -> list[list[float]]: ...
@property
def num_operations(self) -> int: ...
def __len__(self) -> int: ...
46 changes: 46 additions & 0 deletions moyopy/python/moyopy/_data.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from moyopy._base import Operations

class Setting:
"""Preference for the setting of the space group."""
@classmethod
def spglib(cls) -> Setting:
"""The setting of the smallest Hall number."""
@classmethod
def standard(cls) -> Setting:
"""Unique axis b, cell choice 1 for monoclinic, hexagonal axes for rhombohedral,
and origin choice 2 for centrosymmetric space groups."""
@classmethod
def hall_number(cls, hall_number: int) -> Setting:
"""Specific Hall number from 1 to 530."""

class Centering: ...

class HallSymbolEntry:
"""An entry containing space-group information for a specified hall_number."""
def __init__(self, hall_number: int): ...
@property
def hall_number(self) -> int:
"""Number for Hall symbols (1 - 530)."""
@property
def number(self) -> int:
"""ITA number for space group types (1 - 230)."""
@property
def arithmetic_number(self) -> int:
"""Number for arithmetic crystal classes (1 - 73)."""
@property
def setting(self) -> Setting:
"""Setting."""
@property
def hall_symbol(self) -> str:
"""Hall symbol."""
@property
def hm_short(self) -> str:
"""Hermann-Mauguin symbol in short notation."""
@property
def hm_full(self) -> str:
"""Hermann-Mauguin symbol in full notation."""
@property
def centering(self) -> Centering:
"""Centering."""

def operations_from_number(number: int, setting: Setting) -> Operations: ...
100 changes: 16 additions & 84 deletions moyopy/python/moyopy/_moyopy.pyi
Original file line number Diff line number Diff line change
@@ -1,90 +1,8 @@
from __future__ import annotations
from moyopy._base import Cell, Operations # noqa: F401
from moyopy._data import Centering, HallSymbolEntry, Setting, operations_from_number # noqa: F401

__version__: str

###############################################################################
# base
###############################################################################

class Cell:
def __init__(
self,
basis: list[list[float]],
positions: list[list[float]],
numbers: list[int],
): ...
@property
def basis(self) -> list[list[float]]: ...
@property
def positions(self) -> list[list[float]]: ...
@property
def numbers(self) -> list[int]: ...
def serialize_json(self) -> str: ...
@classmethod
def deserialize_json(cls, json_str: str) -> Cell: ...

class Operations:
@property
def rotations(self) -> list[list[list[float]]]: ...
@property
def translations(self) -> list[list[float]]: ...
@property
def num_operations(self) -> int: ...
def __len__(self) -> int: ...

###############################################################################
# data
###############################################################################

class Setting:
"""Preference for the setting of the space group."""
@classmethod
def spglib(cls) -> Setting:
"""The setting of the smallest Hall number."""
@classmethod
def standard(cls) -> Setting:
"""Unique axis b, cell choice 1 for monoclinic, hexagonal axes for rhombohedral,
and origin choice 2 for centrosymmetric space groups."""
@classmethod
def hall_number(cls, hall_number: int) -> Setting:
"""Specific Hall number from 1 to 530."""

def operations_from_number(number: int, setting: Setting) -> Operations: ...

class Centering: ...

class HallSymbolEntry:
"""An entry containing space-group information for a specified hall_number."""
def __init__(self, hall_number: int): ...
@property
def hall_number(self) -> int:
"""Number for Hall symbols (1 - 530)."""
@property
def number(self) -> int:
"""ITA number for space group types (1 - 230)."""
@property
def arithmetic_number(self) -> int:
"""Number for arithmetic crystal classes (1 - 73)."""
@property
def setting(self) -> Setting:
"""Setting."""
@property
def hall_symbol(self) -> str:
"""Hall symbol."""
@property
def hm_short(self) -> str:
"""Hermann-Mauguin symbol in short notation."""
@property
def hm_full(self) -> str:
"""Hermann-Mauguin symbol in full notation."""
@property
def centering(self) -> Centering:
"""Centering."""

###############################################################################
# lib
###############################################################################

class MoyoDataset:
"""A dataset containing symmetry information of the input crystal structure."""
def __init__(
Expand Down Expand Up @@ -173,3 +91,17 @@ class MoyoDataset:
@property
def angle_tolerance(self) -> float | None:
"""Actually used `angle_tolerance` in iterative symmetry search."""

__all__ = [
# base
"Cell",
"Operations",
# data
"Setting",
"Centering",
"HallSymbolEntry",
"operations_from_number",
# lib
"__version__",
"MoyoDataset",
]
Loading

0 comments on commit 00e72cc

Please sign in to comment.