Skip to content

Commit

Permalink
Update ElectroChemSequence model
Browse files Browse the repository at this point in the history
- Add `name` field and `set_name` method
- Add `Config` class
- Implement `__eq__` method
  • Loading branch information
edan-bainglass committed Aug 18, 2023
1 parent 55860d7 commit 5e0931e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions aiida_aurora/schemas/cycling.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,22 @@ def __getitem__(self, item):


class ElectroChemSequence(BaseModel):
name: str = ""
method: Sequence[ElectroChemPayloads]

class Config:
validate_assignment = True
extra = Extra.forbid

@property
def n_steps(self):
"Number of steps of the method"
return len(self.method)

def set_name(self, name: str) -> None:
"""docstring"""
self.name = name

def add_step(self, elem):
if not isinstance(elem, get_args(ElectroChemPayloads)):
raise ValueError("Invalid technique")
Expand All @@ -576,6 +585,7 @@ def move_step_forward(self, i):
j = i + 1
self.method[i], self.method[j] = self.method[j], self.method[i]

class Config:
validate_assignment = True
extra = Extra.forbid
def __eq__(self, other: object) -> bool:
if not isinstance(other, ElectroChemSequence):
return NotImplemented
return self.name == other.name

0 comments on commit 5e0931e

Please sign in to comment.