Skip to content

Commit

Permalink
ruff format
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyan1214 committed Nov 26, 2024
1 parent af65c64 commit 1396624
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pelicun/resources/auto/Hazus_Earthquake_IM.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,8 @@ def getHAZUSBridgeSlightDamageModifier(hazus_class, aim):
demand_cloning=None,
residual_drift_inference=None,
coupled_demands=coupled_demands,
)
demand_sample, _ = assessment.demand.save_sample(
save_units=True
)
demand_sample, _ = assessment.demand.save_sample(save_units=True)
edp_types = demand_sample.columns.get_level_values(level='type')
if (edp_types == 'SA_0.3').sum() != 1:
msg = (
Expand All @@ -446,7 +444,9 @@ def getHAZUSBridgeSlightDamageModifier(hazus_class, aim):
].values.flatten()

ratio = 2.5 * sa_1p0 / sa_0p3
operation = [f'*{ratio[i]}' if ratio[i] <= 1.0 else 1.0 for i in range(len(ratio))]
operation = [
f'*{ratio[i]}' if ratio[i] <= 1.0 else 1.0 for i in range(len(ratio))
]

assert len(operation) == sample_size

Expand Down
12 changes: 9 additions & 3 deletions pelicun/tests/basic/test_damage_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,9 @@ def test__create_dmg_RVs(self, assessment_instance: Assessment) -> None:
capacity_rv_reg.generate_sample(
sample_size=len(operation_list), method='LHS'
)
cmp_b_scaled_theta0 = np.array([30.0 * 1.20, 30.0 + 0.10, 30.0 / 1.20, 30.0 - 0.10, 30.0 * 1.10])
cmp_b_scaled_theta0 = np.array(
[30.0 * 1.20, 30.0 + 0.10, 30.0 / 1.20, 30.0 - 0.10, 30.0 * 1.10]
)
for rv_name, rv in capacity_rv_reg.RV.items():
uniform_sample = rv._uni_sample
sample = rv.sample
Expand All @@ -595,11 +597,15 @@ def test__create_dmg_RVs(self, assessment_instance: Assessment) -> None:
if rv_name == 'FRG-cmp.A-1-2-3-1-1':
theta = 1.20 * 30.0
beta = 0.5
assert sample[i] == np.exp(norm.ppf(uniform_sample[i], loc=np.log(theta), scale=beta))
assert sample[i] == np.exp(
norm.ppf(uniform_sample[i], loc=np.log(theta), scale=beta)
)
elif rv_name == 'FRG-cmp.B-1-2-3-1-1':
theta = cmp_b_scaled_theta0[i]
beta = 0.5
assert sample[i] == np.exp(norm.ppf(uniform_sample[i], loc=np.log(theta), scale=beta))
assert sample[i] == np.exp(
norm.ppf(uniform_sample[i], loc=np.log(theta), scale=beta)
)

def test__evaluate_damage_state(self, assessment_instance: Assessment) -> None:
# We define a single component with 3 limit states.
Expand Down

0 comments on commit 1396624

Please sign in to comment.