Exemplo n.º 1
0
 def testVectorEncoderOPFInstance(self):
   """calling VectorEncoder from OPF"""
   opfVect = VectorEncoderOPF(3, 1, 3, n=211, w=21, dataType="int")
   data=[1,2,3]
   enc=opfVect.encode(data)
   dec=opfVect.decode(enc)
   data2=opfVect.getData(dec)
   self.assertEqual(data, data2, "VectorEncoderOPF did not encode/decode correctly.")
Exemplo n.º 2
0
  def testVectorEncoderOPFTypeCast(self):
    """for calling from OPF, use this to cast data type"""
    opfVect = VectorEncoderOPF(3, 1, 3, n=300, w=21, dataType="str")
    data=[1,2,3]
    enc=opfVect.encode(data)
    dec=opfVect.decode(enc)
    data2=opfVect.getData(dec)
    self.assertIsInstance(data2[0], str, "VectorEncoderOPF did not cast output to str(ing)")

    opfVect = VectorEncoderOPF(3, 1, 3, n=300, w=21, dataType="int")
    data=[1,2,3]
    enc=opfVect.encode(data)
    dec=opfVect.decode(enc)
    data2=opfVect.getData(dec)
    self.assertIsInstance(data2[0], int, "VectorEncoderOPF did not cast output to int")