code: def test_stumpi_self_join_KNN():
      m = 3
      zone = int(np.ceil(m / 4))
  
      for k in range(2, 4):
          seed = np.random.randint(100000)
          np.random.seed(seed)
  
          T = np.random.rand(30)
          stream = stumpi(T, m, egress=False, k=k)
          for i in range(34):
              t = np.random.rand()
              stream.update(t)
  
          comp_P = stream.P_
          comp_I = stream.I_
          comp_left_P = stream.left_P_
          comp_left_I = stream.left_I_
  
          ref_mp = naive.stump(
              stream.T_, m, exclusion_zone=zone, row_wise=True, k=k
          )
          ref_P = ref_mp[:, :k]
          ref_I = ref_mp[:, k : 2 * k]
          ref_left_I = ref_mp[:, 2 * k].astype(np.int64)
          ref_left_P = np.full_like(
              ref_left_I, np.inf, dtype=np.float64
          )
          for i, j in enumerate(ref_left_I):
              if j >= 0:
                  D = core.mass(
                      stream.T_[i : i + m], stream.T_[j : j + m]
                  )
                  ref_left_P[i] = D[0]
  
          naive.replace_inf(ref_P)
          naive.replace_inf(ref_left_P)
          naive.replace_inf(comp_P)
          naive.replace_inf(comp_left_P)
  
          npt.assert_almost_equal(ref_P, comp_P)
          npt.assert_almost_equal(ref_I, comp_I)
          npt.assert_almost_equal(ref_left_P, comp_left_P)
          npt.assert_almost_equal(ref_left_I, comp_left_I)
  
          np.random.seed(seed)
          T = np.random.rand(30)
          T = pd.Series(T)
          stream = stumpi(T, m, egress=False, k=k)
          for i in range(34):
              t = np.random.rand()
              stream.update(t)
  
          comp_P = stream.P_
          comp_I = stream.I_
          comp_left_P = stream.left_P_
          comp_left_I = stream.left_I_
  
          naive.replace_inf(comp_P)
          naive.replace_inf(comp_left_P)
  
          npt.assert_almost_equal(ref_P, comp_P)
          npt.assert_almost_equal(ref_I, comp_I)
          npt.assert_almost_equal(ref_left_P, comp_left_P)
          npt.assert_almost_equal(ref_left_I, comp_left_I)
  
imports: import functools
  import naive
  import numpy
  import numpy.testing
  import pandas
  import pytest
  from stumpy import config, core, stumpi
label_desc: Use image node_id 13 for calling a global function with example usage: test_stumpi_self_join_KNN() without return types