Skip to content

Commit

Permalink
Merge pull request #24 from Quantum-Accelerators/Andrew-S-Rosen-patch-2
Browse files Browse the repository at this point in the history
Fix for ASE 3.23.0
  • Loading branch information
Andrew-S-Rosen authored Jun 26, 2024
2 parents 8960c3f + 145350d commit 03250cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
15 changes: 7 additions & 8 deletions src/raspa_ase/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,26 @@ class RaspaProfile(BaseProfile):
RASPA profile, which defines the command that will be executed and where.
"""

def __init__(self, binary: Path | str | None = None, **kwargs) -> None:
def __init__(self, command: Path | str | None = None, **kwargs) -> None:
"""
Initialize the RASPA profile. $RASPA_DIR must be set in the environment.
Parameters
----------
binary
The binary to run RASPA. This defaults to doing `${RASPA_DIR}/bin/simulate`
command
The command to run RASPA. This defaults to doing `${RASPA_DIR}/bin/simulate`
and typically does not need to be changed.
Returns
-------
None
"""
super().__init__(**kwargs)
if not binary:
if not command:
raspa_dir = os.environ.get("RASPA_DIR")
if not raspa_dir:
raise OSError("RASPA_DIR environment variable not set")
binary = f"{raspa_dir}/bin/simulate"
self.binary = binary
command = f"{raspa_dir}/bin/simulate"
super().__init__(command, **kwargs)

def get_calculator_command(self, inputfile: str = SIMULATION_INPUT) -> list[str]:
"""
Expand All @@ -68,7 +67,7 @@ def get_calculator_command(self, inputfile: str = SIMULATION_INPUT) -> list[str]
list[str]
The command to run the calculator.
"""
return [self.binary, f"{inputfile}"]
return [self.command, f"{inputfile}"]

def version(self) -> str:
"""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_profile_bad(monkeypatch):

def test_profile():
profile = RaspaProfile()
assert profile.binary == f"{os.getenv('RASPA_DIR')}/bin/simulate"
assert profile.command == f"{os.getenv('RASPA_DIR')}/bin/simulate"

assert profile.get_calculator_command() == [
f"{os.getenv('RASPA_DIR')}/bin/simulate",
Expand All @@ -31,8 +31,8 @@ def test_profile():


def test_profil2e():
profile = RaspaProfile(binary="my/path")
assert profile.binary == "my/path"
profile = RaspaProfile(command="my/path")
assert profile.command == "my/path"

assert profile.get_calculator_command() == [
"my/path",
Expand Down

0 comments on commit 03250cb

Please sign in to comment.