docstr: Test that the solution to the discrete approximation of a continuous
  system actually approximates the solution to the continuous system.
  This is an indirect test of the correctness of the implementation
  of cont2discrete.
docstr_tok: ["Test","that","the","solution","to","the","discrete","approximation","of","a","continuous","system","actually","approximates","the","solution","to","the","continuous","system",".","This","is","an","indirect","test","of","the","correctness","of","the","implementation","of","cont2discrete","."]
code: def test_discrete_approx(self):
      """
      Test that the solution to the discrete approximation of a continuous
      system actually approximates the solution to the continuous system.
      This is an indirect test of the correctness of the implementation
      of cont2discrete.
      """
  
      def u(t):
          return np.sin(2.5 * t)
  
      a = np.array([[-0.01]])
      b = np.array([[1.0]])
      c = np.array([[1.0]])
      d = np.array([[0.2]])
      x0 = 1.0
  
      t = np.linspace(0, 10.0, 101)
      dt = t[1] - t[0]
      u1 = u(t)
  
      # Use lsim2 to compute the solution to the continuous system.
      t, yout, xout = lsim2(
          (a, b, c, d), T=t, U=u1, X0=x0, rtol=1e-9, atol=1e-11
      )
  
      # Convert the continuous system to a discrete approximation.
      dsys = c2d((a, b, c, d), dt, method="bilinear")
  
      # Use dlsim with the pairwise averaged input to compute the output
      # of the discrete system.
      u2 = 0.5 * (u1[:-1] + u1[1:])
      t2 = t[:-1]
      td2, yd2, xd2 = dlsim(dsys, u=u2.reshape(-1, 1), t=t2, x0=x0)
  
      # ymid is the average of consecutive terms of the "exact" output
      # computed by lsim2.  This is what the discrete approximation
      # actually approximates.
      ymid = 0.5 * (yout[:-1] + yout[1:])
  
      assert_allclose(yd2.ravel(), ymid, rtol=1e-4)
  
imports: from __future__ import division, print_function, absolute_import
  import numpy
  from numpy.testing import assert_array_almost_equal, assert_almost_equal, assert_allclose, assert_equal
  import warnings
  from scipy.signal import cont2discrete
  from scipy.signal import dlsim, ss2tf, ss2zpk, lsim2, lti
label_desc: Use image node_id 9 for calling the TestC2D obj's underlying member method code with example usage: obj.test_discrete_approx() and returns: np