Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exclude: |
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand Down Expand Up @@ -42,7 +42,7 @@ repos:
['--no-error-on-unmatched-pattern', '--ignore-unknown']

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
rev: v0.45.0
hooks:
- id: markdownlint
args: ["--fix"]
Expand All @@ -59,26 +59,26 @@ repos:
args: ["--ignore=E006,E011"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
rev: v0.11.0.1
hooks:
- id: shellcheck
args: ["-x"] # Check external files

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: v1.7.1.15
rev: v1.7.7.24
hooks:
- id: actionlint

- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
rev: v1.37.1
hooks:
- id: yamllint
args:
["-d", "{rules: {line-length: {max: 120}},
ignore-from-file: [.gitignore],}"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.2
rev: v0.12.12
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --config=pyproject.toml]
Expand All @@ -94,7 +94,7 @@ repos:
then /bin/mkdir .mypy_cache; fi; exit 0'

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.10.1"
rev: "v1.17.1"
hooks:
- id: mypy
verbose: true
Expand Down
12 changes: 6 additions & 6 deletions tests/test_powerPlant.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ def test_power_plants():

loss_var = pp.financial_losses(damages=damage, energy_price=elec_price, r=r_var)

assert np.isclose(
loss_cst.mean(), loss_var.mean()
), "Losses are not calculated properly"
assert np.isclose(loss_cst.mean(), loss_var.mean()), (
"Losses are not calculated properly"
)

# Now the same pp in two different ways

pp2 = PowerPlants(capacity=900913242.0091324, av_rate=1, name=name)
loss_var2 = pp2.financial_losses(damages=damage, energy_price=elec_price, r=r_var)

assert np.isclose(
loss_var.mean(), loss_var2.mean()
), "Losses are not calculated properly"
assert np.isclose(loss_var.mean(), loss_var2.mean()), (
"Losses are not calculated properly"
)

print("FINISHED DCV TEST SUCCESSFULLY!!!")
26 changes: 13 additions & 13 deletions tests/test_realstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def test_asset():
variance_loss = losses[0].var()
expected_variance_loss = 724.0
print(
f'Mean Financial Losses: {real_asset.financial_losses(["2030-02-09"], damage=discrete_rand_var)[0].mean()}'
f"Mean Financial Losses: {real_asset.financial_losses(['2030-02-09'], damage=discrete_rand_var)[0].mean()}"
)
print(
f'Variance Financial Losses: {real_asset.financial_losses(["2030-02-09"], damage=discrete_rand_var)[0].var()}'
f"Variance Financial Losses: {real_asset.financial_losses(['2030-02-09'], damage=discrete_rand_var)[0].var()}"
)
assert np.allclose(mean_loss, expected_mean_loss), "Mean is not calculated properly"
assert np.allclose(
variance_loss, expected_variance_loss
), "Variance is not calculated properly"
assert np.allclose(variance_loss, expected_variance_loss), (
"Variance is not calculated properly"
)

intervals_osc = np.array(
[
Expand Down Expand Up @@ -150,12 +150,12 @@ def test_asset():
]
)

assert np.allclose(
discrete_rand_var_osc.intervals, expected_intervals
), "Intervals are not calculated properly"
assert np.allclose(
discrete_rand_var_osc.probabilities, expected_probabilities
), "Probabilities are not calculated properly"
assert np.allclose(discrete_rand_var_osc.intervals, expected_intervals), (
"Intervals are not calculated properly"
)
assert np.allclose(discrete_rand_var_osc.probabilities, expected_probabilities), (
"Probabilities are not calculated properly"
)

# zero included

Expand Down Expand Up @@ -246,7 +246,7 @@ def test_asset():
loan_amounts=loan_amounts,
)

print(f" LTV mean value (first date, fist asset): {ltv[0,0].mean()}")
print(f" LTV mean value (first date, fist asset): {ltv[0, 0].mean()}")
means = DiscreteRandomVariable.means_vectorized(ltv)
print(f" LTV mean values: {means}")

Expand All @@ -257,7 +257,7 @@ def test_asset():
assert np.allclose(means, expected_means), "LTV mean values calculation failed"

# Variances
print(f" LTV variance (first date, fist asset): {ltv[0,0].var()}")
print(f" LTV variance (first date, fist asset): {ltv[0, 0].var()}")
vars = DiscreteRandomVariable.vars_vectorized(ltv)
print(f" LTV variances: {vars}")

Expand Down
Loading