ParticleListLike
- plasmapy.particles.particle_collections.ParticleListLike: TypeAlias = plasmapy.particles.particle_collections.ParticleList | collections.abc.Sequence[str | int | numpy.integer | plasmapy.particles.particle_class.Particle | plasmapy.particles.particle_class.CustomParticle | astropy.units.quantity.Quantity]
An
objectis particle-list-like if it can be identified as aParticleListor cast into one.When used as a type annotation,
ParticleListLikeindicates that the corresponding argument should represent a sequence of physical particles. Each item in aParticleListLikeobject must be particle-like.Notes
DimensionlessParticleinstances do not uniquely represent a physical particle, and are thus notParticleLikeand cannot be contained in aParticleListLikeobject.See also
Examples
Using
ParticleListLikeas a type annotation indicates that an argument or variable should represent a sequence ofParticleLikeobjects.>>> from plasmapy.particles import ParticleList, ParticleListLike >>> def contains_only_leptons(particles: ParticleListLike): ... particle_list = ParticleList(particles) ... return all(particle_list.is_category("lepton")) >>> contains_only_leptons(["electron", "muon"]) True