Initial commit: Four-Quadrant Balance Sheet Matrix (FQBM) framework
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
30
tests/test_differential_model.py
Normal file
30
tests/test_differential_model.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""Tests for Part XIV: differential model and stability checks."""
|
||||
|
||||
import numpy as np
|
||||
from fqbm.state import FQBMState
|
||||
from fqbm.system.differential_model import (
|
||||
solve_trajectory,
|
||||
check_stability,
|
||||
DifferentialParams,
|
||||
)
|
||||
|
||||
|
||||
def test_solve_trajectory():
|
||||
x0 = FQBMState(B=100, R=50, Loans=500, Deposits=600, E_b=50, S=1.0)
|
||||
params = DifferentialParams(monetary_shock=1.0, credit_cycle=0.01)
|
||||
t, X = solve_trajectory(x0, (0, 1), params, t_eval=np.linspace(0, 1, 11))
|
||||
assert t.shape[0] == 11
|
||||
assert X.shape == (11, 12)
|
||||
assert X[-1, 0] > X[0, 0] # B increased
|
||||
assert X[-1, 1] > X[0, 1] # R increased
|
||||
assert X[-1, 3] >= X[0, 3] # Loans
|
||||
|
||||
|
||||
def test_check_stability():
|
||||
x = FQBMState(R=100, Loans=1000, E_b=100)
|
||||
checks = check_stability(x, k=0.08, reserve_threshold=50, debt_gdp=0.5, r=0.05, g=0.02, primary_balance_gdp=0.02)
|
||||
assert "CR_ok" in checks
|
||||
assert "reserves_ok" in checks
|
||||
assert "debt_sustainable" in checks
|
||||
assert checks["CR_ok"] is True
|
||||
assert checks["reserves_ok"] is True
|
||||
Reference in New Issue
Block a user