class_docstr: Compute an incremental z-normalized matrix profile for streaming data
  
  This is based on the on-line STOMPI and STAMPI algorithms.
  
  Parameters
  ----------
  T : numpy.ndarray
      The time series or sequence for which the matrix profile and matrix profile
      indices will be returned
  
  m : int
      Window size
  
  egress : bool, default True
      If set to `True`, the oldest data point in the time series is removed and
      the time series length remains constant rather than forever increasing
  
  normalize : bool, default True
      When set to `True`, this z-normalizes subsequences prior to computing distances.
      Otherwise, this class gets re-routed to its complementary non-normalized
      equivalent set in the `@core.non_normalized` class decorator.
  
  p : float, default 2.0
      The p-norm to apply for computing the Minkowski distance. This parameter is
      ignored when `normalize == True`.
  
  k : int, default 1
      The number of top `k` smallest distances used to construct the matrix profile.
      Note that this will increase the total computational time and memory usage
      when k > 1.
  
  mp : numpy.ndarry, default None
      A pre-computed matrix profile (and corresponding matrix profile indices).
      This is a 2D array of shape `(len(T) - m + 1, 2 * k + 2)`, where the first `k`
      columns are top-k matrix profile, and the next `k` columns are their
      corresponding indices. The last two columns correspond to the top-1 left and
      top-1 right matrix profile indices. When None (default), this array is computed
      internally using `stumpy.stump`.
  
  T_subseq_isconstant_func : function, default None
      A custom, user-defined function that returns a boolean array that indicates
      whether a subsequence in `T` is constant (True). The function must only take
      two arguments, `a`, a 1-D array, and `w`, the window size, while additional
      arguments may be specified by currying the user-defined function using
      `functools.partial`. Any subsequence with at least one np.nan/np.inf will
      automatically have its corresponding value set to False in this boolean array.
  
  Attributes
  ----------
  P_ : numpy.ndarray
      The updated (top-k) matrix profile for `T`. When `k=1` (default), the first
      (and only) column in this 2D array consists of the matrix profile. When
      `k > 1`, the output has exactly `k` columns consisting of the top-k matrix
      profile.
  
  I_ : numpy.ndarray
      The updated (top-k) matrix profile indices for `T`. When `k=1` (default),
      the first (and only) column in this 2D array consists of the matrix profile
      indices. When `k > 1`, the output has exactly `k` columns consisting of the
      top-k matrix profile indices.
  
  left_P_ : numpy.ndarray
      The updated left (top-1) matrix profile for `T`
  
  left_I_ : numpy.ndarray
      The updated left (top-1) matrix profile indices for `T`
  
  T_ : numpy.ndarray
      The updated time series or sequence for which the matrix profile and matrix
      profile indices are computed
  
  Methods
  -------
  update(t)
      Append a single new data point, `t`, to the time series, `T`, and update the
      matrix profile
  
  Notes
  -----
  `DOI: 10.1007/s10618-017-0519-9     <https://www.cs.ucr.edu/~eamonn/MP_journal.pdf>`__
  
  See Table V
  
  Note that line 11 is missing an important `sqrt` operation!
  
  Examples
  --------
  >>> import stumpy
  >>> import numpy as np
  >>> stream = stumpy.stumpi(
  ...     np.array([584., -11., 23., 79., 1001., 0.]),
  ...     m=3)
  >>> stream.update(-19.0)
  >>> stream.left_P_
  array([       inf, 3.00009263, 2.69407392, 3.05656417])
  >>> stream.left_I_
  array([-1,  0,  1,  2])
