pyhf.schema.validate#
- pyhf.schema.validate(spec: Mapping, schema_name: str, *, version: str | None = None, allow_tensors: bool = True)[source]#
Validate the provided instance,
spec
, against the schema associated withschema_name
.- Parameters:
spec (
object
) – An object instance to validate against a schema.schema_name (
string
) – The name of a schema to validate against. Seepyhf.schema.load_schema()
for more details.version (
string
) – The version of the schema to use. Seepyhf.schema.load_schema()
for more details.allow_tensors (
bool
) – A flag to enable or disable tensors as part of schema validation. If enabled, tensors in thespec
will be treated like pythonlist
. Default:True
.
- Raises:
InvalidSpecification – if the provided instance does not validate against the schema.
- Returns:
if there are no errors with the provided instance.
- Return type:
None
Example
>>> import pyhf >>> model = pyhf.simplemodels.uncorrelated_background( ... signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0] ... ) >>> pyhf.schema.validate(model.spec, "model.json") >>>