From a94dd44ced8fcb94c712b02eeda9a099085b78d1 Mon Sep 17 00:00:00 2001 From: Adam Zsarnoczay <33822153+zsarnoczay@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:50:49 -0800 Subject: [PATCH] Minor updates to damage_model.py - The lines in the docstring for _handle_operation_list were too long - The keys of the parsed_scaling_specification dict do not need to be initialized --- pelicun/model/damage_model.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pelicun/model/damage_model.py b/pelicun/model/damage_model.py index 5fa63ce2..ae3a2f0f 100644 --- a/pelicun/model/damage_model.py +++ b/pelicun/model/damage_model.py @@ -911,7 +911,7 @@ def _handle_operation_list( self, initial_value: float, operations: list[tuple[str, float]] ) -> np.ndarray: """ - Apply a list of operations to an initial value and return the results as a numpy array. + Apply one or more operations to an initial value and return the results. Parameters. ---------- @@ -919,8 +919,9 @@ def _handle_operation_list( The initial value to which the operations will be applied. operations : list of tuple A list of operations where each operation is represented as a tuple. - The first element of the tuple is a string representing the operation type, - and the second element is a float representing the value to be used in the operation. + The first element of the tuple is a string representing the operation + type, and the second element is a float representing the value to be + used in the operation. Returns ------- @@ -1201,12 +1202,12 @@ def _create_dmg_RVs( # noqa: N802, C901 components that should be present in the `capacity_sample`. The second level key is the limit state to apply the scaling to. The values should be strings or list of strings. The strings should - containing an operation followed by the value formatted as - a float. The operation can be '+' for addition, '-' for - subtraction, '*' for multiplication, and '/' for division. If - different operations are required for different realizations, a - list of strings can be provided. When 'ALL' is used as the key, - the operation will be applied to all limit states. + contain an operation followed by the value formatted as a float. + The operation can be '+' for addition, '-' for subtraction, '*' + for multiplication, and '/' for division. If different operations + are required for different realizations, a list of strings can + be provided. When 'ALL' is used as the key, the operation will + be applied to all limit states. Returns ------- @@ -1365,8 +1366,6 @@ def parse_scaling_specification(scaling_specification: dict) -> dict: # noqa: C # validate contents for key, value in scaling_specification.items(): # loop through limit states - if key not in parsed_scaling_specification: - parsed_scaling_specification[key] = defaultdict(list) if 'ALL' in value: if len(value) > 1: msg = (