summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--scipy/base/convertcode.py24
-rw-r--r--scipy/base/src/arrayobject.c19
2 files changed, 15 insertions, 28 deletions
diff --git a/scipy/base/convertcode.py b/scipy/base/convertcode.py
index 4040ded59..cf1e9e7a0 100644
--- a/scipy/base/convertcode.py
+++ b/scipy/base/convertcode.py
@@ -28,11 +28,6 @@ import warnings
import glob
flatindex_re = re.compile('([.]flat(\s*?[[=]))')
-int_re = re.compile('int\s*[(][^)]*[)]')
-bool_re = re.compile('bool\s*[(][^)]*[)]')
-float_re = re.compile('float\s*[(][^)]*[)]')
-complex_re = re.compile('complex\s*[(][^)]*[)]')
-unicode_re = re.compile('unicode\s*[(][^)]*[)]')
def replacetypechars(astr):
# astr = astr.replace("'s'","'h'")
@@ -47,15 +42,10 @@ def changeimports(fstr, name, newname):
importstr = 'import %s' % name
importasstr = 'import %s as ' % name
fromstr = 'from %s import ' % name
- fromallstr = 'from %s import *' % name
fromall=0
fstr = fstr.replace(importasstr, 'import %s as ' % newname)
fstr = fstr.replace(importstr, 'import %s as %s' % (newname,name))
- if (fstr.find(fromallstr) >= 0):
- warnings.warn('Usage of %s found.' % fromallstr)
- fstr = fstr.replace(fromallstr, 'from %s import *' % newname)
- fromall=1
ind = 0
Nlen = len(fromstr)
@@ -98,18 +88,6 @@ def replaceother(astr):
#astr = shpe.sub('\\1=\\1.reshape(\\2)', astr)
return astr
-def warnofnewtypes(filestr):
- if int_re.search(filestr) or \
- float_re.search(filestr) or \
- complex_re.search(filestr) or \
- unicode_re.search(filestr) or \
- bool_re.search(filestr):
- warnings.warn("Use of builtin bool, int, float, complex, or unicode\n" \
- "found when import * used -- these will be handled by\n" \
- "new array scalars under scipy")
-
- return
-
import datetime
def fromstr(filestr):
filestr = replacetypechars(filestr)
@@ -130,8 +108,6 @@ def fromstr(filestr):
fromall = fromall1 or fromall2 or fromall3
filestr = replaceattr(filestr)
filestr = replaceother(filestr)
- if fromall:
- warnofnewtypes(filestr)
today = datetime.date.today().strftime('%b %d, %Y')
name = os.path.split(sys.argv[0])[-1]
filestr = '## Automatically adapted for '\
diff --git a/scipy/base/src/arrayobject.c b/scipy/base/src/arrayobject.c
index f678114a8..0c8ff4380 100644
--- a/scipy/base/src/arrayobject.c
+++ b/scipy/base/src/arrayobject.c
@@ -721,8 +721,7 @@ PyArray_FromDimsAndDataAndDescr(int nd, int *d,
{
PyObject *ret;
- if (!PyArray_ISNBO(descr->byteorder) && \
- (descr->byteorder != '|'))
+ if (!PyArray_ISNBO(descr->byteorder))
descr->byteorder = '=';
#if SIZEOF_INTP != SIZEOF_INT
@@ -812,6 +811,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
itemsize = descr->elsize;
type = descr->typeobj;
copyswap = descr->f->copyswap;
+ swap = !PyArray_ISNBO(descr->byteorder);
if (type->tp_itemsize != 0) /* String type */
obj = type->tp_alloc(type, itemsize);
else
@@ -850,6 +850,7 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
vobj->obval = NULL;
vobj->ob_size = itemsize;
vobj->flags = BEHAVED_FLAGS | OWNDATA;
+ swap = 0;
if (type != &PyVoidArrType_Type && descr->fields) {
name = PyString_InternFromString("fields");
PyObject_GenericSetAttr(obj, name, \
@@ -877,7 +878,6 @@ PyArray_Scalar(void *data, PyArray_Descr *descr, PyObject *base)
destptr = _SOFFSET_(obj, type_num);
}
/* copyswap for OBJECT increments the reference count */
- swap = !PyArray_ISNBO(descr->byteorder);
copyswap(destptr, data, swap, itemsize);
return obj;
}
@@ -5825,7 +5825,7 @@ array_fromattr(PyObject *op, PyArray_Descr *typecode, int flags)
return r;
}
-/* Steals a reference to newtype */
+/* Steals a reference to newtype --- which can be NULL */
static PyObject *
array_fromobject(PyObject *op, PyArray_Descr *newtype, int min_depth,
int max_depth, int flags)
@@ -5939,6 +5939,7 @@ PyArray_ObjectType(PyObject *op, int minimum_type)
FORTRAN,
ALIGNED,
WRITEABLE,
+ NOTSWAPPED,
ENSURECOPY,
UPDATEIFCOPY,
FORCECAST,
@@ -5982,6 +5983,16 @@ PyArray_FromAny(PyObject *op, PyArray_Descr *descr, int min_depth,
if (requires & ENSURECOPY) {
requires |= DEFAULT_FLAGS;
}
+ if (requires & NOTSWAPPED) {
+ if (!descr && PyArray_Check(op) && \
+ !PyArray_ISNBO(PyArray_DESCR(op)->byteorder)) {
+ descr = PyArray_DescrNew(PyArray_DESCR(op));
+ }
+ else if ((descr && !PyArray_ISNBO(descr->byteorder))) {
+ PyArray_DESCR_REPLACE(descr);
+ }
+ descr->byteorder = PyArray_NATIVE;
+ }
return array_fromobject(op, descr, min_depth, max_depth,
requires);