code: def test_numpy_endog():
      # Test various types of numpy endog inputs
  
      # Check behavior of the link maintained between passed `endog` and
      # `mod.endog` arrays
      endog = np.array([1.0, 2.0])
      mod = MLEModel(endog, **kwargs)
      assert_equal(mod.endog.base is not mod.data.orig_endog, True)
      assert_equal(mod.endog.base is not endog, True)
      assert_equal(mod.data.orig_endog.base is not endog, True)
      endog[0] = 2
      # there is no link to mod.endog
      assert_equal(mod.endog, np.r_[1, 2].reshape(2, 1))
      # there remains a link to mod.data.orig_endog
      assert_equal(mod.data.orig_endog, endog)
  
      # Check behavior with different memory layouts / shapes
  
      # Example  (failure): 0-dim array
      endog = np.array(1.0)
      # raises error due to len(endog) failing in statsmodels base classes
      assert_raises(TypeError, check_endog, endog, **kwargs)
  
      # Example : 1-dim array, both C- and F-contiguous, length 2
      endog = np.array([1.0, 2.0])
      assert_equal(endog.ndim, 1)
      assert_equal(endog.flags["C_CONTIGUOUS"], True)
      assert_equal(endog.flags["F_CONTIGUOUS"], True)
      assert_equal(endog.shape, (2,))
      mod = check_endog(endog, **kwargs)
      mod.filter([])
  
      # Example : 2-dim array, C-contiguous, long-shaped: (nobs, k_endog)
      endog = np.array([1.0, 2.0]).reshape(2, 1)
      assert_equal(endog.ndim, 2)
      assert_equal(endog.flags["C_CONTIGUOUS"], True)
      # On newer numpy (>= 0.10), this array is (rightly) both C and F contiguous
      # assert_equal(endog.flags['F_CONTIGUOUS'], False)
      assert_equal(endog.shape, (2, 1))
      mod = check_endog(endog, **kwargs)
      mod.filter([])
  
      # Example : 2-dim array, C-contiguous, wide-shaped: (k_endog, nobs)
      endog = np.array([1.0, 2.0]).reshape(1, 2)
      assert_equal(endog.ndim, 2)
      assert_equal(endog.flags["C_CONTIGUOUS"], True)
      # On newer numpy (>= 0.10), this array is (rightly) both C and F contiguous
      # assert_equal(endog.flags['F_CONTIGUOUS'], False)
      assert_equal(endog.shape, (1, 2))
      # raises error because arrays are always interpreted as
      # (nobs, k_endog), which means that k_endog=2 is incompatibile with shape
      # of design matrix (1, 1)
      assert_raises(ValueError, check_endog, endog, **kwargs)
  
      # Example : 2-dim array, F-contiguous, long-shaped (nobs, k_endog)
      endog = np.array([1.0, 2.0]).reshape(1, 2).transpose()
      assert_equal(endog.ndim, 2)
      # On newer numpy (>= 0.10), this array is (rightly) both C and F contiguous
      # assert_equal(endog.flags['C_CONTIGUOUS'], False)
      assert_equal(endog.flags["F_CONTIGUOUS"], True)
      assert_equal(endog.shape, (2, 1))
      mod = check_endog(endog, **kwargs)
      mod.filter([])
  
      # Example : 2-dim array, F-contiguous, wide-shaped (k_endog, nobs)
      endog = np.array([1.0, 2.0]).reshape(2, 1).transpose()
      assert_equal(endog.ndim, 2)
      # On newer numpy (>= 0.10), this array is (rightly) both C and F contiguous
      # assert_equal(endog.flags['C_CONTIGUOUS'], False)
      assert_equal(endog.flags["F_CONTIGUOUS"], True)
      assert_equal(endog.shape, (1, 2))
      # raises error because arrays are always interpreted as
      # (nobs, k_endog), which means that k_endog=2 is incompatibile with shape
      # of design matrix (1, 1)
      assert_raises(ValueError, check_endog, endog, **kwargs)
  
      # Example  (failure): 3-dim array
      endog = np.array([1.0, 2.0]).reshape(2, 1, 1)
      # raises error due to direct ndim check in statsmodels base classes
      assert_raises(ValueError, check_endog, endog, **kwargs)
  
      # Example : np.array with 2 columns
      # Update kwargs for k_endog=2
      kwargs2 = {
          "k_states": 1,
          "design": [[1], [0.0]],
          "obs_cov": [[1, 0], [0, 1]],
          "transition": [[1]],
          "selection": [[1]],
          "state_cov": [[1]],
          "initialization": "approximate_diffuse",
      }
      endog = np.array([[1.0, 2.0], [3.0, 4.0]])
      mod = check_endog(endog, k_endog=2, **kwargs2)
      mod.filter([])
  
imports: from statsmodels.compat.pandas import MONTH_END
  import os
  import re
  import warnings
  import numpy
  from numpy.testing import assert_, assert_allclose, assert_almost_equal, assert_equal, assert_raises
  import pandas
  import pytest
  from statsmodels.datasets import nile
  from statsmodels.tsa.statespace import kalman_filter, kalman_smoother, sarimax, varmax
  from statsmodels.tsa.statespace.mlemodel import MLEModel, MLEResultsWrapper
  from statsmodels.tsa.statespace.tests.results import results_sarimax, results_var_misc
label_desc: Use image node_id 20 for calling a global function with example usage: test_numpy_endog() without return types