Exemplo n.º 1
0
  def testDecoding(self):
    s = ScalarEncoder(1,1,3,n=3, name='idx', forced=True)
    v = VectorEncoder(3, s, typeCastFn=float)
    data=[1,2,3]
    enc = v.encode(data)

    #decode
    dec = v.decode(enc)
    print "decoded=", dec
    res= v.getData(dec)
    self.assertEqual(data, res, "Decoded data not equal to original")
Exemplo n.º 2
0
  def testEncoding(self):
    s = ScalarEncoder(1,1,3,n=3, name='idx', forced=True)
    v = VectorEncoder(3, s, typeCastFn=float)

    data=[1,2,3]
    print "data=", data
    # encode
    enc = v.encode(data)
    print "encoded=", enc
    correct = [1,0,0,0,1,0,0,0,1]
    self.assertTrue((enc==correct).all(), "Did not encode correctly")