class_docstr: Tests for AdaptiveScalarEncoder
docstr: Test the input description generation and topDown decoding
docstr_tok: ["Test","the","input","description","generation","and","topDown","decoding"]
code: def testTopDownDecode(self):
      """Test the input description generation and topDown decoding"""
      l = self._l
      v = l.minval
  
      while v < l.maxval:
          output = l.encode(v)
          decoded = l.decode(output)
  
          (fieldsDict, _) = decoded
          self.assertEqual(len(fieldsDict), 1)
  
          (ranges, _) = fieldsDict.values()[0]
          self.assertEqual(len(ranges), 1)
  
          (rangeMin, rangeMax) = ranges[0]
          self.assertEqual(rangeMin, rangeMax)
          self.assertLess(abs(rangeMin - v), l.resolution)
  
          topDown = l.topDownCompute(output)[0]
          self.assertLessEqual(abs(topDown.value - v), l.resolution)
  
          # Test bucket support
          bucketIndices = l.getBucketIndices(v)
          topDown = l.getBucketInfo(bucketIndices)[0]
          self.assertLessEqual(abs(topDown.value - v), l.resolution / 2)
          self.assertEqual(
              topDown.value, l.getBucketValues()[bucketIndices[0]]
          )
          self.assertEqual(topDown.scalar, topDown.value)
          self.assertTrue(numpy.array_equal(topDown.encoding, output))
  
          # Next value
          v += l.resolution / 4
  
file_path: nupic-legacy/tests/unit/nupic/encoders/adaptivescalar_test.py
imports: import tempfile
  import unittest
  import numpy
  from nupic.data import SENTINEL_VALUE_FOR_MISSING_DATA
  from nupic.encoders.adaptive_scalar import AdaptiveScalarEncoder
  from nupic.encoders.base import defaultDtype
label_desc: Use image node_id 4 for calling the AdaptiveScalarTest obj's underlying member method code with example usage: obj.testTopDownDecode() without return types