source: misc/tools/acceptance_tests/test_int32_type.py @ 7656

Last change on this file since 7656 was 7656, checked in by gray, 14 years ago

Updating acceptance test files. Still pre-2010 tests.

File size: 1.4 KB
Line 
1"""
2This program checks the underlying type object for int32 data types.
3"""
4
5import platform
6import numpy as num
7
8
9ROWHDR_WIDTH = 15
10
11NAME_COLWIDTH = 11
12STR_COLWIDTH = 10
13KIND_COLWIDTH = 11
14CHAR_COLWIDTH = 11
15ID_COLWIDTH = 10
16
17NUM_BITS = platform.architecture()[0]
18
19def show(a, t):
20    element = a.flatten()[0]
21    print ('%s | %s | %s | %s | %s | %10x |'
22           % (t.rjust(ROWHDR_WIDTH),
23              a.dtype.name.center(NAME_COLWIDTH),
24              a.dtype.str.center(STR_COLWIDTH),
25              a.dtype.kind.center(KIND_COLWIDTH),
26              a.dtype.char.center(CHAR_COLWIDTH),
27              id(type(element)))
28          )
29
30print ("This table shows 'dtype' attributes for the '32bit integer' types on a "
31       "%s platform:" % NUM_BITS)
32
33print ''
34print ('%s | .dtype.name | .dtype.str | .dtype.kind | .dtype.char | id(type)     |'
35       % ' '.rjust(ROWHDR_WIDTH))
36print ('%s-+-------------+------------+-------------+-------------+--------------+'
37       % '-'.rjust(ROWHDR_WIDTH))
38
39# check all attributes of 'numpy', ignore that cause exception.
40for t in dir(num):
41    try:
42        a = eval('num.array([[1,2],[3,4]], dtype=num.%s)' % t)
43    except (TypeError, ValueError):
44        pass
45    else:
46#        if a.dtype.name != 'object':
47        if a.dtype.name == 'int32':
48            show(a, t)
49
50print ('%s-+-------------+------------+-------------+-------------+--------------+'
51       % '-'.rjust(ROWHDR_WIDTH))
Note: See TracBrowser for help on using the repository browser.