phasespace


Namephasespace JSON
Version 1.9.0 PyPI version JSON
download
home_pagehttps://github.com/zfit/phasespace
SummaryTensorFlow implementation of the Raubold and Lynch method for n-body events
upload_time2023-07-20 21:30:49
maintainerzfit
docs_urlNone
authorAlbert Puig Navarro
requires_python>=3.7
licenseBSD-3-Clause
keywords tensorflow phasespace hep
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            *******************************
PhaseSpace
*******************************

.. image:: https://joss.theoj.org/papers/10.21105/joss.01570/status.svg
   :target: https://doi.org/10.21105/joss.01570
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2591993.svg
   :target: https://doi.org/10.5281/zenodo.2591993
.. image:: https://img.shields.io/pypi/status/phasespace.svg
   :target: https://pypi.org/project/phasespace/
.. image:: https://img.shields.io/pypi/pyversions/phasespace.svg
   :target: https://pypi.org/project/phasespace/
.. image:: https://github.com/zfit/phasespace/workflows/tests/badge.svg
   :target: https://github.com/zfit/phasespace/actions/workflows/ci.yml?query=branch%3Amaster
.. image:: https://codecov.io/gh/zfit/phasespace/branch/master/graph/badge.svg
   :target: https://codecov.io/gh/zfit/phasespace
.. image:: https://readthedocs.org/projects/phasespace/badge/?version=stable
   :target: https://phasespace.readthedocs.io/en/latest/?badge=stable
   :alt: Documentation Status
.. image:: https://badges.gitter.im/zfit/phasespace.svg
   :target: https://gitter.im/zfit/phasespace?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
   :alt: Gitter chat
.. image:: https://badge.fury.io/py/phasespace.svg
   :target: https://badge.fury.io/py/phasespace

Python implementation of the Raubold and Lynch method for `n`-body events using
TensorFlow as a backend.

The code is based on the GENBOD function (W515 from CERNLIB), documented in [1]
and tries to follow it as closely as possible.

Detailed documentation, including the API, can be found in https://phasespace.readthedocs.io.
Don't hesitate to join our `gitter`_ channel for questions and comments.

If you use phasespace in a scientific publication we would appreciate citations to the `JOSS`_ publication:

