How to use the particle.Particle 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_utilities.py View on Github external
def test_programmatic_name():
    """
    Test makes sure that all literals defined in particle.shared_literals
    match what is returned by Particle.programmatic_name.
    """
    for literal_name, pid in common_particles.items():
        if literal_name in ("photon", "proton", "antiproton", "neutron", "antineutron"):
            continue
        try:  # some particles in the literals may not be in the table (e.g the neutrinos as of 2018)
            p = Particle.from_pdgid(pid)
            assert Particle.from_pdgid(pid).programmatic_name == literal_name
        except ParticleNotFound:
            pass
github scikit-hep / particle / tests / particle / test_utilities.py View on Github external
def test_programmatic_name():
    """
    Test makes sure that all literals defined in particle.shared_literals
    match what is returned by Particle.programmatic_name.
    """
    for literal_name, pid in common_particles.items():
        if literal_name in ("photon", "proton", "antiproton", "neutron", "antineutron"):
            continue
        try:  # some particles in the literals may not be in the table (e.g the neutrinos as of 2018)
            p = Particle.from_pdgid(pid)
            assert Particle.from_pdgid(pid).programmatic_name == literal_name
        except ParticleNotFound:
            pass
github jdf / processing.py / mode / examples / Topics / Simulate / MultipleParticleSystems / crazy_particle.py View on Github external
from particle import Particle

# A subclass of Particle


class CrazyParticle(Particle):
    # Just adding one variable to a CrazyParticle.
    # It inherits all other fields from "Particle", and we don't have to
    # retype them!
    # The CrazyParticle constructor can call the parent class (super class)
    # constructor.

    def __init__(self, l):
        # "super" means do everything from the constructor in Particle.
        super(CrazyParticle, self).__init__(l)
        # One more line of code to deal with the variable, theta.
        self.theta = 0.0

    # Notice we don't have the method run() here, it is inherited from Particle.
    # This update() method overrides the parent class update().
    def update(self):
        super(CrazyParticle, self).update()
github probcomp / Venturecxx / backend / lite / infer.py View on Github external
#print map(len, scaffold.border)

    self.T = len(self.scaffold.border)
    T = self.T
    P = self.P

#    assert T == 1 # TODO temporary
    rhoDBs = [None for t in range(T)]
    rhoWeights = [None for t in range(T)]

    for t in reversed(range(T)):
      rhoWeights[t],rhoDBs[t] = detachAndExtractAtBorder(trace,scaffold.border[t],scaffold)

    assertTorus(scaffold)

    particles = [Particle(trace) for p in range(P+1)]
    self.particles = particles

    particleWeights = [None for p in range(P+1)]


    # Simulate and calculate initial xiWeights

    for p in range(P):
      particleWeights[p] = regenAndAttachAtBorder(particles[p],scaffold.border[0],scaffold,False,OmegaDB(),{})

    particleWeights[P] = regenAndAttachAtBorder(particles[P],scaffold.border[0],scaffold,True,rhoDBs[0],{})
    # assert_almost_equal(particleWeights[P],rhoWeights[0])

#   for every time step,
    for t in range(1,T):
      newParticles = [None for p in range(P+1)]
github nwang57 / FastSLAM / fast_slam.py View on Github external
def __init__(self, x, y, orien, particle_size = 50):
        self.world = World()
        self.particles = [Particle(x, y, random.random()* 2.*math.pi) for i in xrange(particle_size)]
        self.robot = Particle(x, y, orien, is_robot=True)
        self.particle_size = particle_size
github jdf / processing.py / mode / examples / Topics / Simulate / SmokeParticleSystem / particle_system.py View on Github external
def __init__(self, num, v, img):
        self.particles = []  # Initialize the list.
        self.origin = v.get()  # Store the origin.
        self.img = img
        for i in range(num):
            # Add "num" amount of particles to the arraylist.
            self.particles.append(Particle(self.origin, img))
github probcomp / Venturecxx / backend / lite / infer.py View on Github external
def f(x):
    with fixed_randomness:
      scaffold.lkernels[pnode] = DeterministicLKernel(psp,VentureNumber(x))
      # The particle is a way to regen without clobbering the underlying trace
      # TODO Do repeated regens along the same scaffold actually work?
      return regenAndAttach(Particle(trace),scaffold,False,OmegaDB(),{})
  return f
github jdf / processing.py / mode / examples / Contributed Libraries in Python / MSAFluid / particle_system.py View on Github external
def __init__(self, maxParticles=5000):
        self.maxParticles = maxParticles
        self.curIndex = 0
        self.particles = [Particle() for _ in range(self.maxParticles)]
github probcomp / Venturecxx / backend / lite / infer.py View on Github external
for p in range(P):
      particleWeights[p] = regenAndAttachAtBorder(particles[p],scaffold.border[0],scaffold,False,OmegaDB(),{})

    particleWeights[P] = regenAndAttachAtBorder(particles[P],scaffold.border[0],scaffold,True,rhoDBs[0],{})
    # assert_almost_equal(particleWeights[P],rhoWeights[0])

#   for every time step,
    for t in range(1,T):
      newParticles = [None for p in range(P+1)]
      newParticleWeights = [None for p in range(P+1)]
      # Sample new particle and propagate
      for p in range(P):
        parent = sampleLogCategorical(particleWeights)
        newParticles[p] = Particle(particles[parent])
        newParticleWeights[p] = regenAndAttachAtBorder(newParticles[p],self.scaffold.border[t],self.scaffold,False,OmegaDB(),{})
      newParticles[P] = Particle(particles[P])
      newParticleWeights[P] = regenAndAttachAtBorder(newParticles[P],self.scaffold.border[t],self.scaffold,True,rhoDBs[t],{})
      # assert_almost_equal(newParticleWeights[P],rhoWeights[t])
      particles = newParticles
      particleWeights = newParticleWeights

    # Now sample a NEW particle in proportion to its weight
    finalIndex = sampleLogCategorical(particleWeights[0:-1])
    assert finalIndex < P

    self.finalIndex = finalIndex
    self.particles = particles

    return particles[finalIndex],self._compute_alpha(particleWeights, finalIndex)
github FergusGriggs / Fegaria-Remastered / src / entity_manager.py View on Github external
def SpawnParticle(position, colour, life = 2, magnitude = 1, size = 5, angle = None, spread = math.pi / 4, GRAV = 0.25, velocity = None, outline = True):
    particles.append(Particle(position, colour, life, magnitude, size, angle, spread, GRAV, velocity, outline));