From 8a40932db7ba5a2b6fc759ec8d9475d3dd667153 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Wed, 18 Dec 2024 23:15:02 +0100 Subject: [PATCH 1/3] Problem.add_parameter: Rename kwarg estimated->estimate Change the `estimated` argument in Problem.add_parameter to `estimate` to match the column name. --- petab/v1/problem.py | 10 ++++------ petab/v2/problem.py | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/petab/v1/problem.py b/petab/v1/problem.py index 6be96c68..972fe5b8 100644 --- a/petab/v1/problem.py +++ b/petab/v1/problem.py @@ -1074,7 +1074,7 @@ def add_observable( def add_parameter( self, id_: str, - estimated: bool | str | int = True, + estimate: bool | str | int = True, nominal_value=None, scale: str = None, lb: Number = None, @@ -1089,7 +1089,7 @@ def add_parameter( Arguments: id_: The parameter id - estimated: Whether the parameter is estimated + estimate: Whether the parameter is estimated nominal_value: The nominal value of the parameter scale: The parameter scale lb: The lower bound of the parameter @@ -1104,11 +1104,9 @@ def add_parameter( record = { PARAMETER_ID: [id_], } - if estimated is not None: + if estimate is not None: record[ESTIMATE] = [ - int(estimated) - if isinstance(estimated, bool | int) - else estimated + int(estimate) if isinstance(estimate, bool | int) else estimate ] if nominal_value is not None: record[NOMINAL_VALUE] = [nominal_value] diff --git a/petab/v2/problem.py b/petab/v2/problem.py index f8dad754..bf569c24 100644 --- a/petab/v2/problem.py +++ b/petab/v2/problem.py @@ -829,7 +829,7 @@ def add_observable( def add_parameter( self, id_: str, - estimated: bool | str | int = True, + estimate: bool | str | int = True, nominal_value=None, scale: str = None, lb: Number = None, @@ -844,7 +844,7 @@ def add_parameter( Arguments: id_: The parameter id - estimated: Whether the parameter is estimated + estimate: Whether the parameter is estimated nominal_value: The nominal value of the parameter scale: The parameter scale lb: The lower bound of the parameter @@ -859,11 +859,9 @@ def add_parameter( record = { PARAMETER_ID: [id_], } - if estimated is not None: + if estimate is not None: record[ESTIMATE] = [ - int(estimated) - if isinstance(estimated, bool | int) - else estimated + int(estimate) if isinstance(estimate, bool | int) else estimate ] if nominal_value is not None: record[NOMINAL_VALUE] = [nominal_value] From 54624fe67681c2f6030f03bc51c5fc960e226d71 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 19 Dec 2024 08:46:38 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Dilan Pathirana <59329744+dilpath@users.noreply.github.com> --- petab/v1/problem.py | 2 +- petab/v2/problem.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/petab/v1/problem.py b/petab/v1/problem.py index 972fe5b8..e79959f4 100644 --- a/petab/v1/problem.py +++ b/petab/v1/problem.py @@ -1075,7 +1075,7 @@ def add_parameter( self, id_: str, estimate: bool | str | int = True, - nominal_value=None, + nominal_value: Number | None = None, scale: str = None, lb: Number = None, ub: Number = None, diff --git a/petab/v2/problem.py b/petab/v2/problem.py index bf569c24..90642c21 100644 --- a/petab/v2/problem.py +++ b/petab/v2/problem.py @@ -830,7 +830,7 @@ def add_parameter( self, id_: str, estimate: bool | str | int = True, - nominal_value=None, + nominal_value: Number | None = None, scale: str = None, lb: Number = None, ub: Number = None, From 2926214dd3e587c4eeead574bac6e779664cef5f Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Thu, 19 Dec 2024 08:48:51 +0100 Subject: [PATCH 3/3] .. --- petab/v1/problem.py | 4 +--- petab/v2/problem.py | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/petab/v1/problem.py b/petab/v1/problem.py index e79959f4..5c0dcf61 100644 --- a/petab/v1/problem.py +++ b/petab/v1/problem.py @@ -1105,9 +1105,7 @@ def add_parameter( PARAMETER_ID: [id_], } if estimate is not None: - record[ESTIMATE] = [ - int(estimate) if isinstance(estimate, bool | int) else estimate - ] + record[ESTIMATE] = [int(estimate)] if nominal_value is not None: record[NOMINAL_VALUE] = [nominal_value] if scale is not None: diff --git a/petab/v2/problem.py b/petab/v2/problem.py index 90642c21..79bb6196 100644 --- a/petab/v2/problem.py +++ b/petab/v2/problem.py @@ -860,9 +860,7 @@ def add_parameter( PARAMETER_ID: [id_], } if estimate is not None: - record[ESTIMATE] = [ - int(estimate) if isinstance(estimate, bool | int) else estimate - ] + record[ESTIMATE] = [int(estimate)] if nominal_value is not None: record[NOMINAL_VALUE] = [nominal_value] if scale is not None: