VariableSchema#
- class pymc_marketing.data.idata.schema.VariableSchema(**data)[source]#
Schema for a single variable in InferenceData.
Validates the structure (dimensions and dtype) of xarray.DataArray variables within InferenceData groups.
- Parameters:
- name
str Variable name
- requiredbool, default
True Whether this variable must be present
- dims
tupleofstror “*” Expected dimension names. Use “*” to accept any dimensions.
- dtype
str,tupleofstr, orNone Expected numpy dtype(s) (e.g., “float64”, “int64”, or (“float64”, “int64”)). Use None to skip dtype validation.
- description
str, default “” Human-readable description of this variable
- name
Examples
>>> schema = VariableSchema( ... name="channel_contribution", ... dims=("date", "channel"), ... dtype="float64", ... required=True, ... ) >>> data_array = xr.DataArray(...) >>> errors = schema.validate_variable(data_array) >>> if errors: ... print("Validation errors:", errors)
Methods
VariableSchema.__init__(**data)Create a new model by parsing and validating input data from keyword arguments.
VariableSchema.construct([_fields_set])VariableSchema.copy(*[, include, exclude, ...])Returns a copy of the model.
VariableSchema.dict(*[, include, exclude, ...])VariableSchema.json(*[, include, exclude, ...])VariableSchema.model_construct([_fields_set])Creates a new instance of the
Modelclass with validated data.VariableSchema.model_copy(*[, update, deep])!!! abstract "Usage Documentation"
VariableSchema.model_dump(*[, mode, ...])!!! abstract "Usage Documentation"
VariableSchema.model_dump_json(*[, indent, ...])!!! abstract "Usage Documentation"
VariableSchema.model_json_schema([by_alias, ...])Generates a JSON schema for a model class.
Compute the class name for parametrizations of generic classes.
VariableSchema.model_post_init(context, /)Override this method to perform additional initialization after
__init__andmodel_construct.VariableSchema.model_rebuild(*[, force, ...])Try to rebuild the pydantic-core schema for the model.
VariableSchema.model_validate(obj, *[, ...])Validate a pydantic model instance.
VariableSchema.model_validate_json(json_data, *)!!! abstract "Usage Documentation"
Validate the given object with string data against the Pydantic model.
VariableSchema.parse_file(path, *[, ...])VariableSchema.parse_raw(b, *[, ...])VariableSchema.schema([by_alias, ref_template])VariableSchema.schema_json(*[, by_alias, ...])VariableSchema.update_forward_refs(**localns)VariableSchema.validate(value)VariableSchema.validate_variable(data_array)Validate variable structure.
Attributes
model_computed_fieldsmodel_configConfiguration for the model, should be a dictionary conforming to [
ConfigDict][pydantic.config.ConfigDict].model_extraGet extra fields set during validation.
model_fieldsmodel_fields_setReturns the set of fields that have been explicitly set on this model instance.
namerequireddimsdtypedescription