def __new__(cls, owner, value, updater=None, differentiator=None, jacobinator=None, description="", constant=False, save=True, copy=False): """Parameters ---------- owner : Frame Parent frame object to which the field belongs value : number, array, string Initial value of the field. Needs to have correct type and shape updater : Heartbeat, Updater, callable or None, optional, default : None Instruction for field update differentiator : Heartbeat, Updater, callable or None, optional, default : None Instruction for calculating derivative jacobinator : Heartbeat, Updater, callable or None, optional, default : None Instruction for calculating the Jacobi matrix description : string, optional, default : "" Descriptive string for the field constant : boolean, optional, default : False True if the field is immutable. save : boolean, optional, default : True If False the field is not written into output files copy : boolean, optional, default : False If True <value> will be copied, not referenced""" obj = np.array(value, copy=copy).view(cls) if obj.shape == (): obj = np.array([value], copy=copy).view(cls) obj._owner = owner obj.updater = Heartbeat(updater) obj.differentiator = Heartbeat(differentiator) obj.jacobinator = Heartbeat(jacobinator) obj.description = description obj.constant = constant obj.save = save obj._buffer = None return obj
def __array_finalize__(self, obj): if obj is None: return self._owner = getattr(obj, "_owner", None) self.updater = getattr(obj, "updater", Heartbeat(None)) self.differentiator = getattr(obj, "differentiator", Heartbeat(None)) self.jacobinator = getattr(obj, "jacobinator", Heartbeat(None)) self.description = getattr(obj, "description", "") self.constant = getattr(obj, "constant", False) self._save = getattr(obj, "_save", True) self._buffer = getattr(obj, "_buffer", None)
def updater(self, value): if isinstance(value, Heartbeat): self._updater = value self._updateorder = None elif isinstance(value, list): self._checkupdatelist(value) self._updater = Heartbeat(self._createupdatefromlist(value)) self._updateorder = value.copy() else: self._updater = Heartbeat(value) self._updateorder = None
def jacobinator(self, value): if isinstance(value, Heartbeat): self._jacobinator = value else: self._jacobinator = Heartbeat(value)
def differentiator(self, value): if isinstance(value, Heartbeat): self._differentiator = value else: self._differentiator = Heartbeat(value)
def finalizer(self, value): if isinstance(value, Heartbeat): self._finalizer = value else: self._finalizer = Heartbeat(value)
def failop(self, value): if isinstance(value, Heartbeat): self._failop = value else: self._failop = Heartbeat(value)
def preparator(self, value): if isinstance(value, Heartbeat): self._preparator = value else: self._preparator = Heartbeat(value)
def updater(self, value): if isinstance(value, Heartbeat): self._updater = value else: self._updater = Heartbeat(value)