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 with schema_name.

  • spec (object) – An object instance to validate against a schema.

  • schema_name (string) – The name of a schema to validate against. See pyhf.schema.load_schema() for more details.

  • version (string) – The version of the schema to use. See pyhf.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 the spec will be treated like python list. Default: True.


InvalidSpecification – if the provided instance does not validate against the schema.


if there are no errors with the provided instance.

Return type:



>>> 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")