How to use the particle.particle.Particle.findall function in particle

To help you get started, we’ve selected a few particle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_fuzzy_name_search():
    particles = Particle.findall("p~")
    assert len(particles) == 2
    assert -2212 in particles
    assert -1000010010 in particles
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_keyword_lambda_style_search():
    particles = Particle.findall(pdg_name=lambda x: "p" == x)
    assert len(particles) == 4
    assert 2212 in particles
    assert -2212 in particles
    assert 1000010010 in particles
    assert -1000010010 in particles

    # Fuzzy name
    particles = Particle.findall(name=lambda x: "p" in x)
    assert len(particles) > 2
    assert 2212 in particles
    assert -2212 in particles

    # Name and particle
    assert len(Particle.findall(name=lambda x: x == "p", particle=True)) == 2

    # Unit based comparison
    assert 2212 in Particle.findall(lifetime=lambda x: x > 1 * second)
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_complex_search():
    # Find all strange mesons with c*tau > 1 meter
    particles = Particle.findall(
        lambda p: p.pdgid.is_meson
        and p.pdgid.has_strange
        and p.width > 0
        and p.ctau > 1000.0,
        particle=True,
    )
    assert len(particles) == 2  # K+ and KL0
    assert 130 in particles
    assert 321 in particles

    # Find all strange anti-mesons with c*tau > 1 meter
    particles = Particle.findall(
        lambda p: p.pdgid.is_meson
        and p.pdgid.has_strange
        and p.width > 0
        and p.ctau > 1000.0,
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_lambda_style_search():
    particles = Particle.findall(lambda p: p.pdg_name == "p")
    assert len(particles) == 4
    assert 2212 in particles
    assert -2212 in particles
    assert 1000010010 in particles
    assert -1000010010 in particles

    [p.pdgid for p in Particle.findall(lambda p: p.pdg_name == "p" and p > 0)] == [
        2212,
        1000010010,
    ]
    [p.pdgid for p in Particle.findall(lambda p: p.pdg_name == "p" and p < 0)] == [
        -2212,
        -1000010010,
    ]
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
particles = Particle.findall(name="p")
    assert len(particles) == 2
    assert 2212 in particles
    assert 1000010010 in particles

    [p.pdgid for p in Particle.findall(pdg_name="p", particle=True)] == [
        2212,
        1000010010,
    ]
    [p.pdgid for p in Particle.findall(pdg_name="p", particle=False)] == [
        -2212,
        -1000010010,
    ]

    [p.pdgid for p in Particle.findall(name="p", particle=True)] == [2212, 1000010010]
    [p.pdgid for p in Particle.findall(name="p~", particle=False)] == [
        -2212,
        -1000010010,
    ]
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_keyword_lambda_style_search():
    particles = Particle.findall(pdg_name=lambda x: "p" == x)
    assert len(particles) == 4
    assert 2212 in particles
    assert -2212 in particles
    assert 1000010010 in particles
    assert -1000010010 in particles

    # Fuzzy name
    particles = Particle.findall(name=lambda x: "p" in x)
    assert len(particles) > 2
    assert 2212 in particles
    assert -2212 in particles

    # Name and particle
    assert len(Particle.findall(name=lambda x: x == "p", particle=True)) == 2

    # Unit based comparison
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_keyword_style_search():
    particles = Particle.findall(pdg_name="p")
    assert len(particles) == 4
    assert 2212 in particles
    assert -2212 in particles
    assert 1000010010 in particles
    assert -1000010010 in particles
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
def test_lambda_style_search():
    particles = Particle.findall(lambda p: p.pdg_name == "p")
    assert len(particles) == 4
    assert 2212 in particles
    assert -2212 in particles
    assert 1000010010 in particles
    assert -1000010010 in particles

    [p.pdgid for p in Particle.findall(lambda p: p.pdg_name == "p" and p > 0)] == [
        2212,
        1000010010,
    ]
    [p.pdgid for p in Particle.findall(lambda p: p.pdg_name == "p" and p < 0)] == [
        -2212,
        -1000010010,
    ]
github scikit-hep / particle / tests / particle / test_particle.py View on Github external
assert 2212 in particles
    assert -2212 in particles
    assert 1000010010 in particles
    assert -1000010010 in particles

    # Fuzzy name
    particles = Particle.findall(name=lambda x: "p" in x)
    assert len(particles) > 2
    assert 2212 in particles
    assert -2212 in particles

    # Name and particle
    assert len(Particle.findall(name=lambda x: x == "p", particle=True)) == 2

    # Unit based comparison
    assert 2212 in Particle.findall(lifetime=lambda x: x > 1 * second)