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:
daDataArray

User-supplied input carrying some or all of the budget dims.

coordsMapping[str, list]

The model’s coordinates for the budget dims.

labelstr

Name of the input, used in error messages.

Returns:
DataArray

da reindexed onto coords. Dims outside coords (a date or bound dim, say) are left untouched, as are dims carrying no coordinates, which reindex labels positionally.

Raises:
ValueError

If the input carries coordinates the model does not have, or does not cover every coordinate the model does.