Skip to content

Commit

Permalink
Add pyhf.default_backend
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewfeickert committed Sep 22, 2022
1 parent a14fdd4 commit 7d836f8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/release-notes/v0.7.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ This is a minor release from ``v0.6.3`` → ``v0.7.0``.
Important Notes
---------------

* A `pyhf.default_backend` has been added that is configurable through a
``default`` kwarg in :func:`pyhf.set_backend`.
(PR :pr:`1646`)
* All backends are now fully compatible and tested with
`Python 3.10 <https://peps.python.org/pep-0310/>`_.
(PR :pr:`1809`)
Expand Down Expand Up @@ -60,6 +63,31 @@ Python API
... data, model, scan, return_results=True, calctype="toybased", ntoys=3000
... )
* A ``pyhf.default_backend`` has been added that is configurable through a
``default`` kwarg in :func:`pyhf.set_backend`.
(PR :pr:`1646`)
This allows setting setting the ``pyhf.default_backend`` to be different from the value of
``pyhf.tensorlib`` returned by :func:`pyhf.get_backend`, which can be useful in situations where
a model construction is needed.

.. code:: pycon
>>> import jax
>>> import pyhf
>>> pyhf.set_backend("jax", default=True)
>>> pyhf.set_backend("numpy")
>>> pyhf.get_backend()
(<pyhf.tensor.numpy_backend.numpy_backend object at 0x...>, <pyhf.optimize.scipy_optimizer object at 0x...>)
>>> pyhf.default_backend
<pyhf.tensor.jax_backend.jax_backend object at 0x...>
>>> def example_op(x):
... return 2 * pyhf.default_backend.power(pyhf.default_backend.astensor(x), 3)
...
>>> example_op([2.0])
DeviceArray([16.], dtype=float64)
>>> jax.jacrev(jax.jit(example_op))([2.0])
[DeviceArray([24.], dtype=float64, weak_type=True)]
Deprecations
------------

Expand Down

0 comments on commit 7d836f8

Please sign in to comment.