Skip to content

Commit

Permalink
Blackened
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed Nov 29, 2021
1 parent 283fa48 commit 642431e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
33 changes: 15 additions & 18 deletions pymatgen/ext/optimade.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class OptimadeRester:
This class is ready to use but considered in-development and subject to change.
[1] Andersen, C.W., *et al*.
OPTIMADE, an API for exchanging materials data.
[1] Andersen, C.W., *et al*.
OPTIMADE, an API for exchanging materials data.
Sci Data 8, 217 (2021). https://doi.org/10.1038/s41597-021-00974-z
"""
Expand Down Expand Up @@ -160,11 +160,11 @@ def _get_json(self, url):

@staticmethod
def _build_filter(
elements: Union[str, List[str]] = None,
nelements: int = None,
nsites: int = None,
elements: Union[str, List[str]] = None,
nelements: int = None,
nsites: int = None,
chemical_formula_anonymous: str = None,
chemical_formula_hill: str = None,
chemical_formula_hill: str = None,
):
"""
Convenience method to build an OPTIMADE filter.
Expand Down Expand Up @@ -271,9 +271,7 @@ def get_snls(
chemical_formula_hill=chemical_formula_hill,
)

return self.get_snls_with_filter(
optimade_filter, additional_response_fields=additional_response_fields
)
return self.get_snls_with_filter(optimade_filter, additional_response_fields=additional_response_fields)

def get_structures_with_filter(self, optimade_filter: str) -> Dict[str, Dict[str, Structure]]:
"""
Expand All @@ -294,8 +292,8 @@ def get_structures_with_filter(self, optimade_filter: str) -> Dict[str, Dict[str
return all_structures

def get_snls_with_filter(
self,
optimade_filter: str,
self,
optimade_filter: str,
additional_response_fields: Union[str, List[str], Set[str]] = None,
) -> Dict[str, Dict[str, StructureNL]]:
"""
Expand Down Expand Up @@ -383,9 +381,9 @@ def _get_comp(sp_dict):
)
# Grab any custom fields or non-mandatory fields if they were requested
namespaced_data = {
k: v for k, v in data["attributes"].items()
if k.startswith("_")
or k not in {"lattice_vectors", "species", "cartesian_site_positions"}
k: v
for k, v in data["attributes"].items()
if k.startswith("_") or k not in {"lattice_vectors", "species", "cartesian_site_positions"}
}

# TODO: follow `references` to add reference information here
Expand All @@ -411,9 +409,9 @@ def _get_comp(sp_dict):
)
# Grab any custom fields or non-mandatory fields if they were requested
namespaced_data = {
k: v for k, v in data["attributes"].items()
if k.startswith("_")
or k not in {"lattice_vectors", "species", "cartesian_site_positions"}
k: v
for k, v in data["attributes"].items()
if k.startswith("_") or k not in {"lattice_vectors", "species", "cartesian_site_positions"}
}

# TODO: follow `references` to add reference information here
Expand Down Expand Up @@ -543,7 +541,6 @@ def _handle_response_fields(self, additional_response_fields: Union[str, List[st
if not additional_response_fields:
additional_response_fields = set()
return ",".join(set(additional_response_fields).union(self.mandatory_response_fields))


def refresh_aliases(self, providers_url="https://providers.optimade.org/providers.json"):
"""
Expand Down
1 change: 0 additions & 1 deletion pymatgen/ext/tests/test_optimade.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def test_get_snls_mp(self):
assert "nsites" in sp.data["_optimade"]
assert "nelements" in sp.data["_optimade"]


# Tests fail in CI for unknown reason, use for development only.
# def test_get_structures_mcloud_2dstructures(self):
#
Expand Down

0 comments on commit 642431e

Please sign in to comment.