class_docstr_tok: ["Compute","an","incremental","z-normalized","matrix","profile","for","streaming","data","This","is","based","on","the","on-line","STOMPI","and","STAMPI","algorithms",".","Parameters","--","--","--","--","--","T",":","numpy.ndarray","The","time","series","or","sequence","for","which","the","matrix","profile","and","matrix","profile","indices","will","be","returned","m",":","int","Window","size","egress",":","bool",",","default","True","If","set","to","`","True","`",",","the","oldest","data","point","in","the","time","series","is","removed","and","the","time","series","length","remains","constant","rather","than","forever","increasing","normalize",":","bool",",","default","True","When","set","to","`","True","`",",","this","z-normalizes","subsequences","prior","to","computing","distances",".","Otherwise",",","this","class","gets","re-routed","to","its","complementary","non-normalized","equivalent","set","in","the","`","@","core.non_normalized","`","class","decorator",".","p",":","float",",","default","2.0","The","p-norm","to","apply","for","computing","the","Minkowski","distance",".","This","parameter","is","ignored","when","`","normalize","==","True","`",".","k",":","int",",","default","1","The","number","of","top","`","k","`","smallest","distances","used","to","construct","the","matrix","profile",".","Note","that","this","will","increase","the","total","computational","time","and","memory","usage","when","k",">","1.","mp",":","numpy.ndarry",",","default","None","A","pre-computed","matrix","profile","(","and","corresponding","matrix","profile","indices",")",".","This","is","a","2D","array","of","shape","`","(","len","(","T",")","-","m","+","1",",","2","*","k","+","2",")","`",",","where","the","first","`","k","`","columns","are","top-k","matrix","profile",",","and","the","next","`","k","`","columns","are","their","corresponding","indices",".","The","last","two","columns","correspond","to","the","top-1","left","and","top-1","right","matrix","profile","indices",".","When","None","(","default",")",",","this","array","is","computed","internally","using","`","stumpy.stump","`",".","T_subseq_isconstant_func",":","function",",","default","None","A","custom",",","user-defined","function","that","returns","a","boolean","array","that","indicates","whether","a","subsequence","in","`","T","`","is","constant","(","True",")",".","The","function","must","only","take","two","arguments",",","`","a","`",",","a","1-D","array",",","and","`","w","`",",","the","window","size",",","while","additional","arguments","may","be","specified","by","currying","the","user-defined","function","using","`","functools.partial","`",".","Any","subsequence","with","at","least","one","np.nan\/np.inf","will","automatically","have","its","corresponding","value","set","to","False","in","this","boolean","array",".","Attributes","--","--","--","--","--","P_",":","numpy.ndarray","The","updated","(","top-k",")","matrix","profile","for","`","T","`",".","When","`","k=1","`","(","default",")",",","the","first","(","and","only",")","column","in","this","2D","array","consists","of","the","matrix","profile",".","When","`","k",">","1","`",",","the","output","has","exactly","`","k","`","columns","consisting","of","the","top-k","matrix","profile",".","I_",":","numpy.ndarray","The","updated","(","top-k",")","matrix","profile","indices","for","`","T","`",".","When","`","k=1","`","(","default",")",",","the","first","(","and","only",")","column","in","this","2D","array","consists","of","the","matrix","profile","indices",".","When","`","k",">","1","`",",","the","output","has","exactly","`","k","`","columns","consisting","of","the","top-k","matrix","profile","indices",".","left_P_",":","numpy.ndarray","The","updated","left","(","top-1",")","matrix","profile","for","`","T","`","left_I_",":","numpy.ndarray","The","updated","left","(","top-1",")","matrix","profile","indices","for","`","T","`","T_",":","numpy.ndarray","The","updated","time","series","or","sequence","for","which","the","matrix","profile","and","matrix","profile","indices","are","computed","Methods","--","--","--","-","update","(","t",")","Append","a","single","new","data","point",",","`","t","`",",","to","the","time","series",",","`","T","`",",","and","update","the","matrix","profile","Notes","--","--","-","`","DOI",":","10.1007\/s10618-017-0519-9","<","https",":","\/\/www.cs.ucr.edu\/~eamonn\/MP_journal.pdf",">","`","__","See","Table","V","Note","that","line","11","is","missing","an","important","`","sqrt","`","operation","!","Examples","--","--","--","--",">",">",">","import","stumpy",">",">",">","import","numpy","as","np",">",">",">","stream","=","stumpy.stumpi","(","...","np.array","(","[","584.",",","-11.",",","23.",",","79.",",","1001.",",","0",".","]",")",",","...","m=3",")",">",">",">","stream.update","(","-19.0",")",">",">",">","stream.left_P_","array","(","[","inf",",","3.00009263",",","2.69407392",",","3.05656417","]",")",">",">",">","stream.left_I_","array","(","[","-1",",","0",",","1",",","2","]",")"]
docstr: Ingress a new data point and update the (top-k) matrix profile and matrix
  profile indices without egressing the oldest data point
  
  Parameters
  ----------
  t : float
      A single new data point to be appended to `T`
