code: def test_float(self):
      np.random.seed(1234)
      series = np.random.random(100)
      float_coder = FloatCode("t", 5, 0, False, 10, True)
      float_coder.compute_code(data_series=series)
      r = float_coder.encode("0.323")
      assert np.array_equal(np.array(r), np.array([40, 32, 25, 17, 3]))
      decoded = float_coder.decode(r)
      assert decoded == "0.32290"
      r = float_coder.encode("1.323")
      assert np.array_equal(np.array(r), np.array([41, 30, 20, 10, 0]))
      decoded = float_coder.decode(r)
      assert decoded == "0.99208"
      r = float_coder.encode("nan")
      assert np.array_equal(np.array(r), np.array([42, 39, 29, 19, 9]))
      decoded = float_coder.decode(r)
      assert decoded == "nan"
  
      float_coder = FloatCode("t", 5, 0, False, 10, True, "yeo-johnson")
      float_coder.compute_code(data_series=series)
      r = float_coder.encode("0.323")
      assert np.array_equal(np.array(r), np.array([41, 30, 25, 14, 5]))
      decoded = float_coder.decode(r)
      assert decoded == "0.32300"
      r = float_coder.encode("1.323")
      assert np.array_equal(np.array(r), np.array([43, 39, 21, 16, 3]))
      decoded = float_coder.decode(r)
      assert decoded == "1.08064"
      r = float_coder.encode("nan")
      assert np.array_equal(np.array(r), np.array([44, 39, 29, 19, 9]))
      decoded = float_coder.decode(r)
      assert decoded == "nan"
  
      float_coder = FloatCode("t", 5, 0, False, 10, True, "robust")
      float_coder.compute_code(data_series=series)
      r = float_coder.encode("0.323")
      assert np.array_equal(np.array(r), np.array([40, 37, 24, 10, 8]))
      decoded = float_coder.decode(r)
      assert decoded == "0.32299"
      r = float_coder.encode("1.323")
      assert np.array_equal(np.array(r), np.array([42, 30, 27, 19, 3]))
      decoded = float_coder.decode(r)
      assert decoded == "0.89536"
      r = float_coder.encode("nan")
      assert np.array_equal(np.array(r), np.array([43, 39, 29, 19, 9]))
      decoded = float_coder.decode(r)
      assert decoded == "nan"
  
      float_coder = FloatCode("t", 5, 0, True, 377, True)
      float_coder.compute_code(data_series=series)
      r = float_coder.encode("0.323")
      assert np.array_equal(
          np.array(r), np.array([1508, 1228, 765, 663, 194])
      )
      decoded = float_coder.decode(r)
      assert decoded == "0.32299999994"
      r = float_coder.encode("nan")
      assert np.array_equal(
          np.array(r), np.array([1885, 1507, 1130, 753, 376])
      )
      decoded = float_coder.decode(r)
      assert decoded == "nan"
      assert float_coder.end_id == 1886
      assert float_coder.code_range[0] == (1508, 1886)
      assert float_coder.code_range[1] == (1131, 1508)
      assert float_coder.code_range[2] == (754, 1131)
      assert float_coder.code_range[3] == (377, 754)
      assert float_coder.code_range[4] == (0, 377)
  
      float_coder = FloatCode("t", 5, 0, True, 377, False)
      float_coder.compute_code(data_series=series)
      assert float_coder.end_id == 1885
      assert float_coder.code_range[0] == (1508, 1885)
      assert float_coder.code_range[1] == (1131, 1508)
      assert float_coder.code_range[2] == (754, 1131)
      assert float_coder.code_range[3] == (377, 754)
      assert float_coder.code_range[4] == (0, 377)
      try:
          float_coder.encode("nan")
      except ValueError as e:
          assert (
              str(e)
              == "colum t cannot handle nan, please set hasnan=True"
          )
  
file_path: NeMo/tests/collections/nlp/test_num_encoding.py
imports: import string
  import numpy
  import pytest
  from nemo.collections.common.tokenizers.column_coder import CategoryCode, ColumnCodes, FloatCode, IntCode
label_desc: Use image node_id 1 for calling the TestColumnCoder obj's underlying member method code with example usage: obj.test_float() without return types