1.1 --- a/vigranumpy.new/src/test_arraytypes.py Thu Jul 30 21:12:37 2009 +0200
1.2 +++ b/vigranumpy.new/src/test_arraytypes.py Thu Jul 30 21:12:49 2009 +0200
1.3 @@ -1,7 +1,7 @@
1.4 # run with a simple 'nosetests' in this directory
1.5 # (and nose installed, i.e. 'easy_install nose')
1.6
1.7 -import arraytypes, ufunc, numpy, copy
1.8 +import arraytypes, ufunc, numpy, copy, sys
1.9 import vigranumpytest as vt
1.10 from nose.tools import assert_equal, raises
1.11
1.12 @@ -18,6 +18,7 @@
1.13 def checkArray(cls, channels, dim):
1.14 def testCopy(img):
1.15 b = cls(img, order='A')
1.16 + assert_equal(sys.getrefcount(b), 2)
1.17 assert_equal(b.shape, img.shape)
1.18 assert_equal(b.strides, img.strides)
1.19 assert_equal(b.order, img.order)
1.20 @@ -26,6 +27,7 @@
1.21 assert (b == img).all()
1.22 assert not numpy.may_share_memory(b, img)
1.23 b = img.copy(order='A')
1.24 + assert_equal(sys.getrefcount(b), 2)
1.25 assert_equal(b.shape, img.shape)
1.26 assert_equal(b.strides, img.strides)
1.27 assert_equal(b.order, img.order)
1.28 @@ -66,6 +68,7 @@
1.29 assert type(img) is cls
1.30 assert isinstance(img, numpy.ndarray)
1.31 assert_equal(img.dtype, numpy.float32)
1.32 + assert_equal(sys.getrefcount(img), 2)
1.33
1.34 # test shape
1.35 assert_equal(img.shape, rshape)
1.36 @@ -106,6 +109,7 @@
1.37
1.38 # test shape, strides, and copy for 'F' order
1.39 img = cls(shape, order='F')
1.40 + assert_equal(sys.getrefcount(img), 2)
1.41 assert_equal(img.shape, rshape)
1.42 assert_equal(img.strides, ffstrides)
1.43 assert_equal(img.order, "F")
1.44 @@ -119,6 +123,7 @@
1.45
1.46 # test shape, strides, and copy for 'A' order (should be equal to 'V' order)
1.47 img = cls(shape, order='A')
1.48 + assert_equal(sys.getrefcount(img), 2)
1.49 assert_equal(img.shape, rshape)
1.50 assert_equal(img.strides, fvstrides)
1.51 assert_equal(img.order, "F" if channels == 1 else "V")
1.52 @@ -132,6 +137,7 @@
1.53
1.54 # test shape, strides, and copy for 'C' order
1.55 img = cls(shape, order='C')
1.56 + assert_equal(sys.getrefcount(img), 2)
1.57 assert_equal(img.shape, rshape)
1.58 assert_equal(img.strides, fcstrides)
1.59 assert_equal(img.order, "C")
1.60 @@ -148,6 +154,7 @@
1.61
1.62 # test shape, strides, and copy for dtype uint8
1.63 b = cls(img, dtype=numpy.uint8, order='V')
1.64 + assert_equal(sys.getrefcount(b), 2)
1.65 assert_equal(b.dtype, numpy.uint8)
1.66 assert_equal(b.shape, rshape)
1.67 assert_equal(b.strides, bvstrides)
1.68 @@ -163,6 +170,7 @@
1.69 assert_equal(b.strides, (b*2).strides)
1.70
1.71 b = cls(img, dtype=numpy.uint8, order='C')
1.72 + assert_equal(sys.getrefcount(b), 2)
1.73 assert_equal(b.shape, rshape)
1.74 assert_equal(b.strides, bcstrides)
1.75 assert_equal(b.order, "C")
1.76 @@ -174,6 +182,7 @@
1.77 assert_equal(b.strides, (b*2).strides)
1.78
1.79 b = cls(img, dtype=numpy.uint8, order='F')
1.80 + assert_equal(sys.getrefcount(b), 2)
1.81 assert_equal(b.shape, rshape)
1.82 assert_equal(b.strides, bfstrides)
1.83 assert_equal(b.order, "F")
2.1 --- a/vigranumpy.new/src/vigranumpytest.cxx Thu Jul 30 21:12:37 2009 +0200
2.2 +++ b/vigranumpy.new/src/vigranumpytest.cxx Thu Jul 30 21:12:49 2009 +0200
2.3 @@ -40,7 +40,6 @@
2.4 #include <vigra/numpy_array.hxx>
2.5 #include <vigra/numpy_array_converters.hxx>
2.6 #include <iostream>
2.7 -#include <boost/mpl/next_prior.hpp>
2.8
2.9 namespace vigra {
2.10
2.11 @@ -52,6 +51,9 @@
2.12 template <unsigned int N, class T, class Stride>
2.13 ArrayVector<npy_intp> test(NumpyArray<N, T, Stride> const & array)
2.14 {
2.15 + NumpyArray<N, T> c(array, true);
2.16 + vigra_postcondition(c.pyObject()->ob_refcnt == 1,
2.17 + "freshly created NumpyArray<N, T> has reference count > 1.");
2.18 return ((NumpyAnyArray const &)array).shape();
2.19 }
2.20