Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 import templates_mod
00009 import unittest
00010 import numpy
00011
00012 class TestTemplates(unittest.TestCase):
00013
00014 def testTemplates(self):
00015 for dtype in (numpy.int16, numpy.int32, numpy.float32, numpy.complex128):
00016 v = numpy.arange(12, dtype=dtype)
00017 for shape in ((12,), (4, 3), (2, 6)):
00018 a1 = numpy.zeros(shape, dtype=dtype)
00019 a2 = v.reshape(a1.shape)
00020 templates_mod.fill(a1)
00021 self.assert_((a1 == a2).all())
00022 a1 = numpy.zeros((12,), dtype=numpy.float64)
00023 self.assertRaises(TypeError, templates_mod.fill, a1)
00024 a1 = numpy.zeros((12,2,3), dtype=numpy.float32)
00025 self.assertRaises(TypeError, templates_mod.fill, a1)
00026
00027 if __name__=="__main__":
00028 unittest.main()