Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-particle for openSUSE:Factory
checked in at 2023-01-24 19:43:50
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-particle (Old)
and /work/SRC/openSUSE:Factory/.python-particle.new.32243 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-particle"
Tue Jan 24 19:43:50 2023 rev:13 rq:1060616 version:0.21.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-particle/python-particle.changes
2022-05-02 16:25:40.508845251 +0200
+++
/work/SRC/openSUSE:Factory/.python-particle.new.32243/python-particle.changes
2023-01-24 20:32:32.260440308 +0100
@@ -1,0 +2,20 @@
+Tue Jan 24 09:56:11 UTC 2023 - Matej Cepl <[email protected]>
+
+- Switch to %pyproject_wheel/install, there is no need to create
+ setup.py manually.
+
+-------------------------------------------------------------------
+Mon Jan 23 19:57:57 UTC 2023 - Atri Bhattacharya <[email protected]>
+
+- Update to version 0.21.1:
+ * Particle class and submodules: Better test coverage.
+ * PDGID class method and related standalone functions:
+ - Minor code simplifications.
+ - Significant improvements to test coverage.
+ * README: info added on how to create user-defined particles.
+- Update tests.tar.xz to tag 0.21.1.
+- Create a basic setup.py file to allow building and installation.
+- Manually copy missed data files into buildroot.
+- Disable python3.6 building, no longer supported by upstream.
+
+-------------------------------------------------------------------
Old:
----
particle-0.20.1.tar.gz
New:
----
particle-0.21.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-particle.spec ++++++
--- /var/tmp/diff_new_pack.JPMhw7/_old 2023-01-24 20:32:33.016444309 +0100
+++ /var/tmp/diff_new_pack.JPMhw7/_new 2023-01-24 20:32:33.036444415 +0100
@@ -1,7 +1,7 @@
#
# spec file for package python-particle
#
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -18,8 +18,9 @@
%global modname particle
%define skip_python2 1
+%define skip_python36 1
Name: python-particle
-Version: 0.20.1
+Version: 0.21.1
Release: 0
Summary: PDG particle data and identification codes
License: BSD-3-Clause
@@ -27,9 +28,12 @@
Source0:
https://files.pythonhosted.org/packages/source/p/particle/%{modname}-%{version}.tar.gz
# Downloaded separately from github using _service file
Source1: tests.tar.xz
+BuildRequires: %{python_module hatch_vcs}
+BuildRequires: %{python_module hatchling}
+BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools_scm}
-BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module toml}
+BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-attrs >= 19.2
@@ -56,10 +60,14 @@
sed -Ei "1{/^#!\/usr\/bin\/env python/d}" src/particle/__main__.py
%build
-%python_build
+%pyproject_wheel
%install
-%python_install
+%pyproject_install
+%{python_expand # Copy missed files
+cp -R src/particle/data %{buildroot}%{$python_sitelib}/%{modname}/
+cp -R src/particle/lhcb %{buildroot}%{$python_sitelib}/%{modname}/
+}
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%check
@@ -68,7 +76,7 @@
%files %{python_files}
%doc README.rst
%license LICENSE
-%{python_sitelib}/%{modname}/
-%{python_sitelib}/%{modname}-%{version}-py%{python_version}.egg-info/
+%{python_sitelib}/%{modname}
+%{python_sitelib}/%{modname}-%{version}*-info/
%changelog
++++++ _service ++++++
--- /var/tmp/diff_new_pack.JPMhw7/_old 2023-01-24 20:32:33.084444669 +0100
+++ /var/tmp/diff_new_pack.JPMhw7/_new 2023-01-24 20:32:33.088444691 +0100
@@ -2,7 +2,7 @@
<service name="tar_scm" mode="disabled">
<param
name="url">https://github.com/scikit-hep/particle.git</param>
<param name="scm">git</param>
- <param name="revision">v0.20.0</param>
+ <param name="revision">v0.21.1</param>
<param name="subdir">tests</param>
<param name="version">_none_</param>
<param name="filename">tests</param>
++++++ particle-0.20.1.tar.gz -> particle-0.21.1.tar.gz ++++++
++++ 8340 lines of diff (skipped)
++++++ tests.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/__init__.py new/tests/__init__.py
--- old/tests/__init__.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/__init__.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/conftest.py new/tests/conftest.py
--- old/tests/conftest.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/conftest.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
from enum import IntEnum
import pytest
@@ -122,6 +124,13 @@
AntiElectronStar = -4000011
# Generator specific pseudoparticles or concepts
AntiCHadron = -84
+ GenSpecific910 = 910
+ GenSpecific999 = 999
+ GenSpecific1910 = 1910
+ GenSpecific2910 = 2910
+ GenSpecific3910 = 3910
+ OpticalPhoton = 20022
+ Geantino = 480000000
# Invalid ID
Invalid1 = 0 # illegal ID
Invalid2 = 99999999 # general form is a 7-digit number
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/converters/__init__.py
new/tests/converters/__init__.py
--- old/tests/converters/__init__.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/converters/__init__.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/converters/test_corsika.py
new/tests/converters/test_corsika.py
--- old/tests/converters/test_corsika.py 1970-01-01 01:00:00.000000000
+0100
+++ new/tests/converters/test_corsika.py 2023-01-04 12:06:53.000000000
+0100
@@ -0,0 +1,22 @@
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
+#
+# Distributed under the 3-clause BSD license, see accompanying file LICENSE
+# or https://github.com/scikit-hep/particle for details.
+
+from __future__ import annotations
+
+from particle import PDGID, Corsika7ID, Particle
+from particle.converters import Corsika72PDGIDBiMap
+
+
+def test_Corsika72PDGID():
+ pdgid = Corsika72PDGIDBiMap[Corsika7ID(5)]
+ assert pdgid == -13
+
+ cid = Corsika72PDGIDBiMap[PDGID(13)]
+ assert cid.is_particle()
+ assert cid == 6
+
+ p = Particle.from_pdgid(cid.to_pdgid())
+ # should be muon
+ assert p.charge == -1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/converters/test_maps.py
new/tests/converters/test_maps.py
--- old/tests/converters/test_maps.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/converters/test_maps.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
from particle import data
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/corsika/__init__.py
new/tests/corsika/__init__.py
--- old/tests/corsika/__init__.py 1970-01-01 01:00:00.000000000 +0100
+++ new/tests/corsika/__init__.py 2023-01-04 12:06:53.000000000 +0100
@@ -0,0 +1,4 @@
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
+#
+# Distributed under the 3-clause BSD license, see accompanying file LICENSE
+# or https://github.com/scikit-hep/particle for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/corsika/test_corsika7id.py
new/tests/corsika/test_corsika7id.py
--- old/tests/corsika/test_corsika7id.py 1970-01-01 01:00:00.000000000
+0100
+++ new/tests/corsika/test_corsika7id.py 2023-01-04 12:06:53.000000000
+0100
@@ -0,0 +1,51 @@
+from __future__ import annotations
+
+import pytest
+
+from particle.corsika import Corsika7ID
+from particle.exceptions import MatchingIDNotFound
+from particle.pdgid import PDGID
+
+
+def test_class_string_representations():
+ pid = Corsika7ID(1)
+ assert pid == 1
+ assert pid.__str__() == "<Corsika7ID: 1>"
+
+
+def test_class_return_type():
+ assert isinstance(Corsika7ID(3), Corsika7ID)
+
+
+def test_from_pdgid():
+ assert Corsika7ID.from_pdgid(-13) == 5
+
+ assert Corsika7ID.from_pdgid(PDGID(-13)) == 5
+ assert Corsika7ID.from_pdgid(PDGID(13)) == Corsika7ID(6)
+
+
+def test_from_pdgid_non_matching():
+ with pytest.raises(MatchingIDNotFound):
+ Corsika7ID.from_pdgid(55)
+
+
+def test_to_pdgid():
+ cid = Corsika7ID(5)
+ assert cid.to_pdgid() == -13
+ assert cid.to_pdgid() == PDGID(-13)
+
+
+def test_is_particle():
+ cid = Corsika7ID(1)
+ assert cid.is_particle()
+ cid = Corsika7ID(75)
+ assert not cid.is_particle()
+
+
+def test_from_particle_description():
+ cid, is_mother = Corsika7ID.from_particle_description(-6001)
+ assert is_mother
+ assert cid.is_particle()
+ cid, is_mother = Corsika7ID.from_particle_description(75001)
+ assert not is_mother
+ assert not cid.is_particle()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/geant/__init__.py new/tests/geant/__init__.py
--- old/tests/geant/__init__.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/geant/__init__.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/geant/test_geant3id.py
new/tests/geant/test_geant3id.py
--- old/tests/geant/test_geant3id.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/geant/test_geant3id.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
from particle.exceptions import MatchingIDNotFound
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/lhcb/test_lhcb_name.py
new/tests/lhcb/test_lhcb_name.py
--- old/tests/lhcb/test_lhcb_name.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/lhcb/test_lhcb_name.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
from particle import Particle
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/__init__.py
new/tests/particle/__init__.py
--- old/tests/particle/__init__.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/particle/__init__.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_convert.py
new/tests/particle/test_convert.py
--- old/tests/particle/test_convert.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/particle/test_convert.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
# Requires pandas
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_decfilenames.py
new/tests/particle/test_decfilenames.py
--- old/tests/particle/test_decfilenames.py 2022-01-15 18:07:50.000000000
+0100
+++ new/tests/particle/test_decfilenames.py 2023-01-04 12:06:53.000000000
+0100
@@ -1,9 +1,11 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
from particle.particle import Particle, ParticleNotFound
# All particle names found in DECAY.DEC
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_enums.py
new/tests/particle/test_enums.py
--- old/tests/particle/test_enums.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/particle/test_enums.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,9 +1,11 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
from particle.particle.enums import Charge, SpinType
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_generation.py
new/tests/particle/test_generation.py
--- old/tests/particle/test_generation.py 2022-01-15 18:07:50.000000000
+0100
+++ new/tests/particle/test_generation.py 2023-01-04 12:06:53.000000000
+0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
# Requires pandas
@@ -13,16 +15,16 @@
from particle import data
from particle.particle.convert import produce_files
-FILES = ["particle2020.csv", "particle2021.csv"]
+FILES = ["particle2021.csv", "particle2022.csv"]
def test_generate(tmp_path):
"This verifies that the input and output files match."
- particle2020 = tmp_path / "particle2020.csv"
particle2021 = tmp_path / "particle2021.csv"
+ particle2022 = tmp_path / "particle2022.csv"
- produce_files(particle2020, particle2021, "DUMMY", "2021")
+ produce_files(particle2021, particle2022, "DUMMY", "2022")
"""
# No longer test this file, which eventually will be removed
@@ -33,8 +35,8 @@
assert src == res
"""
- particle2021_data = data.basepath / "particle2021.csv"
- with particle2021.open() as src, particle2021_data.open() as res:
+ particle2022_data = data.basepath / "particle2022.csv"
+ with particle2022.open() as src, particle2022_data.open() as res:
src = [line for line in src.readlines() if not line.startswith("#")]
res = [line for line in res.readlines() if not line.startswith("#")]
assert src == res
@@ -42,8 +44,8 @@
@pytest.mark.parametrize("filename", FILES)
def test_csv_file_duplicates(filename):
- with data.basepath / filename as particle_data:
- p = pd.read_csv(particle_data, comment="#")
+ particle_data = data.basepath / filename
+ p = pd.read_csv(particle_data, comment="#")
duplicates = {item for item, count in Counter(p.ID).items() if count > 1}
assert duplicates == set()
@@ -51,7 +53,7 @@
@pytest.mark.parametrize("filename", FILES)
def test_csv_file_has_latex(filename):
- with data.basepath / filename as particle_data:
- p = pd.read_csv(particle_data, comment="#")
+ particle_data = data.basepath / filename
+ p = pd.read_csv(particle_data, comment="#")
assert p[p.Latex == ""].empty
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_kinematics.py
new/tests/particle/test_kinematics.py
--- old/tests/particle/test_kinematics.py 2022-01-15 18:07:50.000000000
+0100
+++ new/tests/particle/test_kinematics.py 2023-01-04 12:06:53.000000000
+0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
from hepunits.constants import hbar
from hepunits.units import GeV, MeV, ps
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_literals.py
new/tests/particle/test_literals.py
--- old/tests/particle/test_literals.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/particle/test_literals.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,9 +1,11 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
from particle import literals as lp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_particle.py
new/tests/particle/test_particle.py
--- old/tests/particle/test_particle.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/particle/test_particle.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,9 +1,11 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
from hepunits import meter, second
from pytest import approx
@@ -145,6 +147,59 @@
assert int(p.pdgid) == 211
+def test_from_name():
+ p = Particle.from_name("pi+")
+ assert p.name == "pi+"
+
+
+def test_from_name_ParticleNotFound():
+ """
+ Exception raised because the name given matches all pions,
+ e.g. pi+, pi-, pi(2)(1670)+, etc.
+ """
+ with pytest.raises(ParticleNotFound):
+ _ = Particle.from_name("pi")
+
+
+def test_from_nucleus_info():
+ p = Particle.from_nucleus_info(1, 2)
+ assert p.pdgid == 1000010020
+ p = Particle.from_nucleus_info(92, 235)
+ assert p.pdgid == 1000922350
+ p = Particle.from_nucleus_info(1, 2, anti=True)
+ assert p.pdgid == -1000010020
+
+
+def test_from_nucleus_info_ParticleNotFound():
+ with pytest.raises(ParticleNotFound):
+ _ = Particle.from_nucleus_info(z=999, a=999)
+
+ # No exited nuclei in database
+ _ = Particle.from_nucleus_info(1, 2, i=1)
+
+
+def test_from_nucleus_info_InvalidParticle():
+ with pytest.raises(InvalidParticle) as e:
+ _ = Particle.from_nucleus_info(z=2, a=1)
+
+ with pytest.raises(InvalidParticle) as e:
+ _ = Particle.from_nucleus_info(z=1, a=1000)
+
+ with pytest.raises(InvalidParticle) as e:
+ _ = Particle.from_nucleus_info(z=1000, a=1)
+
+ with pytest.raises(InvalidParticle) as e:
+ _ = Particle.from_nucleus_info(z=1, a=1, l_strange=999)
+
+ with pytest.raises(InvalidParticle) as e:
+ _ = Particle.from_nucleus_info(z=1, a=1, i=999)
+
+ # No strange nuclei in database and strange PDGID not implemented
+ with pytest.raises(InvalidParticle) as e:
+ _ = Particle.from_nucleus_info(1, 2, l_strange=1)
+ assert str(e.value) == "Input PDGID 1000110020 is invalid!"
+
+
def test_sorting():
assert Particle.from_pdgid(211) < Particle.from_pdgid(311)
assert Particle.from_pdgid(211) < Particle.from_pdgid(-311)
@@ -308,8 +363,6 @@
[423, "Width < 2.1 MeV"], # D*(2007)0
[10431, "Width < 10.0 MeV"], # D(s0)*(2317)+
[20433, "Width < 6.3 MeV"], # D(s1)(2460)+
- [4212, "Width < 4.6 MeV"], # Sigma(c)(2455)+
- [4214, "Width < 17.0 MeV"], # Sigma(c)(2520)+
)
@@ -320,18 +373,18 @@
def test_default_table_loading():
- assert Particle.table_names() == ("particle2021.csv", "nuclei2020.csv")
+ assert Particle.table_names() == ("particle2022.csv", "nuclei2020.csv")
def test_default_table_loading_bis():
Particle.all()
p = Particle.from_pdgid(211)
assert p.table_loaded() is True
- assert p.table_names() == ("particle2021.csv", "nuclei2020.csv")
+ assert p.table_names() == ("particle2022.csv", "nuclei2020.csv")
def test_explicit_table_loading():
- Particle.load_table(data.basepath / "particle2021.csv")
+ Particle.load_table(data.basepath / "particle2022.csv")
assert Particle.table_loaded()
assert len(Particle.table_names()) == 1
assert Particle.all() is not None
@@ -346,6 +399,8 @@
assert len(Particle.all()) == 610
Particle.load_table(data.basepath / "particle2021.csv")
assert len(Particle.all()) == 616
+ Particle.load_table(data.basepath / "particle2022.csv")
+ assert len(Particle.all()) == 616
Particle.load_table(data.basepath / "nuclei2020.csv")
assert len(Particle.all()) == 5880
@@ -683,3 +738,8 @@
@pytest.mark.parametrize("name,pid", decfile_style_names)
def test_decfile_style_names(name, pid):
assert Particle.from_evtgen_name(name).pdgid == pid
+
+
[email protected]("name,pid", decfile_style_names)
+def test_evtgen_name(name, pid):
+ assert Particle.from_evtgen_name(name).evtgen_name == name
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_performance.py
new/tests/particle/test_performance.py
--- old/tests/particle/test_performance.py 2022-01-15 18:07:50.000000000
+0100
+++ new/tests/particle/test_performance.py 2023-01-04 12:06:53.000000000
+0100
@@ -1,20 +1,22 @@
+from __future__ import annotations
+
from particle import Particle, data
def test_load_particle_table(benchmark):
- benchmark(Particle.load_table, data.basepath / "particle2021.csv")
+ benchmark(Particle.load_table, data.basepath / "particle2022.csv")
def test_load_nuclei_append(benchmark):
def load_two():
- Particle.load_table(data.basepath / "particle2021.csv")
+ Particle.load_table(data.basepath / "particle2022.csv")
Particle.load_table(data.basepath / "nuclei2020.csv", append=True)
benchmark(load_two)
def test_from_pdgid(benchmark):
- Particle.load_table(data.basepath / "particle2021.csv")
+ Particle.load_table(data.basepath / "particle2022.csv")
table = [int(s.pdgid) for s in Particle.all()]
def get_all(listing):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/particle/test_utilities.py
new/tests/particle/test_utilities.py
--- old/tests/particle/test_utilities.py 2022-01-15 18:07:50.000000000
+0100
+++ new/tests/particle/test_utilities.py 2023-01-04 12:06:53.000000000
+0100
@@ -1,11 +1,17 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
-from particle.particle.utilities import str_with_unc
+from particle.particle.utilities import (
+ greek_letter_name_to_unicode,
+ latex_name_unicode,
+ str_with_unc,
+)
possibilities = (
(1.234567, 0.01, None, "1.235 ± 0.010"),
@@ -20,6 +26,8 @@
(1234.5, 0.03, 0.03, "1234.50 ± 0.03"),
(1234.5, 5, 5, "1234 ± 5"),
(1234.5, 2, 2, "1234.5 ± 2.0"),
+ (1234.5, None, None, "1234.5"),
+ (1234.5, None, 2, "1234.5"),
)
@@ -27,3 +35,27 @@
def test_unc_printout(value, err_u, err_l, test_str):
assert str_with_unc(value, err_u, err_l) == test_str
+
+
+possibilities = (
+ ("\\omega", "Ï"),
+ ("\\Omega", "Ω"),
+ ("\\Lambda", "Î"),
+ ("\\alpha_{x}^{0}\\beta\\Gamma(1234)\\Omega", "α_{x}^{0}βÎ(1234)Ω"),
+)
+
+
[email protected]("name,unicode_name", possibilities)
+def test_latex_name_unicode(name, unicode_name):
+
+ assert latex_name_unicode(name) == unicode_name
+
+
+def test_greek_letter_name_to_unicode():
+ """
+ Test the one exception that is not verified
+ in the test "test_latex_name_unicode" above.
+ """
+ with pytest.raises(KeyError):
+ _ = greek_letter_name_to_unicode("Lambda")
+ _ = greek_letter_name_to_unicode("NonExistent")
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/pdgid/__init__.py new/tests/pdgid/__init__.py
--- old/tests/pdgid/__init__.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/pdgid/__init__.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/pdgid/test_functions.py
new/tests/pdgid/test_functions.py
--- old/tests/pdgid/test_functions.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/pdgid/test_functions.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,9 +1,11 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
from particle.pdgid import (
A,
J,
@@ -87,27 +89,15 @@
def test_is_valid(PDGIDs):
- assert is_valid(PDGIDs.Photon)
- assert is_valid(PDGIDs.Gluon)
- assert is_valid(PDGIDs.Electron)
- assert is_valid(PDGIDs.AntiMuon)
- assert is_valid(PDGIDs.jpsi)
- assert is_valid(PDGIDs.Upsilon_1S)
- assert is_valid(PDGIDs.PiPlus)
- assert is_valid(PDGIDs.KMinus)
- assert is_valid(PDGIDs.D0)
- assert is_valid(PDGIDs.DPlus)
- assert is_valid(PDGIDs.DsPlus)
- assert is_valid(PDGIDs.B0)
- assert is_valid(PDGIDs.Bs)
- assert is_valid(PDGIDs.BcPlus)
- assert is_valid(PDGIDs.Proton)
- assert is_valid(PDGIDs.LcPlus)
- assert is_valid(PDGIDs.Lb)
- assert is_valid(PDGIDs.DD1)
- assert is_valid(PDGIDs.SD0)
- assert not is_valid(PDGIDs.Invalid1)
- assert not is_valid(PDGIDs.Invalid2)
+ _invalid = (
+ PDGIDs.Invalid1,
+ PDGIDs.Invalid2,
+ )
+ _valid = [i for i in PDGIDs if i not in _invalid]
+ for i in _valid:
+ assert is_valid(i)
+ for i in _invalid:
+ assert not is_valid(i)
def test_is_quark(PDGIDs):
@@ -225,6 +215,12 @@
assert not is_meson(id)
+def test_is_meson_B_mass_eigenstates():
+ # Test special IDs of B(L)0, B(sL)0, B(H)0, B(sH)0
+ for pdgid in {150, 350, 510, 530}:
+ assert is_meson(pdgid)
+
+
def test_is_baryon(PDGIDs):
_baryons = (
PDGIDs.Proton,
@@ -251,6 +247,12 @@
assert not is_baryon(id)
+def test_is_baryon_old_codes_diffractive():
+ # Test old codes for diffractive p and n (MC usage)
+ assert is_baryon(2110)
+ assert is_baryon(2210)
+
+
def test_is_hadron(PDGIDs):
for id in PDGIDs:
assert is_hadron(id) == (is_meson(id) or is_baryon(id))
@@ -298,7 +300,16 @@
def test_is_generator_specific(PDGIDs):
- _generator_specific = (PDGIDs.AntiCHadron,)
+ _generator_specific = (
+ PDGIDs.AntiCHadron,
+ PDGIDs.GenSpecific910,
+ PDGIDs.GenSpecific999,
+ PDGIDs.GenSpecific1910,
+ PDGIDs.GenSpecific2910,
+ PDGIDs.GenSpecific3910,
+ PDGIDs.OpticalPhoton,
+ PDGIDs.Geantino,
+ )
_non_generator_specific = [id for id in PDGIDs if id not in
_generator_specific]
for id in _generator_specific:
assert is_generator_specific(id)
@@ -313,6 +324,13 @@
PDGIDs.Pomeron,
PDGIDs.Odderon,
PDGIDs.AntiCHadron,
+ PDGIDs.GenSpecific910,
+ PDGIDs.GenSpecific999,
+ PDGIDs.GenSpecific1910,
+ PDGIDs.GenSpecific2910,
+ PDGIDs.GenSpecific3910,
+ PDGIDs.OpticalPhoton,
+ PDGIDs.Geantino,
)
_non_special_particle = [id for id in PDGIDs if id not in
_special_particle]
for id in _special_particle:
@@ -333,6 +351,9 @@
assert is_nucleus(id)
for id in _non_nuclei:
assert not is_nucleus(id)
+ # test 10-digit IDs that does not conform with form for nuclei (should
start with +/- 10)
+ assert not is_nucleus(2000000010)
+ assert not is_nucleus(1100000010)
def test_is_diquark(PDGIDs):
@@ -699,6 +720,8 @@
assert j_spin(id) is None
for id in _J_eq_None:
assert j_spin(id) is None
+ # Alternative ID=9 for the gluon in codes for glueballs to allow a
notation in close analogy with that of hadrons
+ assert j_spin(9) == 3
def test_S_non_mesons(PDGIDs):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/pdgid/test_literals.py
new/tests/pdgid/test_literals.py
--- old/tests/pdgid/test_literals.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/pdgid/test_literals.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,9 +1,11 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
from particle.pdgid import literals as lid
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/pdgid/test_pdgid.py
new/tests/pdgid/test_pdgid.py
--- old/tests/pdgid/test_pdgid.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/pdgid/test_pdgid.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
from particle.pdgid import PDGID
from particle.pdgid import functions as _functions
from particle.pdgid.pdgid import _fnames
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/pythia/__init__.py new/tests/pythia/__init__.py
--- old/tests/pythia/__init__.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/pythia/__init__.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/pythia/test_pythiaid.py
new/tests/pythia/test_pythiaid.py
--- old/tests/pythia/test_pythiaid.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/pythia/test_pythiaid.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,8 +1,10 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import pytest
from particle.exceptions import MatchingIDNotFound
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/test_module_apis.py
new/tests/test_module_apis.py
--- old/tests/test_module_apis.py 1970-01-01 01:00:00.000000000 +0100
+++ new/tests/test_module_apis.py 2023-01-04 12:06:53.000000000 +0100
@@ -0,0 +1,150 @@
+from __future__ import annotations
+
+from sys import version_info
+
+import pytest
+
+import particle
+
+python37plus_only = pytest.mark.skipif(
+ version_info < (3, 7), reason="requires Python3.7+"
+)
+
+
+@python37plus_only
+def test_top_level_api():
+ assert dir(particle) == [
+ "Charge",
+ "Corsika7ID",
+ "Geant3ID",
+ "Inv",
+ "InvalidParticle",
+ "PDGID",
+ "Parity",
+ "Particle",
+ "ParticleNotFound",
+ "PythiaID",
+ "SpinType",
+ "Status",
+ "__version__",
+ "latex_to_html_name",
+ "lifetime_to_width",
+ "width_to_lifetime",
+ ]
+
+
+@python37plus_only
+def test_api_converters():
+ assert dir(particle.converters) == [
+ "Corsika72PDGIDBiMap",
+ "EvtGen2PDGNameMap",
+ "EvtGenName2PDGIDBiMap",
+ "Geant2PDGIDBiMap",
+ "PDG2EvtGenNameMap",
+ "Pythia2PDGIDBiMap",
+ ]
+
+
+@python37plus_only
+def test_api_corsika():
+ assert dir(particle.corsika) == ["Corsika7ID"]
+
+
+@python37plus_only
+def test_api_data():
+ assert dir(particle.data) == ["basepath"]
+
+
+@python37plus_only
+def test_api_geant():
+ assert dir(particle.geant) == ["Geant3ID"]
+
+
+@python37plus_only
+def test_api_lhcb():
+ assert dir(particle.lhcb) == [
+ "LHCbName2PDGIDBiMap",
+ "from_lhcb_name",
+ "to_lhcb_name",
+ ]
+
+
+@python37plus_only
+def test_api_lhcb_data():
+ assert dir(particle.lhcb.data) == ["basepath"]
+
+
+@python37plus_only
+def test_api_particle():
+ assert dir(particle.particle) == [
+ "Charge",
+ "Inv",
+ "InvalidParticle",
+ "Parity",
+ "Particle",
+ "ParticleNotFound",
+ "SpinType",
+ "Status",
+ "latex_name_unicode",
+ "latex_to_html_name",
+ "lifetime_to_width",
+ "programmatic_name",
+ "width_to_lifetime",
+ ]
+
+
+@python37plus_only
+def test_api_pdgid():
+ assert dir(particle.pdgid) == sorted(
+ [
+ "PDGID",
+ #
+ "is_valid",
+ "abspid",
+ # #
+ "is_Qball",
+ "is_Rhadron",
+ "is_SUSY",
+ "is_baryon",
+ "is_diquark",
+ "is_dyon",
+ "is_excited_quark_or_lepton",
+ "is_gauge_boson_or_higgs",
+ "is_generator_specific",
+ "is_hadron",
+ "is_lepton",
+ "is_meson",
+ "is_nucleus",
+ "is_pentaquark",
+ "is_quark",
+ "is_sm_gauge_boson_or_higgs",
+ "is_sm_lepton",
+ "is_sm_quark",
+ "is_special_particle",
+ "is_technicolor",
+ #
+ "has_down",
+ "has_up",
+ "has_strange",
+ "has_charm",
+ "has_bottom",
+ "has_top",
+ "has_fundamental_anti",
+ #
+ "charge",
+ "three_charge",
+ "j_spin",
+ "J",
+ "s_spin",
+ "S",
+ "l_spin",
+ "L",
+ "A",
+ "Z",
+ ]
+ )
+
+
+@python37plus_only
+def test_api_pythia():
+ assert dir(particle.pythia) == ["PythiaID"]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tests/test_package.py new/tests/test_package.py
--- old/tests/test_package.py 2022-01-15 18:07:50.000000000 +0100
+++ new/tests/test_package.py 2023-01-04 12:06:53.000000000 +0100
@@ -1,10 +1,16 @@
-# Copyright (c) 2018-2022, Eduardo Rodrigues and Henry Schreiner.
+# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
#
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
# or https://github.com/scikit-hep/particle for details.
+from __future__ import annotations
+
import particle
def test_package_import():
assert particle is not None
+
+
+def test_load_version():
+ assert particle.__version__