code: def test_spectral_radius_bound():
      tol = 10 ** (-6)
      rng = np.random.RandomState(utt.fetch_seed())
      x = theano.tensor.matrix()
      radius_bound = spectral_radius_bound(x, 5)
      f = theano.function([x], radius_bound)
  
      shp = (3, 4)
      m = rng.rand(*shp)
      m = np.cov(m).astype(config.floatX)
      radius_bound_theano = f(m)
  
      # test the approximation
      mm = m
      for i in range(5):
          mm = np.dot(mm, mm)
      radius_bound_numpy = np.trace(mm) ** (2 ** (-5))
      assert abs(radius_bound_numpy - radius_bound_theano) < tol
  
      # test the bound
      eigen_val = numpy.linalg.eig(m)
      assert (eigen_val[0].max() - radius_bound_theano) < tol
  
      # test type errors
      xx = theano.tensor.vector()
      ok = False
      try:
          spectral_radius_bound(xx, 5)
      except TypeError:
          ok = True
      assert ok
      ok = False
      try:
          spectral_radius_bound(x, 5.0)
      except TypeError:
          ok = True
      assert ok
  
      # test value error
      ok = False
      try:
          spectral_radius_bound(x, -5)
      except ValueError:
          ok = True
      assert ok
  
file_path: Theano/theano/sandbox/linalg/tests/test_linalg.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import numpy.linalg
  import theano
  from theano import tensor, function
  from theano.tensor.basic import _allclose
  from theano.tests.test_rop import break_op
  from theano.tests import unittest_tools
  from theano import config
  from theano.tensor.nlinalg import MatrixInverse
  from theano.tensor import DimShuffle
  from theano.sandbox.linalg.ops import Cholesky, matrix_inverse, Solve, solve, spectral_radius_bound, imported_scipy, inv_as_solve
  from nose.plugins.skip import SkipTest
label_desc: Use image node_id 2 for calling a global function with example usage: test_spectral_radius_bound() without return types