~ubuntu-branches/ubuntu/feisty/python-numpy/feisty

« back to all changes in this revision

Viewing changes to numpy/core/tests/test_scalarmath.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-07-12 10:00:24 UTC
  • Revision ID: james.westby@ubuntu.com-20060712100024-5lw9q2yczlisqcrt
Tags: upstream-0.9.8
ImportĀ upstreamĀ versionĀ 0.9.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
from numpy.testing import *
 
3
set_package_path()
 
4
import numpy.core.umath as ncu
 
5
from numpy import array
 
6
import numpy as N
 
7
restore_path()
 
8
 
 
9
types = [N.bool_, N.byte, N.ubyte, N.short, N.ushort, N.intc, N.uintc,
 
10
         N.int_, N.uint, N.longlong, N.ulonglong,
 
11
         N.single, N.double, N.longdouble, N.csingle,
 
12
         N.cdouble, N.clongdouble]
 
13
 
 
14
# These were generated using old umath
 
15
typeconv = array([
 
16
    [ 0,  1,  2,  3,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
 
17
    [ 1,  1,  3,  3,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
 
18
    [ 2,  3,  2,  3,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
 
19
    [ 3,  3,  3,  3,  5,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
 
20
    [ 4,  4,  4,  5,  4,  5,  6,  5,  6,  9, 10, 11, 12, 13, 14, 15, 16],
 
21
    [ 5,  5,  5,  5,  5,  5,  9,  5,  9,  9, 10, 12, 12, 13, 15, 15, 16],
 
22
    [ 6,  6,  6,  6,  6,  9,  6,  9,  6,  9, 10, 12, 12, 13, 15, 15, 16],
 
23
    [ 7,  7,  7,  7,  7,  7,  9,  7,  9,  9, 10, 12, 12, 13, 15, 15, 16],
 
24
    [ 8,  8,  8,  8,  8,  9,  8,  9,  8,  9, 10, 12, 12, 13, 15, 15, 16],
 
25
    [ 9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 12, 12, 12, 13, 15, 15, 16],
 
26
    [10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 10, 12, 12, 13, 15, 15, 16],
 
27
    [11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 11, 12, 13, 14, 15, 16],
 
28
    [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 15, 15, 16],
 
29
    [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 16, 16, 16],
 
30
    [14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 14, 15, 16, 14, 15, 16],
 
31
    [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 15, 15, 16],
 
32
    [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16]
 
33
    ])
 
34
 
 
35
typeconv2 = array([
 
36
    ['?','b','B','h','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
 
37
    ['b','b','h','h','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
 
38
    ['B','h','B','h','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
 
39
    ['h','h','h','h','i','i','I','i','I','q','Q','f','d','g','F','D','G'],
 
40
    ['H','H','H','i','H','i','I','i','I','q','Q','f','d','g','F','D','G'],
 
41
    ['i','i','i','i','i','i','q','i','q','q','Q','d','d','g','D','D','G'],
 
42
    ['I','I','I','I','I','q','I','q','I','q','Q','d','d','g','D','D','G'],
 
43
    ['l','l','l','l','l','l','q','l','q','q','Q','d','d','g','D','D','G'],
 
44
    ['L','L','L','L','L','q','L','q','L','q','Q','d','d','g','D','D','G'],
 
45
    ['q','q','q','q','q','q','q','q','q','q','d','d','d','g','D','D','G'],
 
46
    ['Q','Q','Q','Q','Q','Q','Q','Q','Q','d','Q','d','d','g','D','D','G'],
 
47
    ['f','f','f','f','f','d','d','d','d','d','d','f','d','g','F','D','G'],
 
48
    ['d','d','d','d','d','d','d','d','d','d','d','d','d','g','D','D','G'],
 
49
    ['g','g','g','g','g','g','g','g','g','g','g','g','g','g','G','G','G'],
 
50
    ['F','F','F','F','F','D','D','D','D','D','D','F','D','G','F','D','G'],
 
51
    ['D','D','D','D','D','D','D','D','D','D','D','D','D','G','D','D','G'],
 
52
    ['G','G','G','G','G','G','G','G','G','G','G','G','G','G','G','G','G']
 
53
    ],'S1')
 
54
 
 
55
class test_types(ScipyTestCase):
 
56
    def check_types(self, level=1):
 
57
        # list of types
 
58
        for k, atype in enumerate(types):
 
59
            vala = atype(3)
 
60
            for l, btype in enumerate(types):
 
61
                valb = btype(1)
 
62
                val = vala+valb
 
63
                assert val.dtype.num == typeconv[k,l] and \
 
64
                       val.dtype.char == typeconv2[k,l], \
 
65
                       "error with (%d,%d)" % (k,l)