class_docstr: Tests for AdaptiveScalarEncoder
code: def testReadWrite(self):
      originalValue = self._l.encode(1)
  
      proto1 = AdaptiveScalarEncoderProto.new_message()
      self._l.write(proto1)
  
      # Write the proto to a temp file and read it back into a new proto
      with tempfile.TemporaryFile() as f:
          proto1.write(f)
          f.seek(0)
          proto2 = AdaptiveScalarEncoderProto.read(f)
  
      encoder = AdaptiveScalarEncoder.read(proto2)
  
      self.assertIsInstance(encoder, AdaptiveScalarEncoder)
      self.assertEqual(encoder.recordNum, self._l.recordNum)
      self.assertDictEqual(
          encoder.slidingWindow.__dict__, self._l.slidingWindow.__dict__
      )
      self.assertEqual(encoder.w, self._l.w)
      self.assertEqual(encoder.minval, self._l.minval)
      self.assertEqual(encoder.maxval, self._l.maxval)
      self.assertEqual(encoder.periodic, self._l.periodic)
      self.assertEqual(encoder.n, self._l.n)
      self.assertEqual(encoder.radius, self._l.radius)
      self.assertEqual(encoder.resolution, self._l.resolution)
      self.assertEqual(encoder.name, self._l.name)
      self.assertEqual(encoder.verbosity, self._l.verbosity)
      self.assertEqual(encoder.clipInput, self._l.clipInput)
      self.assertTrue(
          numpy.array_equal(encoder.encode(1), originalValue)
      )
      self.assertEqual(
          self._l.decode(encoder.encode(1)),
          encoder.decode(self._l.encode(1)),
      )
  
      # Feed in a new value and ensure the encodings match
      result1 = self._l.encode(7)
      result2 = encoder.encode(7)
      self.assertTrue(numpy.array_equal(result1, result2))
  
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 8 for calling the AdaptiveScalarTest obj's underlying member method code with example usage: obj.testReadWrite() without return types