Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support models with custom modifiers #385

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

alexander-held
Copy link
Member

@alexander-held alexander-held commented Dec 20, 2022

Add support for handling models with custom modifiers as introduced in scikit-hep/pyhf#1991. This means adding a validate kwarg to model_utils.model_and_data to allow turning off workspace / model validation against the respective JSON schema (users could provide their own via the pyhf API, see pyhf.schema.Schema docs). The modifier_set kwarg can be used to inject custom modifiers.

At the moment this also adds a poi_name kwarg to support the use case in #382, but that may be argued to be an invalid model specification to begin with, so it is not clear to me whether this would be generally needed. The fit API is meant to not rely on this option (to also more easily support multi-POI setups) so this may somewhat go against the design philosophy here.

to-do:

may potentially resolve #382

* allow turning off workspace and model validation in model_utils.model_and_data
* allow injecting custom modifiers into model creation in model_utils.model_and_data
* support setting POI in model_utils.model_and_data

@codecov
Copy link

codecov bot commented Dec 20, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (f116d4e) to head (2decbe8).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #385   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           22        22           
  Lines         2093      2094    +1     
  Branches       344       344           
=========================================
+ Hits          2093      2094    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


Returns:
Tuple[pyhf.pdf.Model, List[float]]:
- a HistFactory-style model in ``pyhf`` format
- the data (plus auxdata if requested) for the model
"""
workspace = pyhf.Workspace(spec)
workspace = pyhf.Workspace(spec, validate=validate)
poi_name_kwarg = {"poi_name": poi_name} if poi_name is not None else {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poi_name=None in pyhf.Model means "no POI", while in model_and_data it is now used as the default saying "use the workspace default". Should perhaps use an object() sentinel instead of None.

@rmnmllr
Copy link
Contributor

rmnmllr commented May 2, 2023

hey @alexander-held, would it be possible to merge the latest base branch into the feat/custom-modifier-models branch?
I would like to use the latest fixes with the custom modifiers.

@alexander-held
Copy link
Member Author

Hi @rmnmllr, sure, this branch includes the changes from master now.

@alexander-held alexander-held mentioned this pull request Aug 17, 2023
3 tasks
@alexander-held alexander-held force-pushed the feat/custom-modifier-models branch 2 times, most recently from bd890a4 to 5dc0bef Compare September 20, 2023 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding custom modifiers to cabinetry
2 participants