Skip to content

Commit caca6d8

Browse files
improve docstr for grain boundary and add check on rotation axis
1 parent 766c0eb commit caca6d8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

mp_api/client/routes/materials/grain_boundaries.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def search(
2020
gb_plane: list[str] | None = None,
2121
gb_energy: tuple[float, float] | None = None,
2222
pretty_formula: str | None = None,
23-
rotation_axis: list[str] | None = None,
23+
rotation_axis: tuple[str | float, str | float, str | float] | None = None,
2424
rotation_angle: tuple[float, float] | None = None,
2525
separation_energy: tuple[float, float] | None = None,
2626
sigma: int | None = None,
@@ -40,8 +40,10 @@ def search(
4040
material_ids (List[str]): List of Materials Project IDs to query with.
4141
pretty_formula (str): Formula of the material.
4242
rotation_angle (Tuple[float,float]): Minimum and maximum rotation angle in degrees to consider.
43-
rotation_axis(List[str]): The Miller index of rotation axis. e.g., [1, 0, 0], [1, 1, 0], and [1, 1, 1]
44-
sigma (int): Sigma value of grain boundary.
43+
rotation_axis(List[str]): The Miller index of rotation axis.
44+
A three-tuple of either int or str: e.g.,
45+
[1, 0, 0], [1, 1, 0], ["1", "1", "1"]
46+
sigma (int): Sigma value of grain boundary.
4547
separation_energy (Tuple[float,float]): Minimum and maximum work of separation energy in J/m³ to consider.
4648
sigma (int): Sigma value of the boundary.
4749
type (GBTypeEnum): Grain boundary type.
@@ -84,6 +86,10 @@ def search(
8486
)
8587

8688
if rotation_axis:
89+
if len(rotation_axis) != 3:
90+
raise ValueError(
91+
'`rotation_axis` should be a three-tuple of either int or str, ex: (1,1,0), ("0","0","1")'
92+
)
8793
query_params.update(
8894
{"rotation_axis": ",".join([str(n) for n in rotation_axis])}
8995
)

mp_api/client/routes/materials/phonon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from __future__ import annotations
22

33
import json
4-
import numpy as np
54
from collections import defaultdict
65

6+
import numpy as np
7+
from emmet.core.phonon import PhononBS, PhononBSDOSDoc, PhononDOS
78
from monty.json import MontyDecoder
8-
from emmet.core.phonon import PhononBSDOSDoc, PhononBS, PhononDOS
99

1010
from mp_api.client.core import BaseRester, MPRestError
1111
from mp_api.client.core.utils import validate_ids

0 commit comments

Comments
 (0)