Skip to content

Commit 69bbcf1

Browse files
docstr
1 parent 17136ba commit 69bbcf1

File tree

3 files changed

+35
-14
lines changed

3 files changed

+35
-14
lines changed

mp_api/client/routes/materials/absorption.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,26 @@ def search(
2929
"""Query for optical absorption spectra data.
3030
3131
Arguments:
32-
material_ids (str, List[str]): Search for optical absorption data associated with the specified Material IDs
32+
material_ids (str, List[str]):
33+
Search for optical absorption data associated with the
34+
specified Material ID(s)
35+
num_sites (int, tuple[int, int]):
36+
Search with a single number or a range of number of sites
37+
in the structure.
38+
num_elements (int, tuple[int, int]):
39+
Search with a single number or a range of number of distinct
40+
elements in the structure.
41+
volume (float, tuple[float, float]):
42+
Search with a single number or a range of structural
43+
(lattice) volumes in ų.
44+
If a single number, an uncertainty of ±0.01 is automatically used.
45+
density (float, tuple[float, float]):
46+
Search with a single number or a range of structural
47+
(lattice) densities, in g/cm³.
48+
If a single number, an uncertainty of ±0.01 is automatically used.
49+
band_gap (float, tuple[float, float]):
50+
Search with a single number or a range of band gaps in eV.
51+
If a single number, an uncertainty of ±0.01 is automatically used.
3352
num_chunks (int): Maximum number of chunks of data to yield. None will yield all possible.
3453
chunk_size (int): Number of data entries per chunk.
3554
all_fields (bool): Whether to return all fields in the document. Defaults to True.
@@ -46,11 +65,13 @@ def search(
4665
"band_gap": "bandgap",
4766
}
4867
user_query = locals()
49-
for k in ("num_sites","num_elements","volume","density","band_gap"):
68+
for k in ("num_sites", "num_elements", "volume", "density", "band_gap"):
5069
if (value := user_query.get(k)) is not None:
51-
if k in ("num_sites","num_elements") and isinstance(value, int):
70+
if k in ("num_sites", "num_elements") and isinstance(value, int):
5271
value = (value, value)
53-
elif k in ("volume","density","band_gap") and isinstance(value,int | float):
72+
elif k in ("volume", "density", "band_gap") and isinstance(
73+
value, int | float
74+
):
5475
value = (value - 1e-2, value + 1e-2)
5576

5677
query_params.update(

tests/materials/test_absorption.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
from core_function import client_search_testing
1111

12+
1213
@pytest.mark.skipif(os.getenv("MP_API_KEY") is None, reason="No API key found.")
1314
def test_absorption_search():
14-
1515
client_search_testing(
1616
search_method=AbsorptionRester().search,
1717
excluded_params=[
@@ -29,16 +29,16 @@ def test_absorption_search():
2929
custom_field_tests={
3030
"material_ids": ["mp-149", "mp-239"],
3131
"material_ids": "mp-149",
32-
"num_sites": (6,7),
32+
"num_sites": (6, 7),
3333
"num_sites": 7,
3434
"num_elements": 5,
35-
"num_elements": (4,5),
36-
"volume": (115,116),
35+
"num_elements": (4, 5),
36+
"volume": (115, 116),
3737
"volume": 115.5,
38-
"density": (2.9,3),
38+
"density": (2.9, 3),
3939
"density": 2.933,
40-
"band_gap": (1,1.05),
41-
"band_gap": 1.,
40+
"band_gap": (1, 1.05),
41+
"band_gap": 1.0,
4242
},
4343
sub_doc_fields=[],
44-
)
44+
)

tests/materials/test_doi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
from core_function import client_search_testing
88

9+
910
@pytest.mark.skipif(os.getenv("MP_API_KEY") is None, reason="No API key found.")
1011
def test_doi_search():
11-
1212
client_search_testing(
1313
search_method=DOIRester().search,
1414
excluded_params=[
@@ -25,4 +25,4 @@ def test_doi_search():
2525
"material_ids": "mp-149",
2626
},
2727
sub_doc_fields=[],
28-
)
28+
)

0 commit comments

Comments
 (0)