Skip to content

Commit 2a54097

Browse files
authored
Apply ruff format to originals and validators
1 parent 3eb98bb commit 2a54097

6 files changed

Lines changed: 10 additions & 23 deletions

originals/b7_contract_stochastic_income.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ def exit_constraint(c_high: float) -> bool:
5050

5151

5252
if __name__ == "__main__":
53-
print(solve_contract())
53+
print(solve_contract())

originals/check_HJB_condition.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ def F(rho: float, x: float, y: float, p: float) -> float:
1616
return (
1717
rho * (w**gamma)
1818
+ b * p * gamma * y * (w ** (gamma - 1))
19-
+ 0.5
20-
* sigma**2
21-
* p**2
22-
* gamma
23-
* (gamma - 1)
24-
* y**2
25-
* (w ** (gamma - 2))
19+
+ 0.5 * sigma**2 * p**2 * gamma * (gamma - 1) * y**2 * (w ** (gamma - 2))
2620
)
2721

2822

@@ -31,20 +25,13 @@ def rho_critical(x: float, y: float, p: float) -> float:
3125
if w <= 0:
3226
raise ValueError("Wealth must be positive.")
3327

34-
const = (
35-
b * p * gamma * y * (w ** (gamma - 1))
36-
+ 0.5
37-
* sigma**2
38-
* p**2
39-
* gamma
40-
* (gamma - 1)
41-
* y**2
42-
* (w ** (gamma - 2))
43-
)
28+
const = b * p * gamma * y * (w ** (gamma - 1)) + 0.5 * sigma**2 * p**2 * gamma * (
29+
gamma - 1
30+
) * y**2 * (w ** (gamma - 2))
4431
return -const / (w**gamma)
4532

4633

4734
if __name__ == "__main__":
4835
x0, y0, p0 = 0.0, 1.0, 1.0
4936
rho_star = rho_critical(x0, y0, p0)
50-
print(f"Critical rho: {rho_star:.6f}")
37+
print(f"Critical rho: {rho_star:.6f}")

validators/contract_stochastic_income.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ def reference_compute() -> float:
1818

1919

2020
def validate(answer: float) -> dict:
21-
return result(TASK_ID, EXPECTED, TOL, float(answer))
21+
return result(TASK_ID, EXPECTED, TOL, float(answer))

validators/cpi_target_discount.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ def reference_compute() -> float:
1515

1616

1717
def validate(answer: float) -> dict:
18-
return result(TASK_ID, EXPECTED, TOL, float(answer))
18+
return result(TASK_ID, EXPECTED, TOL, float(answer))

validators/credit_var_quantile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ def reference_compute() -> float:
2323

2424

2525
def validate(answer: float) -> dict:
26-
return result(TASK_ID, EXPECTED, TOL, float(answer))
26+
return result(TASK_ID, EXPECTED, TOL, float(answer))

validators/hjb_discount_threshold.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ def reference_compute() -> float:
1818

1919

2020
def validate(answer: float) -> dict:
21-
return result(TASK_ID, EXPECTED, TOL, float(answer))
21+
return result(TASK_ID, EXPECTED, TOL, float(answer))

0 commit comments

Comments
 (0)