summaryrefslogtreecommitdiff
path: root/numpy/doc/swig/test1D.py
blob: b1909c5b7f0808737f893a0715179475a135777d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
#! /usr/bin/env python

# System imports
from   distutils.util import get_platform
import os
import sys
import unittest

# Import NumPy
import numpy as N
major, minor = [ int(d) for d in N.__version__.split(".")[:2] ]
if major == 0: BadListError = TypeError
else:          BadListError = ValueError

# Add the distutils-generated build directory to the python search path and then
# import the extension module
libDir = "lib.%s-%s" % (get_platform(), sys.version[:3])
sys.path.insert(0,os.path.join("build", libDir))
import Vector

######################################################################

class VectorTestCase(unittest.TestCase):

    ####################################################
    ### Test functions that take arrays of type BYTE ###
    def testScharLength(self):
        "Test scharLength function"
        self.assertEquals(Vector.scharLength([5, 12, 0]), 13)

    def testScharLengthBad(self):
        "Test scharLength function for wrong size"
        self.assertRaises(TypeError, Vector.scharLength, [5, 12])

    def testScharProd(self):
        "Test scharProd function"
        self.assertEquals(Vector.scharProd([1,2,3,4]), 24)

    def testScharProdNonContainer(self):
        "Test scharProd function with None"
        self.assertRaises(TypeError, Vector.scharProd, None)

    def testScharSum(self):
        "Test scharSum function"
        self.assertEquals(Vector.scharSum([-5,6,-7,8]), 2)

    def testScharReverse(self):
        "Test scharReverse function"
        vector = N.array([1,2,4],'b')
        Vector.scharReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testScharOnes(self):
        "Test scharOnes function"
        myArray = N.zeros(5,'b')
        Vector.scharOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testScharZeros(self):
        "Test scharZeros function"
        myArray = N.ones(5,'b')
        Vector.scharZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testScharEOSplit(self):
        "Test scharEOSplit function"
        even, odd = Vector.scharEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testScharTwos(self):
        "Test scharTwos function"
        twos = Vector.scharTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testScharThrees(self):
        "Test scharThrees function"
        threes = Vector.scharThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    #####################################################
    ### Test functions that take arrays of type UBYTE ###
    def testUcharLength(self):
        "Test ucharLength function"
        self.assertEquals(Vector.ucharLength([5, 12, 0]), 13)

    def testUcharLengthBad(self):
        "Test ucharLength function for wrong size"
        self.assertRaises(TypeError, Vector.ucharLength, [5, 12])

    def testUcharProd(self):
        "Test ucharProd function"
        self.assertEquals(Vector.ucharProd([1,2,3,4]), 24)

    def testUcharProdNonContainer(self):
        "Test ucharProd function with None"
        self.assertRaises(TypeError, Vector.ucharProd, None)

    def testUcharSum(self):
        "Test ucharSum function"
        self.assertEquals(Vector.ucharSum([5,6,7,8]), 26)

    def testUcharReverse(self):
        "Test ucharReverse function"
        vector = N.array([1,2,4],'B')
        Vector.ucharReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testUcharOnes(self):
        "Test ucharOnes function"
        myArray = N.zeros(5,'B')
        Vector.ucharOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testUcharZeros(self):
        "Test ucharZeros function"
        myArray = N.ones(5,'B')
        Vector.ucharZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testUcharEOSplit(self):
        "Test ucharEOSplit function"
        even, odd = Vector.ucharEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testUcharTwos(self):
        "Test ucharTwos function"
        twos = Vector.ucharTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testUcharThrees(self):
        "Test ucharThrees function"
        threes = Vector.ucharThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    #####################################################
    ### Test functions that take arrays of type SHORT ###
    def testShortLength(self):
        "Test shortLength function"
        self.assertEquals(Vector.shortLength([5, 12, 0]), 13)

    def testShortLengthBad(self):
        "Test shortLength function for wrong size"
        self.assertRaises(TypeError, Vector.shortLength, [5, 12])

    def testShortProd(self):
        "Test shortProd function"
        self.assertEquals(Vector.shortProd([1,2,3,4]), 24)

    def testShortProdNonContainer(self):
        "Test shortProd function with None"
        self.assertRaises(TypeError, Vector.shortProd, None)

    def testShortSum(self):
        "Test shortSum function"
        self.assertEquals(Vector.shortSum([-5,6,-7,8]), 2)

    def testShortReverse(self):
        "Test shortReverse function"
        vector = N.array([1,2,4],'h')
        Vector.shortReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testShortOnes(self):
        "Test shortOnes function"
        myArray = N.zeros(5,'h')
        Vector.shortOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testShortZeros(self):
        "Test shortZeros function"
        myArray = N.ones(5,'h')
        Vector.shortZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testShortEOSplit(self):
        "Test shortEOSplit function"
        even, odd = Vector.shortEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testShortTwos(self):
        "Test shortTwos function"
        twos = Vector.shortTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testShortThrees(self):
        "Test shortThrees function"
        threes = Vector.shortThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    ######################################################
    ### Test functions that take arrays of type USHORT ###
    def testUshortLength(self):
        "Test ushortLength function"
        self.assertEquals(Vector.ushortLength([5, 12, 0]), 13)

    def testUshortLengthBad(self):
        "Test ushortLength function for wrong size"
        self.assertRaises(TypeError, Vector.ushortLength, [5, 12])

    def testUshortProd(self):
        "Test ushortProd function"
        self.assertEquals(Vector.ushortProd([1,2,3,4]), 24)

    def testUshortProdNonContainer(self):
        "Test ushortProd function with None"
        self.assertRaises(TypeError, Vector.ushortProd, None)

    def testUshortSum(self):
        "Test ushortSum function"
        self.assertEquals(Vector.ushortSum([5,6,7,8]), 26)

    def testUshortReverse(self):
        "Test ushortReverse function"
        vector = N.array([1,2,4],'H')
        Vector.ushortReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testUshortOnes(self):
        "Test ushortOnes function"
        myArray = N.zeros(5,'H')
        Vector.ushortOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testUshortZeros(self):
        "Test ushortZeros function"
        myArray = N.ones(5,'H')
        Vector.ushortZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testUshortEOSplit(self):
        "Test ushortEOSplit function"
        even, odd = Vector.ushortEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testUshortTwos(self):
        "Test ushortTwos function"
        twos = Vector.ushortTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testUshortThrees(self):
        "Test ushortThrees function"
        threes = Vector.ushortThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    ###################################################
    ### Test functions that take arrays of type INT ###
    def testIntLength(self):
        "Test intLength function"
        self.assertEquals(Vector.intLength([5, 12, 0]), 13)

    def testIntLengthBad(self):
        "Test intLength function for wrong size"
        self.assertRaises(TypeError, Vector.intLength, [5, 12])

    def testIntProd(self):
        "Test intProd function"
        self.assertEquals(Vector.intProd([1,2,3,4]), 24)

    def testIntProdNonContainer(self):
        "Test intProd function with None"
        self.assertRaises(TypeError, Vector.intProd, None)

    def testIntSum(self):
        "Test intSum function"
        self.assertEquals(Vector.intSum([-5,6,-7,8]), 2)

    def testIntOnes(self):
        "Test intOnes function"
        myArray = N.zeros(5,'i')
        Vector.intOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testIntReverse(self):
        "Test intReverse function"
        vector = N.array([1,2,4],'i')
        Vector.intReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testIntZeros(self):
        "Test intZeros function"
        myArray = N.ones(5,'i')
        Vector.intZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testIntEOSplit(self):
        "Test intEOSplit function"
        even, odd = Vector.intEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testIntTwos(self):
        "Test intTwos function"
        twos = Vector.intTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testIntThrees(self):
        "Test intThrees function"
        threes = Vector.intThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    ####################################################
    ### Test functions that take arrays of type UINT ###
    def testUintLength(self):
        "Test uintLength function"
        self.assertEquals(Vector.uintLength([5, 12, 0]), 13)

    def testUintLengthBad(self):
        "Test uintLength function for wrong size"

        self.assertRaises(TypeError, Vector.uintLength, [5, 12])

    def testUintProd(self):
        "Test uintProd function"
        self.assertEquals(Vector.uintProd([1,2,3,4]), 24)

    def testUintProdNonContainer(self):
        "Test uintProd function with None"
        self.assertRaises(TypeError, Vector.uintProd, None)

    def testUintSum(self):
        "Test uintSum function"
        self.assertEquals(Vector.uintSum([5,6,7,8]), 26)

    def testUintReverse(self):
        "Test uintReverse function"
        vector = N.array([1,2,4],'I')
        Vector.uintReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testUintOnes(self):
        "Test uintOnes function"
        myArray = N.zeros(5,'I')
        Vector.uintOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testUintZeros(self):
        "Test uintZeros function"
        myArray = N.ones(5,'I')
        Vector.uintZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testUintEOSplit(self):
        "Test uintEOSplit function"
        even, odd = Vector.uintEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testUintTwos(self):
        "Test uintTwos function"
        twos = Vector.uintTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testUintThrees(self):
        "Test uintThrees function"
        threes = Vector.uintThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    ####################################################
    ### Test functions that take arrays of type LONG ###
    def testLongLength(self):
        "Test longLength function"
        self.assertEquals(Vector.longLength([5, 12, 0]), 13)

    def testLongLengthBad(self):
        "Test longLength function for wrong size"
        self.assertRaises(TypeError, Vector.longLength, [5, 12])

    def testLongProd(self):
        "Test longProd function"
        self.assertEquals(Vector.longProd([1,2,3,4]), 24)

    def testLongProdNonContainer(self):
        "Test longProd function with None"
        self.assertRaises(TypeError, Vector.longProd, None)

    def testLongSum(self):
        "Test longSum function"
        self.assertEquals(Vector.longSum([-5,6,-7,8]), 2)

    def testLongReverse(self):
        "Test longReverse function"
        vector = N.array([1,2,4],'l')
        Vector.longReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testLongOnes(self):
        "Test longOnes function"
        myArray = N.zeros(5,'l')
        Vector.longOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testLongZeros(self):
        "Test longZeros function"
        myArray = N.ones(5,'l')
        Vector.longZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testLongEOSplit(self):
        "Test longEOSplit function"
        even, odd = Vector.longEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testLongTwos(self):
        "Test longTwos function"
        twos = Vector.longTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testLongThrees(self):
        "Test longThrees function"
        threes = Vector.longThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    #####################################################
    ### Test functions that take arrays of type ULONG ###
    def testUlongLength(self):
        "Test ulongLength function"
        self.assertEquals(Vector.ulongLength([5, 12, 0]), 13)

    def testUlongLengthBad(self):
        "Test ulongLength function for wrong size"
        self.assertRaises(TypeError, Vector.ulongLength, [5, 12])

    def testUlongProd(self):
        "Test ulongProd function"
        self.assertEquals(Vector.ulongProd([1,2,3,4]), 24)

    def testUlongProdNonContainer(self):
        "Test ulongProd function with None"
        self.assertRaises(TypeError, Vector.ulongProd, None)

    def testUlongSum(self):
        "Test ulongSum function"
        self.assertEquals(Vector.ulongSum([5,6,7,8]), 26)

    def testUlongReverse(self):
        "Test ulongReverse function"
        vector = N.array([1,2,4],'L')
        Vector.ulongReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testUlongOnes(self):
        "Test ulongOnes function"
        myArray = N.zeros(5,'L')
        Vector.ulongOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testUlongZeros(self):
        "Test ulongZeros function"
        myArray = N.ones(5,'L')
        Vector.ulongZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testUlongEOSplit(self):
        "Test ulongEOSplit function"
        even, odd = Vector.ulongEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testUlongTwos(self):
        "Test ulongTwos function"
        twos = Vector.ulongTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testUlongThrees(self):
        "Test ulongThrees function"
        threes = Vector.ulongThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    ########################################################
    ### Test functions that take arrays of type LONGLONG ###
    def testLongLongLength(self):
        "Test longLongLength function"
        self.assertEquals(Vector.longLongLength([5, 12, 0]), 13)

    def testLongLongLengthBad(self):
        "Test longLongLength function for wrong size"
        self.assertRaises(TypeError, Vector.longLongLength, [5, 12])

    def testLongLongProd(self):
        "Test longLongProd function"
        self.assertEquals(Vector.longLongProd([1,2,3,4]), 24)

    def testLongLongProdNonContainer(self):
        "Test longLongProd function with None"
        self.assertRaises(TypeError, Vector.longLongProd, None)

    def testLongLongSum(self):
        "Test longLongSum function"
        self.assertEquals(Vector.longLongSum([-5,6,-7,8]), 2)

    def testLongLongReverse(self):
        "Test longLongReverse function"
        vector = N.array([1,2,4],'q')
        Vector.longLongReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testLongLongOnes(self):
        "Test longLongOnes function"
        myArray = N.zeros(5,'q')
        Vector.longLongOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testLongLongZeros(self):
        "Test longLongZeros function"
        myArray = N.ones(5,'q')
        Vector.longLongZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testLongLongEOSplit(self):
        "Test longLongEOSplit function"
        even, odd = Vector.longLongEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testLongLongTwos(self):
        "Test longLongTwos function"
        twos = Vector.longLongTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testLongLongThrees(self):
        "Test longLongThrees function"
        threes = Vector.longLongThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    #########################################################
    ### Test functions that take arrays of type ULONGLONG ###
    def testUlongLongLength(self):
        "Test ulongLongLength function"
        self.assertEquals(Vector.ulongLongLength([5, 12, 0]), 13)

    def testUlongLongLengthBad(self):
        "Test ulongLongLength function for wrong size"
        self.assertRaises(TypeError, Vector.ulongLongLength, [5, 12])

    def testUlonglongProd(self):
        "Test ulongLongProd function"
        self.assertEquals(Vector.ulongLongProd([1,2,3,4]), 24)

    def testUlongLongProdNonContainer(self):
        "Test ulongLongProd function with None"
        self.assertRaises(TypeError, Vector.ulongLongProd, None)

    def testUlongLongSum(self):
        "Test ulongLongSum function"
        self.assertEquals(Vector.ulongLongSum([5,6,7,8]), 26)

    def testUlongLongReverse(self):
        "Test ulongLongReverse function"
        vector = N.array([1,2,4],'Q')
        Vector.ulongLongReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testUlongLongOnes(self):
        "Test ulongLongOnes function"
        myArray = N.zeros(5,'Q')
        Vector.ulongLongOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))

    def testUlongLongZeros(self):
        "Test ulongLongZeros function"
        myArray = N.ones(5,'Q')
        Vector.ulongLongZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testUlongLongEOSplit(self):
        "Test ulongLongEOSplit function"
        even, odd = Vector.ulongLongEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testUlongLongTwos(self):
        "Test ulongLongTwos function"
        twos = Vector.ulongLongTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testUlongLongThrees(self):
        "Test ulongLongThrees function"
        threes = Vector.ulongLongThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    #####################################################
    ### Test functions that take arrays of type FLOAT ###
    def testFloatLength(self):
        "Test floatLength function"
        self.assertEquals(Vector.floatLength([5, 12, 0]), 13)

    def testFloatLengthBad(self):
        "Test floatLength function for wrong size"
        self.assertRaises(TypeError, Vector.floatLength, [5, 12])

    def testFloatProd(self):
        "Test floatProd function (to 5 decimal places)"
        self.assertAlmostEquals(Vector.floatProd((1,2.718,3,4)), 32.616, 5)

    def testFloatProdBadContainer(self):
        "Test floatProd function with an invalid list"
        self.assertRaises(BadListError, Vector.floatProd, [3.14, "pi"])

    def testFloatSum(self):
        "Test floatSum function"
        self.assertEquals(Vector.floatSum([-5,6,-7,8]), 2)

    def testFloatReverse(self):
        "Test floatReverse function"
        vector = N.array([1,2,4],'f')
        Vector.floatReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testFloatOnes(self):
        "Test floatOnes function"
        myArray = N.zeros(5,'f')
        Vector.floatOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1.,1.,1.,1.,1.]))

    def testFloatOnesNonArray(self):
        "Test floatOnes function with a list"
        self.assertRaises(TypeError, Vector.floatOnes, [True, 0, 2.718, "pi"])

    def testFloatZeros(self):
        "Test floatZeros function"
        myArray = N.ones(5,'f')
        Vector.floatZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testFloatEOSplit(self):
        "Test floatEOSplit function"
        even, odd = Vector.floatEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testFloatTwos(self):
        "Test floatTwos function"
        twos = Vector.floatTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testFloatThrees(self):
        "Test floatThrees function"
        threes = Vector.floatThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

    ######################################################
    ### Test functions that take arrays of type DOUBLE ###
    def testDoubleLength(self):
        "Test doubleLength function"
        self.assertEquals(Vector.doubleLength([5, 12, 0]), 13)

    def testDoubleLengthBad(self):
        "Test doubleLength function for wrong size"
        self.assertRaises(TypeError, Vector.doubleLength, [5, 12])

    def testDoubleProd(self):
        "Test doubleProd function"
        self.assertEquals(Vector.doubleProd((1,2.718,3,4)), 32.616)

    def testDoubleProdBadContainer(self):
        "Test doubleProd function with an invalid list"
        self.assertRaises(BadListError, Vector.doubleProd, [3.14, "pi"])

    def testDoubleSum(self):
        "Test doubleSum function"
        self.assertEquals(Vector.doubleSum([-5,6,-7,8]), 2)

    def testDoubleReverse(self):
        "Test doubleReverse function"
        vector = N.array([1,2,4],'d')
        Vector.doubleReverse(vector)
        self.assertEquals((vector == [4,2,1]).all(), True)

    def testDoubleOnes(self):
        "Test doubleOnes function"
        myArray = N.zeros(5,'d')
        Vector.doubleOnes(myArray)
        N.testing.assert_array_equal(myArray, N.array([1.,1.,1.,1.,1.]))

    def testDoubleOnesNonArray(self):
        "Test doubleOnes function with a list"
        self.assertRaises(TypeError, Vector.doubleOnes, [True, 0, 2.718, "pi"])

    def testDoubleZeros(self):
        "Test doubleZeros function"
        myArray = N.ones(5,'d')
        Vector.doubleZeros(myArray)
        N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))

    def testDoubleEOSplit(self):
        "Test doubleEOSplit function"
        even, odd = Vector.doubleEOSplit([1,2,3])
        self.assertEquals((even == [1,0,3]).all(), True)
        self.assertEquals((odd  == [0,2,0]).all(), True)

    def testDoubleTwos(self):
        "Test doubleTwos function"
        twos = Vector.doubleTwos(5)
        self.assertEquals((twos == [2,2,2,2,2]).all(), True)

    def testDoubleThrees(self):
        "Test doubleThrees function"
        threes = Vector.doubleThrees(6)
        self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)

######################################################################

if __name__ == "__main__":

    # Build the test suite
    suite = unittest.TestSuite()
    suite.addTest(unittest.makeSuite(VectorTestCase))

    # Execute the test suite
    print "Testing 1D Functions of Module Vector"
    print "NumPy version", N.__version__
    print
    result = unittest.TextTestRunner(verbosity=2).run(suite)
    sys.exit(len(result.errors) + len(result.failures))