align_to_model_coords#
- pymc_marketing.mmm.optimization_variables.align_to_model_coords(da, coords, *, label)[source]#
Reindex a labelled input onto the model’s budget coordinates.
Every coordinate-bearing input the optimizer accepts (the optimization mask, the temporal distribution, cost per unit, budget bounds) is ultimately consumed positionally against the model’s tensor layout, so all of them have to be expressed in the model’s coordinate order before use. Reindexing alone is not enough to make that safe: it silently drops labels the model does not have and silently fills missing ones with NaN, so both are rejected here.
- Parameters:
- Returns:
DataArraydareindexed ontocoords. Dims outsidecoords(a date or bound dim, say) are left untouched, as are dims carrying no coordinates, which reindex labels positionally.
- Raises:
ValueErrorIf the input carries coordinates the model does not have, or does not cover every coordinate the model does.