Workspace

class pyhf.pdf.Workspace(spec, **config_kwargs)[source]

Bases: object

An object that is built from a JSON spec that follows workspace.json.

Methods

__init__(spec, **config_kwargs)[source]

Initialize self. See help(type(self)) for accurate signature.

data(model, with_aux=True)[source]

Return the data for the supplied model with or without auxiliary data from the model.

The model is needed as the order of the data depends on the order of the channels in the model.

Parameters
  • model – A model object adhering to the schema model.json

  • with_aux – Whether to include auxiliary data from the model or not

Returns

A list of numbers

Return type

data

get_measurement(**config_kwargs)[source]

Get (or create) a measurement object using the following logic:

  1. if the poi name is given, create a measurement object for that poi

  2. if the measurement name is given, find the measurement for the given name

  3. if the measurement index is given, return the measurement at that index

  4. if there are measurements but none of the above have been specified, return the 0th measurement

  5. otherwise, raises InvalidMeasurement

Parameters
  • poi_name – The name of the parameter of interest to create a new measurement from

  • measurement_name – The name of the measurement to use

  • measurement_index – The index of the measurement to use

Returns

A measurement object adhering to the schema defs.json#/definitions/measurement

Return type

measurement

model(**config_kwargs)[source]

Create a model object with/without patches applied.

Parameters

patches – A list of JSON patches to apply to the model specification

Returns

A model object adhering to the schema model.json

Return type

model