Skip to content

Commit 7ca64b9

Browse files
committed
add test for new table
1 parent cb1a149 commit 7ca64b9

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

ogcore/output_tables.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,8 @@ def model_fit_table(
10851085
model_val = tpi_output["r"][t]
10861086
elif target_desc == r"Capital share of output":
10871087
model_val = (
1088-
1 - tpi_output["w"][t] * tpi_output["L"][t] / tpi_output["Y"][t]
1088+
1
1089+
- tpi_output["w"][t] * tpi_output["L"][t] / tpi_output["Y"][t]
10891090
)
10901091
elif target_desc == r"Labor share of output":
10911092
model_val = (

tests/test_output_tables.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,44 @@ def test_dynamic_revenue_decomposition(include_business_tax, full_break_out):
197197
full_break_out=full_break_out,
198198
)
199199
assert isinstance(df, pd.DataFrame)
200+
201+
202+
@pytest.mark.parametrize(
203+
"targets_dict",
204+
[
205+
# Single macroeconomic moment
206+
{r"Interest rate $(r)$": 0.04},
207+
# Multiple macroeconomic moments
208+
{
209+
r"Investment rate $(I/K)$": 0.07,
210+
r"Capital-Output ratio $(K/Y)$": 3.0,
211+
r"Consumption-Output ratio $(C/Y)$": 0.65,
212+
},
213+
# Fiscal moments
214+
{
215+
r"Revenue to GDP ratio $(T/Y)$": 0.20,
216+
r"Debt to GDP ratio $(D/Y)$": 0.60,
217+
},
218+
# Unrecognized moment key (model value falls back to NaN)
219+
{"Custom unrecognized moment": 0.5},
220+
# Mix of known and unknown moments
221+
{
222+
r"Interest rate $(r)$": 0.04,
223+
"Custom unrecognized moment": 0.5,
224+
},
225+
],
226+
ids=[
227+
"single macro moment",
228+
"multiple macro moments",
229+
"fiscal moments",
230+
"unrecognized moment",
231+
"mixed known and unknown",
232+
],
233+
)
234+
def test_model_fit_table(targets_dict):
235+
df = output_tables.model_fit_table(
236+
targets_dict,
237+
base_params,
238+
base_tpi,
239+
)
240+
assert isinstance(df, pd.DataFrame)

0 commit comments

Comments
 (0)