class_docstr: Tests scalar data class.
      
class_docstr_tok: ["Tests","scalar","data","class","."]
code: def _run_and_test(self, hparams):
      # Construct database
      scalar_data = tx.data.ScalarData(hparams)
  
      self.assertEqual(
          scalar_data.list_items()[0], hparams["dataset"]["data_name"]
      )
  
      iterator = scalar_data.dataset.make_initializable_iterator()
      data_batch = iterator.get_next()
  
      with self.test_session() as sess:
          sess.run(tf.global_variables_initializer())
          sess.run(tf.local_variables_initializer())
          sess.run(tf.tables_initializer())
          sess.run(iterator.initializer)
  
          i = 0
          while True:
              try:
                  # Run the logics
                  data_batch_ = sess.run(data_batch)
                  self.assertEqual(
                      set(data_batch_.keys()),
                      set(scalar_data.list_items()),
                  )
                  value = data_batch_[scalar_data.data_name][0]
                  self.assertEqual(i, value)
                  i += 1
                  # pylint: disable=no-member
                  if hparams["dataset"]["data_type"] == "int":
                      self.assertTrue(isinstance(value, np.int32))
                  else:
                      self.assertTrue(isinstance(value, np.float32))
              except tf.errors.OutOfRangeError:
                  print("Done -- epoch limit reached")
                  break
  
file_path: texar/tests/data/data/scalar_data_test.py
imports: import copy
  import tempfile
  import numpy
  import tensorflow
  import texar.tf
label_desc: Use image node_id 2 for calling the ScalarDataTest obj's underlying member method code with example usage: obj._run_and_test(hparams) without return types