def testSDRRandomEncoder(self): print "Testing RandomEncoder...", fieldWidth = 25 bitsOn = 10 s = SDRRandomEncoder(n=fieldWidth, w=bitsOn, name="foo") for _ in range(100): out = s.encode(0) self.assertEqual(out.shape, (fieldWidth, )) self.assertEqual(out.sum(), bitsOn) #print out x = s.decode(out) print x self.assertIsInstance(x[0], dict) self.assertTrue("foo" in x[0])
def testSDRRandomEncoder(self): print "Testing RandomEncoder...", fieldWidth = 25 bitsOn = 10 s = SDRRandomEncoder(n=fieldWidth, w=bitsOn, name="foo") for _ in range(100): out = s.encode(0) assert out.shape == (fieldWidth,) assert out.sum() == bitsOn #print out x = s.decode(out) print x assert isinstance(x[0], dict) assert "foo" in x[0]
def testSDRRandomEncoder(self): print "Testing RandomEncoder...", fieldWidth = 25 bitsOn = 10 s = SDRRandomEncoder(n=fieldWidth, w=bitsOn, name="foo") for _ in range(100): out = s.encode(0) self.assertEqual(out.shape, (fieldWidth,)) self.assertEqual(out.sum(), bitsOn) #print out x = s.decode(out) print x self.assertIsInstance(x[0], dict) self.assertTrue("foo" in x[0])