def test_lumi(backend): mc = MockConfig( par_map={ 'lumi': { 'paramset': constrained_by_normal( n_parameters=1, inits=[0], bounds=[[-5, 5]], fixed=False, auxdata=[None], sigmas=[None], ), 'slice': slice(0, 1), } }, par_order=['lumi'], samples=['signal', 'background'], ) mega_mods = { 'lumi/lumi': { 'signal': { 'type': 'lumi', 'name': 'lumi', 'data': {'mask': [True, True, True]}, }, 'background': { 'type': 'lumi', 'name': 'lumi', 'data': {'mask': [True, True, True]}, }, }, } hsc = lumi_combined([('lumi', 'lumi')], mc, mega_mods) mod = hsc.apply(pyhf.tensorlib.astensor([0.5])) shape = pyhf.tensorlib.shape(mod) assert shape == (1, 2, 1, 3) mod = np.asarray(pyhf.tensorlib.tolist(mod)) assert np.allclose(mod[0, 0, 0], [0.5, 0.5, 0.5]) assert np.allclose(mod[0, 1, 0], [0.5, 0.5, 0.5]) hsc = lumi_combined([('lumi', 'lumi')], mc, mega_mods, batch_size=4) mod = hsc.apply(pyhf.tensorlib.astensor([[1.0], [2.0], [3.0], [4.0]])) shape = pyhf.tensorlib.shape(mod) assert shape == (1, 2, 4, 3) mod = np.asarray(pyhf.tensorlib.tolist(mod)) assert np.allclose(mod[0, 0, 0], [1.0, 1.0, 1.0]) assert np.allclose(mod[0, 0, 1], [2.0, 2.0, 2.0]) assert np.allclose(mod[0, 0, 2], [3.0, 3.0, 3.0]) assert np.allclose(mod[0, 0, 3], [4.0, 4.0, 4.0])
def test_lumi(backend): mc = MockConfig( par_map={ 'lumi': { 'paramset': paramset(n_parameters=1, inits=[0], bounds=[[-5, 5]]), 'slice': slice(0, 1), } }, par_order=['lumi'], samples=['signal', 'background'], ) mega_mods = { 'signal': { 'lumi/lumi': { 'type': 'lumi', 'name': 'lumi', 'data': { 'mask': [True, True, True] }, } }, 'background': { 'lumi/lumi': { 'type': 'lumi', 'name': 'lumi', 'data': { 'mask': [True, True, True] }, } }, } hsc = lumi_combined([('lumi', 'lumi')], mc, mega_mods) mod = hsc.apply(pyhf.tensorlib.astensor([0.5])) shape = pyhf.tensorlib.shape(mod) assert shape == (1, 2, 1, 3) mod = np.asarray(pyhf.tensorlib.tolist(mod)) assert np.allclose(mod[0, 0, 0], [0.5, 0.5, 0.5]) assert np.allclose(mod[0, 1, 0], [0.5, 0.5, 0.5])