code: def test_interp():
      # univariate time series
      N = 100
      t = np.arange(N) + np.random.rand(N)
      X = [np.column_stack([t, np.random.rand(N)])]
      y = [np.random.rand(N)]
  
      interp = transform.Interp(2)
      interp.fit(X)
      Xc, yc, swt = interp.transform(X, y)
  
      assert len(Xc[0]) == N / 2
      assert len(yc[0]) == N / 2
      assert np.ndim(Xc[0]) == 1
  
      y = [np.random.randint(0, 5, N)]
      interp = transform.Interp(
          5, kind="cubic", categorical_target=True
      )
      interp.fit(X, y)
      Xc, yc, swt = interp.transform(X, y)
  
      assert len(Xc[0]) == N / 5
      assert len(yc[0]) == N / 5
      assert np.ndim(Xc[0]) == 1
      assert np.all(np.isin(yc, np.arange(6)))
  
      # multivariate time series
      N = 100
      D = 5
      t = np.arange(N) + np.random.rand(N)
      X = [np.column_stack([t, np.random.rand(N, D)])]
      y = [np.random.rand(N)]
  
      interp = transform.Interp(2)
      interp.fit(X)
      Xc, yc, swt = interp.transform(X, y)
  
      assert len(Xc[0]) == N / 2
      assert len(yc[0]) == N / 2
      assert Xc[0].shape[1] == D
  
      y = [np.random.randint(0, 5, N)]
      interp = transform.Interp(
          5, kind="cubic", categorical_target=True
      )
      interp.fit(X, y)
      Xc, yc, swt = interp.transform(X, y)
  
      assert len(Xc[0]) == N / 5
      assert len(yc[0]) == N / 5
      assert Xc[0].shape[1] == D
      assert np.all(np.isin(yc, np.arange(6)))
  
      # sorting case
      N = 100
      t = np.arange(N)
      t[0:3] = 0
      X = [np.column_stack([t, np.random.rand(N)])]
      y = [np.random.rand(N)]
  
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
          interp = transform.Interp(
              sample_period=2, assume_sorted=False
          )
          interp.fit(X)
          Xc, yc, swt = interp.transform(X, y)
          assert len(w) == 2
          assert issubclass(w[-1].category, UserWarning)
          assert "duplicate" in str(w[-1].message)
          assert len(Xc[0]) == N / 2
          assert len(yc[0]) == N / 2
          assert np.ndim(Xc[0]) == 1
          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 8 for calling a global function with example usage: test_interp() without return types