Skip to content

Commit 2d48c22

Browse files
committed
Add v2.Problem.__repr__
Add `v2.Problem.__repr__`, and include ID and all models in `__str__`.
1 parent 2ec51e8 commit 2d48c22

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

petab/v2/core.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,8 +1138,13 @@ def __init__(
11381138
self.mapping_tables = mapping_tables or [MappingTable()]
11391139
self.parameter_tables = parameter_tables or [ParameterTable()]
11401140

1141+
def __repr__(self):
1142+
return f"<{self.__class__.__name__} id={self.id!r}>"
1143+
11411144
def __str__(self):
1142-
model = f"with model ({self.model})" if self.model else "without model"
1145+
pid = repr(self.id) if self.id else "without ID"
1146+
1147+
model = f"with models {self.models}" if self.model else "without model"
11431148

11441149
ne = len(self.experiments)
11451150
experiments = f"{ne} experiments"
@@ -1157,7 +1162,7 @@ def __str__(self):
11571162
parameters = f"{nest} estimated parameters"
11581163

11591164
return (
1160-
f"PEtab Problem {model}, {conditions}, {experiments}, "
1165+
f"PEtab Problem {pid} {model}, {conditions}, {experiments}, "
11611166
f"{observables}, {measurements}, {parameters}"
11621167
)
11631168

0 commit comments

Comments
 (0)