Example #1
0
 def testConversionToK(self):
     ik = _arraytok(self.ia)
     fk = _arraytok(self.fa)
     sk = _arraytok(self.sa)
     self.failUnlessEqual(_ktoarray(ik), self.ia, "integer list")
     self.failUnlessEqual(_ktoarray(fk), self.fa, "double list")
     self.failUnlessEqual(_ktoarray(sk), self.sa, "symbol list")
Example #2
0
 def testConversionToK(self):
     ik = _arraytok(self.ia)
     fk = _arraytok(self.fa)
     sk = _arraytok(self.sa)
     self.failUnlessEqual(_ktoarray(ik), self.ia, "integer list")
     self.failUnlessEqual(_ktoarray(fk), self.fa, "double list")
     self.failUnlessEqual(_ktoarray(sk), self.sa, "symbol list")
Example #3
0
File: K.py Project: plusxp/kx-1
 def __init__(self, pyo, t=None):
     '''
     >>> K((1, 2, 3, 4))
     k("1 2 3 4")
     >>> K(dict(a=(1,2,3), b=(3,4,5)))
     k(""" .((`a
        1 2 3
        )
       (`b
        3 4 5
        )) """)
     >>> K(Numeric.array((1,2,3,4)))
     k("1 2 3 4")
     '''
     if type(pyo) is Numeric.ArrayType:
         k = _arraytok(pyo)
     elif type(pyo) is _K:
         k = pyo
         if t and t != k.t:
             raise NotImplemented
     else:
         if not t:
             t = _guesst(pyo)
         else:
             if t > 0:
                 pyt = _pyt[t - 1]
                 pyo = pyt(pyo)
             elif t < 0:
                 pyt = _pyt[-t - 1]
                 pyo = map(pyt, pyo)
         kgen = _kgen(t)
         k = kgen(pyo)
     _K.__init__(self, k)
Example #4
0
File: K.py Project: kevinarpe/kx
 def __init__(self, pyo, t=None):
     '''
     >>> K((1, 2, 3, 4))
     k("1 2 3 4")
     >>> K(dict(a=(1,2,3), b=(3,4,5)))
     k(""" .((`a
        1 2 3
        )
       (`b
        3 4 5
        )) """)
     >>> K(Numeric.array((1,2,3,4)))
     k("1 2 3 4")
     '''
     if type(pyo) is Numeric.ArrayType:
       k = _arraytok(pyo)  
     elif type(pyo) is _K:
         k = pyo
         if t and t != k.t:
             raise NotImplemented
     else:
         if not t:
             t = _guesst(pyo)
         else:
             if t > 0:
                 pyt = _pyt[t-1]
                 pyo = pyt(pyo)
             elif t < 0:
                 pyt = _pyt[-t-1]
                 pyo = map(pyt, pyo)
         kgen = _kgen(t)
         k = kgen(pyo)
     _K.__init__(self, k)