class_docstr: Tests for AdaptiveScalarEncoder
docstr: Non-periodic encoder, min and max not specified
docstr_tok: ["Non-periodic","encoder",",","min","and","max","not","specified"]
code: def testNonPeriodicEncoderMinMaxNotSpec(self):
      """Non-periodic encoder, min and max not specified"""
      l = AdaptiveScalarEncoder(
          name="scalar",
          n=14,
          w=5,
          minval=None,
          maxval=None,
          periodic=False,
          forced=True,
      )
  
      def _verify(v, encoded, expV=None):
          if expV is None:
              expV = v
  
          self.assertTrue(
              numpy.array_equal(
                  l.encode(v), numpy.array(encoded, dtype=defaultDtype)
              )
          )
          self.assertLessEqual(
              abs(
                  l.getBucketInfo(l.getBucketIndices(v))[0].value - expV
              ),
              l.resolution / 2,
          )
  
      def _verifyNot(v, encoded):
          self.assertFalse(
              numpy.array_equal(
                  l.encode(v), numpy.array(encoded, dtype=defaultDtype)
              )
          )
  
      _verify(1, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
      _verify(2, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(10, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(3, [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0])
      _verify(-9, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
      _verify(-8, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
      _verify(-7, [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0])
      _verify(-6, [0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0])
      _verify(-5, [0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0])
      _verify(0, [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0])
      _verify(8, [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0])
      _verify(8, [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0])
      _verify(10, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(11, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(12, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(13, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(14, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(15, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
  
      # """Test switching learning off"""
      l = AdaptiveScalarEncoder(
          name="scalar",
          n=14,
          w=5,
          minval=1,
          maxval=10,
          periodic=False,
          forced=True,
      )
      _verify(1, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
      _verify(10, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(20, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(10, [0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0])
  
      l.setLearning(False)
      _verify(30, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1], expV=20)
      _verify(20, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(-10, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], expV=1)
      _verify(-1, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], expV=1)
  
      l.setLearning(True)
      _verify(30, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verifyNot(20, [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1])
      _verify(-10, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
      _verifyNot(-1, [1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0])
  
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 6 for calling the AdaptiveScalarTest obj's underlying member method code with example usage: obj.testNonPeriodicEncoderMinMaxNotSpec() without return types