Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow strings for has_props #930

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions mp_api/client/routes/materials/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from emmet.core.symmetry import CrystalSystem
from pymatgen.analysis.magnetism import Ordering

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


Expand Down Expand Up @@ -36,7 +36,7 @@ def search(
g_reuss: tuple[float, float] | None = None,
g_voigt: tuple[float, float] | None = None,
g_vrh: tuple[float, float] | None = None,
has_props: list[HasProps] | None = None,
has_props: list[HasProps] | list[str] | None = None,
has_reconstructed: bool | None = None,
is_gap_direct: bool | None = None,
is_metal: bool | None = None,
Expand Down Expand Up @@ -101,7 +101,7 @@ def search(
of the shear modulus.
g_vrh (Tuple[float,float]): Minimum and maximum value in GPa to consider for the Voigt-Reuss-Hill
average of the shear modulus.
has_props: (List[HasProps]): The calculated properties available for the material.
has_props: (List[HasProps], List[str]): The calculated properties available for the material.
has_reconstructed (bool): Whether the entry has any reconstructed surfaces.
is_gap_direct (bool): Whether the material has a direct band gap.
is_metal (bool): Whether the material is considered a metal.
Expand Down Expand Up @@ -253,7 +253,14 @@ def search(
query_params.update({"has_reconstructed": has_reconstructed})

if has_props:
query_params.update({"has_props": ",".join([i.value for i in has_props])})
has_props_clean = []
for prop in has_props:
try:
has_props_clean.append(HasProps(prop).value)
except ValueError:
raise MPRestError(f"'{prop}' is not a valid property.")

query_params.update({"has_props": ",".join(has_props_clean)})

if theoretical is not None:
query_params.update({"theoretical": theoretical})
Expand Down
Loading