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 == lscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.int32(7), allow_downcast=True)
      assert b.type == iscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.int16(7), allow_downcast=True)
      assert b.type == wscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.int8(7), allow_downcast=True)
      assert b.type == bscalar
      f(b, 8.23)
      assert b.get_value() == 8
  
      b = shared(np.float64(7.234), allow_downcast=True)
      assert b.type == dscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(np.float32(7.234), allow_downcast=True)
      assert b.type == fscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(7.234, allow_downcast=True)
      assert b.type == dscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(7.234, allow_downcast=True)
      assert b.type == dscalar
      f(b, 8)
      assert b.get_value() == 8
  
      b = shared(np.zeros((5, 5), dtype="float32"))
      with pytest.raises(TypeError):
          f(b, np.random.random((5, 5)))
  
file_path: pytensor/tests/compile/test_shared.py
imports: import numpy
  import pytest
  import pytensor.tensor
  from pytensor.compile.sharedvalue import SharedVariable, shared
  from pytensor.configdefaults import config
  from pytensor.link.c.type import generic
  from pytensor.misc.safe_asarray import _asarray
  from pytensor.tensor.type import TensorType, bscalar, bvector, dscalar, dvector, fscalar, fvector, iscalar, ivector, lscalar, lvector, wscalar, wvector
  from pytensor.utils import PYTHON_INT_BITWIDTH
label_desc: Use image node_id 7 for calling the TestSharedVariable obj's underlying member method code with example usage: obj.test_scalar_floatX() without return types