|
| 1 | +import sys |
| 2 | +from unittest.mock import patch |
| 3 | + |
| 4 | +import pyhf |
| 5 | + |
| 6 | +jax_backend = pyhf.tensor.jax_backend(precision="64b") |
| 7 | +pyhf.set_backend(jax_backend) |
| 8 | + |
| 9 | + |
| 10 | +@patch.object(sys.modules["pyhf.tensor.common"], "default_backend", new=jax_backend) |
| 11 | +@patch.object(sys.modules["pyhf.pdf"], "default_backend", new=jax_backend) |
| 12 | +@patch("pyhf.default_backend", new=jax_backend) |
| 13 | +@patch.object( |
| 14 | + sys.modules["pyhf.interpolators.code0"], "default_backend", new=jax_backend |
| 15 | +) |
| 16 | +@patch.object( |
| 17 | + sys.modules["pyhf.interpolators.code1"], "default_backend", new=jax_backend |
| 18 | +) |
| 19 | +@patch.object( |
| 20 | + sys.modules["pyhf.interpolators.code2"], "default_backend", new=jax_backend |
| 21 | +) |
| 22 | +@patch.object( |
| 23 | + sys.modules["pyhf.interpolators.code4"], "default_backend", new=jax_backend |
| 24 | +) |
| 25 | +@patch.object( |
| 26 | + sys.modules["pyhf.interpolators.code4p"], "default_backend", new=jax_backend |
| 27 | +) |
| 28 | +@patch.object( |
| 29 | + sys.modules["pyhf.modifiers.shapefactor"], "default_backend", new=jax_backend |
| 30 | +) |
| 31 | +@patch.object( |
| 32 | + sys.modules["pyhf.modifiers.shapesys"], "default_backend", new=jax_backend |
| 33 | +) |
| 34 | +@patch.object( |
| 35 | + sys.modules["pyhf.modifiers.staterror"], "default_backend", new=jax_backend |
| 36 | +) |
| 37 | +@patch.object(sys.modules["pyhf.constraints"], "default_backend", new=jax_backend) |
| 38 | +def simplemodel2(s, b_up, b_nom, b_dn): |
| 39 | + spec = { |
| 40 | + "channels": [ |
| 41 | + { |
| 42 | + "name": "singlechannel", |
| 43 | + "samples": [ |
| 44 | + { |
| 45 | + "name": "signal", |
| 46 | + "data": s, |
| 47 | + "modifiers": [ |
| 48 | + {"name": "mu", "type": "normfactor", "data": None} |
| 49 | + ], |
| 50 | + }, |
| 51 | + { |
| 52 | + "name": "background", |
| 53 | + "data": b_nom, |
| 54 | + "modifiers": [ |
| 55 | + { |
| 56 | + "name": "uncorr_bkguncrt", |
| 57 | + "type": "histosys", |
| 58 | + "data": {"hi_data": b_up, "lo_data": b_dn}, |
| 59 | + } |
| 60 | + ], |
| 61 | + }, |
| 62 | + ], |
| 63 | + } |
| 64 | + ] |
| 65 | + } |
| 66 | + return pyhf.Model(spec) |
0 commit comments