Skip to content

Commit

Permalink
Type annotations and checking.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioannis-vm committed Dec 3, 2024
1 parent 16df91e commit aa7e885
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 5 additions & 8 deletions doc/source/examples/notebooks/example_4.pct.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# %% [markdown]
"""
# Example 4: A loss assessment including both damage states and loss functions.
"""
"""# Example 4: A loss assessment including both damage states and loss functions."""

# %%
import tempfile
Expand All @@ -14,7 +12,6 @@
from pelicun import assessment, file_io
from pelicun.pelicun_warnings import PelicunWarning


temp_dir = tempfile.mkdtemp()

sample_size = 10000
Expand Down Expand Up @@ -77,8 +74,9 @@
# Generate samples
asmnt.demand.generate_sample({'SampleSize': sample_size})


def add_more_edps() -> None:
"""Adds SA_1.13 and residual drift to the demand sample."""
"""Add SA_1.13 and residual drift to the demand sample."""
# Add residual drift and Sa
demand_sample = asmnt.demand.save_sample()

Expand Down Expand Up @@ -107,6 +105,7 @@ def add_more_edps() -> None:

asmnt.demand.load_sample(demand_sample_ext)


add_more_edps()

#
Expand All @@ -117,9 +116,7 @@ def add_more_edps() -> None:
asmnt.stories = 1

# Load component definitions
cmp_marginals = pd.read_csv(
'example_4/CMP_marginals.csv', index_col=0
)
cmp_marginals = pd.read_csv('example_4/CMP_marginals.csv', index_col=0)
cmp_marginals['Blocks'] = cmp_marginals['Blocks']
asmnt.asset.load_cmp_model({'marginals': cmp_marginals})

Expand Down
2 changes: 1 addition & 1 deletion pelicun/model/damage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1362,7 +1362,7 @@ def parse_scaling_specification(scaling_specification: dict) -> dict: # noqa: C
"""
# if there are contents, ensure they are valid.
# See docstring for an example of what is expected.
parsed_scaling_specification = defaultdict(dict)
parsed_scaling_specification: dict = defaultdict(dict)
# validate contents
for key, value in scaling_specification.items():
# loop through limit states
Expand Down
2 changes: 2 additions & 0 deletions pelicun/tests/basic/test_damage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,8 @@ def test__create_dmg_RVs(self, assessment_instance: Assessment) -> None:
for rv_name, rv in capacity_rv_reg.RV.items():
uniform_sample = rv._uni_sample
sample = rv.sample
assert uniform_sample is not None
assert sample is not None
for i in range(len(operation_list)):
if rv_name == 'FRG-cmp.A-1-2-3-1-1':
theta = 1.20 * 30.0
Expand Down

0 comments on commit aa7e885

Please sign in to comment.