code: def test_scalar_floatX(self):
      # the test should assure that floatX is not used in the shared
      # constructor for scalars Shared values can change, and since we don't
      # know the range they might take, we should keep the same
      # bit width / precision as the original value used to create the
      # shared variable.
  
      # Since downcasting of a value now raises an Exception,
  
      def f(var, val):
          var.set_value(val)
  
      b = shared(np.int64(7), allow_downcast=True)
      assert b.type == theano.tensor.lscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.int32(7), allow_downcast=True)
      assert b.type == theano.tensor.iscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.int16(7), allow_downcast=True)
      assert b.type == theano.tensor.wscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.int8(7), allow_downcast=True)
      assert b.type == theano.tensor.bscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.float64(7.234), allow_downcast=True)
      assert b.type == theano.tensor.dscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(np.float32(7.234), allow_downcast=True)
      assert b.type == theano.tensor.fscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(np.float(7.234), allow_downcast=True)
      assert b.type == theano.tensor.dscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(7.234, allow_downcast=True)
      assert b.type == theano.tensor.dscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(np.zeros((5, 5), dtype="float32"))
      self.assertRaises(TypeError, f, b, np.random.rand(5, 5))
  
file_path: Theano/theano/compile/tests/test_shared.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import unittest
  import theano
  from theano.tensor import Tensor, TensorType
  from theano.compile.sharedvalue import shared
  from theano.compile.sharedvalue import SharedVariable
  from theano.compile.sharedvalue import generic
label_desc: Use image node_id 7 for calling the Test_SharedVariable obj's underlying member method code with example usage: obj.test_scalar_floatX() without return types