mario.Database.update_scenarios#

This is the low-level scenario mutation method. It only replaces the matrices you pass and leaves the rest of the stored scenario unchanged.

For the recommended manual workflow, including when to pair it with reset_to_flows(...) or reset_to_coefficients(...), see Shock analyses.

Database.update_scenarios(scenario, **matrices)#

Replace selected stored matrices in an existing scenario.

Parameters:
  • scenario – Existing scenario name to update.

  • **matrices – Keyword mapping matrix_name=dataframe for the blocks to replace. Only the provided blocks are overwritten.

Returns:

The method mutates the stored scenario in place.

Return type:

None

Notes

update_scenarios(...) is a low-level storage operation. It does not create a new scenario, does not recompute dependent matrices and does not clear already materialized derived matrices automatically.

This means that manual scenario edits are safest when paired with either reset_to_flows() or reset_to_coefficients() before changing the selected blocks. Those reset methods collapse the scenario to one consistent storage mode and avoid keeping stale derived matrices around.

When preparing an editable matrix taken from the database, use .copy() before mutating it. For example, Z = db.Z.copy() or z = db.query("z", scenarios="policy").copy(). Without the copy, in-place edits such as *= mutate the scenario storage immediately.

Examples

Manual coefficient-side update in a non-baseline scenario:

db.clone_scenario("baseline", "policy")
db.reset_to_coefficients("policy")
z = db.query("z", scenarios="policy").copy()
z.loc[:, :] *= 0.95
db.update_scenarios("policy", z=z)

After the update, derived matrices such as X or V can be rebuilt on demand from the stored coefficient-side state.