comparison _test_dataset.py @ 29:46c5c90019c2

Changed apply_function so that it propagates methods of the source.
author bengioy@grenat.iro.umontreal.ca
date Fri, 11 Apr 2008 15:46:18 -0400
parents 541a273bc89f
children 5b3afda2f1ad
comparison
equal deleted inserted replaced
28:541a273bc89f 29:46c5c90019c2
78 n = numpy.random.rand(3,8) 78 n = numpy.random.rand(3,8)
79 a=ArrayDataSet(data=n,fields={"x":slice(2),"y":slice(1,4),"z":slice(4,6)}) 79 a=ArrayDataSet(data=n,fields={"x":slice(2),"y":slice(1,4),"z":slice(4,6)})
80 b=a.rename({'xx':'x','zz':'z'}) 80 b=a.rename({'xx':'x','zz':'z'})
81 self.failUnless(b.hasFields('xx','zz') and not b.hasFields('x') and not b.hasFields('y')) 81 self.failUnless(b.hasFields('xx','zz') and not b.hasFields('x') and not b.hasFields('y'))
82 82
83 class T_applyfunctiondataset(unittest.TestCase):
84 def setUp(self):
85 numpy.random.seed(123456)
86
87 def test_function(self):
88 n = numpy.random.rand(3,8)
89 a=ArrayDataSet(data=n,fields={"x":slice(2),"y":slice(1,4),"z":slice(4,6)})
90 b=a.apply_function(lambda x,y: x+y,x+1, ['x','y'], ['x+y','x+1'], False,False,False)
91 print b.fieldNames()
92 print b('x+y')
93
83 94
84 if __name__ == '__main__': 95 if __name__ == '__main__':
85 unittest.main() 96 unittest.main()
86 97