code: def stampi_update(
      tsA,
      m,
      mp,
      mpIndex,
      newval,
      tsB=None,
      distanceProfileFunction=distanceProfile.massDistanceProfile,
  ):
      """Updates the self-matched matrix profile for a time series TsA with the arrival of a new data point newval. Note that comparison of two separate time-series with new data arriving will be built later -> currently, tsB should be set to tsA"""
  
      # Update time-series array with recent value
      tsA_new = np.append(np.copy(tsA), newval)
  
      # Expand matrix profile and matrix profile index to include space for latest point
      mp_new = np.append(np.copy(mp), np.inf)
      mpIndex_new = np.append(np.copy(mpIndex), np.inf)
  
      # Determine new index value
      idx = len(tsA_new) - m
  
      (distanceProfile, querySegmentsID) = distanceProfileFunction(
          tsA_new, idx, m, tsB
      )
  
      # Check which of the indices have found a new minimum
      idsToUpdate = distanceProfile < mp_new
  
      # Update the Matrix Profile Index to indicate that the current index is the minimum location for the aforementioned indices
      mpIndex_new[idsToUpdate] = querySegmentsID[idsToUpdate]
  
      # Update the matrix profile to include the new minimum values (where appropriate)
      mp_final = np.minimum(np.copy(mp_new), distanceProfile)
  
      # Finally, set the last value in the matrix profile to the minimum of the distance profile (with corresponding index)
      mp_final[-1] = np.min(distanceProfile)
      mpIndex_new[-1] = np.argmin(distanceProfile)
  
      return (mp_final, mpIndex_new)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from .None import distanceProfile
  from .None import order
  from .utils import mass, movmeanstd
  import numpy
  import multiprocessing
  from functools import partial
  import math
  from .scrimp import scrimp_plus_plus
label_desc: Use image node_id 9 for calling a global function with example usage: stampi_update(tsA, m, mp, mpIndex, newval, tsB, distanceProfileFunction) and returns: mp_final,  mpIndex_new