ParticleListLike

plasmapy.particles.ParticleListLike

An object is particle-list-like if it can be identified as a ParticleList or cast into one.

When used as a type hint annotation, ParticleListLike indicates that the corresponding argument should represent a sequence of physical particles. Each item in a ParticleListLike object must be particle-like.

Notes

DimensionlessParticle instances do not uniquely represent a physical particle, and are thus not ParticleLike and cannot be contained in a ParticleListLike object.

Examples

Using ParticleListLike as a type hint annotation indicates that an argument or variable should represent a sequence of ParticleLike objects.

>>> 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

alias of Union[ParticleList, Sequence[Union[str, int, integer, Particle, CustomParticle, Quantity]]]