[Numpy-svn] r3804 - in trunk/numpy/core: src tests
numpy-svn at scipy.org
numpy-svn at scipy.org
Tue May 22 22:50:01 EDT 2007
Author: oliphant
Date: 2007-05-22 21:49:54 -0500 (Tue, 22 May 2007)
New Revision: 3804
Modified:
trunk/numpy/core/src/arrayobject.c
trunk/numpy/core/tests/test_unicode.py
Log:
Re-think the byte-swapping unicode tests. They were correct to begin with. Try to fix the new bug on narrow builds.
Modified: trunk/numpy/core/src/arrayobject.c
===================================================================
--- trunk/numpy/core/src/arrayobject.c 2007-05-22 23:33:01 UTC (rev 3803)
+++ trunk/numpy/core/src/arrayobject.c 2007-05-23 02:49:54 UTC (rev 3804)
@@ -1378,13 +1378,13 @@
byte_swap_vector(destptr, length, 4);
#else
/* need aligned data buffer */
- if ((((intp)data) % descr->alignment) != 0) {
+ if ((swap) || ((((intp)data) % descr->alignment) != 0)) {
buffer = _pya_malloc(itemsize);
if (buffer == NULL)
return PyErr_NoMemory();
alloc = 1;
memcpy(buffer, data, itemsize);
- if (!PyArray_ISNOTSWAPPED(base)) {
+ if (swap) {
byte_swap_vector(buffer,
itemsize >> 2, 4);
}
Modified: trunk/numpy/core/tests/test_unicode.py
===================================================================
--- trunk/numpy/core/tests/test_unicode.py 2007-05-22 23:33:01 UTC (rev 3803)
+++ trunk/numpy/core/tests/test_unicode.py 2007-05-23 02:49:54 UTC (rev 3804)
@@ -240,7 +240,10 @@
"""Check byteorder of 0-dimensional objects"""
ua = array(self.ucs_value*self.ulen, dtype='U%s' % self.ulen)
ua2 = ua.newbyteorder()
- self.assert_(ua[()] == ua2[()])
+ # This changes the interpretation of the data region (but not the
+ # actual data), therefore the returned scalars are not
+ # the same (they are byte-swapped versions of each other).
+ self.assert_(ua[()] != ua2[()])
ua3 = ua2.newbyteorder()
# Arrays must be equal after the round-trip
assert_equal(ua, ua3)
@@ -249,8 +252,8 @@
"""Check byteorder of single-dimensional objects"""
ua = array([self.ucs_value*self.ulen]*2, dtype='U%s' % self.ulen)
ua2 = ua.newbyteorder()
- self.assert_(ua[0] == ua2[0])
- self.assert_(ua[-1] == ua2[-1])
+ self.assert_(ua[0] != ua2[0])
+ self.assert_(ua[-1] != ua2[-1])
ua3 = ua2.newbyteorder()
# Arrays must be equal after the round-trip
assert_equal(ua, ua3)
@@ -260,8 +263,8 @@
ua = array([[[self.ucs_value*self.ulen]*2]*3]*4,
dtype='U%s' % self.ulen)
ua2 = ua.newbyteorder()
- self.assert_(ua[0,0,0] == ua2[0,0,0])
- self.assert_(ua[-1,-1,-1] == ua2[-1,-1,-1])
+ self.assert_(ua[0,0,0] != ua2[0,0,0])
+ self.assert_(ua[-1,-1,-1] != ua2[-1,-1,-1])
ua3 = ua2.newbyteorder()
# Arrays must be equal after the round-trip
assert_equal(ua, ua3)
More information about the Numpy-svn
mailing list