| 1 |
from _numpypy.multiarray import * |
| 2 |
from _numpypy.umath import * |
| 3 |
|
| 4 |
inf = float('inf') |
| 5 |
nan = float('nan') |
| 6 |
newaxis = None |
| 7 |
ufunc = type(sin) |
| 8 |
|
| 9 |
types = ['bool8', 'byte', 'ubyte', 'short', 'ushort', 'longlong', 'ulonglong', |
| 10 |
'single', 'double', 'longfloat', 'longdouble', |
| 11 |
'csingle', 'cdouble', 'cfloat', 'clongdouble', |
| 12 |
'void'] |
| 13 |
for t in ('int', 'uint'): |
| 14 |
for s in (8, 16, 32, 64, 'p'): |
| 15 |
types.append(t + str(s)) |
| 16 |
for s in (16, 32, 64): |
| 17 |
types.append('float' + str(s)) |
| 18 |
for s in (64, 128): |
| 19 |
types.append('complex' + str(s)) |
| 20 |
for t in types: |
| 21 |
globals()[t] = dtype(t).type |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
types = ['bool', 'int', 'float', 'complex', 'str', 'object'] |
| 26 |
for t in types: |
| 27 |
globals()[t + '_'] = dtype(t).type |
| 28 |
del types |
| 29 |
globals()['uint'] = dtype('uint').type |
| 30 |
|
| 31 |
types = ['Generic', 'Number', 'Integer', 'SignedInteger', 'UnsignedInteger', |
| 32 |
'Inexact', 'Floating', 'ComplexFloating', 'Flexible', 'Character', |
| 33 |
] |
| 34 |
for t in types: |
| 35 |
globals()[t.lower()] = typeinfo[t] |
| 36 |
|
| 37 |
True_ = bool_(True) |
| 38 |
False_ = bool_(False) |
| 39 |
|
| 40 |
def ones(*args, **kwargs): |
| 41 |
a = zeros(*args, **kwargs) |
| 42 |
a.fill(1) |
| 43 |
return a |
| 44 |
|
| 45 |
def isscalar(a): |
| 46 |
return any([isinstance(a, typeinfo[t]) for t in types]) |