code: def test_stumpi_self_join_egress_KNN():
      m = 3
  
      for k in range(2, 4):
          seed = np.random.randint(100000)
          np.random.seed(seed)
          n = 30
          T = np.random.rand(n)
  
          ref_mp = naive.stumpi_egress(T, m, k=k)
          ref_P = ref_mp.P_.copy()
          ref_I = ref_mp.I_
          ref_left_P = ref_mp.left_P_.copy()
          ref_left_I = ref_mp.left_I_
  
          stream = stumpi(T, m, egress=True, k=k)
  
          comp_P = stream.P_.copy()
          comp_I = stream.I_
          comp_left_P = stream.left_P_.copy()
          comp_left_I = stream.left_I_
  
          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)
  
          for i in range(34):
              t = np.random.rand()
              ref_mp.update(t)
              stream.update(t)
  
              comp_P = stream.P_.copy()
              comp_I = stream.I_
              comp_left_P = stream.left_P_.copy()
              comp_left_I = stream.left_I_
  
              ref_P = ref_mp.P_.copy()
              ref_I = ref_mp.I_
              ref_left_P = ref_mp.left_P_.copy()
              ref_left_I = ref_mp.left_I_
  
              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(n)
          T = pd.Series(T)
  
          ref_mp = naive.stumpi_egress(T, m, k=k)
          ref_P = ref_mp.P_.copy()
          ref_I = ref_mp.I_
          ref_left_P = ref_mp.left_P_.copy()
          ref_left_I = ref_mp.left_I_
  
          stream = stumpi(T, m, egress=True, k=k)
  
          comp_P = stream.P_.copy()
          comp_I = stream.I_
          comp_left_P = stream.left_P_.copy()
          comp_left_I = stream.left_I_
  
          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)
  
          for i in range(34):
              t = np.random.rand()
              t = np.random.rand()
              ref_mp.update(t)
              stream.update(t)
  
              comp_P = stream.P_.copy()
              comp_I = stream.I_
              comp_left_P = stream.left_P_.copy()
              comp_left_I = stream.left_I_
  
              ref_P = ref_mp.P_.copy()
              ref_I = ref_mp.I_
              ref_left_P = ref_mp.left_P_.copy()
              ref_left_I = ref_mp.left_I_
  
              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)
  
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 14 for calling a global function with example usage: test_stumpi_self_join_egress_KNN() without return types