summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COMPATIBILITY2
-rw-r--r--numpy/core/_internal.py14
-rw-r--r--numpy/core/arrayprint.py2
-rw-r--r--numpy/core/blasdot/_dotblas.c9
-rw-r--r--numpy/core/defchararray.py2
-rw-r--r--numpy/core/defmatrix.py12
-rw-r--r--numpy/core/ma.py48
-rw-r--r--numpy/core/memmap.py4
-rw-r--r--numpy/core/numeric.py12
-rw-r--r--numpy/core/numerictypes.py6
-rw-r--r--numpy/core/oldnumeric.py6
-rw-r--r--numpy/core/records.py44
-rw-r--r--numpy/core/src/arraymethods.c4
-rw-r--r--numpy/core/src/arrayobject.c95
-rw-r--r--numpy/core/src/multiarraymodule.c14
-rw-r--r--numpy/core/src/scalartypes.inc.src49
-rw-r--r--numpy/core/src/ufuncobject.c1
-rw-r--r--numpy/core/tests/test_defmatrix.py4
-rw-r--r--numpy/core/tests/test_ma.py1
-rw-r--r--numpy/core/tests/test_multiarray.py28
-rw-r--r--numpy/dft/fftpack.py2
-rw-r--r--numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py4
-rw-r--r--numpy/lib/convertcode.py2
-rw-r--r--numpy/lib/function_base.py26
-rw-r--r--numpy/lib/index_tricks.py6
-rw-r--r--numpy/lib/shape_base.py4
-rw-r--r--numpy/lib/tests/test_polynomial.py2
-rw-r--r--numpy/lib/twodim_base.py2
-rw-r--r--numpy/lib/type_check.py20
-rw-r--r--numpy/linalg/linalg.py12
-rw-r--r--numpy/random/mtrand/mtrand.c6
-rw-r--r--numpy/random/mtrand/numpy.pxi4
-rw-r--r--numpy/version.py2
33 files changed, 193 insertions, 256 deletions
diff --git a/COMPATIBILITY b/COMPATIBILITY
index b9d46cfae..af61427d2 100644
--- a/COMPATIBILITY
+++ b/COMPATIBILITY
@@ -3,7 +3,7 @@
X.flat returns an indexable 1-D iterator (mostly similar to an array
but always 1-d) --- only has .copy and .__array__ attributes of an array!!!
-.typecode() --> .dtypechar
+.typecode() --> .dtype.char
.iscontiguous() --> .flags['CONTIGUOUS'] or .flags.contiguous
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py
index 749e63432..09d913b68 100644
--- a/numpy/core/_internal.py
+++ b/numpy/core/_internal.py
@@ -3,7 +3,7 @@
# that implements more complicated stuff.
import re
-from multiarray import _flagdict, dtypedescr, ndarray
+from multiarray import _flagdict, dtype, ndarray
_defflags = _flagdict.keys()
@@ -186,7 +186,7 @@ def _usefields(adict, align):
num = int(obj[1])
if (num < 0):
raise ValueError, "invalid offset."
- format = dtypedescr(obj[0])
+ format = dtype(obj[0])
if (format.itemsize == 0):
raise ValueError, "all itemsizes must be fixed."
if (n > 2):
@@ -213,10 +213,10 @@ def _usefields(adict, align):
else:
titles.append(None)
- return dtypedescr({"names" : names,
- "formats" : formats,
- "offsets" : offsets,
- "titles" : titles}, align)
+ return dtype({"names" : names,
+ "formats" : formats,
+ "offsets" : offsets,
+ "titles" : titles}, align)
# construct an array_protocol descriptor list
@@ -228,7 +228,7 @@ def _usefields(adict, align):
def _array_descr(descriptor):
fields = descriptor.fields
if fields is None:
- return descriptor.dtypestr
+ return descriptor.str
ordered_fields = [fields[x] + (x,) for x in fields[-1]]
result = []
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 284b4b04e..c22580cf9 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -145,7 +145,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ',
try:
format_function = a._format
except AttributeError:
- dtype = a.dtype
+ dtype = a.dtype.type
if issubclass(dtype, _nt.bool):
format = "%s"
format_function = lambda x, f = format: format % x
diff --git a/numpy/core/blasdot/_dotblas.c b/numpy/core/blasdot/_dotblas.c
index 51d9fa1a2..f04fcb99f 100644
--- a/numpy/core/blasdot/_dotblas.c
+++ b/numpy/core/blasdot/_dotblas.c
@@ -222,9 +222,12 @@ dotblas_matrixproduct(PyObject *dummy, PyObject *args)
}
/* Choose which subtype to return */
- prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);
- prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);
- subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);
+ if (ap1->ob_type != ap2->ob_type) {
+ prior2 = PyArray_GetPriority((PyObject *)ap2, 0.0);
+ prior1 = PyArray_GetPriority((PyObject *)ap1, 0.0);
+ subtype = (prior2 > prior1 ? ap2->ob_type : ap1->ob_type);
+ }
+ else subtype = ap1->ob_type;
ret = (PyArrayObject *)PyArray_New(subtype, nd, dimensions,
typenum, NULL, NULL, 0, 0,
diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py
index 9051df462..6b43d7f6f 100644
--- a/numpy/core/defchararray.py
+++ b/numpy/core/defchararray.py
@@ -300,7 +300,7 @@ def array(obj, itemsize=None, copy=True, unicode=False, fortran=False):
if copy or (itemsize != obj.itemsize) \
or (not unicode and obj.dtype == unicode_) \
or (unicode and obj.dtype == string):
- return obj.astype("%s%d" % (obj.dtypechar, itemsize))
+ return obj.astype("%s%d" % (obj.dtype.char, itemsize))
else:
return obj
diff --git a/numpy/core/defmatrix.py b/numpy/core/defmatrix.py
index b0d45972e..1a9264380 100644
--- a/numpy/core/defmatrix.py
+++ b/numpy/core/defmatrix.py
@@ -58,17 +58,17 @@ class matrix(N.ndarray):
dtype2 = data.dtype
if (dtype is None):
dtype = dtype2
- if (dtype2 is dtype) and (not copy):
+ if (dtype2 == dtype) and (not copy):
return data
return data.astype(dtype)
if isinstance(data, N.ndarray):
if dtype is None:
- intype = data.dtypedescr
+ intype = data.dtype
else:
- intype = N.dtypedescr(dtype)
+ intype = N.dtype(dtype)
new = data.view(matrix)
- if intype != data.dtypedescr:
+ if intype != data.dtype:
return new.astype(intype)
if copy: return new.copy()
else: return new
@@ -94,7 +94,7 @@ class matrix(N.ndarray):
if not (fortran or arr.flags.contiguous):
arr = arr.copy()
- ret = N.ndarray.__new__(subtype, shape, arr.dtypedescr,
+ ret = N.ndarray.__new__(subtype, shape, arr.dtype,
buffer=arr,
fortran=fortran)
return ret
@@ -199,7 +199,7 @@ class matrix(N.ndarray):
return self.transpose()
def getH(self):
- if issubclass(self.dtype, N.complexfloating):
+ if issubclass(self.dtype.type, N.complexfloating):
return self.transpose().conjugate()
else:
return self.transpose()
diff --git a/numpy/core/ma.py b/numpy/core/ma.py
index 03e94b68e..c736b3e34 100644
--- a/numpy/core/ma.py
+++ b/numpy/core/ma.py
@@ -83,7 +83,7 @@ def default_fill_value (obj):
elif isinstance(obj, types.ComplexType):
return default_complex_fill_value
elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):
- x = obj.dtypechar
+ x = obj.dtype.char
if x in typecodes['Float']:
return default_real_fill_value
if x in typecodes['Integer']:
@@ -105,7 +105,7 @@ def minimum_fill_value (obj):
elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):
return sys.maxint
elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):
- x = obj.dtypechar
+ x = obj.dtype.char
if x in typecodes['Float']:
return numeric.inf
if x in typecodes['Integer']:
@@ -122,7 +122,7 @@ def maximum_fill_value (obj):
elif isinstance(obj, types.IntType) or isinstance(obj, types.LongType):
return -sys.maxint
elif isinstance(obj, MaskedArray) or isinstance(obj, ndarray):
- x = obj.dtypechar
+ x = obj.dtype.char
if x in typecodes['Float']:
return -inf
if x in typecodes['Integer']:
@@ -161,7 +161,7 @@ def is_mask (m):
"""Is m a legal mask? Does not check contents, only type.
"""
if m is nomask or (isinstance(m, ndarray) and \
- m.dtype is MaskType):
+ m.dtype.type is MaskType):
return 1
else:
return 0
@@ -176,7 +176,7 @@ def make_mask (m, copy=0, flag=0):
if m is nomask:
return nomask
elif isinstance(m, ndarray):
- if m.dtype is MaskType:
+ if m.dtype.type is MaskType:
if copy:
result = numeric.array(m, dtype=MaskType, copy=copy)
else:
@@ -525,12 +525,12 @@ class MaskedArray (object):
then the candidate data is data.data and the
mask used is data.mask. If data is a numeric array,
it is used as the candidate raw data.
- If dtypechar is not None and
- is != data.dtypechar then a data copy is required.
+ If dtype.char is not None and
+ is != data.dtype.char then a data copy is required.
Otherwise, the candidate is used.
If a data copy is required, raw data stored is the result of:
- numeric.array(data, dtype=dtypechar, copy=copy)
+ numeric.array(data, dtype=dtype.char, copy=copy)
If mask is nomask there are no masked values. Otherwise mask must
be convertible to an array of booleans with the same shape as x.
@@ -549,7 +549,7 @@ class MaskedArray (object):
need_data_copied = copy
if isinstance(data, MaskedArray):
c = data.data
- ctc = c.dtypechar
+ ctc = c.dtype.char
if tc is None:
tc = ctc
elif dtype2char(tc) != ctc:
@@ -561,7 +561,7 @@ class MaskedArray (object):
elif isinstance(data, ndarray):
c = data
- ctc = c.dtypechar
+ ctc = c.dtype.char
if tc is None:
tc = ctc
elif dtype2char(tc) != ctc:
@@ -979,9 +979,9 @@ array(data = %(data)s,
def __iadd__(self, other):
"Add other to self in place."
- t = self._data.dtypechar
+ t = self._data.dtype.char
f = filled(other,0)
- t1 = f.dtypechar
+ t1 = f.dtype.char
if t == t1:
pass
elif t in typecodes['Integer']:
@@ -1022,9 +1022,9 @@ array(data = %(data)s,
def __imul__(self, other):
"Add other to self in place."
- t = self._data.dtypechar
+ t = self._data.dtype.char
f = filled(other,0)
- t1 = f.dtypechar
+ t1 = f.dtype.char
if t == t1:
pass
elif t in typecodes['Integer']:
@@ -1065,9 +1065,9 @@ array(data = %(data)s,
def __isub__(self, other):
"Subtract other from self in place."
- t = self._data.dtypechar
+ t = self._data.dtype.char
f = filled(other,0)
- t1 = f.dtypechar
+ t1 = f.dtype.char
if t == t1:
pass
elif t in typecodes['Integer']:
@@ -1110,9 +1110,9 @@ array(data = %(data)s,
def __idiv__(self, other):
"Divide self by other in place."
- t = self._data.dtypechar
+ t = self._data.dtype.char
f = filled(other,0)
- t1 = f.dtypechar
+ t1 = f.dtype.char
if t == t1:
pass
elif t in typecodes['Integer']:
@@ -1348,10 +1348,6 @@ array(data = %(data)s,
size = property(fget=_get_size, doc="Number of elements in the array.")
## CHECK THIS: signature of numeric.array.size?
- def _get_dtypechar(self):
- return self._data.dtypechar
- dtypechar = property(fget=_get_dtypechar, doc="type character of the array.")
-
def _get_dtype(self):
return self._data.dtype
dtype = property(fget=_get_dtype, doc="type of the array elements.")
@@ -1464,7 +1460,7 @@ def masked_values (data, value, rtol=1.e-5, atol=1.e-8, copy=1):
"""
abs = umath.absolute
d = filled(data, value)
- if issubclass(d.dtype, numeric.floating):
+ if issubclass(d.dtype.type, numeric.floating):
m = umath.less_equal(abs(d-value), atol+rtol*abs(value))
m = make_mask(m, flag=1)
return array(d, mask = m, copy=copy,
@@ -1480,7 +1476,7 @@ def masked_object (data, value, copy=1):
def arrayrange(start, stop=None, step=1, dtype=None):
"""Just like range() except it returns a array whose type can be specified
- by the keyword argument dtypechar.
+ by the keyword argument dtype.
"""
return array(numeric.arrayrange(start, stop, step, dtype))
@@ -1573,7 +1569,7 @@ def power (a, b, third=None):
m = mask_or(ma, mb)
fa = filled(a, 1)
fb = filled(b, 1)
- if fb.dtypechar in typecodes["Integer"]:
+ if fb.dtype.char in typecodes["Integer"]:
return masked_array(umath.power(fa, fb), m)
md = make_mask(umath.less_equal (fa, 0), flag=1)
m = mask_or(m, md)
@@ -2143,8 +2139,6 @@ array.copy = _m(not_implemented)
array.cumprod = _m(not_implemented)
array.cumsum = _m(not_implemented)
array.diagonal = _m(diagonal)
-array.dtypedescr = property(_m(not_implemented))
-array.dtypestr = property(_m(not_implemented))
array.dump = _m(not_implemented)
array.dumps = _m(not_implemented)
array.fill = _m(not_implemented)
diff --git a/numpy/core/memmap.py b/numpy/core/memmap.py
index a9093f96a..77d5ff552 100644
--- a/numpy/core/memmap.py
+++ b/numpy/core/memmap.py
@@ -1,7 +1,7 @@
__all__ = ['memmap']
import mmap
-from numeric import uint8, ndarray, dtypedescr
+from numeric import uint8, ndarray, dtype
from numerictypes import nbytes
valid_filemodes = ["r", "c", "r+", "w+"]
@@ -35,7 +35,7 @@ class memmap(ndarray):
fid.seek(0,2)
flen = fid.tell()
- descr = dtypedescr(dtype)
+ descr = dtype(dtype)
_dbytes = descr.itemsize
if shape is None:
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 7cdebbf5d..82f720c71 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -1,5 +1,5 @@
__all__ = ['newaxis', 'ndarray', 'bigndarray', 'flatiter', 'ufunc',
- 'arange', 'array', 'zeros', 'empty', 'broadcast', 'dtypedescr',
+ 'arange', 'array', 'zeros', 'empty', 'broadcast', 'dtype',
'fromstring', 'fromfile', 'frombuffer','newbuffer','getbuffer',
'where', 'concatenate', 'fastCopyAndTranspose', 'lexsort',
'register_dtype', 'set_numeric_ops', 'can_cast',
@@ -45,7 +45,7 @@ ndarray = multiarray.ndarray
bigndarray = multiarray.bigndarray
flatiter = multiarray.flatiter
broadcast = multiarray.broadcast
-dtypedescr=multiarray.dtypedescr
+dtype=multiarray.dtype
ufunc = type(sin)
arange = multiarray.arange
@@ -223,7 +223,7 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None):
', ', "array(")
else: # show zero-length shape unless it is (0,)
lst = "[], shape=%s" % (repr(arr.shape),)
- typeless = arr.dtype in _typelessdata
+ typeless = arr.dtype.type in _typelessdata
if arr.__class__ is not ndarray:
cName= arr.__class__.__name__
@@ -232,10 +232,10 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None):
if typeless and arr.size:
return cName + "(%s)" % lst
else:
- typename=arr.dtype.__name__[:-8]
- if issubclass(arr.dtype, flexible):
+ typename=arr.dtype.type.__name__[:-8]
+ if issubclass(arr.dtype.type, flexible):
if typename not in ['unicode','string','void']:
- typename = arr.dtype.__name__
+ typename = arr.dtype.type.__name__
typename = "(%s,%d)" % (typename, arr.itemsize)
return cName + "(%s, dtype=%s)" % (lst, typename)
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index 9d5f9d8b3..9455981cb 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -149,7 +149,7 @@ def _add_types():
name = a.lower()
if isinstance(typeinfo[a], type(())):
typeobj = typeinfo[a][-1]
-
+
# define C-name and insert typenum and typechar references also
allTypes[name] = typeobj
typeDict[name] = typeobj
@@ -313,7 +313,7 @@ def obj2dtype(rep, default=None):
if isinstance(rep, type):
return _python_type(rep)
if isinstance(rep, ndarray):
- return rep.dtype
+ return rep.dtype.type
res = typeDict.get(rep, default)
return res
@@ -371,7 +371,7 @@ for key in _dtype2char_dict.keys():
if issubclass(key, allTypes['flexible']):
_typestr[key] = _dtype2char_dict[key]
else:
- _typestr[key] = empty((1,),key).dtypestr[1:]
+ _typestr[key] = empty((1,),key).dtype.str[1:]
# Now add the types we've determined to this module
for key in allTypes:
diff --git a/numpy/core/oldnumeric.py b/numpy/core/oldnumeric.py
index 4fcccff56..09f7775f0 100644
--- a/numpy/core/oldnumeric.py
+++ b/numpy/core/oldnumeric.py
@@ -261,7 +261,7 @@ def resize(a, new_shape):
new_shape = (new_shape,)
a = ravel(a)
Na = len(a)
- if not Na: return mu.zeros(new_shape, a.dtypechar)
+ if not Na: return mu.zeros(new_shape, a.dtype.char)
total_size = um.multiply.reduce(new_shape)
n_copies = int(total_size / Na)
extra = total_size % Na
@@ -447,9 +447,9 @@ def round_(a, decimals=0):
and imaginary parts separately if the array is complex.
"""
a = asarray(a)
- if not issubclass(a.dtype, _nx.inexact):
+ if not issubclass(a.dtype.type, _nx.inexact):
return a
- if issubclass(a.dtype, _nx.complexfloating):
+ if issubclass(a.dtype.type, _nx.complexfloating):
return round_(a.real, decimals) + 1j*round_(a.imag, decimals)
if decimals is not 0:
decimals = asarray(decimals)
diff --git a/numpy/core/records.py b/numpy/core/records.py
index 3f881fa5f..2805ff188 100644
--- a/numpy/core/records.py
+++ b/numpy/core/records.py
@@ -49,9 +49,9 @@ class format_parser:
def _parseFormats(self, formats, aligned=0):
""" Parse the field formats """
-
- dtypedescr = sb.dtypedescr(formats, aligned)
- fields = dtypedescr.fields
+
+ dtype = sb.dtype(formats, aligned)
+ fields = dtype.fields
keys = fields[-1]
self._f_formats = [fields[key][0] for key in keys]
self._offsets = [fields[key][1] for key in keys]
@@ -94,10 +94,10 @@ class format_parser:
self._titles += [None]*(self._nfields-len(titles))
def _createdescr(self):
- self._descr = sb.dtypedescr({'names':self._names,
- 'formats':self._f_formats,
- 'offsets':self._offsets,
- 'titles':self._titles})
+ self._descr = sb.dtype({'names':self._names,
+ 'formats':self._f_formats,
+ 'offsets':self._offsets,
+ 'titles':self._titles})
class record(nt.void):
def __repr__(self):
@@ -107,18 +107,18 @@ class record(nt.void):
return str(self.item())
def __getattribute__(self, attr):
- if attr in ['setfield', 'getfield', 'dtypedescr']:
+ if attr in ['setfield', 'getfield', 'dtype']:
return nt.void.__getattribute__(self, attr)
- fielddict = nt.void.__getattribute__(self, 'dtypedescr').fields
+ fielddict = nt.void.__getattribute__(self, 'dtype').fields
res = fielddict.get(attr,None)
if res:
return self.getfield(*res[:2])
return nt.void.__getattribute__(self, attr)
def __setattr__(self, attr, val):
- if attr in ['setfield', 'getfield', 'dtypedescr']:
+ if attr in ['setfield', 'getfield', 'dtype']:
raise AttributeError, "Cannot set '%s' attribute" % attr;
- fielddict = nt.void.__getattribute__(self,'dtypedescr').fields
+ fielddict = nt.void.__getattribute__(self,'dtype').fields
res = fielddict.get(attr,None)
if res:
return self.setfield(val,*res[:2])
@@ -126,10 +126,10 @@ class record(nt.void):
return nt.void.__setattr__(self,attr,val)
def __getitem__(self, obj):
- return self.getfield(*(self.dtypedescr.fields[obj][:2]))
+ return self.getfield(*(self.dtype.fields[obj][:2]))
def __setitem__(self, obj, val):
- return self.setfield(val, *(self.dtypedescr.fields[obj][:2]))
+ return self.setfield(val, *(self.dtype.fields[obj][:2]))
# The recarray is almost identical to a standard array (which supports
@@ -145,7 +145,7 @@ class recarray(sb.ndarray):
buf=None, offset=0, strides=None, byteorder=None,
aligned=0):
- if isinstance(formats, sb.dtypedescr):
+ if isinstance(formats, sb.dtype):
descr = formats
else:
parsed = format_parser(formats, names, titles, aligned)
@@ -164,7 +164,7 @@ class recarray(sb.ndarray):
return self
def __getattribute__(self, attr):
- fielddict = sb.ndarray.__getattribute__(self,'dtypedescr').fields
+ fielddict = sb.ndarray.__getattribute__(self,'dtype').fields
try:
res = fielddict[attr][:2]
except:
@@ -173,7 +173,7 @@ class recarray(sb.ndarray):
obj = self.getfield(*res)
# if it has fields return a recarray, otherwise return
# normal array
- if obj.dtypedescr.fields:
+ if obj.dtype.fields:
return obj
if obj.dtype in [sb.string, sb.unicode_]:
return obj.view(chararray)
@@ -181,7 +181,7 @@ class recarray(sb.ndarray):
def __setattr__(self, attr, val):
- fielddict = sb.ndarray.__getattribute__(self,'dtypedescr').fields
+ fielddict = sb.ndarray.__getattribute__(self,'dtype').fields
try:
res = fielddict[attr][:2]
except:
@@ -218,8 +218,8 @@ def fromarrays(arrayList, formats=None, names=None, titles=None, shape=None,
for obj in arrayList:
if not isinstance(obj, sb.ndarray):
raise ValueError, "item in the array list must be an ndarray."
- formats += _typestr[obj.dtype]
- if issubclass(obj.dtype, nt.flexible):
+ formats += _typestr[obj.dtype.type]
+ if issubclass(obj.dtype.type, nt.flexible):
formats += `obj.itemsize`
formats += ','
formats=formats[:-1]
@@ -394,7 +394,7 @@ def array(obj, formats=None, names=None, titles=None, shape=None,
elif isinstance(obj, recarray):
new = obj.copy()
parsed = format_parser(formats, names, titles, aligned)
- new.dtypedescr = parsed._descr
+ new.dtype = parsed._descr
return new
elif isinstance(obj, file):
return fromfile(obj, formats=formats, names=names, titles=titles,
@@ -404,7 +404,3 @@ def array(obj, formats=None, names=None, titles=None, shape=None,
return obj.view(recarray)
else:
raise ValueError("Unknown input type")
-
-
-
-
diff --git a/numpy/core/src/arraymethods.c b/numpy/core/src/arraymethods.c
index 15d8eb3fe..27e8d4866 100644
--- a/numpy/core/src/arraymethods.c
+++ b/numpy/core/src/arraymethods.c
@@ -884,8 +884,8 @@ array_reduce(PyArrayObject *self, PyObject *args)
(PyObject *)self->ob_type,
Py_BuildValue("(N)",
PyInt_FromLong(0)),
- PyObject_GetAttrString((PyObject *)self,
- "dtypechar")));
+ PyObject_GetAttrString((PyObject *)(self->descr),
+ "char")));
/* Now fill in object's state. This is a tuple with
4 arguments
diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c
index 9b34fcda0..047bb9683 100644
--- a/numpy/core/src/arrayobject.c
+++ b/numpy/core/src/arrayobject.c
@@ -3850,7 +3850,7 @@ PyArray_FillWithScalar(PyArrayObject *arr, PyObject *obj)
static PyObject *
array_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"shape", "dtype", "buffer",
+ static char *kwlist[] = {"shape", "dtype", "buffer", /* XXX ? */
"offset", "strides",
"fortran", NULL};
PyArray_Descr *descr=NULL;
@@ -4216,16 +4216,6 @@ array_nbytes_get(PyArrayObject *self)
}
-static PyObject *
-array_typechar_get(PyArrayObject *self)
-{
- if PyArray_ISEXTENDED(self)
- return PyString_FromFormat("%c%d", (self->descr->type),
- self->descr->elsize);
- else
- return PyString_FromStringAndSize(&(self->descr->type), 1);
-}
-
static PyObject *arraydescr_protocol_typestr_get(PyArray_Descr *);
static PyObject *
@@ -4383,15 +4373,6 @@ array_struct_get(PyArrayObject *self)
}
static PyObject *
-array_type_get(PyArrayObject *self)
-{
- Py_INCREF(self->descr->typeobj);
- return (PyObject *)self->descr->typeobj;
-}
-
-
-
-static PyObject *
array_base_get(PyArrayObject *self)
{
if (self->base == NULL) {
@@ -4642,19 +4623,7 @@ static PyGetSetDef array_getsetlist[] = {
(getter)array_base_get,
NULL,
"base object"},
- {"dtype",
- (getter)array_type_get,
- NULL,
- "get array type class"},
- {"dtypechar",
- (getter)array_typechar_get,
- NULL,
- "get array type character code"},
- {"dtypestr",
- (getter)array_typestr_get,
- NULL,
- "get array type string"},
- {"dtypedescr",
+ {"dtype",
(getter)array_descr_get,
(setter)array_descr_set,
"get(set) data-type-descriptor for array"},
@@ -4731,7 +4700,7 @@ static char Arraytype__doc__[] =
" 2) If buffer is an object exporting the buffer interface, then\n"
" all keywords are interpreted.\n"
" The dtype parameter can be any object that can be interpreted \n"
- " as a numpy.dtypedescr object.\n\n"
+ " as a numpy.dtype object.\n\n"
" No __init__ method is needed because the array is fully \n"
" initialized after the __new__ method.";
@@ -8010,10 +7979,10 @@ arraydescr_dealloc(PyArray_Descr *self)
/* we need to be careful about setting attributes because these
objects are pointed to by arrays that depend on them for interpreting
- data. Currently no attributes of dtypedescr objects can be set.
+ data. Currently no attributes of dtype objects can be set.
*/
static PyMemberDef arraydescr_members[] = {
- {"dtype", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},
+ {"type", T_OBJECT, offsetof(PyArray_Descr, typeobj), RO, NULL},
{"kind", T_CHAR, offsetof(PyArray_Descr, kind), RO, NULL},
{"char", T_CHAR, offsetof(PyArray_Descr, type), RO, NULL},
{"num", T_INT, offsetof(PyArray_Descr, type_num), RO, NULL},
@@ -8037,16 +8006,28 @@ arraydescr_subdescr_get(PyArray_Descr *self)
static PyObject *
arraydescr_protocol_typestr_get(PyArray_Descr *self)
{
- char basic_=self->kind;
- char endian = self->byteorder;
-
- if (endian == '=') {
- endian = '<';
- if (!PyArray_IsNativeByteOrder(endian)) endian = '>';
- }
-
- return PyString_FromFormat("%c%c%d", endian, basic_,
- self->elsize);
+ char basic_=self->kind;
+ char endian = self->byteorder;
+
+ if (endian == '=') {
+ endian = '<';
+ if (!PyArray_IsNativeByteOrder(endian)) endian = '>';
+ }
+
+ return PyString_FromFormat("%c%c%d", endian, basic_,
+ self->elsize);
+}
+
+static PyObject *
+arraydescr_protocol_typename_get(PyArray_Descr *self)
+{
+ int len;
+ PyTypeObject *typeobj = self->typeobj;
+
+ /* Both are equivalents, but second is more resistent to changes */
+/* len = strlen(typeobj->tp_name) - 8; */
+ len = strchr(typeobj->tp_name, (int)'_')-(typeobj->tp_name);
+ return PyString_FromStringAndSize(typeobj->tp_name, len);
}
static PyObject *
@@ -8114,10 +8095,14 @@ static PyGetSetDef arraydescr_getsets[] = {
(getter)arraydescr_protocol_descr_get,
NULL,
"The array_protocol type descriptor."},
- {"dtypestr",
+ {"str",
(getter)arraydescr_protocol_typestr_get,
NULL,
"The array_protocol typestring."},
+ {"name",
+ (getter)arraydescr_protocol_typename_get,
+ NULL,
+ "The array_protocol typename."},
{"isbuiltin",
(getter)arraydescr_isbuiltin_get,
NULL,
@@ -8208,7 +8193,7 @@ arraydescr_reduce(PyArray_Descr *self, PyObject *args)
if (ret == NULL) return NULL;
mod = PyImport_ImportModule("numpy.core.multiarray");
if (mod == NULL) {Py_DECREF(ret); return NULL;}
- obj = PyObject_GetAttrString(mod, "dtypedescr");
+ obj = PyObject_GetAttrString(mod, "dtype");
Py_DECREF(mod);
if (obj == NULL) {Py_DECREF(ret); return NULL;}
PyTuple_SET_ITEM(ret, 0, obj);
@@ -8394,11 +8379,11 @@ PyArray_DescrNewByteorder(PyArray_Descr *self, char newendian)
static char doc_arraydescr_newbyteorder[] = "self.newbyteorder(<endian>)"
- " returns a copy of the dtypedescr object\n"
+ " returns a copy of the dtype object\n"
" with altered byteorders. If <endian> is not given all byteorders\n"
" are swapped. Otherwise endian can be '>', '<', or '=' to force\n"
" a byteorder. Descriptors in all fields are also updated in the\n"
- " new dtypedescr object.";
+ " new dtype object.";
static PyObject *
arraydescr_newbyteorder(PyArray_Descr *self, PyObject *args)
@@ -8436,7 +8421,7 @@ arraydescr_str(PyArray_Descr *self)
PyErr_Clear();
}
else sub = PyObject_Str(lst);
- Py_XDECREF(lst);
+ Py_XDECREF(lst);
if (self->type_num != PyArray_VOID) {
PyObject *p;
PyObject *t=PyString_FromString("'");
@@ -8475,7 +8460,7 @@ static PyObject *
arraydescr_repr(PyArray_Descr *self)
{
PyObject *sub, *s;
- s = PyString_FromString("dtypedescr(");
+ s = PyString_FromString("dtype(");
sub = arraydescr_str(self);
PyString_ConcatAndDel(&s, sub);
sub = PyString_FromString(")");
@@ -8487,8 +8472,8 @@ static int
arraydescr_compare(PyArray_Descr *self, PyObject *other)
{
if (!PyArray_DescrCheck(other)) {
- PyErr_SetString(PyExc_TypeError,
- "not a dtypedescr object.");
+ PyErr_SetString(PyExc_TypeError,
+ "not a dtype object.");
return -1;
}
if (PyArray_EquivTypes(self, (PyArray_Descr *)other)) return 0;
@@ -8499,7 +8484,7 @@ arraydescr_compare(PyArray_Descr *self, PyObject *other)
static PyTypeObject PyArrayDescr_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
- "numpy.dtypedescr", /* tp_name */
+ "numpy.dtype", /* tp_name */
sizeof(PyArray_Descr), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c
index 06265ba6b..63bd73858 100644
--- a/numpy/core/src/multiarraymodule.c
+++ b/numpy/core/src/multiarraymodule.c
@@ -37,7 +37,7 @@ _arraydescr_fromobj(PyObject *obj)
PyArray_Descr *new;
int ret;
- dtypedescr = PyObject_GetAttrString(obj, "dtypedescr");
+ dtypedescr = PyObject_GetAttrString(obj, "dtype");
PyErr_Clear();
if (dtypedescr) {
ret = PyArray_DescrConverter(dtypedescr, &new);
@@ -160,7 +160,7 @@ PyArray_View(PyArrayObject *self, PyArray_Descr *type, PyTypeObject *pytype)
PyArray_BASE(new) = (PyObject *)self;
if (type != NULL) {
- if (PyObject_SetAttrString(new, "dtypedescr",
+ if (PyObject_SetAttrString(new, "dtype",
(PyObject *)type) < 0) {
Py_DECREF(new);
Py_DECREF(type);
@@ -4065,7 +4065,7 @@ static PyObject *
_array_fromobject(PyObject *ignored, PyObject *args, PyObject *kws)
{
PyObject *op, *ret=NULL;
- static char *kwd[]= {"object", "dtype", "copy", "fortran", "subok",
+ static char *kwd[]= {"object", "dtype", "copy", "fortran", "subok", /* XXX ? */
NULL};
Bool subok=FALSE;
Bool copy=TRUE;
@@ -4182,13 +4182,13 @@ array_empty(PyObject *ignored, PyObject *args, PyObject *kwds)
return ret;
}
-static char doc_scalar[] = "scalar(dtypedescr,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. The dtypedescr must be a valid data-type descriptor. If dtypedescr corresponds to an OBJECT descriptor, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.";
+static char doc_scalar[] = "scalar(dtype,obj) will return a new scalar array of the given type initialized with obj. Mainly for pickle support. The dtype must be a valid data-type descriptor. If dtype corresponds to an OBJECT descriptor, then obj can be any object, otherwise obj must be a string. If obj is not given it will be interpreted as None for object type and zeros for all other types.";
static PyObject *
array_scalar(PyObject *ignored, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"dtypedescr","obj", NULL};
+ static char *kwlist[] = {"dtype","obj", NULL};
PyArray_Descr *typecode;
PyObject *obj=NULL;
int alloc=0;
@@ -4284,7 +4284,7 @@ static char doc_zeros[] = "zeros((d1,...,dn),dtype=int,fortran=0) will return a
static PyObject *
array_zeros(PyObject *ignored, PyObject *args, PyObject *kwds)
{
- static char *kwlist[] = {"shape","dtype","fortran",NULL};
+ static char *kwlist[] = {"shape","dtype","fortran",NULL}; /* XXX ? */
PyArray_Descr *typecode=NULL;
PyArray_Dims shape = {NULL, 0};
Bool fortran = FALSE;
@@ -5501,7 +5501,7 @@ DL_EXPORT(void) initmultiarray(void) {
PyDict_SetItemString(d, "broadcast",
(PyObject *)&PyArrayMultiIter_Type);
Py_INCREF(&PyArrayDescr_Type);
- PyDict_SetItemString(d, "dtypedescr", (PyObject *)&PyArrayDescr_Type);
+ PyDict_SetItemString(d, "dtype", (PyObject *)&PyArrayDescr_Type);
/* Doesn't need to be exposed to Python
Py_INCREF(&PyArrayMapIter_Type);
diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.inc.src
index 2a8fcf4a9..8fed7cb4a 100644
--- a/numpy/core/src/scalartypes.inc.src
+++ b/numpy/core/src/scalartypes.inc.src
@@ -718,24 +718,6 @@ gentype_size_get(PyObject *self)
return PyInt_FromLong(1);
}
-
-static PyObject *
-gentype_typechar_get(PyObject *self)
-{
- PyArray_Descr *descr;
- char type;
- int elsize;
-
- descr = PyArray_DescrFromScalar(self);
- type = descr->type;
- elsize = descr->elsize;
- Py_DECREF(descr);
- if (PyArray_IsScalar(self, Flexible))
- return PyString_FromFormat("%c%d", (int)type, elsize);
- else
- return PyString_FromStringAndSize(&type, 1);
-}
-
static void
gentype_struct_free(void *ptr, void *arr)
{
@@ -769,7 +751,7 @@ gentype_typestr_get(PyObject *self)
PyObject *ret;
arr = (PyArrayObject *)PyArray_FromScalar(self, NULL);
- ret = PyObject_GetAttrString((PyObject *)arr, "dtypestr");
+ ret = PyObject_GetAttrString((PyObject *)arr->descr, "str");
Py_DECREF(arr);
return ret;
}
@@ -788,13 +770,6 @@ gentype_descr_get(PyObject *self)
static PyObject *
-gentype_type_get(PyObject *self)
-{
- Py_INCREF(self->ob_type);
- return (PyObject *)self->ob_type;
-}
-
-static PyObject *
gentype_typedescr_get(PyObject *self)
{
return (PyObject *)PyArray_DescrFromScalar(self);
@@ -937,19 +912,7 @@ static PyGetSetDef gentype_getsets[] = {
(getter)gentype_base_get,
(setter)0,
"base object"},
- {"dtype",
- (getter)gentype_type_get,
- (setter)0,
- "get gentype type class"},
- {"dtypechar",
- (getter)gentype_typechar_get,
- (setter)0,
- "get gentype type character code"},
- {"dtypestr",
- (getter)gentype_typestr_get,
- NULL,
- "get array type string"},
- {"dtypedescr",
+ {"dtype",
(getter)gentype_typedescr_get,
NULL,
"get array data-descriptor"},
@@ -1143,7 +1106,7 @@ voidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
PyObject *value, *src;
int mysize;
char *dptr;
- static char *kwlist[] = {"value", "dtype", "offset", 0};
+ static char *kwlist[] = {"value", "dtype", "offset", 0};/* XXX ? */
if ((self->flags & WRITEABLE) != WRITEABLE) {
PyErr_SetString(PyExc_RuntimeError,
@@ -1200,7 +1163,7 @@ gentype_reduce(PyObject *self, PyObject *args)
Py_DECREF(mod);
if (obj == NULL) return NULL;
PyTuple_SET_ITEM(ret, 0, obj);
- obj = PyObject_GetAttrString((PyObject *)self, "dtypedescr");
+ obj = PyObject_GetAttrString((PyObject *)self, "dtype");
if PyArray_IsScalar(self, Object) {
mod = ((PyObjectScalarObject *)self)->obval;
PyTuple_SET_ITEM(ret, 1,
@@ -1375,10 +1338,10 @@ static PyGetSetDef voidtype_getsets[] = {
(getter)voidtype_flags_get,
(setter)0,
"integer value of flags"},
- {"dtypedescr",
+ {"dtype",
(getter)voidtype_dtypedescr_get,
(setter)0,
- "dtypedescr object"},
+ "dtype object"},
{NULL, NULL}
};
diff --git a/numpy/core/src/ufuncobject.c b/numpy/core/src/ufuncobject.c
index b903b6646..00dee2f19 100644
--- a/numpy/core/src/ufuncobject.c
+++ b/numpy/core/src/ufuncobject.c
@@ -2515,7 +2515,6 @@ _find_array_wrap(PyObject *args)
{
int nargs, i;
int np = 0;
- int argmax = 0;
double priority[MAX_ARGS];
double maxpriority;
PyObject *with_wrap[MAX_ARGS];
diff --git a/numpy/core/tests/test_defmatrix.py b/numpy/core/tests/test_defmatrix.py
index 009c583cc..0fd60c6bd 100644
--- a/numpy/core/tests/test_defmatrix.py
+++ b/numpy/core/tests/test_defmatrix.py
@@ -82,14 +82,14 @@ class test_autocasting(ScipyTestCase):
mB = mA.copy()
O = ones((10,10), float64) * 0.1
mB = mB + O
- assert mB.dtype == float64
+ assert mB.dtype.type == float64
assert all(mA != mB)
assert all(mB == mA+0.1)
mC = mA.copy()
O = ones((10,10), complex128)
mC = mC * O
- assert mC.dtype == complex128
+ assert mC.dtype.type == complex128
assert all(mA != mB)
class test_algebra(ScipyTestCase):
diff --git a/numpy/core/tests/test_ma.py b/numpy/core/tests/test_ma.py
index dd06aed7a..c5ceb2f79 100644
--- a/numpy/core/tests/test_ma.py
+++ b/numpy/core/tests/test_ma.py
@@ -39,7 +39,6 @@ class test_ma(ScipyTestCase):
self.assertEqual(shape(xm), s)
self.assertEqual(xm.shape, s)
self.assertEqual(xm.dtype, x.dtype)
- self.assertEqual(xm.dtypechar, x.dtypechar)
self.assertEqual( xm.size , reduce(lambda x,y:x*y, s))
self.assertEqual(count(xm) , len(m1) - reduce(lambda x,y:x+y, m1))
self.failUnless(eq(xm, xf))
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index 3f57566ca..a3b4eecd4 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -50,24 +50,24 @@ class test_attributes(ScipyTestCase):
num = self.two.itemsize
assert_equal(self.two.size, 20)
assert_equal(self.two.nbytes, 20*num)
- assert_equal(self.two.itemsize, self.two.dtypedescr.itemsize)
+ assert_equal(self.two.itemsize, self.two.dtype.itemsize)
assert_equal(self.two.base, arange(20))
def check_dtypeattr(self):
- assert_equal(self.one.dtype, int_)
- assert_equal(self.three.dtype, float_)
- assert_equal(self.one.dtypechar, 'l')
- assert_equal(self.three.dtypechar, 'd')
- self.failUnless(self.three.dtypestr[0] in '<>')
- assert_equal(self.one.dtypestr[1], 'i')
- assert_equal(self.three.dtypestr[1], 'f')
+ assert_equal(self.one.dtype, dtype(int_))
+ assert_equal(self.three.dtype, dtype(float_))
+ assert_equal(self.one.dtype.char, 'l')
+ assert_equal(self.three.dtype.char, 'd')
+ self.failUnless(self.three.dtype.str[0] in '<>')
+ assert_equal(self.one.dtype.str[1], 'i')
+ assert_equal(self.three.dtype.str[1], 'f')
class test_dtypedescr(ScipyTestCase):
def check_construction(self):
- d1 = dtypedescr('i4')
- assert_equal(d1, dtypedescr(int32))
- d2 = dtypedescr('f8')
- assert_equal(d2, dtypedescr(float64))
+ d1 = dtype('i4')
+ assert_equal(d1, dtype(int32))
+ d2 = dtype('f8')
+ assert_equal(d2, dtype(float64))
class test_zero_rank(ScipyTestCase):
def setUp(self):
@@ -77,14 +77,14 @@ class test_zero_rank(ScipyTestCase):
a,b = self.d
self.failUnlessEqual(a[...], 0)
self.failUnlessEqual(b[...], 'x')
- self.failUnless(type(a[...]) is a.dtype)
+ self.failUnless(type(a[...]) is a.dtype.type)
self.failUnless(type(b[...]) is str)
def check_empty_subscript(self):
a,b = self.d
self.failUnlessEqual(a[()], 0)
self.failUnlessEqual(b[()], 'x')
- self.failUnless(type(a[()]) is a.dtype)
+ self.failUnless(type(a[()]) is a.dtype.type)
self.failUnless(type(b[()]) is str)
def check_invalid_subscript(self):
diff --git a/numpy/dft/fftpack.py b/numpy/dft/fftpack.py
index c5bb085e2..441aae5f5 100644
--- a/numpy/dft/fftpack.py
+++ b/numpy/dft/fftpack.py
@@ -55,7 +55,7 @@ def _raw_fft(a, n=None, axis=-1, init_function=fftpack.cffti,
index = [slice(None)]*len(s)
index[axis] = slice(0,s[axis])
s[axis] = n
- z = zeros(s, a.dtypechar)
+ z = zeros(s, a.dtype.char)
z[index] = a
a = z
diff --git a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
index 9cd01fa7c..281018b64 100644
--- a/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
+++ b/numpy/f2py/tests/array_from_pyobj/tests/test_array_from_pyobj.py
@@ -177,8 +177,8 @@ class Array:
self.pyarr = array(array(obj,
dtype = typ.dtypechar).reshape(*dims),
fortran=not self.intent.is_intent('c'))
- assert self.pyarr.dtypechar==typ.dtypechar,\
- `self.pyarr.dtypechar,typ.dtypechar`
+ assert self.pyarr.dtype.char==typ.dtypechar,\
+ `self.pyarr.dtype.char,typ.dtypechar`
assert self.pyarr.flags['OWNDATA']
self.pyarr_attr = wrap.array_attrs(self.pyarr)
diff --git a/numpy/lib/convertcode.py b/numpy/lib/convertcode.py
index 6a62f2502..3e0a679f0 100644
--- a/numpy/lib/convertcode.py
+++ b/numpy/lib/convertcode.py
@@ -61,7 +61,7 @@ def changeimports(fstr, name, newname):
return fstr, fromall
def replaceattr(astr):
- astr = astr.replace(".typecode()",".dtypechar")
+ astr = astr.replace(".typecode()",".dtype.char")
astr = astr.replace(".iscontiguous()",".flags.contiguous")
astr = astr.replace(".byteswapped()",".byteswap()")
astr = astr.replace(".toscalar()", ".item()")
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 0b9928577..d0a28b4dd 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -163,7 +163,7 @@ def asarray_chkfinite(a):
"""Like asarray, but check that no NaNs or Infs are present.
"""
a = asarray(a)
- if (a.dtypechar in _nx.typecodes['AllFloat']) \
+ if (a.dtype.char in _nx.typecodes['AllFloat']) \
and (_nx.isnan(a).any() or _nx.isinf(a).any()):
raise ValueError, "array must not contain infs or NaNs"
return a
@@ -322,13 +322,13 @@ def gradient(f, *varargs):
slice2 = [slice(None)]*N
slice3 = [slice(None)]*N
- otype = f.dtypechar
+ otype = f.dtype.char
if otype not in ['f', 'd', 'F', 'D']:
otype = 'd'
for axis in range(N):
# select out appropriate parts for this dimension
- out = zeros(f.shape, f.dtypechar)
+ out = zeros(f.shape, f.dtype.char)
slice1[axis] = slice(1, -1)
slice2[axis] = slice(2, None)
slice3[axis] = slice(None, -2)
@@ -387,7 +387,7 @@ def angle(z, deg=0):
else:
fact = 1.0
z = asarray(z)
- if (issubclass(z.dtype, _nx.complexfloating)):
+ if (issubclass(z.dtype.type, _nx.complexfloating)):
zimag = z.imag
zreal = z.real
else:
@@ -420,10 +420,10 @@ def sort_complex(a):
"""
b = array(a,copy=True)
b.sort()
- if not issubclass(b.dtype, _nx.complexfloating):
- if b.dtypechar in 'bhBH':
+ if not issubclass(b.dtype.type, _nx.complexfloating):
+ if b.dtype.char in 'bhBH':
return b.astype('F')
- elif b.dtypechar == 'g':
+ elif b.dtype.char == 'g':
return b.astype('G')
else:
return b.astype('D')
@@ -480,7 +480,7 @@ def nansum(a, axis=-1):
"""Sum the array over the given axis, treating NaNs as 0.
"""
y = array(a)
- if not issubclass(y.dtype, _nx.integer):
+ if not issubclass(y.dtype.type, _nx.integer):
y[isnan(a)] = 0
return y.sum(axis)
@@ -488,7 +488,7 @@ def nanmin(a, axis=-1):
"""Find the minimium over the given axis, ignoring NaNs.
"""
y = array(a)
- if not issubclass(y.dtype, _nx.integer):
+ if not issubclass(y.dtype.type, _nx.integer):
y[isnan(a)] = _nx.inf
return y.min(axis)
@@ -496,7 +496,7 @@ def nanargmin(a, axis=-1):
"""Find the indices of the minimium over the given axis ignoring NaNs.
"""
y = array(a)
- if not issubclass(y.dtype, _nx.integer):
+ if not issubclass(y.dtype.type, _nx.integer):
y[isnan(a)] = _nx.inf
return y.argmin(axis)
@@ -504,7 +504,7 @@ def nanmax(a, axis=-1):
"""Find the maximum over the given axis ignoring NaNs.
"""
y = array(a)
- if not issubclass(y.dtype, _nx.integer):
+ if not issubclass(y.dtype.type, _nx.integer):
y[isnan(a)] = -_nx.inf
return y.max(axis)
@@ -512,7 +512,7 @@ def nanargmax(a, axis=-1):
"""Find the maximum over the given axis ignoring NaNs.
"""
y = array(a)
- if not issubclass(y.dtype, _nx.integer):
+ if not issubclass(y.dtype.type, _nx.integer):
y[isnan(a)] = -_nx.inf
return y.argmax(axis)
@@ -608,7 +608,7 @@ class vectorize(object):
if self.otypes == '':
otypes = []
for k in range(self.nout):
- otypes.append(asarray(theout[k]).dtypechar)
+ otypes.append(asarray(theout[k]).dtype.char)
self.otypes = ''.join(otypes)
if (self.ufunc is None) or (self.lastcallargs != nargs):
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py
index b09538e42..fc06a2600 100644
--- a/numpy/lib/index_tricks.py
+++ b/numpy/lib/index_tricks.py
@@ -207,9 +207,9 @@ class concatenator(object):
objs.append(newobj)
if isinstance(newobj, _nx.ndarray) and not scalar:
if final_dtypedescr is None:
- final_dtypedescr = newobj.dtypedescr
- elif newobj.dtypedescr > final_dtypedescr:
- final_dtypedescr = newobj.dtypedescr
+ final_dtypedescr = newobj.dtype
+ elif newobj.dtype > final_dtypedescr:
+ final_dtypedescr = newobj.dtype
if final_dtypedescr is not None:
for k in scalars:
objs[k] = objs[k].astype(final_dtypedescr)
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index 886a465db..0515a74ab 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -29,7 +29,7 @@ def apply_along_axis(func1d,axis,arr,*args):
res = func1d(arr[tuple(i.tolist())],*args)
# if res is a number, then we have a smaller output array
if isscalar(res):
- outarr = zeros(outshape,asarray(res).dtypechar)
+ outarr = zeros(outshape,asarray(res).dtype)
outarr[ind] = res
Ntot = product(outshape)
k = 1
@@ -51,7 +51,7 @@ def apply_along_axis(func1d,axis,arr,*args):
holdshape = outshape
outshape = list(arr.shape)
outshape[axis] = len(res)
- outarr = zeros(outshape,asarray(res).dtypechar)
+ outarr = zeros(outshape,asarray(res).dtype)
outarr[tuple(i.tolist())] = res
k = 1
while k < Ntot:
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py
index dac4d866f..6813192c1 100644
--- a/numpy/lib/tests/test_polynomial.py
+++ b/numpy/lib/tests/test_polynomial.py
@@ -73,8 +73,6 @@ poly1d([ 2.])
(poly1d([ 1., -1.]), poly1d([ 0.]))
"""
-from numpy.testing import *
-
import doctest
def test_suite(level=1):
return doctest.DocTestSuite()
diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py
index 49aa09757..5b4574089 100644
--- a/numpy/lib/twodim_base.py
+++ b/numpy/lib/twodim_base.py
@@ -117,7 +117,7 @@ def vander(x, N=None):
"""
x = asarray(x)
if N is None: N=len(x)
- X = ones( (len(x),N), x.dtypechar)
+ X = ones( (len(x),N), x.dtype)
for i in range(N-1):
X[:,i] = x**(N-i-1)
return X
diff --git a/numpy/lib/type_check.py b/numpy/lib/type_check.py
index 28f01cbc7..7a00d9be3 100644
--- a/numpy/lib/type_check.py
+++ b/numpy/lib/type_check.py
@@ -20,15 +20,15 @@ def mintypecode(typechars,typeset='GDFgdf',default='d'):
The returned type character must be the smallest size such that
an array of the returned type can handle the data from an array of
type t for each t in typechars (or if typechars is an array,
- then its dtypechar).
+ then its dtype.char).
If the typechars does not intersect with the typeset, then default
is returned.
- If t in typechars is not a string then t=asarray(t).dtypechar is
+ If t in typechars is not a string then t=asarray(t).dtype.char is
applied.
"""
- typecodes = [(type(t) is type('') and t) or asarray(t).dtypechar\
+ typecodes = [(type(t) is type('') and t) or asarray(t).dtype.char\
for t in typechars]
intersection = [t for t in typecodes if t in typeset]
if not intersection:
@@ -63,10 +63,10 @@ def isreal(x):
return imag(x) == _nx.zeros_like(x)
def iscomplexobj(x):
- return issubclass( asarray(x).dtype, _nx.complexfloating)
+ return issubclass( asarray(x).dtype.type, _nx.complexfloating)
def isrealobj(x):
- return not issubclass( asarray(x).dtype, _nx.complexfloating)
+ return not issubclass( asarray(x).dtype.type, _nx.complexfloating)
#-----------------------------------------------------------------------------
@@ -81,7 +81,7 @@ def nan_to_num(x):
# Inf -> limits.double_max
# -Inf -> limits.double_min
try:
- t = x.dtype
+ t = x.dtype.type
except AttributeError:
t = obj2dtype(type(x))
if issubclass(t, _nx.complexfloating):
@@ -98,7 +98,7 @@ def nan_to_num(x):
are_inf = isposinf(y)
are_neg_inf = isneginf(y)
are_nan = isnan(y)
- maxf, minf = _getmaxmin(y.dtype)
+ maxf, minf = _getmaxmin(y.dtype.type)
y[are_nan] = 0
y[are_inf] = maxf
y[are_neg_inf] = minf
@@ -110,11 +110,11 @@ def nan_to_num(x):
def real_if_close(a,tol=100):
a = asarray(a)
- if a.dtypechar not in 'FDG':
+ if a.dtype.char not in 'FDG':
return a
if tol > 1:
import getlimits
- f = getlimits.finfo(a.dtype)
+ f = getlimits.finfo(a.dtype.type)
tol = f.eps * tol
if _nx.allclose(a.imag, 0, atol=tol):
a = a.real
@@ -167,7 +167,7 @@ def common_type(*arrays):
kind = 0
precision = 0
for a in arrays:
- t = a.dtypechar
+ t = a.dtype.char
kind = max(kind, array_kind[t])
precision = max(precision, array_precision[t])
return array_type[kind][precision]
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
index e6a7bc3cb..88d76d24e 100644
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -33,7 +33,7 @@ def _commonType(*arrays):
# force higher precision in lite version
precision = 1
for a in arrays:
- t = a.dtypechar
+ t = a.dtype.char
kind = max(kind, _array_kind[t])
precision = max(precision, _array_precision[t])
return _array_type[kind][precision]
@@ -55,7 +55,7 @@ _fastCT = fastCopyAndTranspose
def _fastCopyAndTranspose(type, *arrays):
cast_arrays = ()
for a in arrays:
- if a.dtypechar == type:
+ if a.dtype.char == type:
cast_arrays = cast_arrays + (_fastCT(a),)
else:
cast_arrays = cast_arrays + (_fastCT(a.astype(type)),)
@@ -209,16 +209,16 @@ def Heigenvalues(a, UPLO='L'):
def _convertarray(a):
if issubclass(a.dtype, complexfloating):
- if a.dtypechar == 'D':
+ if a.dtype.char == 'D':
a = _fastCT(a)
else:
a = _fastCT(a.astype('D'))
else:
- if a.dtypechar == 'd':
+ if a.dtype.char == 'd':
a = _fastCT(a)
else:
a = _fastCT(a.astype('d'))
- return a, a.dtypechar
+ return a, a.dtype.char
# Eigenvectors
@@ -370,7 +370,7 @@ def svd(a, full_matrices = 1):
def generalized_inverse(a, rcond = 1.e-10):
a = array(a, copy=0)
- if a.dtypechar in typecodes['Complex']:
+ if a.dtype.char in typecodes['Complex']:
a = conjugate(a)
u, s, vt = svd(a, 0)
m = u.shape[0]
diff --git a/numpy/random/mtrand/mtrand.c b/numpy/random/mtrand/mtrand.c
index 2ea2049b8..29d91e3cc 100644
--- a/numpy/random/mtrand/mtrand.c
+++ b/numpy/random/mtrand/mtrand.c
@@ -1,4 +1,4 @@
-/* Generated by Pyrex 0.9.3.1 on Thu Jan 5 00:40:10 2006 */
+/* Generated by Pyrex 0.9.3.1 on Sat Jan 14 17:53:56 2006 */
#include "Python.h"
#include "structmember.h"
@@ -42,7 +42,7 @@ struct __pyx_obj_6mtrand_RandomState {
rk_state (*internal_state);
};
-static PyTypeObject *__pyx_ptype_6mtrand_dtypedescr = 0;
+static PyTypeObject *__pyx_ptype_6mtrand_dtype = 0;
static PyTypeObject *__pyx_ptype_6mtrand_ndarray = 0;
static PyTypeObject *__pyx_ptype_6mtrand_RandomState = 0;
static PyObject *__pyx_k2;
@@ -5124,7 +5124,7 @@ DL_EXPORT(void) initmtrand(void) {
if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};
if (__Pyx_InternStrings(__pyx_intern_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};
if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; goto __pyx_L1;};
- __pyx_ptype_6mtrand_dtypedescr = __Pyx_ImportType("numpy", "dtypedescr", sizeof(PyArray_Descr)); if (!__pyx_ptype_6mtrand_dtypedescr) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; goto __pyx_L1;}
+ __pyx_ptype_6mtrand_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (!__pyx_ptype_6mtrand_dtype) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; goto __pyx_L1;}
__pyx_ptype_6mtrand_ndarray = __Pyx_ImportType("numpy", "ndarray", sizeof(PyArrayObject)); if (!__pyx_ptype_6mtrand_ndarray) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 36; goto __pyx_L1;}
if (PyType_Ready(&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}
if (PyObject_SetAttrString(__pyx_m, "RandomState", (PyObject *)&__pyx_type_6mtrand_RandomState) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 266; goto __pyx_L1;}
diff --git a/numpy/random/mtrand/numpy.pxi b/numpy/random/mtrand/numpy.pxi
index 9ce61583a..0a2d289da 100644
--- a/numpy/random/mtrand/numpy.pxi
+++ b/numpy/random/mtrand/numpy.pxi
@@ -29,7 +29,7 @@ cdef extern from "numpy/arrayobject.h":
ctypedef int intp
- ctypedef extern class numpy.dtypedescr [object PyArray_Descr]:
+ ctypedef extern class numpy.dtype [object PyArray_Descr]:
cdef int type_num, elsize
cdef char type
@@ -39,7 +39,7 @@ cdef extern from "numpy/arrayobject.h":
cdef intp *dimensions
cdef intp *strides
cdef object base
- cdef dtypedescr descr
+ cdef dtype descr
cdef int flags
ndarray PyArray_SimpleNew(int ndims, intp* dims, int item_type)
diff --git a/numpy/version.py b/numpy/version.py
index 64f7aa11b..3427faf10 100644
--- a/numpy/version.py
+++ b/numpy/version.py
@@ -1,4 +1,4 @@
-version='0.9.3'
+version='0.9.4'
import os
svn_version_file = os.path.join(os.path.dirname(__file__),