templates.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # Copyright Jim Bosch & Ankit Daftery 2010-2012.
00004 # Distributed under the Boost Software License, Version 1.0.
00005 #    (See accompanying file LICENSE_1_0.txt or copy at
00006 #          http://www.boost.org/LICENSE_1_0.txt)
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()


boost_numpy
Author(s): Jim Bosch, Ankit Daftery
autogenerated on Fri Aug 28 2015 10:10:40