diff --git a/src/pyhf/cli/spec.py b/src/pyhf/cli/spec.py index dd10a7f696..20d137379a 100644 --- a/src/pyhf/cli/spec.py +++ b/src/pyhf/cli/spec.py @@ -7,6 +7,7 @@ from pyhf.workspace import Workspace from pyhf import modifiers from pyhf import utils +from pyhf import parameters log = logging.getLogger(__name__) diff --git a/src/pyhf/modifiers/__init__.py b/src/pyhf/modifiers/__init__.py index 2f7dc0e4b8..d0f558d620 100644 --- a/src/pyhf/modifiers/__init__.py +++ b/src/pyhf/modifiers/__init__.py @@ -4,7 +4,35 @@ from .shapefactor import shapefactor_builder, shapefactor_combined from .normsys import normsys_builder, normsys_combined from .shapesys import shapesys_builder, shapesys_combined -from .staterror import staterr_builder, staterror_combined +from .staterror import staterror_builder, staterror_combined + +__all__ = [ + 'histosys', + 'histosys_builder', + 'histosys_combined', + 'lumi', + 'lumi_builder', + 'lumi_combined', + 'normfactor', + 'normfactor_builder', + 'normfactor_combined', + 'normsys', + 'normsys_builder', + 'normsys_combined', + 'pyhfset', + 'shapefactor', + 'shapefactor_builder', + 'shapefactor_combined', + 'shapesys', + 'shapesys_builder', + 'shapesys_combined', + 'staterror', + 'staterror_builder', + 'staterror_combined', +] + +def __dir__(): + return __all__ pyhfset = { 'histosys': (histosys_builder, histosys_combined), @@ -13,5 +41,7 @@ 'normsys': (normsys_builder, normsys_combined), 'shapefactor': (shapefactor_builder, shapefactor_combined), 'shapesys': (shapesys_builder, shapesys_combined), - 'staterror': (staterr_builder, staterror_combined), + 'staterror': (staterror_builder, staterror_combined), } + + diff --git a/src/pyhf/modifiers/histosys.py b/src/pyhf/modifiers/histosys.py index 48eecce8ee..e2d8546087 100644 --- a/src/pyhf/modifiers/histosys.py +++ b/src/pyhf/modifiers/histosys.py @@ -12,6 +12,7 @@ def required_parset(sample_data, modifier_data): 'paramset_type': constrained_by_normal, 'n_parameters': 1, 'is_shared': True, + 'is_scalar': True, 'inits': (0.0,), 'bounds': ((-5.0, 5.0),), 'fixed': False, diff --git a/src/pyhf/modifiers/lumi.py b/src/pyhf/modifiers/lumi.py index d647bc4492..d082ca69a5 100644 --- a/src/pyhf/modifiers/lumi.py +++ b/src/pyhf/modifiers/lumi.py @@ -11,6 +11,7 @@ def required_parset(sample_data, modifier_data): 'paramset_type': constrained_by_normal, 'n_parameters': 1, 'is_shared': True, + 'is_scalar': True, 'inits': None, # lumi 'bounds': None, # (0, 10*lumi) 'fixed': False, diff --git a/src/pyhf/modifiers/normfactor.py b/src/pyhf/modifiers/normfactor.py index 2a839babb2..1fb83efe71 100644 --- a/src/pyhf/modifiers/normfactor.py +++ b/src/pyhf/modifiers/normfactor.py @@ -11,6 +11,7 @@ def required_parset(sample_data, modifier_data): 'paramset_type': unconstrained, 'n_parameters': 1, 'is_shared': True, + 'is_scalar': True, 'inits': (1.0,), 'bounds': ((0, 10),), 'fixed': False, diff --git a/src/pyhf/modifiers/normsys.py b/src/pyhf/modifiers/normsys.py index 477a4b8e33..4d8ac79f74 100644 --- a/src/pyhf/modifiers/normsys.py +++ b/src/pyhf/modifiers/normsys.py @@ -12,6 +12,7 @@ def required_parset(sample_data, modifier_data): 'paramset_type': constrained_by_normal, 'n_parameters': 1, 'is_shared': True, + 'is_scalar': True, 'inits': (0.0,), 'bounds': ((-5.0, 5.0),), 'fixed': False, diff --git a/src/pyhf/modifiers/shapefactor.py b/src/pyhf/modifiers/shapefactor.py index 9e78304047..595a4f4909 100644 --- a/src/pyhf/modifiers/shapefactor.py +++ b/src/pyhf/modifiers/shapefactor.py @@ -11,6 +11,7 @@ def required_parset(sample_data, modifier_data): 'paramset_type': unconstrained, 'n_parameters': len(sample_data), 'is_shared': True, + 'is_scalar': False, 'inits': (1.0,) * len(sample_data), 'bounds': ((0.0, 10.0),) * len(sample_data), 'fixed': False, diff --git a/src/pyhf/modifiers/shapesys.py b/src/pyhf/modifiers/shapesys.py index 82ffbbb020..09c4aa4c71 100644 --- a/src/pyhf/modifiers/shapesys.py +++ b/src/pyhf/modifiers/shapesys.py @@ -17,6 +17,7 @@ def required_parset(sample_data, modifier_data): 'paramset_type': constrained_by_poisson, 'n_parameters': n_parameters, 'is_shared': False, + 'is_scalar': False, 'inits': (1.0,) * n_parameters, 'bounds': ((1e-10, 10.0),) * n_parameters, 'fixed': False, diff --git a/src/pyhf/modifiers/staterror.py b/src/pyhf/modifiers/staterror.py index 7e85a05e31..e7b868a9f6 100644 --- a/src/pyhf/modifiers/staterror.py +++ b/src/pyhf/modifiers/staterror.py @@ -11,6 +11,7 @@ def required_parset(sample_data, modifier_data): 'paramset_type': constrained_by_normal, 'n_parameters': len(sample_data), 'is_shared': True, + 'is_scalar': False, 'inits': (1.0,) * len(sample_data), 'bounds': ((1e-10, 10.0),) * len(sample_data), 'fixed': False, @@ -18,7 +19,7 @@ def required_parset(sample_data, modifier_data): } -class staterr_builder: +class staterror_builder: def __init__(self, config): self._mega_mods = {} self.config = config diff --git a/tests/test_export.py b/tests/test_export.py index 4ff0f2c784..241d7bdb62 100644 --- a/tests/test_export.py +++ b/tests/test_export.py @@ -353,7 +353,7 @@ def test_export_sample_zerodata(mocker, spec): mocker.patch('pyhf.writexml._ROOT_DATA_FILE') # make sure no RuntimeWarning, https://stackoverflow.com/a/45671804 - with pytest.warns(DeprecationWarning) as record: + with pytest.warns(None) as record: for modifierspec in samplespec['modifiers']: pyhf.writexml.build_modifier( {'measurements': [{'config': {'parameters': []}}]}, @@ -362,7 +362,7 @@ def test_export_sample_zerodata(mocker, spec): samplename, sampledata, ) - assert record + assert not record.list @pytest.mark.parametrize( diff --git a/tests/test_public_api_repr.py b/tests/test_public_api_repr.py index f75c42385b..6030ba00de 100644 --- a/tests/test_public_api_repr.py +++ b/tests/test_public_api_repr.py @@ -149,22 +149,29 @@ def test_interpolators_public_api(): def test_modifiers_public_api(): - assert dir(pyhf.modifiers) == [ - "combined", - "histosys", - "histosys_combined", - "lumi", - "lumi_combined", - "normfactor", - "normfactor_combined", - "normsys", - "normsys_combined", - "shapefactor", - "shapefactor_combined", - "shapesys", - "shapesys_combined", - "staterror", - "staterror_combined", + assert dir(pyhf.modifiers) == [ + 'histosys', + 'histosys_builder', + 'histosys_combined', + 'lumi', + 'lumi_builder', + 'lumi_combined', + 'normfactor', + 'normfactor_builder', + 'normfactor_combined', + 'normsys', + 'normsys_builder', + 'normsys_combined', + 'pyhfset', + 'shapefactor', + 'shapefactor_builder', + 'shapefactor_combined', + 'shapesys', + 'shapesys_builder', + 'shapesys_combined', + 'staterror', + 'staterror_builder', + 'staterror_combined', ] diff --git a/tests/test_simplemodels.py b/tests/test_simplemodels.py index b4bf6db813..ac3842cca2 100644 --- a/tests/test_simplemodels.py +++ b/tests/test_simplemodels.py @@ -12,9 +12,9 @@ def test_correlated_background(): ) assert model.config.channels == ["single_channel"] assert model.config.samples == ["background", "signal"] - assert model.config.par_order == ["mu", "correlated_bkg_uncertainty"] - assert model.config.par_names() == ['mu', 'correlated_bkg_uncertainty'] - assert model.config.suggested_init() == [1.0, 0.0] + assert model.config.par_order == ["correlated_bkg_uncertainty", "mu"] + assert model.config.par_names() == ['correlated_bkg_uncertainty', "mu"] + assert model.config.suggested_init() == [0.0, 1.0] def test_uncorrelated_background():