AbstractParticle

class plasmapy.particles.AbstractParticle

Bases: abc.ABC

An abstract base class that defines the interface for particles.

Attributes Summary

charge
json_dict A dictionary representation of the particle object that is JSON friendly (i.e.
mass

Methods Summary

json_dump(fp, **kwargs) Writes the particle’s json_dict to the fp file object using json.dump.
json_dumps(**kwargs) Serialize the particle’s json_dict into a JSON formatted str using json.dumps.

Attributes Documentation

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 ParticleJSONDecoder knows how to decoded 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 creaed
    "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

Methods Documentation

json_dump(fp, **kwargs)

Writes the particle’s json_dict to the fp file object using json.dump.

Parameters:
json_dumps(**kwargs) → str

Serialize the particle’s json_dict into a JSON formatted str using json.dumps.

Parameters:**kwargs – Any keyword accepted by json.dumps.
Returns:JSON formatted str.
Return type:str