code: def massDistanceProfile(tsA, idx, m, tsB=None):
      """
      Returns the distance profile of a query within tsA against the time series tsB using the more efficient MASS comparison.
  
      Parameters
      ----------
      tsA: Time series containing the query for which to calculate the distance profile.
      idx: Starting location of the query within tsA
      m: Length of query.
      tsB: Time series to compare the query against. Note that, if no value is provided, tsB = tsA by default.
      """
  
      selfJoin = False
      if tsB is None:
          selfJoin = True
          tsB = tsA
  
      query = tsA[idx : (idx + m)]
      n = len(tsB)
      distanceProfile = np.real(
          np.sqrt(mass(query, tsB).astype(complex))
      )
      if selfJoin:
          trivialMatchRange = (
              int(max(0, idx - np.round(m / 2, 0))),
              int(min(idx + np.round(m / 2 + 1, 0), n)),
          )
          distanceProfile[
              trivialMatchRange[0] : trivialMatchRange[1]
          ] = np.inf
  
      # Both the distance profile and corresponding matrix profile index (which should just have the current index)
      return (distanceProfile, np.full(n - m + 1, idx, dtype=float))
  
file_path: matrixprofile-ts/matrixprofile/distanceProfile.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  from .utils import *
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: massDistanceProfile(tsA, idx, m, tsB) and returns: distanceProfile,  np