[Numpy-svn] r2787 - in trunk/numpy/core: src tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Jul 8 05:26:46 EDT 2006
Author: oliphant
Date: 2006-07-08 04:26:41 -0500 (Sat, 08 Jul 2006)
New Revision: 2787
Modified:
trunk/numpy/core/src/arrayobject.c
trunk/numpy/core/tests/test_multiarray.py
Log:
Fix 0-stride contiguous bug.
Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c 2006-07-08 04:00:53 UTC (rev 2786)
+++ trunk/numpy/core/src/arrayobject.c 2006-07-08 09:26:41 UTC (rev 2787)
@@ -4566,9 +4566,7 @@
register intp sd;
register intp dim;
register int i;
- register intp stride;
-
if (ap->nd == 0) return 1;
sd = ap->descr->elsize;
if (ap->nd == 1) return (ap->dimensions[0] == 1 || \
@@ -4577,9 +4575,7 @@
dim = ap->dimensions[i];
/* contiguous by definition */
if (dim == 0) return 1;
- stride = ap->strides[i];
- if (stride == 0 && dim == 1) continue;
- if (stride != sd) return 0;
+ if (ap->strides[i] != sd) return 0;
sd *= dim;
}
return 1;
@@ -4592,7 +4588,6 @@
register intp sd;
register intp dim;
register int i;
- register intp stride;
if (ap->nd == 0) return 1;
sd = ap->descr->elsize;
@@ -4602,9 +4597,7 @@
dim = ap->dimensions[i];
/* fortran contiguous by definition */
if (dim == 0) return 1;
- stride = ap->strides[i];
- if (stride == 0 && dim == 1) continue;
- if (stride != sd) return 0;
+ if (ap->strides[i] != sd) return 0;
sd *= dim;
}
return 1;
Modified: trunk/numpy/core/tests/test_multiarray.py
===================================================================
--- trunk/numpy/core/tests/test_multiarray.py 2006-07-08 04:00:53 UTC (rev 2786)
+++ trunk/numpy/core/tests/test_multiarray.py 2006-07-08 09:26:41 UTC (rev 2787)
@@ -344,6 +344,11 @@
axes.remove(i)
assert all(amax == aargmax.choose(*a.transpose(i,*axes)))
+class test_newaxis(ScipyTestCase):
+ def check_basic(self):
+ sk = array([0,-0.1,0.1])
+ res = 250*sk[:,newaxis]
+ assert_almost_equal(res.ravel(),250*sk)
# Import tests from unicode
set_local_path()
More information about the Numpy-svn
mailing list