Commit 1d00d8ad authored by Mark Florisson's avatar Mark Florisson

Fix two memoryview related tests (py3k)

parent 8512993a
...@@ -55,24 +55,16 @@ def test_copy_to(): ...@@ -55,24 +55,16 @@ def test_copy_to():
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
''' '''
cdef int[:,:,:] from_mvs, to_mvs cdef int[:, :, :] from_mvs, to_mvs
from_mvs = np.arange(8, dtype=np.int32).reshape(2,2,2) from_mvs = np.arange(8, dtype=np.int32).reshape(2,2,2)
cdef int *from_dta = <int*>from_mvs._data cdef int *from_data = <int *> from_mvs._data
for i in range(2*2*2): print ' '.join(str(from_data[i]) for i in range(2*2*2))
print from_dta[i],
print
# for i in range(2*2*2):
# from_dta[i] = i
to_mvs = array((2,2,2), sizeof(int), 'i') to_mvs = array((2,2,2), sizeof(int), 'i')
to_mvs[...] = from_mvs to_mvs[...] = from_mvs
cdef int *to_data = <int*>to_mvs._data cdef int *to_data = <int*>to_mvs._data
for i in range(2*2*2): print ' '.join(str(from_data[i]) for i in range(2*2*2))
print from_dta[i], print ' '.join(str(to_data[i]) for i in range(2*2*2))
print
for i in range(2*2*2):
print to_data[i],
print
@testcase @testcase
def test_overlapping_copy(): def test_overlapping_copy():
......
...@@ -243,9 +243,12 @@ ctypedef td_h_short td_h_cy_short ...@@ -243,9 +243,12 @@ ctypedef td_h_short td_h_cy_short
cdef void dealloc_callback(void *data): cdef void dealloc_callback(void *data):
print "deallocating..." print "deallocating..."
def index(array array): def build_numarray(array array):
array.callback_free_data = dealloc_callback array.callback_free_data = dealloc_callback
print np.asarray(array)[3, 2] return np.asarray(array)
def index(array array):
print build_numarray(array)[3, 2]
@testcase_numpy_1_5 @testcase_numpy_1_5
def test_coerce_to_numpy(): def test_coerce_to_numpy():
...@@ -254,7 +257,7 @@ def test_coerce_to_numpy(): ...@@ -254,7 +257,7 @@ def test_coerce_to_numpy():
generated format strings. generated format strings.
>>> test_coerce_to_numpy() >>> test_coerce_to_numpy()
(97, 98, 600L, 700, 800) [97, 98, 600, 700, 800]
deallocating... deallocating...
(600, 700) (600, 700)
deallocating... deallocating...
...@@ -359,7 +362,9 @@ def test_coerce_to_numpy(): ...@@ -359,7 +362,9 @@ def test_coerce_to_numpy():
# #
### Create a NumPy array and see if our element can be correctly retrieved ### Create a NumPy array and see if our element can be correctly retrieved
# #
index(<MyStruct[:4, :5]> <MyStruct *> mystructs) mystruct_array = build_numarray(<MyStruct[:4, :5]> <MyStruct *> mystructs)
print [int(x) for x in mystruct_array[3, 2]]
del mystruct_array
index(<SmallStruct[:4, :5]> <SmallStruct *> smallstructs) index(<SmallStruct[:4, :5]> <SmallStruct *> smallstructs)
index(<NestedStruct[:4, :5]> <NestedStruct *> nestedstructs) index(<NestedStruct[:4, :5]> <NestedStruct *> nestedstructs)
index(<PackedStruct[:4, :5]> <PackedStruct *> packedstructs) index(<PackedStruct[:4, :5]> <PackedStruct *> packedstructs)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment