Skip to content

Commit

Permalink
Minor updates to damage_model.py
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
zsarnoczay authored Nov 27, 2024
1 parent 1396624 commit a94dd44
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions pelicun/model/damage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,16 +911,17 @@ 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.
----------
initial_value : float
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
-------
Expand Down Expand Up @@ -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
-------
Expand Down Expand Up @@ -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 = (
Expand Down

0 comments on commit a94dd44

Please sign in to comment.