diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/numeric.py | 2 | ||||
-rw-r--r-- | numpy/core/src/arrayobject.c | 16 |
2 files changed, 11 insertions, 7 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 19f0c1fb5..c56301a08 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -427,7 +427,7 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): if issubclass(arr.dtype.type, flexible): typename = str(arr.dtype) lf = '\n'+' '*len("array(") - return cName + "(%s, %sdtype=%s)" % (lst, lf, typename) + return cName + "(%s, %sdtype='%s')" % (lst, lf, typename) def array_str(a, max_line_width=None, precision=None, suppress_small=None): return array2string(a, max_line_width, precision, suppress_small, ' ', "", str) diff --git a/numpy/core/src/arrayobject.c b/numpy/core/src/arrayobject.c index 8bd67cb7f..53cc31498 100644 --- a/numpy/core/src/arrayobject.c +++ b/numpy/core/src/arrayobject.c @@ -7739,6 +7739,12 @@ PyArray_FromArray(PyArrayObject *arr, PyArray_Descr *newtype, int flags) if (newtype == NULL) {newtype = oldtype; Py_INCREF(oldtype);} type = newtype->type_num; itemsize = newtype->elsize; + if (itemsize == 0) { + PyArray_DESCR_REPLACE(newtype); + if (newtype == NULL) return NULL; + newtype->elsize = oldtype->elsize; + itemsize = newtype->elsize; + } /* Don't copy if sizes are compatible */ if ((flags & ENSURECOPY) || PyArray_EquivTypes(oldtype, newtype)) { @@ -11126,13 +11132,11 @@ arraydescr_str(PyArray_Descr *self) PyString_ConcatAndDel(&t, PyString_FromString(")")); sub = t; } + else if (PyDataType_ISFLEXIBLE(self) || !PyArray_ISNBO(self->byteorder)) { + sub = arraydescr_protocol_typestr_get(self); + } else { - if (!PyArray_ISNBO(self->byteorder)) { - sub = arraydescr_protocol_typestr_get(self); - } - else { - sub = arraydescr_typename_get(self); - } + sub = arraydescr_typename_get(self); } return sub; } |