Skip to content

Commit

Permalink
rename id to id_ to avoid conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
shyuep committed Jun 15, 2024
1 parent b040e87 commit 565dd24
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pymatgen/core/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2939,25 +2939,25 @@ def to(self, filename: PathLike = "", fmt: FileFormats = "", **kwargs) -> str:
return str(writer)

@classmethod
def from_id(cls, id: str, source: StructureSources = "Materials Project", **kwargs) -> Structure:
def from_id(cls, id_: str, source: StructureSources = "Materials Project", **kwargs) -> Structure:
"""
Load a structure file based on an id, usually from an online source.
Args:
id: The id. E.g., the materials project id.
id_: The id assicuared with the structure. E.g., the materials project id.
source: Source of the data. Defaults to "Materials Project".
**kwargs: Pass-through to any API calls.
"""
if source == "Materials Project":
from pymatgen.ext.matproj import MPRester

mpr = MPRester(**kwargs)
return mpr.get_structure_by_material_id(id) # type: ignore
return mpr.get_structure_by_material_id(id_) # type: ignore
if source == "COD":
from pymatgen.ext.cod import COD

cod = COD()
return cod.get_structure_by_id(int(id))
return cod.get_structure_by_id(int(id_))
raise ValueError(f"Invalid source: {source}")

@classmethod
Expand Down

0 comments on commit 565dd24

Please sign in to comment.