Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __repr__ for parameter mapping classes #1799

Merged
merged 1 commit into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions python/amici/parameter_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,15 @@ def __init__(
scale_map_sim_fix = {key: LIN for key in map_sim_fix}
self.scale_map_sim_fix = scale_map_sim_fix

def __repr__(self):
return (f"{self.__class__.__name__}("
f"map_sim_var={repr(self.map_sim_var)},"
f"scale_map_sim_var={repr(self.scale_map_sim_var)},"
f"map_preeq_fix={repr(self.map_preeq_fix)},"
f"scale_map_preeq_fix={repr(self.scale_map_preeq_fix)},"
f"map_sim_fix={repr(self.map_sim_fix)},"
f"scale_map_sim_fix={repr(self.scale_map_sim_fix)})")


class ParameterMapping(Sequence):
r"""Parameter mapping for multiple conditions.
Expand All @@ -111,8 +120,7 @@ def __init__(
self.parameter_mappings = parameter_mappings

def __iter__(self):
for mapping in self.parameter_mappings:
yield mapping
yield from self.parameter_mappings

def __getitem__(self, item):
return self.parameter_mappings[item]
Expand All @@ -126,6 +134,9 @@ def append(
"""Append a condition specific parameter mapping."""
self.parameter_mappings.append(parameter_mapping_for_condition)

def __repr__(self):
return f"{self.__class__.__name__}({repr(self.parameter_mappings)})"


def fill_in_parameters(
edatas: List[amici.ExpData],
Expand Down Expand Up @@ -355,7 +366,7 @@ def scale_parameters_dict(
:param petab_scale_dict:
Target scales of ``values``
"""
if not value_dict.keys() == petab_scale_dict.keys():
if value_dict.keys() != petab_scale_dict.keys():
raise AssertionError("Keys don't match.")

for key, value in value_dict.items():
Expand All @@ -378,7 +389,7 @@ def unscale_parameters_dict(
:param petab_scale_dict:
Target scales of ``values``
"""
if not value_dict.keys() == petab_scale_dict.keys():
if value_dict.keys() != petab_scale_dict.keys():
raise AssertionError("Keys don't match.")

for key, value in value_dict.items():
Expand Down