.. code-block:: bibtex

    @article{puig_eschle_phasespace-2019,
      title = {phasespace: n-body phase space generation in Python},
      doi = {10.21105/joss.01570},
      url = {https://doi.org/10.21105/joss.01570},
      year = {2019},
      month = {oct},
      publisher = {The Open Journal},
      author = {Albert Puig and Jonas Eschle},
      journal = {Journal of Open Source Software}
    }

Free software: BSD-3-Clause.

[1]  F. James, Monte Carlo Phase Space, CERN 68-15 (1968)

.. _JOSS: https://joss.theoj.org/papers/10.21105/joss.01570
.. _Gitter: https://gitter.im/zfit/phasespace


Why?
====
Lately, data analysis in High Energy Physics (HEP), traditionally performed within the `ROOT`_ ecosystem,
has been moving more and more towards Python.
The possibility of carrying out purely Python-based analyses has become real thanks to the
development of many open source Python packages,
which have allowed to replace most ROOT functionality with Python-based packages.

One of the aspects where this is still not possible is in the random generation of `n`-body phase space events,
which are widely used in the field, for example to study kinematics
of the particle decays of interest, or to perform importance sampling in the case of complex amplitude models.
This has been traditionally done with the `TGenPhaseSpace`_ class, which is based of the GENBOD function of the
CERNLIB FORTRAN libraries and which requires a full working ROOT installation.

This package aims to address this issue by providing a TensorFlow-based implementation of such a function
to generate `n`-body decays without requiring a ROOT installation.
Additionally, an oft-needed functionality to generate complex decay chains, not included in ``TGenPhaseSpace``,
is also offered, leaving room for decaying resonances (which don't have a fixed mass, but can be seen as a
broad peak).

.. _ROOT: https://root.cern.ch
.. _TGenPhaseSpace: https://root.cern.ch/doc/master/classTGenPhaseSpace.html

Installing
==========

To install with pip:

.. code-block:: console

    $ pip install phasespace

This is the preferred method to install ``phasespace``, as it will always install the most recent stable release.
To install the necessary dependencies to be used with
`DecayLanguage <https://github.com/scikit-hep/decaylanguage>`_, use

.. code-block:: console

    $ pip install "phasespace[fromdecay]"


How to use
==========

Phasespace can directly be used to generate from a DecayChain using the
`DecayLanguage <https://github.com/scikit-hep/decaylanguage>`_ package as
`explained in the tutorial <https://phasespace.readthedocs.io/en/latest/GenMultiDecay_Tutorial.html>`_.

The generation of simple `n`-body decays can be done using the ``nbody_decay`` shortcut to create a decay chain
with a very simple interface: one needs to pass the mass of the top particle and the masses of the children particle as
a list, optionally giving the names of the particles. Then, the ``generate`` method can be used to produce the desired sample.
For example, to generate `B^0\to K\pi`, we would do:

.. code-block:: python

   import phasespace

   B0_MASS = 5279.65
   PION_MASS = 139.57018
   KAON_MASS = 493.677

   weights, particles = phasespace.nbody_decay(B0_MASS,
                                               [PION_MASS, KAON_MASS]).generate(n_events=1000)

Behind the scenes, this function runs the TensorFlow graph. It returns `tf.Tensor`, which, as TensorFlow 2.x is in eager mode,
is basically a numpy array. Any `tf.Tensor` can be explicitly converted to a numpy array by calling `tf.Tensor.numpy()` on it.
The `generate` function returns a `tf.Tensor` of 1000 elements in the case of ``weights`` and a list of
``n particles`` (2) arrays of (1000, 4) shape,
where each of the 4-dimensions corresponds to one of the components of the generated Lorentz 4-vector.
All particles are generated in the rest frame of the top particle; boosting to a certain momentum (or list of momenta) can be
achieved by passing the momenta to the ``boost_to`` argument.

Sequential decays can be handled with the ``GenParticle`` class (used internally by ``generate``) and its ``set_children`` method.
As an example, to build the `B^{0}\to K^{*}\gamma` decay in which `K^*\to K\pi`, we would write:

.. code-block:: python

   from phasespace import GenParticle

   B0_MASS = 5279.65
   KSTARZ_MASS = 895.55
   PION_MASS = 139.57018
   KAON_MASS = 493.677

   kaon = GenParticle('K+', KAON_MASS)
   pion = GenParticle('pi-', PION_MASS)
   kstar = GenParticle('K*', KSTARZ_MASS).set_children(kaon, pion)
   gamma = GenParticle('gamma', 0)
   bz = GenParticle('B0', B0_MASS).set_children(kstar, gamma)

   weights, particles = bz.generate(n_events=1000)

Where we have used the fact that ``set_children`` returns the parent particle.
In this case, ``particles`` is a ``dict`` with the particle names as keys:

.. code-block:: pycon

   >>> particles
   {'K*': array([[ 1732.79325872, -1632.88873127,   950.85807735,  2715.78804872],
          [-1633.95329448,   239.88921123, -1961.0402768 ,  2715.78804872],
          [  407.15613764, -2236.6569286 , -1185.16616251,  2715.78804872],
          ...,
          [ 1091.64603395, -1301.78721269,  1920.07503991,  2715.78804872],
          [ -517.3125083 ,  1901.39296899,  1640.15905194,  2715.78804872],
          [  656.56413668,  -804.76922982,  2343.99214816,  2715.78804872]]),
    'K+': array([[  750.08077976,  -547.22569019,   224.6920906 ,  1075.30490935],
          [-1499.90049089,   289.19714633, -1935.27960292,  2514.43047106],
          [   97.64746732, -1236.68112923,  -381.09526192,  1388.47607911],
          ...,
          [  508.66157459,  -917.93523639,  1474.7064148 ,  1876.11771642],
          [ -212.28646168,   540.26381432,   610.86656669,   976.63988936],
          [  177.16656666,  -535.98777569,   946.12636904,  1207.28744488]]),
    'gamma': array([[-1732.79325872,  1632.88873127,  -950.85807735,  2563.79195128],
          [ 1633.95329448,  -239.88921123,  1961.0402768 ,  2563.79195128],
          [ -407.15613764,  2236.6569286 ,  1185.16616251,  2563.79195128],
          ...,
          [-1091.64603395,  1301.78721269, -1920.07503991,  2563.79195128],
          [  517.3125083 , -1901.39296899, -1640.15905194,  2563.79195128],
          [ -656.56413668,   804.76922982, -2343.99214816,  2563.79195128]]),
    'pi-': array([[  982.71247896, -1085.66304109,   726.16598675,  1640.48313937],
          [ -134.0528036 ,   -49.3079351 ,   -25.76067389,   201.35757766],
          [  309.50867032,  -999.97579937,  -804.0709006 ,  1327.31196961],
          ...,
          [  582.98445936,  -383.85197629,   445.36862511,   839.6703323 ],
          [ -305.02604662,  1361.12915468,  1029.29248526,  1739.14815935],
          [  479.39757002,  -268.78145413,  1397.86577911,  1508.50060384]])}

The `GenParticle` class is able to cache the graphs so it is possible to generate in a loop
without overhead:

.. code-block:: pycon

    for i in range(10):
        weights, particles = bz.generate(n_events=1000)
        ...
        (do something with weights and particles)
        ...

This way of generating is recommended in the case of large samples, as it allows to benefit from
parallelisation while at the same time keep the memory usage low.

If we want to operate with the TensorFlow graph instead, we can use the `generate_tensor` method
of `GenParticle`, which has the same signature as `generate`.

More examples can be found in the ``tests`` folder and in the `documentation`_.

.. _documentation: https://phasespace.readthedocs.io/en/latest/usage.html


Physics validation
==================

Physics validation is performed continuously in the included tests (``tests/test_physics.py``), run through GitHub Actions.
This validation is performed at two levels:

- In simple `n`-body decays, the results of ``phasespace`` are checked against ``TGenPhaseSpace``.
- For sequential decays, the results of ``phasespace`` are checked against `RapidSim`_, a "fast Monte Carlo generator
  for simulation of heavy-quark hadron decays".
  In the case of resonances, differences are expected because our tests don't include proper modelling of their
  mass shape, as it would require the introduction of
  further dependencies. However, the results of the comparison can be expected visually.

The results of all physics validation performed by the ``tests_physics.py`` test are written in ``tests/plots``.

.. _RapidSim: https://github.com/gcowan/RapidSim/


Contributing
============

Contributions are always welcome, please have a look at the `Contributing guide`_.

.. _Contributing guide: CONTRIBUTING.rst


*********
Changelog
*********

Develop
==========


Major Features and Improvements
-------------------------------

Behavioral changes
------------------


Bug fixes and small changes
---------------------------

Requirement changes
-------------------


Thanks
------
1.9.0 (20 Jul 2023)
===================

Add support for Python 3.11, drop support for 3.7

1.8.0 (27 Jan 2023)
===================

Requirement changes
-------------------
- upgrade to zfit >= 0.10.0 and zfit-physics >= 0.3.0
- pinning uproot and awkward to ~4 and ~1, respectively


1.7.0 (1. Sep 2022)
====================

Upgraded Python and TensorFlow version.

Added ``tf`` and ``tensorflow`` extra to requirements. If you intend to use
phasespace with TensorFlow in the future (and not another backend like numpy or JAX),
make sure to always install with ``phasespace[tf]``.

Requirement changes
-------------------
- upgrade to TensorFlow >= 2.7
- Python from 3.7 to 3.10 is now supported

1.6.0 (14 Apr 2022)
====================

Major Features and Improvements
-------------------------------
- Improved GenMultiDecay to have better control on the decay mass of non-stable particles.
- Added a `particle_model_map` argument to the `GenMultiDecay` class. This is a
  dict where the key is a particle name and the value is a mass function name.
  The feature can be seen in the
  `GenMultiDecay Tutorial <https://github.com/zfit/phasespace/blob/master/docs/GenMultiDecay_Tutorial.ipynb>`_.


1.5.0 (27 Nov 2021)
===================


Major Features and Improvements
-------------------------------
- add support to generate from a DecayChain using
  `the decaylanguage <https://github.com/scikit-hep/decaylanguage>`_ package from Scikit-HEP.
  This is in the new subpackage "fromdecay" and can be used by installing the extra with
  ``pip install phasespace[fromdecay]``.


Requirement changes
-------------------
- drop Python 3.6 support


Thanks
------
- to Simon Thor for contributing the ``fromdecay`` subpackage.

1.4.2 (5.11.2021)
==================

Requirement changes
-------------------
- Losen restriction on TensorFlow, allow version 2.7 (and 2.5, 2.6)

1.4.1 (27.08.2021)
==================

Requirement changes
-------------------
- Losen restriction on TensorFlow, allow version 2.6 (and 2.5)

1.4.0 (11.06.2021)
==================

Requirement changes
-------------------
- require TensorFlow 2.5 as 2.4 breaks some functionality

1.3.0 (28.05.2021)
===================


Major Features and Improvements
-------------------------------

- Support Python 3.9
- Support TensorFlow 2.5
- improved compilation in tf.functions, use of XLA where applicable
- developer: modernization of setup, CI and more

Thanks
------

- Remco de Boer for many commits and cleanups

1.2.0 (17.12.20)
================


Major Features and Improvements
-------------------------------

- Python 3.8 support
- Allow eager execution by setting with `tf.config.run_functions_eagerly(True)`
  or the environment variable "PHASESPACE_EAGER"
- Deterministic random number generation via seed
  or `tf.random.Generator` instance

Behavioral changes
------------------


Bug fixes and small changes
---------------------------

Requirement changes
-------------------

- tighten TensorFlow to 2.3/2.4
- tighten TensorFlow Probability to 0.11/0.12

Thanks
------
- Remco de Boer and Stefan Pflüger for discussions on random number genration

1.1.0 (27.1.2020)
=================

This release switched to TensorFlow 2.0 eager mode. Please upgrade your TensorFlow installation if possible and change
your code (minimal changes) as described under "Behavioral changes".
In case this is currently impossible to do, please downgrade to < 1.1.0.

Major Features and Improvements
-------------------------------
 - full TF2 compatibility

Behavioral changes
------------------
 - `generate` now returns an eager Tensor. This is basically a numpy array wrapped by TensorFlow.
   To explicitly convert it to a numpy array, use the `numpy()` method of the eager Tensor.
 - `generate_tensor` is now depreceated, `generate` can directly be used instead.


Bug fixes and small changes
---------------------------

Requirement changes
-------------------
 - requires now TensorFlow >= 2.0.0


Thanks
------


1.0.4 (13-10-2019)
==========================


Major Features and Improvements
-------------------------------

Release to conda-forge, thanks to Chris Burr

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/zfit/phasespace",
    "name": "phasespace",
    "maintainer": "zfit",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "zfit@physik.uzh.ch",
    "keywords": "TensorFlow,phasespace,HEP",
    "author": "Albert Puig Navarro",
    "author_email": "apuignav@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e5/e6/1ece012055ef092699cb098b96b4a111a81d340f6ab0e94d0b9d72bb7a14/phasespace-1.9.0.tar.gz",
    "platform": null,
    "description": "*******************************\nPhaseSpace\n*******************************\n\n.. image:: https://joss.theoj.org/papers/10.21105/joss.01570/status.svg\n   :target: https://doi.org/10.21105/joss.01570\n.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2591993.svg\n   :target: https://doi.org/10.5281/zenodo.2591993\n.. image:: https://img.shields.io/pypi/status/phasespace.svg\n   :target: https://pypi.org/project/phasespace/\n.. image:: https://img.shields.io/pypi/pyversions/phasespace.svg\n   :target: https://pypi.org/project/phasespace/\n.. image:: https://github.com/zfit/phasespace/workflows/tests/badge.svg\n   :target: https://github.com/zfit/phasespace/actions/workflows/ci.yml?query=branch%3Amaster\n.. image:: https://codecov.io/gh/zfit/phasespace/branch/master/graph/badge.svg\n   :target: https://codecov.io/gh/zfit/phasespace\n.. image:: https://readthedocs.org/projects/phasespace/badge/?version=stable\n   :target: https://phasespace.readthedocs.io/en/latest/?badge=stable\n   :alt: Documentation Status\n.. image:: https://badges.gitter.im/zfit/phasespace.svg\n   :target: https://gitter.im/zfit/phasespace?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge\n   :alt: Gitter chat\n.. image:: https://badge.fury.io/py/phasespace.svg\n   :target: https://badge.fury.io/py/phasespace\n\nPython implementation of the Raubold and Lynch method for `n`-body events using\nTensorFlow as a backend.\n\nThe code is based on the GENBOD function (W515 from CERNLIB), documented in [1]\nand tries to follow it as closely as possible.\n\nDetailed documentation, including the API, can be found in https://phasespace.readthedocs.io.\nDon't hesitate to join our `gitter`_ channel for questions and comments.\n\nIf you use phasespace in a scientific publication we would appreciate citations to the `JOSS`_ publication:\n\n.. code-block:: bibtex\n\n    @article{puig_eschle_phasespace-2019,\n      title = {phasespace: n-body phase space generation in Python},\n      doi = {10.21105/joss.01570},\n      url = {https://doi.org/10.21105/joss.01570},\n      year = {2019},\n      month = {oct},\n      publisher = {The Open Journal},\n      author = {Albert Puig and Jonas Eschle},\n      journal = {Journal of Open Source Software}\n    }\n\nFree software: BSD-3-Clause.\n\n[1]  F. James, Monte Carlo Phase Space, CERN 68-15 (1968)\n\n.. _JOSS: https://joss.theoj.org/papers/10.21105/joss.01570\n.. _Gitter: https://gitter.im/zfit/phasespace\n\n\nWhy?\n====\nLately, data analysis in High Energy Physics (HEP), traditionally performed within the `ROOT`_ ecosystem,\nhas been moving more and more towards Python.\nThe possibility of carrying out purely Python-based analyses has become real thanks to the\ndevelopment of many open source Python packages,\nwhich have allowed to replace most ROOT functionality with Python-based packages.\n\nOne of the aspects where this is still not possible is in the random generation of `n`-body phase space events,\nwhich are widely used in the field, for example to study kinematics\nof the particle decays of interest, or to perform importance sampling in the case of complex amplitude models.\nThis has been traditionally done with the `TGenPhaseSpace`_ class, which is based of the GENBOD function of the\nCERNLIB FORTRAN libraries and which requires a full working ROOT installation.\n\nThis package aims to address this issue by providing a TensorFlow-based implementation of such a function\nto generate `n`-body decays without requiring a ROOT installation.\nAdditionally, an oft-needed functionality to generate complex decay chains, not included in ``TGenPhaseSpace``,\nis also offered, leaving room for decaying resonances (which don't have a fixed mass, but can be seen as a\nbroad peak).\n\n.. _ROOT: https://root.cern.ch\n.. _TGenPhaseSpace: https://root.cern.ch/doc/master/classTGenPhaseSpace.html\n\nInstalling\n==========\n\nTo install with pip:\n\n.. code-block:: console\n\n    $ pip install phasespace\n\nThis is the preferred method to install ``phasespace``, as it will always install the most recent stable release.\nTo install the necessary dependencies to be used with\n`DecayLanguage <https://github.com/scikit-hep/decaylanguage>`_, use\n\n.. code-block:: console\n\n    $ pip install \"phasespace[fromdecay]\"\n\n\nHow to use\n==========\n\nPhasespace can directly be used to generate from a DecayChain using the\n`DecayLanguage <https://github.com/scikit-hep/decaylanguage>`_ package as\n`explained in the tutorial <https://phasespace.readthedocs.io/en/latest/GenMultiDecay_Tutorial.html>`_.\n\nThe generation of simple `n`-body decays can be done using the ``nbody_decay`` shortcut to create a decay chain\nwith a very simple interface: one needs to pass the mass of the top particle and the masses of the children particle as\na list, optionally giving the names of the particles. Then, the ``generate`` method can be used to produce the desired sample.\nFor example, to generate `B^0\\to K\\pi`, we would do:\n\n.. code-block:: python\n\n   import phasespace\n\n   B0_MASS = 5279.65\n   PION_MASS = 139.57018\n   KAON_MASS = 493.677\n\n   weights, particles = phasespace.nbody_decay(B0_MASS,\n                                               [PION_MASS, KAON_MASS]).generate(n_events=1000)\n\nBehind the scenes, this function runs the TensorFlow graph. It returns `tf.Tensor`, which, as TensorFlow 2.x is in eager mode,\nis basically a numpy array. Any `tf.Tensor` can be explicitly converted to a numpy array by calling `tf.Tensor.numpy()` on it.\nThe `generate` function returns a `tf.Tensor` of 1000 elements in the case of ``weights`` and a list of\n``n particles`` (2) arrays of (1000, 4) shape,\nwhere each of the 4-dimensions corresponds to one of the components of the generated Lorentz 4-vector.\nAll particles are generated in the rest frame of the top particle; boosting to a certain momentum (or list of momenta) can be\nachieved by passing the momenta to the ``boost_to`` argument.\n\nSequential decays can be handled with the ``GenParticle`` class (used internally by ``generate``) and its ``set_children`` method.\nAs an example, to build the `B^{0}\\to K^{*}\\gamma` decay in which `K^*\\to K\\pi`, we would write:\n\n.. code-block:: python\n\n   from phasespace import GenParticle\n\n   B0_MASS = 5279.65\n   KSTARZ_MASS = 895.55\n   PION_MASS = 139.57018\n   KAON_MASS = 493.677\n\n   kaon = GenParticle('K+', KAON_MASS)\n   pion = GenParticle('pi-', PION_MASS)\n   kstar = GenParticle('K*', KSTARZ_MASS).set_children(kaon, pion)\n   gamma = GenParticle('gamma', 0)\n   bz = GenParticle('B0', B0_MASS).set_children(kstar, gamma)\n\n   weights, particles = bz.generate(n_events=1000)\n\nWhere we have used the fact that ``set_children`` returns the parent particle.\nIn this case, ``particles`` is a ``dict`` with the particle names as keys:\n\n.. code-block:: pycon\n\n   >>> particles\n   {'K*': array([[ 1732.79325872, -1632.88873127,   950.85807735,  2715.78804872],\n          [-1633.95329448,   239.88921123, -1961.0402768 ,  2715.78804872],\n          [  407.15613764, -2236.6569286 , -1185.16616251,  2715.78804872],\n          ...,\n          [ 1091.64603395, -1301.78721269,  1920.07503991,  2715.78804872],\n          [ -517.3125083 ,  1901.39296899,  1640.15905194,  2715.78804872],\n          [  656.56413668,  -804.76922982,  2343.99214816,  2715.78804872]]),\n    'K+': array([[  750.08077976,  -547.22569019,   224.6920906 ,  1075.30490935],\n          [-1499.90049089,   289.19714633, -1935.27960292,  2514.43047106],\n          [   97.64746732, -1236.68112923,  -381.09526192,  1388.47607911],\n          ...,\n          [  508.66157459,  -917.93523639,  1474.7064148 ,  1876.11771642],\n          [ -212.28646168,   540.26381432,   610.86656669,   976.63988936],\n          [  177.16656666,  -535.98777569,   946.12636904,  1207.28744488]]),\n    'gamma': array([[-1732.79325872,  1632.88873127,  -950.85807735,  2563.79195128],\n          [ 1633.95329448,  -239.88921123,  1961.0402768 ,  2563.79195128],\n          [ -407.15613764,  2236.6569286 ,  1185.16616251,  2563.79195128],\n          ...,\n          [-1091.64603395,  1301.78721269, -1920.07503991,  2563.79195128],\n          [  517.3125083 , -1901.39296899, -1640.15905194,  2563.79195128],\n          [ -656.56413668,   804.76922982, -2343.99214816,  2563.79195128]]),\n    'pi-': array([[  982.71247896, -1085.66304109,   726.16598675,  1640.48313937],\n          [ -134.0528036 ,   -49.3079351 ,   -25.76067389,   201.35757766],\n          [  309.50867032,  -999.97579937,  -804.0709006 ,  1327.31196961],\n          ...,\n          [  582.98445936,  -383.85197629,   445.36862511,   839.6703323 ],\n          [ -305.02604662,  1361.12915468,  1029.29248526,  1739.14815935],\n          [  479.39757002,  -268.78145413,  1397.86577911,  1508.50060384]])}\n\nThe `GenParticle` class is able to cache the graphs so it is possible to generate in a loop\nwithout overhead:\n\n.. code-block:: pycon\n\n    for i in range(10):\n        weights, particles = bz.generate(n_events=1000)\n        ...\n        (do something with weights and particles)\n        ...\n\nThis way of generating is recommended in the case of large samples, as it allows to benefit from\nparallelisation while at the same time keep the memory usage low.\n\nIf we want to operate with the TensorFlow graph instead, we can use the `generate_tensor` method\nof `GenParticle`, which has the same signature as `generate`.\n\nMore examples can be found in the ``tests`` folder and in the `documentation`_.\n\n.. _documentation: https://phasespace.readthedocs.io/en/latest/usage.html\n\n\nPhysics validation\n==================\n\nPhysics validation is performed continuously in the included tests (``tests/test_physics.py``), run through GitHub Actions.\nThis validation is performed at two levels:\n\n- In simple `n`-body decays, the results of ``phasespace`` are checked against ``TGenPhaseSpace``.\n- For sequential decays, the results of ``phasespace`` are checked against `RapidSim`_, a \"fast Monte Carlo generator\n  for simulation of heavy-quark hadron decays\".\n  In the case of resonances, differences are expected because our tests don't include proper modelling of their\n  mass shape, as it would require the introduction of\n  further dependencies. However, the results of the comparison can be expected visually.\n\nThe results of all physics validation performed by the ``tests_physics.py`` test are written in ``tests/plots``.\n\n.. _RapidSim: https://github.com/gcowan/RapidSim/\n\n\nContributing\n============\n\nContributions are always welcome, please have a look at the `Contributing guide`_.\n\n.. _Contributing guide: CONTRIBUTING.rst\n\n\n*********\nChangelog\n*********\n\nDevelop\n==========\n\n\nMajor Features and Improvements\n-------------------------------\n\nBehavioral changes\n------------------\n\n\nBug fixes and small changes\n---------------------------\n\nRequirement changes\n-------------------\n\n\nThanks\n------\n1.9.0 (20 Jul 2023)\n===================\n\nAdd support for Python 3.11, drop support for 3.7\n\n1.8.0 (27 Jan 2023)\n===================\n\nRequirement changes\n-------------------\n- upgrade to zfit >= 0.10.0 and zfit-physics >= 0.3.0\n- pinning uproot and awkward to ~4 and ~1, respectively\n\n\n1.7.0 (1. Sep 2022)\n====================\n\nUpgraded Python and TensorFlow version.\n\nAdded ``tf`` and ``tensorflow`` extra to requirements. If you intend to use\nphasespace with TensorFlow in the future (and not another backend like numpy or JAX),\nmake sure to always install with ``phasespace[tf]``.\n\nRequirement changes\n-------------------\n- upgrade to TensorFlow >= 2.7\n- Python from 3.7 to 3.10 is now supported\n\n1.6.0 (14 Apr 2022)\n====================\n\nMajor Features and Improvements\n-------------------------------\n- Improved GenMultiDecay to have better control on the decay mass of non-stable particles.\n- Added a `particle_model_map` argument to the `GenMultiDecay` class. This is a\n  dict where the key is a particle name and the value is a mass function name.\n  The feature can be seen in the\n  `GenMultiDecay Tutorial <https://github.com/zfit/phasespace/blob/master/docs/GenMultiDecay_Tutorial.ipynb>`_.\n\n\n1.5.0 (27 Nov 2021)\n===================\n\n\nMajor Features and Improvements\n-------------------------------\n- add support to generate from a DecayChain using\n  `the decaylanguage <https://github.com/scikit-hep/decaylanguage>`_ package from Scikit-HEP.\n  This is in the new subpackage \"fromdecay\" and can be used by installing the extra with\n  ``pip install phasespace[fromdecay]``.\n\n\nRequirement changes\n-------------------\n- drop Python 3.6 support\n\n\nThanks\n------\n- to Simon Thor for contributing the ``fromdecay`` subpackage.\n\n1.4.2 (5.11.2021)\n==================\n\nRequirement changes\n-------------------\n- Losen restriction on TensorFlow, allow version 2.7 (and 2.5, 2.6)\n\n1.4.1 (27.08.2021)\n==================\n\nRequirement changes\n-------------------\n- Losen restriction on TensorFlow, allow version 2.6 (and 2.5)\n\n1.4.0 (11.06.2021)\n==================\n\nRequirement changes\n-------------------\n- require TensorFlow 2.5 as 2.4 breaks some functionality\n\n1.3.0 (28.05.2021)\n===================\n\n\nMajor Features and Improvements\n-------------------------------\n\n- Support Python 3.9\n- Support TensorFlow 2.5\n- improved compilation in tf.functions, use of XLA where applicable\n- developer: modernization of setup, CI and more\n\nThanks\n------\n\n- Remco de Boer for many commits and cleanups\n\n1.2.0 (17.12.20)\n================\n\n\nMajor Features and Improvements\n-------------------------------\n\n- Python 3.8 support\n- Allow eager execution by setting with `tf.config.run_functions_eagerly(True)`\n  or the environment variable \"PHASESPACE_EAGER\"\n- Deterministic random number generation via seed\n  or `tf.random.Generator` instance\n\nBehavioral changes\n------------------\n\n\nBug fixes and small changes\n---------------------------\n\nRequirement changes\n-------------------\n\n- tighten TensorFlow to 2.3/2.4\n- tighten TensorFlow Probability to 0.11/0.12\n\nThanks\n------\n- Remco de Boer and Stefan Pfl\u00fcger for discussions on random number genration\n\n1.1.0 (27.1.2020)\n=================\n\nThis release switched to TensorFlow 2.0 eager mode. Please upgrade your TensorFlow installation if possible and change\nyour code (minimal changes) as described under \"Behavioral changes\".\nIn case this is currently impossible to do, please downgrade to < 1.1.0.\n\nMajor Features and Improvements\n-------------------------------\n - full TF2 compatibility\n\nBehavioral changes\n------------------\n - `generate` now returns an eager Tensor. This is basically a numpy array wrapped by TensorFlow.\n   To explicitly convert it to a numpy array, use the `numpy()` method of the eager Tensor.\n - `generate_tensor` is now depreceated, `generate` can directly be used instead.\n\n\nBug fixes and small changes\n---------------------------\n\nRequirement changes\n-------------------\n - requires now TensorFlow >= 2.0.0\n\n\nThanks\n------\n\n\n1.0.4 (13-10-2019)\n==========================\n\n\nMajor Features and Improvements\n-------------------------------\n\nRelease to conda-forge, thanks to Chris Burr\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "TensorFlow implementation of the Raubold and Lynch method for n-body events",
    "version": "1.9.0",
    "project_urls": {
        "Homepage": "https://github.com/zfit/phasespace"
    },
    "split_keywords": [
        "tensorflow",
        "phasespace",
        "hep"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3fdbfd56d343c6332896df77dfd0e47661dd5071cde5de6af67ae4a3f8e244c",
                "md5": "84472be29d99225ca5e0ec8d475e2c66",
                "sha256": "8ae3190d9ac51148ccf16d9ca076f6e7ac9df7ff3d7bf9a55ed857fb9a0e390e"
            },
            "downloads": -1,
            "filename": "phasespace-1.9.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "84472be29d99225ca5e0ec8d475e2c66",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.7",
            "size": 39187,
            "upload_time": "2023-07-20T21:30:46",
            "upload_time_iso_8601": "2023-07-20T21:30:46.465376Z",
            "url": "https://files.pythonhosted.org/packages/f3/fd/bfd56d343c6332896df77dfd0e47661dd5071cde5de6af67ae4a3f8e244c/phasespace-1.9.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e5e61ece012055ef092699cb098b96b4a111a81d340f6ab0e94d0b9d72bb7a14",
                "md5": "b619653448465b88c63f8eec98765186",
                "sha256": "0b6ce3afc027a819f011b0dbbb164f0164e5f276d8ed7b47d8ff14ea9e59dbb2"
            },
            "downloads": -1,
            "filename": "phasespace-1.9.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b619653448465b88c63f8eec98765186",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 30449661,
            "upload_time": "2023-07-20T21:30:49",
            "upload_time_iso_8601": "2023-07-20T21:30:49.736352Z",
            "url": "https://files.pythonhosted.org/packages/e5/e6/1ece012055ef092699cb098b96b4a111a81d340f6ab0e94d0b9d72bb7a14/phasespace-1.9.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-20 21:30:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "zfit",
    "github_project": "phasespace",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "phasespace"
}
        
Elapsed time: 0.08884s