docstr_tok: ["Ingress","a","new","data","point","and","update","the","(","top-k",")","matrix","profile","and","matrix","profile","indices","without","egressing","the","oldest","data","point","Parameters","--","--","--","--","--","t",":","float","A","single","new","data","point","to","be","appended","to","`","T","`"]
code: def _update(self, t):
      """
      Ingress a new data point and update the (top-k) matrix profile and matrix
      profile indices without egressing the oldest data point
  
      Parameters
      ----------
      t : float
          A single new data point to be appended to `T`
      """
      n = self._T.shape[0]
      l = n - self._m + 1
      T_new = np.append(self._T, t)
      QT_new = np.empty(self._QT.shape[0] + 1, dtype=np.float64)
      S = T_new[l:]
      t_drop = T_new[l - 1]
  
      if np.isfinite(t):
          self._T_isfinite = np.append(self._T_isfinite, True)
      else:
          self._T_isfinite = np.append(self._T_isfinite, False)
          t = 0
          T_new[-1] = 0
          S[-1] = 0
  
      if np.any(~self._T_isfinite[-self._m :]):
          μ_Q = np.inf
          σ_Q = np.nan
          Q_subseq_isconstant = False
      else:
          Q_subseq_isconstant = core.process_isconstant(
              S, self._m, self._T_subseq_isconstant_func
          )[0]
          μ_Q, σ_Q = [
              arr[0] for arr in core.compute_mean_std(S, self._m)
          ]
  
      M_T_new = np.append(self._M_T, μ_Q)
      Σ_T_new = np.append(self._Σ_T, σ_Q)
      T_subseq_isconstant_new = np.append(
          self._T_subseq_isconstant, Q_subseq_isconstant
      )
  
      QT_new[1:] = (
          self._QT[:l] - T_new[:l] * t_drop + T_new[self._m :] * t
      )
      QT_new[0] = np.sum(T_new[: self._m] * S[: self._m])
  
      D = core.calculate_distance_profile(
          self._m,
          QT_new,
          μ_Q,
          σ_Q,
          M_T_new,
          Σ_T_new,
          Q_subseq_isconstant,
          T_subseq_isconstant_new,
      )
      if np.any(~self._T_isfinite[-self._m :]):
          D[:] = np.inf
  
      core.apply_exclusion_zone(
          D, D.shape[0] - 1, self._excl_zone, np.inf
      )
  
      update_idx = np.argwhere(D[:l] < self._P[:l, -1]).flatten()
      for i in update_idx:
          idx = np.searchsorted(self._P[i], D[i], side="right")
          core._shift_insert_at_index(self._P[i], idx, D[i])
          core._shift_insert_at_index(self._I[i], idx, l)
  
      # Calculating top-k matrix profile and (top-1) left matrix profile (and their
      # corresponding indices) for new subsequence whose distance profile is `D`
      P_new = np.full(self._k, np.inf, dtype=np.float64)
      I_new = np.full(self._k, -1, dtype=np.int64)
      for i, d in enumerate(D):
          if d < P_new[-1]:  # maximum value in sorted array P_new
              idx = np.searchsorted(P_new, d, side="right")
              core._shift_insert_at_index(P_new, idx, d)
              core._shift_insert_at_index(I_new, idx, i)
  
      left_I_new = I_new[0]
      left_P_new = P_new[0]
  
      self._T = T_new
      self._P = np.append(self._P, P_new.reshape(1, -1), axis=0)
      self._I = np.append(self._I, I_new.reshape(1, -1), axis=0)
      self._left_P = np.append(self._left_P, left_P_new)
      self._left_I = np.append(self._left_I, left_I_new)
      self._QT = QT_new
      self._M_T = M_T_new
      self._Σ_T = Σ_T_new
      self._T_subseq_isconstant = T_subseq_isconstant_new
  
file_path: stumpy/stumpy/stumpi.py
imports: import numpy
  from .None import config, core, stump
  from .aampi import aampi
label_desc: Use image node_id 4 for calling the stumpi obj's underlying member method code with example usage: obj._update(t) without return types