AbstractParticle
- class plasmapy.particles.particle_class.AbstractParticle[source]
Bases:
ABC
An abstract base class that defines the interface for particles.
Attributes Summary
Provide the particle's electric charge.
A dictionary representation of the particle object that is JSON friendly (i.e. convertible to a JSON object).
Provide the particle's mass.
Methods Summary
json_dump
(fp, **kwargs)Write the particle's
json_dict
to thefp
file object usingjson.dump
.json_dumps
(**kwargs)Serialize the particle's
json_dict
into a JSON formattedstr
usingjson.dumps
.Attributes Documentation
- charge
Provide the particle’s electric charge.
- json_dict
A dictionary representation of the particle object that is JSON friendly (i.e. convertible to a JSON object).
The dictionary should maintain the following format so that
ParticleJSONDecoder
knows how to decode the resulting JSON object.{ "plasmapy_particle": { # string representation of the particle class "type": "Particle", # string representation of the module contains the particle class "module": "plasmapy.particles.particle_class", # date stamp of when the object was created "date_created": "2020-07-20 17:46:13 UTC", # parameters used to initialized the particle class "__init__": { # tuple of positional arguments "args": (), # dictionary of keyword arguments "kwargs": {}, }, } }
Only the
"__init__"
entry should be modified by the subclass.
- mass
Provide the particle’s mass.
Methods Documentation
- json_dump(fp, **kwargs: dict[str, Any]) None [source]
Write the particle’s
json_dict
to thefp
file object usingjson.dump
.- Parameters:
fp (file object) – Destination file object to write the JSON serialized
json_dict
.**kwargs – Any keyword accepted by
json.dump
.
- json_dumps(**kwargs: object) str [source]
Serialize the particle’s
json_dict
into a JSON formattedstr
usingjson.dumps
.- Parameters:
**kwargs – Any keyword accepted by
json.dumps
.- Returns:
JSON formatted
str
.- Return type: