Hello community,
here is the log from the commit of package python-particle for openSUSE:Factory
checked in at 2020-11-19 12:00:24
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-particle (Old)
and /work/SRC/openSUSE:Factory/.python-particle.new.5913 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-particle"
Thu Nov 19 12:00:24 2020 rev:3 rq:849274 version:0.13.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-particle/python-particle.changes
2020-11-03 15:16:41.876047680 +0100
+++
/work/SRC/openSUSE:Factory/.python-particle.new.5913/python-particle.changes
2020-11-23 10:45:15.170288374 +0100
@@ -1,0 +2,8 @@
+Fri Nov 13 23:13:23 UTC 2020 - Atri Bhattacharya <[email protected]>
+
+- Update to version 0.13.1:
+ * PDG ID: Minor simplifications in some PID functions.
+ * Particle class: Test for Particle.is_unflavoured_meson added.
+ * Miscellaneous: Full static typing implemented.
+
+-------------------------------------------------------------------
Old:
----
particle-0.13.0.tar.gz
New:
----
particle-0.13.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-particle.spec ++++++
--- /var/tmp/diff_new_pack.HHIQGk/_old 2020-11-23 10:45:15.790288992 +0100
+++ /var/tmp/diff_new_pack.HHIQGk/_new 2020-11-23 10:45:15.794288996 +0100
@@ -19,7 +19,7 @@
%global modname particle
%define skip_python2 1
Name: python-particle
-Version: 0.13.0
+Version: 0.13.1
Release: 0
Summary: PDG particle data and identification codes
License: BSD-3-Clause
++++++ particle-0.13.0.tar.gz -> particle-0.13.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/MANIFEST.in
new/particle-0.13.1/MANIFEST.in
--- old/particle-0.13.0/MANIFEST.in 2020-10-30 20:56:45.000000000 +0100
+++ new/particle-0.13.1/MANIFEST.in 2020-11-10 18:32:56.000000000 +0100
@@ -17,3 +17,5 @@
include src/particle/version.py
include LICENSE README.rst CONTRIBUTING.md pyproject.toml setup.py setup.cfg
+
+recursive-include src py.typed
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/PKG-INFO new/particle-0.13.1/PKG-INFO
--- old/particle-0.13.0/PKG-INFO 2020-10-30 20:56:49.820654000 +0100
+++ new/particle-0.13.1/PKG-INFO 2020-11-10 18:33:02.348700300 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: particle
-Version: 0.13.0
+Version: 0.13.1
Summary: Extended PDG particle data and MC identification codes
Home-page: https://github.com/scikit-hep/particle
Author: Eduardo Rodrigues
@@ -24,6 +24,10 @@
:alt: PyPI
:target: https://pypi.python.org/pypi/particle
+ .. image:: https://img.shields.io/conda/vn/conda-forge/particle.svg
+ :alt: conda-forge
+ :target: https://anaconda.org/conda-forge/particle
+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2552429.svg
:target: https://doi.org/10.5281/zenodo.2552429
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/README.rst
new/particle-0.13.1/README.rst
--- old/particle-0.13.0/README.rst 2020-10-30 20:56:45.000000000 +0100
+++ new/particle-0.13.1/README.rst 2020-11-10 18:32:56.000000000 +0100
@@ -14,6 +14,10 @@
:alt: PyPI
:target: https://pypi.python.org/pypi/particle
+.. image:: https://img.shields.io/conda/vn/conda-forge/particle.svg
+ :alt: conda-forge
+ :target: https://anaconda.org/conda-forge/particle
+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2552429.svg
:target: https://doi.org/10.5281/zenodo.2552429
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/setup.cfg
new/particle-0.13.1/setup.cfg
--- old/particle-0.13.0/setup.cfg 2020-10-30 20:56:49.820654000 +0100
+++ new/particle-0.13.1/setup.cfg 2020-11-10 18:33:02.348700300 +0100
@@ -53,20 +53,24 @@
where = src
[options.package_data]
-* = *.csv, *.fwf, *.mcd
+* = *.csv, *.fwf, *.mcd, *.py.typed
[options.extras_require]
test =
pytest
pandas; python_version>"3.4"
dev =
+ pytest
pandas; python_version>"3.4"
- check-manifest>=0.39
+ check-manifest>=0.42
black==20.8b1
+ mypy==0.790
all =
+ pytest
pandas; python_version>"3.4"
- check-manifest>=0.39
+ check-manifest>=0.42
black==20.8b1
+ mypy==0.790
[tool:pytest]
testpaths =
@@ -78,6 +82,20 @@
ignore =
src/particle/version.py
+[mypy]
+warn_unused_configs = True
+warn_unused_ignores = True
+python_version = 3.5
+files = src
+check_untyped_defs = True
+disallow_untyped_defs = True
+
+[mypy-numpy]
+ignore_missing_imports = True
+
+[mypy-pandas]
+ignore_missing_imports = True
+
[egg_info]
tag_build =
tag_date = 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/__main__.py
new/particle-0.13.1/src/particle/__main__.py
--- old/particle-0.13.0/src/particle/__main__.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/__main__.py 2020-11-10
18:32:56.000000000 +0100
@@ -16,6 +16,7 @@
def main():
+ # type: () -> None
parser = argparse.ArgumentParser(
prog="particle",
description="Particle command line display utility. Has two modes.",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/converters/bimap.py
new/particle-0.13.1/src/particle/converters/bimap.py
--- old/particle-0.13.0/src/particle/converters/bimap.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/converters/bimap.py 2020-11-10
18:32:56.000000000 +0100
@@ -18,9 +18,29 @@
from .. import data
from ..exceptions import MatchingIDNotFound
+from typing import (
+ Any,
+ Callable,
+ Dict,
+ Generic,
+ Iterator,
+ TextIO,
+ Tuple,
+ Type,
+ TypeVar,
+ Union,
+ overload,
+)
+
+A = TypeVar("A")
+B = TypeVar("B")
+A_conv = Callable[[str], Union[A, int]]
+B_conv = Callable[[str], Union[B, int]]
-class BiMap(object):
+
+class BiMap(Generic[A, B]):
def __init__(self, class_A, class_B, converters=(int, int), filename=None):
+ # type: (Type[A], Type[B], Tuple[A_conv, B_conv], Union[str, TextIO,
None]) -> None
"""
Bi-bidirectional map class.
@@ -61,21 +81,22 @@
>>> bimap = BiMap(PDGID, PythiaID, filename=filename)
"""
- self.class_A = class_A
- self.class_B = class_B
+ self.class_A = class_A # type: Type[A]
+ self.class_B = class_B # type: Type[B]
name_A = self.class_A.__name__.upper()
name_B = self.class_B.__name__.upper()
if filename is None:
filename = "{a}_to_{b}.csv".format(a=name_A.lower(),
b=name_B.lower())
- filename = data.open_text(data, filename)
- elif not hasattr(filename, "read"):
+ file_object = data.open_text(data, filename)
+ elif hasattr(filename, "read"):
+ file_object = filename
+ else:
# Conversion to handle pathlib on Python < 3.6:
- filename = str(filename)
- filename = open(filename)
+ file_object = open(str(filename))
- with filename as _f:
+ with file_object as _f:
self._to_map = {
converters[1](v[name_B]): converters[0](v[name_A])
for v in csv.DictReader(l for l in _f if not l.startswith("#"))
@@ -86,23 +107,36 @@
for v in csv.DictReader(l for l in _f if not l.startswith("#"))
}
+ @overload
+ def __getitem__(self, value):
+ # type: (A) -> B
+ pass
+
+ @overload
+ def __getitem__(self, value):
+ # type: (B) -> A
+ pass
+
def __getitem__(self, value):
+ # type: (Any) -> Any
if isinstance(value, self.class_B):
try:
- return self.class_A(self._to_map[value])
+ return self.class_A(self._to_map[value]) # type: ignore
except KeyError:
pass
elif isinstance(value, self.class_A):
try:
- return self.class_B(self._from_map[value])
+ return self.class_B(self._from_map[value]) # type: ignore
except KeyError:
pass
+
msg = "Matching {a}-{b} for input {v} not found !".format(
a=self.class_A.__name__, b=self.class_B.__name__, v=value
)
raise MatchingIDNotFound(msg)
def __repr__(self):
+ # type: () -> str
return "<{self.__class__.__name__}({a}-{b}): {n} matches>".format(
self=self,
a=self.class_A.__name__,
@@ -110,15 +144,14 @@
n=self.__len__(),
)
- def __str__(self):
- return repr(self)
-
def __len__(self):
+ # type: () -> int
"""Returns the number of matches."""
return len(self._to_map)
def DirectionalMaps(name_A, name_B, converters=(str, str), filename=None):
+ # type: (str, str, Tuple[Callable[[str],str], Callable[[str],str]],
Union[None, str, TextIO]) -> Tuple[DirectionalMap, DirectionalMap]
"""
Directional map class providing a to and from mapping.
@@ -153,13 +186,14 @@
skipinitialspace = True
if filename is None:
- filename = data.open_text(data, "conversions.csv")
- elif not hasattr(filename, "read"):
+ file_object = data.open_text(data, "conversions.csv")
+ elif hasattr(filename, "read"):
+ file_object = filename
+ else:
# Conversion to handle pathlib on Python < 3.6:
- filename = str(filename)
- filename = open(filename)
+ file_object = open(str(filename))
- with filename as _f:
+ with file_object as _f:
to_map = {
converters[1](v[name_B]): converters[0](v[name_A])
for v in csv.DictReader(
@@ -186,6 +220,7 @@
class DirectionalMap(Mapping):
def __init__(self, name_A, name_B, map):
+ # type: (str, str, Dict[str, str]) -> None
"""
Directional map class providing a A -> B mapping.
@@ -203,6 +238,7 @@
self._map = map
def __getitem__(self, value):
+ # type: (str) -> str
try:
return self._map[value]
except KeyError:
@@ -212,16 +248,16 @@
raise MatchingIDNotFound(msg)
def __iter__(self):
+ # type: () -> Iterator[str]
return iter(self._map)
def __repr__(self):
+ # type: () -> str
return "<{self.__class__.__name__}({a}->{b}): {n} matches>".format(
self=self, a=self.name_A, b=self.name_B, n=self.__len__()
)
- def __str__(self):
- return repr(self)
-
def __len__(self):
+ # type: () -> int
"""Returns the number of matches."""
return len(self._map)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/data/__init__.py
new/particle-0.13.1/src/particle/data/__init__.py
--- old/particle-0.13.0/src/particle/data/__init__.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/data/__init__.py 2020-11-10
18:32:56.000000000 +0100
@@ -5,6 +5,6 @@
# or https://github.com/scikit-hep/particle for details.
try:
- from importlib.resources import open_text
+ from importlib.resources import open_text # type: ignore
except ImportError:
- from importlib_resources import open_text # type: ignore
+ from importlib_resources import open_text
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/geant/geant3id.py
new/particle-0.13.1/src/particle/geant/geant3id.py
--- old/particle-0.13.0/src/particle/geant/geant3id.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/geant/geant3id.py 2020-11-10
18:32:56.000000000 +0100
@@ -49,6 +49,7 @@
@classmethod
def from_pdgid(cls, pdgid):
+ # type: (int) -> Geant3ID
"""
Constructor from a PDGID.
"""
@@ -60,15 +61,19 @@
)
def to_pdgid(self):
+ # type: () -> PDGID
return PDGID(_bimap[self])
def __repr__(self):
+ # type: () -> str
return "<Geant3ID: {:d}>".format(int(self))
def __str__(self):
+ # type: () -> str
return repr(self)
def __neg__(self):
+ # type: () -> Geant3ID
"""
Note:
Allowed operation though ALL Geant3 identification codes are positive!
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/particle/convert.py
new/particle-0.13.1/src/particle/particle/convert.py
--- old/particle-0.13.0/src/particle/particle/convert.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/particle/convert.py 2020-11-10
18:32:56.000000000 +0100
@@ -53,8 +53,10 @@
import os
from datetime import date
-import numpy as np # type: ignore
-import pandas as pd # type: ignore
+import numpy as np
+import pandas as pd
+
+from typing import TextIO, List, Optional, Dict, TypeVar, Callable, Union,
Iterable, Any
try:
from io import StringIO
@@ -86,6 +88,7 @@
def get_from_latex(filename):
+ # type: (str) -> pd.Series
"""
Produce a pandas series from a file with LaTeX mappings in itself.
The CVS file format is the following: PDGID, ParticleLatexName.
@@ -95,14 +98,18 @@
def filter_file(fileobject):
+ # type: (Union[str, TextIO]) -> TextIO
"""
Open a file if not already a file-like object, and strip lines that start
with *.
Returns a new file-like object (StringIO instance).
"""
if not hasattr(fileobject, "read"):
+ assert isinstance(fileobject, str)
fileobject = open(fileobject, encoding="utf-8")
+ assert not isinstance(fileobject, str)
+
stream = StringIO()
for line in fileobject:
# We need to strip the unicode byte ordering if present before
checking for *
@@ -116,7 +123,11 @@
return stream
-def get_from_pdg_extended(filename, latexes=None):
+T = TypeVar("T")
+
+
+def get_from_pdg_extended(filename, latexes=()):
+ # type: (str, Iterable[str]) -> pd.DataFrame
"""
Read an "extended style" PDG data file (only produced in 2008), plus a
list of LaTeX files,
to produce a pandas DataFrame with particle information.
@@ -136,6 +147,7 @@
"Read a file, plus a list of LaTeX files, to produce a pandas DataFrame
with particle information"
def unmap(mapping):
+ # type: (Dict[str, T]) -> Callable[[str], T]
return lambda x: mapping[x.strip()]
# Convert each column from text to appropriate data type
@@ -154,16 +166,15 @@
Quarks=lambda x: x.strip(),
)
- filename = filter_file(filename)
-
- # Read in the table, apply the converters, add names, ignore comments
- pdg_table = pd.read_csv(
- filename,
-
names="Mass,MassUpper,MassLower,Width,WidthUpper,WidthLower,I,G,J,P,C,Anti,"
- "ID,Charge,Rank,Status,Name,Quarks".split(","),
- converters=PDG_converters,
- comment="#",
- )
+ with filter_file(filename) as file_object:
+ # Read in the table, apply the converters, add names, ignore comments
+ pdg_table = pd.read_csv(
+ file_object,
+
names="Mass,MassUpper,MassLower,Width,WidthUpper,WidthLower,I,G,J,P,C,Anti,"
+ "ID,Charge,Rank,Status,Name,Quarks".split(","),
+ converters=PDG_converters,
+ comment="#",
+ )
# Read the LaTeX
latex_series = pd.concat([get_from_latex(latex) for latex in latexes])
@@ -245,6 +256,7 @@
def sort_particles(table):
+ # type: (pd.DataFrame) -> None
"Sort a particle list table nicely"
table["TmpVals"] = abs(table.index - 0.25)
table.sort_values("TmpVals", inplace=True)
@@ -252,6 +264,7 @@
def get_from_pdg_mcd(filename):
+ # type: (str) -> pd.DataFrame
"""
Reads in a current-style PDG .mcd file (mass_width_2020.mcd file tested).
@@ -266,40 +279,40 @@
# Also, we can't use * as a comment char, since it is valid
# in the particle names, as well!
- filename = filter_file(filename)
+ with filter_file(filename) as file_object:
- nar = pd.read_fwf(
- filename,
- colspecs=(
- (0, 8),
- (8, 16),
- (16, 24),
- (24, 32),
- (32, 51),
- (51, 60),
- (60, 69),
- (69, 88),
- (88, 97),
- (97, 106),
- (106, 128),
- ),
- header=None,
- names=(
- "ID1",
- "ID2",
- "ID3",
- "ID4",
- "Mass",
- "MassUpper",
- "MassLower",
- "Width",
- "WidthUpper",
- "WidthLower",
- "NameCharge",
- ),
- )
+ nar = pd.read_fwf(
+ file_object,
+ colspecs=(
+ (0, 8),
+ (8, 16),
+ (16, 24),
+ (24, 32),
+ (32, 51),
+ (51, 60),
+ (60, 69),
+ (69, 88),
+ (88, 97),
+ (97, 106),
+ (106, 128),
+ ),
+ header=None,
+ names=(
+ "ID1",
+ "ID2",
+ "ID3",
+ "ID4",
+ "Mass",
+ "MassUpper",
+ "MassLower",
+ "Width",
+ "WidthUpper",
+ "WidthLower",
+ "NameCharge",
+ ),
+ )
- ds = []
+ ds_list = []
for i in range(4):
name = "ID{0}".format(i + 1)
d = nar[~pd.isna(nar[name])].copy()
@@ -309,9 +322,9 @@
abcd = nc[1].str.split(",", 4, expand=True)
d["charge"] = abcd[i]
d.set_index("ID", inplace=True)
- ds.append(d)
+ ds_list.append(d)
- ds = pd.concat(ds)
+ ds = pd.concat(ds_list)
del ds["NameCharge"], ds["ID1"], ds["ID2"], ds["ID3"], ds["ID4"]
ds.sort_index(inplace=True)
@@ -323,6 +336,7 @@
def update_from_mcd(full_table, update_table):
+ # type: (pd.DataFrame, pd.DataFrame) -> pd.DataFrame
"""
Update the full table (aka the PDG extended-style table) with the
up-to-date information from the PDG .mcd file.
@@ -342,6 +356,7 @@
def produce_files(particle2008, particle2020, version, year):
+ # type: (str, str, str, str) -> None
"This produces listed output files from all input files."
with data.open_text(data, "mass_width_2008.fwf") as fwf_f:
@@ -386,10 +401,10 @@
with open(particle2020, "w", newline="\n", encoding="utf-8") as f:
f.write(version_header(particle2020, version))
new_table.to_csv(f, float_format="%.12g")
- f.close()
def version_header(filename, version_number):
+ # type: (str, str) -> str
filename = os.path.basename(filename)
VERSION = version_number # version of CSV files
DATE = date.isoformat(date.today())
@@ -399,6 +414,7 @@
def main(version, year):
+ # type: (str, str) -> None
"Regenerate output files - run directly inside the package"
master_dir = os.path.dirname(FILE_DIR)
data_dir = os.path.join(master_dir, "data")
@@ -409,6 +425,7 @@
def convert(version, output, fwf, latex=None):
+ # type: (str, str, str, Optional[str]) -> None
latexes = [data.open_text(data, "pdgid_to_latexname.csv")]
if latex:
latexes.append(latex)
@@ -417,14 +434,15 @@
with open(output, "w", newline="\n", encoding="utf-8") as f:
f.write(version_header(output, version))
table.to_csv(f, float_format="%.12g")
- f.close()
def run_regen(args):
+ # type: (Any) -> None
main(args.version, args.year)
def run_convert(args):
+ # type: (Any) -> None
convert(args.version, args.output, args.fwf, args.latex)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/particle/particle.py
new/particle-0.13.1/src/particle/particle/particle.py
--- old/particle-0.13.0/src/particle/particle/particle.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/particle/particle.py 2020-11-10
18:32:56.000000000 +0100
@@ -189,8 +189,8 @@
The upper uncertainty on the particle decay width, in MeV.
"""
- pdgid = attr.ib(converter=PDGID)
- pdg_name = attr.ib()
+ pdgid = attr.ib(converter=PDGID) # type: PDGID
+ pdg_name = attr.ib() # type: str
mass = attr.ib(
minus_one, converter=_none_or_positive_converter
) # type: Optional[float]
@@ -218,10 +218,10 @@
anti_flag = attr.ib(
Inv.Same, converter=Inv
) # Info about particle name for anti-particles
- rank = attr.ib(0)
+ rank = attr.ib(0) # type: int
status = attr.ib(Status.NotInPDT, converter=Status)
quarks = attr.ib("", converter=str)
- latex_name = attr.ib("Unknown")
+ latex_name = attr.ib("Unknown") # type: str
def __repr__(self):
# type: () -> str
@@ -283,7 +283,7 @@
cls,
exclusive_fields=(), # type: Iterable[str]
exclude_fields=(), # type: Iterable[str]
- n_rows=-1,
+ n_rows=-1, # type: int
filter_fn=None, # type: Optional[Callable[[Particle], bool]]
):
# type: (...) -> List[List[Any]]
@@ -412,7 +412,7 @@
@classmethod
def to_dict(cls, *args, **kwargs):
- # type: (...) -> Dict[List[str], List[Any]]
+ # type: (Any, Any) -> Dict[List[str], List[Any]]
"""
Render a search (via `findall`) on the internal particle data CSV table
as a `dict`, loading the table from the default location if no table
has yet been loaded.
@@ -585,7 +585,7 @@
# The following __le__ and __eq__ needed for total ordering (sort, etc)
- def __le__(self, other):
+ def __lt__(self, other):
# type: (Any) -> bool
# Sort by absolute particle numbers
# The positive one should come first
@@ -619,7 +619,7 @@
Note that the returned value corresponds to that effectively encoded
in the particle PDG ID.
"""
- return self.pdgid.J # type: ignore
+ return self.pdgid.J
@property
def L(self):
@@ -630,7 +630,7 @@
Note that the returned value corresponds to that effectively encoded
in the particle PDG ID.
"""
- return self.pdgid.L # type: ignore
+ return self.pdgid.L
@property
def S(self):
@@ -641,7 +641,7 @@
Note that the returned value corresponds to that effectively encoded
in the particle PDG ID.
"""
- return self.pdgid.S # type: ignore
+ return self.pdgid.S
@property
def charge(self):
@@ -655,17 +655,17 @@
Consistency of both ways of retrieving the particle charge is
guaranteed
for all PDG table particles.
"""
- return self.three_charge / 3 if self.three_charge is not None else
None # type: ignore
+ return self.three_charge / 3 if self.three_charge is not None else None
@property
def three_charge(self):
# type: () -> Optional[int]
"Three times the particle charge (charge * 3), in units of the
positron charge."
- if not self.pdgid.is_nucleus: # type: ignore
+ if not self.pdgid.is_nucleus:
# Return int(...) not to return the actual enum Charge
return int(self._three_charge) if self._three_charge != Charge.u
else None
else:
- return self.pdgid.three_charge # type: ignore
+ return self.pdgid.three_charge
@property
def lifetime(self):
@@ -709,11 +709,11 @@
Note that this is relevant for bosons only. SpinType.NonDefined is
returned otherwise.
"""
# Non-valid or non-standard PDG IDs
- if self.pdgid.j_spin is None: # type: ignore
+ if self.pdgid.j_spin is None:
return SpinType.NonDefined
# Fermions - 2J+1 is always an even number
- if self.pdgid.j_spin % 2 == 0: # type: ignore
+ if self.pdgid.j_spin % 2 == 0:
return SpinType.NonDefined
if self.J in [0, 1, 2]:
@@ -740,14 +740,36 @@
def is_unflavoured_meson(self):
# type: () -> bool
"""
- Unflavoured mesons are self-conjugate (hence zero-charge) mesons
- with all their flavour (strange, charm, bottom and top) quantum
numbers equal to zero.
+ Is the particle a light non-strange meson or a quarkonium?
+
+ Indeed, unflavoured mesons are either:
+ all light mesons with no net flavour quantum number (S = C = B = T =
0),
+ or quarkonia, which are self-conjugate heavy flavour mesons,
+ with all their flavour quantum numbers and charge equal to zero.
"""
- if self.is_self_conjugate and self.three_charge == 0 and
self.pdgid.is_meson: # type: ignore
- return True
- else:
+ pid = self.pdgid
+
+ if not pid.is_meson:
return False
+ # Heavy flavour
+ if pid.has_charm or pid.has_bottom or pid.has_top:
+ return True if self.is_self_conjugate else False
+ # Light or strange mesons at this point
+ else:
+ # Special case of the KS and KL
+ if pid in {130, 310}:
+ return False
+ # I = 1 light mesons have no s-sbar component, hence has_strange
== False
+ if _digit(pid, Location.Nq3) == 1 and not pid.has_strange:
+ return True
+ # I = 0 light mesons have a s-sbar component, has_strange == True,
+ # thought their net S = 0
+ elif _digit(pid, Location.Nq3) in {2, 3} and self.three_charge ==
0:
+ return True
+ else: # Only K-mesons at this point
+ return False
+
def invert(self):
# type: () -> Particle
"Get the antiparticle."
@@ -830,7 +852,7 @@
return True # antiparticle flips sign of particle
if self.pdgid in (23, 25, 111, 130, 310, 311, -311):
return True # the Z0, H0, pi0, KL0, KS0, K0 and K0bar
- if self.pdgid.is_diquark: # type: ignore
+ if self.pdgid.is_diquark:
return False
if abs(self.pdgid) in (2212, 2112):
return False # proton and neutron
@@ -852,23 +874,23 @@
]
):
return False
- elif pid.has_strange or pid.has_charm or pid.has_bottom or
pid.has_top: # type: ignore
+ elif pid.has_strange or pid.has_charm or pid.has_bottom or
pid.has_top:
return False
else: # Light unflavoured mesons
return True
# Lambda baryons
if (
- self.pdgid.is_baryon # type: ignore
+ self.pdgid.is_baryon
and _digit(self.pdgid, Location.Nq2) == 1
and self.I
== 0.0 # 1st check alone is not sufficient to filter out
lowest-ground Sigma's
- and self.pdgid.has_strange # type: ignore
+ and self.pdgid.has_strange
and not (
- self.pdgid.has_charm or self.pdgid.has_bottom or
self.pdgid.has_top # type: ignore
+ self.pdgid.has_charm or self.pdgid.has_bottom or
self.pdgid.has_top
)
):
return False
- if self.pdgid.is_nucleus: # type: ignore
+ if self.pdgid.is_nucleus:
return False
return True
@@ -880,10 +902,10 @@
"""
if self._three_charge is None:
return "None"
- elif not self.pdgid.is_nucleus: # type: ignore
+ elif not self.pdgid.is_nucleus:
return Charge_undo[Charge(self._three_charge)]
else:
- return str(self.pdgid.charge) # type: ignore
+ return str(self.pdgid.charge)
def _str_mass(self):
# type: () -> str
@@ -1087,7 +1109,7 @@
@classmethod
def find(cls, *args, **search_terms):
- # type: (...) -> Particle
+ # type: (Any, Any) -> Particle
"""
Require that the search returns one and only one result.
The method otherwise raises a ParticleNotFound or RuntimeError
exception.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/pdgid/functions.py
new/particle-0.13.1/src/particle/pdgid/functions.py
--- old/particle-0.13.0/src/particle/pdgid/functions.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/pdgid/functions.py 2020-11-10
18:32:56.000000000 +0100
@@ -52,12 +52,14 @@
def is_valid(pdgid):
# type: (PDGID_TYPE) -> bool
"""Is it a valid PDG ID?"""
- if _fundamental_id(pdgid) > 0:
+ if _fundamental_id(pdgid) != 0: # function always returns a number >= 0
return True
if is_meson(pdgid):
return True
if is_baryon(pdgid):
return True
+ if is_gauge_boson_or_higgs(pdgid):
+ return True
if is_pentaquark(pdgid):
return True
if is_SUSY(pdgid):
@@ -70,8 +72,6 @@
return True
if is_pentaquark(pdgid):
return True
- if is_gauge_boson_or_higgs(pdgid):
- return True
if is_generator_specific(pdgid):
return True
if is_technicolor(pdgid):
@@ -79,11 +79,7 @@
if is_composite_quark_or_lepton(pdgid):
return True
if _extra_bits(pdgid) > 0:
- if is_nucleus(pdgid):
- return True
- if is_Qball(pdgid):
- return True
- return False
+ return is_Qball(pdgid) or is_nucleus(pdgid)
return False
@@ -686,7 +682,7 @@
# the charge sign will be changed below if pid < 0
if _digit(pdgid, Location.Nl) == 2:
charge = -charge
- elif sid > 0 and sid <= 100: # use table
+ elif 0 < sid <= 100: # use table
charge = ch100[sid - 1]
if aid in {1000017, 1000018, 1000034, 1000052, 1000053, 1000054}:
charge = 0
@@ -718,13 +714,13 @@
return None
if _fundamental_id(pdgid) > 0:
fund = _fundamental_id(pdgid)
- if fund > 0 and fund < 7:
+ if 0 < fund < 7:
return 2 # 4th generation quarks not dealt with !
if fund == 9:
return 3
- if fund > 10 and fund < 17:
+ if 10 < fund < 17:
return 2 # 4th generation leptons not dealt with !
- if fund > 20 and fund < 25:
+ if 20 < fund < 25:
return 3
return None
elif abs(int(pdgid)) in {1000000010, 1000010010}: # neutron, proton
@@ -819,42 +815,46 @@
nl = (abspid(pdgid) // 10000) % 10
js = abspid(pdgid) % 10
- if nl == 0 and js == 3:
- return 0
- elif nl == 0 and js == 5:
- return 1
- elif nl == 0 and js == 7:
- return 2
- elif nl == 0 and js == 9:
- return 3
- elif nl == 0 and js == 1:
- return 0
- elif nl == 1 and js == 3:
- return 1
- elif nl == 1 and js == 5:
- return 2
- elif nl == 1 and js == 7:
- return 3
- elif nl == 1 and js == 9:
- return 4
- elif nl == 2 and js == 3:
- return 1
- elif nl == 2 and js == 5:
- return 2
- elif nl == 2 and js == 7:
- return 3
- elif nl == 2 and js == 9:
- return 4
- elif nl == 1 and js == 1:
- return 1
- elif nl == 3 and js == 3:
- return 2
- elif nl == 3 and js == 5:
- return 3
- elif nl == 3 and js == 7:
- return 4
- elif nl == 3 and js == 9:
- return 5
+ if nl == 0:
+ if js == 1:
+ return 0
+ if js == 3:
+ return 0
+ if js == 5:
+ return 1
+ if js == 7:
+ return 2
+ if js == 9:
+ return 3
+ elif nl == 1:
+ if js == 1:
+ return 1
+ if js == 3:
+ return 1
+ if js == 5:
+ return 2
+ if js == 7:
+ return 3
+ if js == 9:
+ return 4
+ elif nl == 2:
+ if js == 3:
+ return 1
+ if js == 5:
+ return 2
+ if js == 7:
+ return 3
+ if js == 9:
+ return 4
+ elif nl == 3:
+ if js == 3:
+ return 2
+ if js == 5:
+ return 3
+ if js == 7:
+ return 4
+ if js == 9:
+ return 5
return 0
@@ -928,6 +928,10 @@
Returns 0 if the particle is not fundamental or not standard (PDG ID with
more than 7 digits).
PDGID=100 is a special case (internal generator ID's are 81-100).
+
+ Notes
+ -----
+ Function always returns a number >= 0.
"""
if _extra_bits(pdgid) > 0:
return 0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/pdgid/pdgid.py
new/particle-0.13.1/src/particle/pdgid/pdgid.py
--- old/particle-0.13.0/src/particle/pdgid/pdgid.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/pdgid/pdgid.py 2020-11-10
18:32:56.000000000 +0100
@@ -63,8 +63,68 @@
val += "{item:14} {value}\n".format(item=item, value=getattr(self,
item))
return val
+ A = property(_functions.A, doc=_functions.A.__doc__)
+ J = property(_functions.J, doc=_functions.J.__doc__)
+ L = property(_functions.L, doc=_functions.L.__doc__)
+ S = property(_functions.S, doc=_functions.S.__doc__)
+ Z = property(_functions.Z, doc=_functions.Z.__doc__)
+ abspid = property(_functions.abspid, doc=_functions.abspid.__doc__)
+ charge = property(_functions.charge, doc=_functions.charge.__doc__)
+ has_bottom = property(_functions.has_bottom,
doc=_functions.has_bottom.__doc__)
+ has_charm = property(_functions.has_charm,
doc=_functions.has_charm.__doc__)
+ has_down = property(_functions.has_down, doc=_functions.has_down.__doc__)
+ has_fundamental_anti = property(
+ _functions.has_fundamental_anti,
doc=_functions.has_fundamental_anti.__doc__
+ )
+ has_strange = property(_functions.has_strange,
doc=_functions.has_strange.__doc__)
+ has_top = property(_functions.has_top, doc=_functions.has_top.__doc__)
+ has_up = property(_functions.has_up, doc=_functions.has_up.__doc__)
+ is_Qball = property(_functions.is_Qball, doc=_functions.is_Qball.__doc__)
+ is_Rhadron = property(_functions.is_Rhadron,
doc=_functions.is_Rhadron.__doc__)
+ is_SUSY = property(_functions.is_SUSY, doc=_functions.is_SUSY.__doc__)
+ is_baryon = property(_functions.is_baryon,
doc=_functions.is_baryon.__doc__)
+ is_composite_quark_or_lepton = property(
+ _functions.is_composite_quark_or_lepton,
+ doc=_functions.is_composite_quark_or_lepton.__doc__,
+ )
+ is_diquark = property(_functions.is_diquark,
doc=_functions.is_diquark.__doc__)
+ is_dyon = property(_functions.is_dyon, doc=_functions.is_dyon.__doc__)
+ is_gauge_boson_or_higgs = property(
+ _functions.is_gauge_boson_or_higgs,
+ doc=_functions.is_gauge_boson_or_higgs.__doc__,
+ )
+ is_generator_specific = property(
+ _functions.is_generator_specific,
doc=_functions.is_generator_specific.__doc__
+ )
+ is_hadron = property(_functions.is_hadron,
doc=_functions.is_hadron.__doc__)
+ is_lepton = property(_functions.is_lepton,
doc=_functions.is_lepton.__doc__)
+ is_meson = property(_functions.is_meson, doc=_functions.is_meson.__doc__)
+ is_nucleus = property(_functions.is_nucleus,
doc=_functions.is_nucleus.__doc__)
+ is_pentaquark = property(
+ _functions.is_pentaquark, doc=_functions.is_pentaquark.__doc__
+ )
+ is_quark = property(_functions.is_quark, doc=_functions.is_quark.__doc__)
+ is_sm_gauge_boson_or_higgs = property(
+ _functions.is_sm_gauge_boson_or_higgs,
+ doc=_functions.is_sm_gauge_boson_or_higgs.__doc__,
+ )
+ is_special_particle = property(
+ _functions.is_special_particle,
doc=_functions.is_special_particle.__doc__
+ )
+ is_technicolor = property(
+ _functions.is_technicolor, doc=_functions.is_technicolor.__doc__
+ )
+ is_valid = property(_functions.is_valid, doc=_functions.is_valid.__doc__)
+ j_spin = property(_functions.j_spin, doc=_functions.j_spin.__doc__)
+ l_spin = property(_functions.l_spin, doc=_functions.l_spin.__doc__)
+ s_spin = property(_functions.s_spin, doc=_functions.s_spin.__doc__)
+ three_charge = property(
+ _functions.three_charge, doc=_functions.three_charge.__doc__
+ )
-# Decorate the PDGID class with all relevant functions defined in the
pdgid.functions module
+
+# Verify the PDGID class has all relevant functions defined in the
pdgid.functions module
for _n in _fnames:
- _decorator = property(getattr(_functions, _n), doc=getattr(_functions,
_n).__doc__)
- setattr(PDGID, _n, _decorator)
+ assert _n in dir(
+ PDGID
+ ), "{} missing from PDGID class! Update the list in pdgid.py".format(_n)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/pythia/pythiaid.py
new/particle-0.13.1/src/particle/pythia/pythiaid.py
--- old/particle-0.13.0/src/particle/pythia/pythiaid.py 2020-10-30
20:56:45.000000000 +0100
+++ new/particle-0.13.1/src/particle/pythia/pythiaid.py 2020-11-10
18:32:56.000000000 +0100
@@ -44,6 +44,7 @@
@classmethod
def from_pdgid(cls, pdgid):
+ # type: (int) -> PythiaID
"""
Constructor from a PDGID.
"""
@@ -55,15 +56,19 @@
)
def to_pdgid(self):
+ # type: () -> PDGID
return PDGID(_bimap[self])
def __repr__(self):
+ # type: () -> str
return "<PythiaID: {:d}>".format(int(self))
def __str__(self):
+ # type: () -> str
return repr(self)
def __neg__(self):
+ # type: () -> PythiaID
return self.__class__(-int(self))
__invert__ = __neg__
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle/version.py
new/particle-0.13.1/src/particle/version.py
--- old/particle-0.13.0/src/particle/version.py 2020-10-30 20:56:49.000000000
+0100
+++ new/particle-0.13.1/src/particle/version.py 2020-11-10 18:33:01.000000000
+0100
@@ -1,4 +1,4 @@
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
-version = '0.13.0'
+version = '0.13.1'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle.egg-info/PKG-INFO
new/particle-0.13.1/src/particle.egg-info/PKG-INFO
--- old/particle-0.13.0/src/particle.egg-info/PKG-INFO 2020-10-30
20:56:49.000000000 +0100
+++ new/particle-0.13.1/src/particle.egg-info/PKG-INFO 2020-11-10
18:33:01.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: particle
-Version: 0.13.0
+Version: 0.13.1
Summary: Extended PDG particle data and MC identification codes
Home-page: https://github.com/scikit-hep/particle
Author: Eduardo Rodrigues
@@ -24,6 +24,10 @@
:alt: PyPI
:target: https://pypi.python.org/pypi/particle
+ .. image:: https://img.shields.io/conda/vn/conda-forge/particle.svg
+ :alt: conda-forge
+ :target: https://anaconda.org/conda-forge/particle
+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.2552429.svg
:target: https://doi.org/10.5281/zenodo.2552429
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle.egg-info/SOURCES.txt
new/particle-0.13.1/src/particle.egg-info/SOURCES.txt
--- old/particle-0.13.0/src/particle.egg-info/SOURCES.txt 2020-10-30
20:56:49.000000000 +0100
+++ new/particle-0.13.1/src/particle.egg-info/SOURCES.txt 2020-11-10
18:33:02.000000000 +0100
@@ -8,6 +8,7 @@
src/particle/__init__.py
src/particle/__main__.py
src/particle/exceptions.py
+src/particle/py.typed
src/particle/shared_literals.py
src/particle/version.py
src/particle.egg-info/PKG-INFO
@@ -19,6 +20,7 @@
src/particle/converters/bimap.py
src/particle/converters/evtgen.py
src/particle/converters/geant.py
+src/particle/converters/py.typed
src/particle/converters/pythia.py
src/particle/data/README.rst
src/particle/data/__init__.py
@@ -36,19 +38,24 @@
src/particle/data/pdgid_to_geant3id.csv
src/particle/data/pdgid_to_latexname.csv
src/particle/data/pdgid_to_pythiaid.csv
+src/particle/data/py.typed
src/particle/geant/__init__.py
src/particle/geant/geant3id.py
+src/particle/geant/py.typed
src/particle/particle/__init__.py
src/particle/particle/convert.py
src/particle/particle/enums.py
src/particle/particle/kinematics.py
src/particle/particle/literals.py
src/particle/particle/particle.py
+src/particle/particle/py.typed
src/particle/particle/regex.py
src/particle/particle/utilities.py
src/particle/pdgid/__init__.py
src/particle/pdgid/functions.py
src/particle/pdgid/literals.py
src/particle/pdgid/pdgid.py
+src/particle/pdgid/py.typed
src/particle/pythia/__init__.py
+src/particle/pythia/py.typed
src/particle/pythia/pythiaid.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/particle-0.13.0/src/particle.egg-info/requires.txt
new/particle-0.13.1/src/particle.egg-info/requires.txt
--- old/particle-0.13.0/src/particle.egg-info/requires.txt 2020-10-30
20:56:49.000000000 +0100
+++ new/particle-0.13.1/src/particle.egg-info/requires.txt 2020-11-10
18:33:01.000000000 +0100
@@ -11,15 +11,19 @@
importlib_resources>=1.0
[all]
-check-manifest>=0.39
+pytest
+check-manifest>=0.42
black==20.8b1
+mypy==0.790
[all:python_version > "3.4"]
pandas
[dev]
-check-manifest>=0.39
+pytest
+check-manifest>=0.42
black==20.8b1
+mypy==0.790
[dev:python_version > "3.4"]
pandas
_______________________________________________
openSUSE Commits mailing list -- [email protected]
To unsubscribe, email [email protected]
List Netiquette: https://en.opensuse.org/openSUSE:Mailing_list_netiquette
List Archives:
https://lists.opensuse.org/archives/list/[email protected]