code: def test_interp_long_to_wide():
      # Test 1
      t = np.array([1.1, 1.2, 2.1, 3.3, 3.4, 3.5]).astype(float)
      s = np.array([0, 1, 0, 0, 1, 1]).astype(float)
      v1 = np.array([3, 4, 5, 7, 15, 25]).astype(float)
      v2 = np.array([5, 7, 6, 9, 22, 35]).astype(float)
      y = np.array([1, 2, 2, 2, 3, 3]).astype(float)
      df = np.column_stack([t, s, v1, v2])
  
      X = [df, df]
      y = [y, y]
  
      stacked_interp = transform.InterpLongToWide(0.5)
      stacked_interp.fit(X, y)
      Xc, yc, swt = stacked_interp.transform(X, y)
  
      # --Checks--
      # linearly sampled time within bounds = 1.2, 1.7, 2.2, 2.7, 3.2 --> len(Xc[0]) = 5
      assert len(Xc[0]) == 5
      # Xc shape[1] = unique(s) * no. dimensions of values (V1) = 2 * 2 = 4
      assert Xc[0].shape[1] == 4
      assert swt is None
  
      # Test 2
      y = [1, 2]
      stacked_interp.fit(X, y)
      Xc, yc, swt = stacked_interp.transform(X, y)
      assert np.array_equal(yc, y)
  
      # Test 3
      N = 100
      sample_period = 0.5
      t = np.arange(N) + np.random.rand(N)
      s = np.array([1, 2] * int(N / 2))
      np.random.shuffle(s)
  
      v1 = np.arange(N) + np.random.rand(N)
      v2 = np.arange(N) + np.random.rand(N)
      v3 = np.arange(N) + np.random.rand(N)
      df = np.column_stack([t, s, v1, v2, v3])
      X = [df, df, df]
      dm = np.arange(N) + np.random.rand(N)
      y = [dm, dm, dm]
  
      stacked_interp = transform.InterpLongToWide(sample_period)
      stacked_interp.fit(X, y)
  
      Xc, yc, swt = stacked_interp.transform(X, y)
  
      # --Checks--
      assert Xc[0].shape[1] == len(np.unique(s)) * (X[0].shape[1] - 2)
      assert len(Xc[0]) <= N / sample_period
  
      # Test 3 - duplicate entries for t
      t = np.array([1.1, 1.1, 1.2, 2.1, 3.3, 3.4, 3.5]).astype(float)
      s = np.array([0, 0, 1, 0, 0, 1, 1]).astype(float)
      v1 = np.array([3, 3, 4, 5, 7, 15, 25]).astype(float)
      v2 = np.array([5, 5, 7, 6, 9, 22, 35]).astype(float)
      y = np.array([1, 1, 2, 2, 2, 3, 3]).astype(float)
      df = np.column_stack([t, s, v1, v2])
  
      X = [df, df]
      y = [y, y]
  
      with warnings.catch_warnings(record=True) as w:
          stacked_interp = transform.InterpLongToWide(
              0.5, assume_sorted=False
          )
          stacked_interp.fit(X, y)
          Xc, yc, swt = stacked_interp.transform(X, y)
  
          assert len(w) == 1
          assert issubclass(w[-1].category, UserWarning)
          assert "duplicate" in str(w[-1].message)
  
          # --Checks--
          assert len(Xc[0]) == 5
          assert Xc[0].shape[1] == 4
          assert swt is None
          assert np.count_nonzero(np.isnan(Xc)) == 0
  
file_path: seglearn/seglearn/tests/test_transform.py
imports: import warnings
  import numpy
  import pytest
  import seglearn.transform
  from seglearn.base import TS_Data
  from seglearn.feature_functions import all_features, mean
  from seglearn.util import get_ts_data_parts
label_desc: Use image node_id 9 for calling a global function with example usage: test_interp_long_to_wide() without return types