Entity
Definition of abstract Entity class.
This module defines the Entity class, inherited by all physical simulation elements (including hardware and photons).
- class sequence.kernel.entity.ClassicalEntity(name: str, timeline: Timeline)
Abstract Entity class for purely classical entities. Entity should use the provided pseudo random number generator (PRNG) to produce reproducible random numbers. As a result, simulations with the same seed can reproduce identical results. Function “get_generator” returns the PRNG.
Compared with Entity, ClassicalEntity does not have _observers and _receivers
- name
name of the entity.
- Type:
str
- add_receiver(receiver)
Method to add a receiver (to receive photons).
- attach(observer)
Method to add an observer (to receive hardware updates).
- detach(observer)
Method to remove an observer.
- get(photon, **kwargs)
Method for an entity to receive a photon.
If entity is a node, may forward to external quantum channel. Must be overwritten to be used, or will raise exception.
- Parameters:
photon (Photon) – photon received by the entity.
**kwargs – other arguments required by a particular hardware component.
- get_generator() Generator
Method to get random generator of parent node.
If entity is not attached to a node, return default generator.
- abstractmethod init() None
Method to initialize entity (abstract).
Entity init methods are invoked for all timeline entities when the timeline is initialized. This method can be used to perform any necessary functions before simulation.
- notify(info)
Method to notify all attached observers of an update.
- remove_from_timeline() None
Method to remove entity from attached timeline.
This is to allow unused entities to be garbage collected.
- class sequence.kernel.entity.Entity(name: str, timeline: Timeline)
Abstract Entity class. Entity should use the provided pseudo random number generator (PRNG) to produce reproducible random numbers. As a result, simulations with the same seed can reproduce identical results. Function “get_generator” returns the PRNG.
- name
name of the entity.
- Type:
str
- _observers
a list of observers for the entity.
- Type:
list[Any]
- attach(observer: Any) None
Method to add an observer (to receive hardware updates).
- detach(observer: Any) None
Method to remove an observer.
- get(photon: Photon, **kwargs)
Method for an entity to receive a photon.
If entity is a node, may forward to external quantum channel. Must be overwritten to be used, or will raise exception.
- Parameters:
photon (Photon) – photon received by the entity.
**kwargs – other arguments required by a particular hardware component.
- get_generator() Generator
Method to get random generator of parent node.
If entity is not attached to a node, return default generator.
- abstractmethod init() None
Method to initialize entity (abstract).
Entity init methods are invoked for all timeline entities when the timeline is initialized. This method can be used to perform any necessary functions before simulation.
- notify(info: dict[str, Any]) None
Method to notify all attached observers of an update.
- remove_from_timeline() None
Method to remove entity from attached timeline.
This is to allow unused entities to be garbage collected.