Skip to content

Commit

Permalink
em_framework/points: Add string representation to Experiment class (#297
Browse files Browse the repository at this point in the history
)

* em_framework/points: Add string representation to Experiment class

* points: Add formal string representation __repr__ to Experiment class

.__repr__() provides the formal string representation of an object, aimed at the programmer.
.__str__() provides the informal string representation of an object, aimed at the user.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
EwoutH and pre-commit-ci[bot] authored Oct 26, 2023
1 parent 211699b commit b76b487
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions ema_workbench/em_framework/points.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@ def __init__(self, name, model_name, policy, scenario, experiment_id):
self.model_name = model_name
self.scenario = scenario

def __repr__(self):
return (
f"Experiment(name={self.name!r}, model_name={self.model_name!r}, "
f"policy={self.policy!r}, scenario={self.scenario!r}, "
f"experiment_id={self.experiment_id!r})"
)

def __str__(self):
return f"Experiment {self.experiment_id} (model: {self.model_name}, policy: {self.policy.name}, scenario: {self.scenario.name})"


class ExperimentReplication(NamedDict):
"""helper class that combines scenario, policy, any constants, and
Expand Down

0 comments on commit b76b487

Please sign in to comment.