[Numpy-svn] r3628 - trunk/numpy/doc/swig
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Mar 31 21:06:53 EDT 2007
Author: wfspotz at sandia.gov
Date: 2007-03-31 20:06:47 -0500 (Sat, 31 Mar 2007)
New Revision: 3628
Modified:
trunk/numpy/doc/swig/Series.i
trunk/numpy/doc/swig/numpy.i
trunk/numpy/doc/swig/series.cxx
trunk/numpy/doc/swig/series.h
trunk/numpy/doc/swig/testSeries.py
Log:
Added tests for ARGOUT_ARRAY1 and ARGOUT_ARRAY2 typemaps
Modified: trunk/numpy/doc/swig/Series.i
===================================================================
--- trunk/numpy/doc/swig/Series.i 2007-03-31 23:45:45 UTC (rev 3627)
+++ trunk/numpy/doc/swig/Series.i 2007-04-01 01:06:47 UTC (rev 3628)
@@ -18,16 +18,25 @@
%apply (TYPE IN_ARRAY1[ANY]) {(TYPE vector[3])};
%apply (TYPE* IN_ARRAY1, int DIM1) {(TYPE* series, int size)};
%apply (int DIM1, TYPE* IN_ARRAY1) {(int size, TYPE* series)};
-%apply (TYPE IN_ARRAY2[ANY][ANY]) {(TYPE matrix[2][2])};
-%apply (TYPE* IN_ARRAY2, int DIM1, int DIM2) {(TYPE* matrix, int rows, int cols)};
-%apply (int DIM1, int DIM2, TYPE* IN_ARRAY2) {(int rows, int cols, TYPE* matrix)};
+
%apply (TYPE INPLACE_ARRAY1[ANY]) {(TYPE array[3])};
%apply (TYPE* INPLACE_ARRAY1, int DIM1) {(TYPE* array, int size)};
%apply (int DIM1, TYPE* INPLACE_ARRAY1) {(int size, TYPE* array)};
+
+%apply (TYPE ARGOUT_ARRAY1[ANY]) {(TYPE even[3])};
+%apply (TYPE ARGOUT_ARRAY1[ANY]) {(TYPE odd[ 3])};
+
+%apply (TYPE IN_ARRAY2[ANY][ANY]) {(TYPE matrix[ANY][ANY])};
+%apply (TYPE* IN_ARRAY2, int DIM1, int DIM2) {(TYPE* matrix, int rows, int cols)};
+%apply (int DIM1, int DIM2, TYPE* IN_ARRAY2) {(int rows, int cols, TYPE* matrix)};
+
%apply (TYPE INPLACE_ARRAY2[ANY][ANY]) {(TYPE array[3][3])};
%apply (TYPE* INPLACE_ARRAY2, int DIM1, int DIM2) {(TYPE* array, int rows, int cols)};
%apply (int DIM1, int DIM2, TYPE* INPLACE_ARRAY2) {(int rows, int cols, TYPE* array)};
+%apply (TYPE ARGOUT_ARRAY2[ANY][ANY]) {(TYPE lower[3][3])};
+%apply (TYPE ARGOUT_ARRAY2[ANY][ANY]) {(TYPE upper[3][3])};
+
%enddef /* %apply_numpy_typemaps() macro */
%apply_numpy_typemaps(signed char )
Modified: trunk/numpy/doc/swig/numpy.i
===================================================================
--- trunk/numpy/doc/swig/numpy.i 2007-03-31 23:45:45 UTC (rev 3627)
+++ trunk/numpy/doc/swig/numpy.i 2007-04-01 01:06:47 UTC (rev 3628)
@@ -292,6 +292,7 @@
}
return success;
}
+
/* End John Hunter translation (with modifications by Bill Spotz)
*/
@@ -617,56 +618,32 @@
*/
%typemap(in,numinputs=0)
(DATA_TYPE ARGOUT_ARRAY1[ANY])
+ (PyObject * array = NULL)
{
- $1 = (DATA_TYPE*) malloc($1_dim0*sizeof(DATA_TYPE));
- if (!$1) {
- PyErr_SetString(PyExc_RuntimeError, "Failed to allocate memory");
- SWIG_fail;
- }
+ npy_intp dims[1] = { $1_dim0 };
+ array = PyArray_SimpleNew(1, dims, DATA_TYPECODE);
+ $1 = ($1_ltype)((PyArrayObject*)array)->data;
}
%typemap(argout)
(DATA_TYPE ARGOUT_ARRAY1[ANY])
{
- PyObject * obj = NULL;
- npy_intp dimensions[1] = { $1_dim0 };
- PyObject* outArray = PyArray_FromDimsAndData(1, dimensions, DATA_TYPECODE, (char*)$1);
- if ($result == Py_None) {
- Py_DECREF($result);
- $result = outArray;
- }
- else {
- if (!PyTuple_Check($result)) $result = Py_BuildValue("(O)", $result);
- obj = Py_Build_Value("(O)", outArray);
- $result = PySequence_Concat($result, obj);
- }
+ $result = SWIG_Python_AppendOutput($result,array$argnum);
}
/* Typemap suite for (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
*/
%typemap(in,numinputs=0)
(DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
+ (PyObject * array = NULL)
{
- $1 = (DATA_TYPE*) malloc($1_dim0 * $1_dim1 * sizeof(DATA_TYPE));
- if (!$1) {
- PyErr_SetString(PyExc_RuntimeError, "Failed to allocate memory");
- SWIG_fail;
- }
+ npy_intp dims[2] = { $1_dim0, $1_dim1 };
+ array = PyArray_SimpleNew(2, dims, DATA_TYPECODE);
+ $1 = ($1_ltype)((PyArrayObject*)array)->data;
}
%typemap(argout)
- (DATA_TYPE ARGOUT_ARRAY1[ANY][ANY])
+ (DATA_TYPE ARGOUT_ARRAY2[ANY][ANY])
{
- PyObject * obj = NULL;
- npy_intp dimensions[2] = { $1_dim0, $1_dim1 };
- PyObject* outArray = PyArray_FromDimsAndData(1, dimensions, DATA_TYPECODE, (char*)$1);
- if ($result == Py_None) {
- Py_DECREF($result);
- $result = outArray;
- }
- else {
- if (!PyTuple_Check($result)) $result = Py_BuildValue("(O)", $result);
- obj = Py_Build_Value("(O)", outArray);
- $result = PySequence_Concat($result, obj);
- }
+ $result = SWIG_Python_AppendOutput($result,array$argnum);
}
%enddef /* %numpy_typemaps() macro */
Modified: trunk/numpy/doc/swig/series.cxx
===================================================================
--- trunk/numpy/doc/swig/series.cxx 2007-03-31 23:45:45 UTC (rev 3627)
+++ trunk/numpy/doc/swig/series.cxx 2007-04-01 01:06:47 UTC (rev 3628)
@@ -5,18 +5,20 @@
// The following macro defines a family of functions with the forms
//
-// TYPE SNAMELength( TYPE vector[3]);
-// TYPE SNAMEProd( TYPE * series, int size);
-// TYPE SNAMESum( int size, TYPE * series);
-// void SNAMEReverse(TYPE array[3]);
-// void SNAMEOnes( TYPE * array, int size);
-// void SNAMEZeros( int size, TYPE * array);
-// TYPE SNAMEDet( TYPE matrix[2][2]);
-// TYPE SNAMEMax( TYPE * matrix, int rows, int cols);
-// TYPE SNAMEMin( int rows, int cols, TYPE * matrix);
-// void SNAMEScale( TYPE matrix[3][3]);
-// void SNAMEFloor( TYPE * array, int rows, int cols, TYPE floor);
-// void SNAMECeil( int rows, int cols, TYPE * array, TYPE ceil);
+// TYPE SNAMELength( TYPE vector[3]);
+// TYPE SNAMEProd( TYPE * series, int size);
+// TYPE SNAMESum( int size, TYPE * series);
+// void SNAMEReverse( TYPE array[3]);
+// void SNAMEOnes( TYPE * array, int size);
+// void SNAMEZeros( int size, TYPE * array);
+// void SNAMEEOSplit( TYPE vector[3], TYPE even[3], odd[3]);
+// TYPE SNAMEDet( TYPE matrix[2][2]);
+// TYPE SNAMEMax( TYPE * matrix, int rows, int cols);
+// TYPE SNAMEMin( int rows, int cols, TYPE * matrix);
+// void SNAMEScale( TYPE matrix[3][3]);
+// void SNAMEFloor( TYPE * array, int rows, int cols, TYPE floor);
+// void SNAMECeil( int rows, int cols, TYPE * array, TYPE ceil);
+// void SNAMELUSplit( TYPE in[3][3], TYPE lower[3][3], TYPE upper[3][3]);
//
// for any specified type TYPE (for example: short, unsigned int, long
// long, etc.) with given short name SNAME (for example: short, uint,
@@ -30,12 +32,14 @@
// * 1D in-place arrays, hard-coded length
// * 1D in-place arrays
// * 1D in-place arrays, data last
+// * 1D argout arrays, hard-coded length
// * 2D input arrays, hard-coded length
// * 2D input arrays
// * 2D input arrays, data last
// * 2D in-place arrays, hard-coded lengths
// * 2D in-place arrays
// * 2D in-place arrays, data last
+// * 2D argout arrays, hard-coded length
//
#define TEST_FUNCS(TYPE, SNAME) \
\
@@ -71,6 +75,18 @@
for (int i=0; i<size; ++i) array[i] = 0; \
} \
\
+void SNAME ## EOSplit(TYPE vector[3], TYPE even[3], TYPE odd[3]) { \
+ for (int i=0; i<3; ++i) { \
+ if (i % 2 == 0) { \
+ even[i] = vector[i]; \
+ odd[ i] = 0; \
+ } else { \
+ even[i] = 0; \
+ odd[ i] = vector[i]; \
+ } \
+ } \
+} \
+\
TYPE SNAME ## Det(TYPE matrix[2][2]) { \
return matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]; \
} \
@@ -123,6 +139,20 @@
if (array[index] > ceil) array[index] = ceil; \
} \
} \
+} \
+\
+void SNAME ## LUSplit(TYPE matrix[3][3], TYPE lower[3][3], TYPE upper[3][3]) { \
+ for (int i=0; i<3; ++i) { \
+ for (int j=0; j<3; ++j) { \
+ if (i >= j) { \
+ lower[i][j] = matrix[i][j]; \
+ upper[i][j] = 0; \
+ } else { \
+ lower[i][j] = 0; \
+ upper[i][j] = matrix[i][j]; \
+ } \
+ } \
+ } \
}
TEST_FUNCS(signed char , schar )
Modified: trunk/numpy/doc/swig/series.h
===================================================================
--- trunk/numpy/doc/swig/series.h 2007-03-31 23:45:45 UTC (rev 3627)
+++ trunk/numpy/doc/swig/series.h 2007-04-01 01:06:47 UTC (rev 3628)
@@ -4,18 +4,20 @@
// The following macro defines the prototypes for a family of
// functions with the forms
//
-// TYPE SNAMELength( TYPE vector[3]);
-// TYPE SNAMEProd( TYPE * series, int size);
-// TYPE SNAMESum( int size, TYPE * series);
-// void SNAMEReverse(TYPE array[3]);
-// void SNAMEOnes( TYPE * array, int size);
-// void SNAMEZeros( int size, TYPE * array);
-// TYPE SNAMEDet( TYPE matrix[2][2]);
-// TYPE SNAMEMax( TYPE * matrix, int rows, int cols);
-// TYPE SNAMEMin( int rows, int cols, TYPE * matrix);
-// void SNAMEScale( TYPE array[3][3]);
-// void SNAMEFloor( TYPE * array, int rows, int cols, TYPE floor);
-// void SNAMECeil( int rows, int cols, TYPE * array, TYPE ceil );
+// TYPE SNAMELength( TYPE vector[3]);
+// TYPE SNAMEProd( TYPE * series, int size);
+// TYPE SNAMESum( int size, TYPE * series);
+// void SNAMEReverse( TYPE array[3]);
+// void SNAMEOnes( TYPE * array, int size);
+// void SNAMEZeros( int size, TYPE * array);
+// void SNAMEEOSplit( TYPE vector[3], TYPE even[3], TYPE odd[3]);
+// TYPE SNAMEDet( TYPE matrix[2][2]);
+// TYPE SNAMEMax( TYPE * matrix, int rows, int cols);
+// TYPE SNAMEMin( int rows, int cols, TYPE * matrix);
+// void SNAMEScale( TYPE array[3][3]);
+// void SNAMEFloor( TYPE * array, int rows, int cols, TYPE floor);
+// void SNAMECeil( int rows, int cols, TYPE * array, TYPE ceil );
+// void SNAMESetIdent(TYPE in[3][3], TYPE lower[3][3], TYPE upper[3][3]);
//
// for any specified type TYPE (for example: short, unsigned int, long
// long, etc.) with given short name SNAME (for example: short, uint,
@@ -29,27 +31,31 @@
// * 1D in-place arrays, hard-coded length
// * 1D in-place arrays
// * 1D in-place arrays, data last
+// * 1D argout arrays, hard-coded length
// * 2D input arrays, hard-coded lengths
// * 2D input arrays
// * 2D input arrays, data last
// * 2D in-place arrays, hard-coded lengths
// * 2D in-place arrays
// * 2D in-place arrays, data last
+// * 2D argout arrays, hard-coded length
//
#define TEST_FUNC_PROTOS(TYPE, SNAME) \
\
-TYPE SNAME ## Length( TYPE vector[3]); \
-TYPE SNAME ## Prod( TYPE * series, int size); \
-TYPE SNAME ## Sum( int size, TYPE * series); \
-void SNAME ## Reverse(TYPE array[3]); \
-void SNAME ## Ones( TYPE * array, int size); \
-void SNAME ## Zeros( int size, TYPE * array); \
-TYPE SNAME ## Det( TYPE matrix[2][2]); \
-TYPE SNAME ## Max( TYPE * matrix, int rows, int cols); \
-TYPE SNAME ## Min( int rows, int cols, TYPE * matrix); \
-void SNAME ## Scale( TYPE array[3][3], TYPE val); \
-void SNAME ## Floor( TYPE * array, int rows, int cols, TYPE floor); \
-void SNAME ## Ceil( int rows, int cols, TYPE * array, TYPE ceil );
+TYPE SNAME ## Length( TYPE vector[3]); \
+TYPE SNAME ## Prod( TYPE * series, int size); \
+TYPE SNAME ## Sum( int size, TYPE * series); \
+void SNAME ## Reverse( TYPE array[3]); \
+void SNAME ## Ones( TYPE * array, int size); \
+void SNAME ## Zeros( int size, TYPE * array); \
+void SNAME ## EOSplit( TYPE vector[3], TYPE even[3], TYPE odd[3]); \
+TYPE SNAME ## Det( TYPE matrix[2][2]); \
+TYPE SNAME ## Max( TYPE * matrix, int rows, int cols); \
+TYPE SNAME ## Min( int rows, int cols, TYPE * matrix); \
+void SNAME ## Scale( TYPE array[3][3], TYPE val); \
+void SNAME ## Floor( TYPE * array, int rows, int cols, TYPE floor); \
+void SNAME ## Ceil( int rows, int cols, TYPE * array, TYPE ceil ); \
+void SNAME ## LUSplit( TYPE matrix[3][3], TYPE lower[3][3], TYPE upper[3][3]);
TEST_FUNC_PROTOS(signed char , schar )
TEST_FUNC_PROTOS(unsigned char , uchar )
Modified: trunk/numpy/doc/swig/testSeries.py
===================================================================
--- trunk/numpy/doc/swig/testSeries.py 2007-03-31 23:45:45 UTC (rev 3627)
+++ trunk/numpy/doc/swig/testSeries.py 2007-04-01 01:06:47 UTC (rev 3628)
@@ -62,6 +62,12 @@
Series.scharZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testScharEOSplit(self):
+ "Test scharEOSplit function"
+ even, odd = Series.scharEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testScharDet(self):
"Test scharDet function"
matrix = [[6,7],[8,9]]
@@ -103,6 +109,12 @@
Series.scharCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,-2],[-6,5]]))
+ def testScharLUSplit(self):
+ "Test scharLUSplit function"
+ lower, upper = Series.scharLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
#####################################################
### Test functions that take arrays of type UBYTE ###
def testUcharLength(self):
@@ -143,6 +155,12 @@
Series.ucharZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testUcharEOSplit(self):
+ "Test ucharEOSplit function"
+ even, odd = Series.ucharEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testUcharDet(self):
"Test ucharDet function"
matrix = [[7,6],[9,8]]
@@ -184,6 +202,12 @@
Series.ucharCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,2],[5,5]]))
+ def testUcharLUSplit(self):
+ "Test ucharLUSplit function"
+ lower, upper = Series.ucharLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
#####################################################
### Test functions that take arrays of type SHORT ###
def testShortLength(self):
@@ -224,6 +248,12 @@
Series.shortZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testShortEOSplit(self):
+ "Test shortEOSplit function"
+ even, odd = Series.shortEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testShortDet(self):
"Test shortDet function"
matrix = [[6,7],[8,9]]
@@ -265,6 +295,12 @@
Series.shortCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,-2],[-6,5]]))
+ def testShortLUSplit(self):
+ "Test shortLUSplit function"
+ lower, upper = Series.shortLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
######################################################
### Test functions that take arrays of type USHORT ###
def testUshortLength(self):
@@ -305,6 +341,12 @@
Series.ushortZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testUshortEOSplit(self):
+ "Test ushortEOSplit function"
+ even, odd = Series.ushortEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testUshortDet(self):
"Test ushortDet function"
matrix = [[7,6],[9,8]]
@@ -346,6 +388,12 @@
Series.ushortCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,2],[5,5]]))
+ def testUshortLUSplit(self):
+ "Test ushortLUSplit function"
+ lower, upper = Series.ushortLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
###################################################
### Test functions that take arrays of type INT ###
def testIntLength(self):
@@ -386,6 +434,12 @@
Series.intZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testIntEOSplit(self):
+ "Test intEOSplit function"
+ even, odd = Series.intEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testIntDet(self):
"Test intDet function"
matrix = [[6,7],[8,9]]
@@ -427,6 +481,12 @@
Series.intCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,-2],[-6,5]]))
+ def testIntLUSplit(self):
+ "Test intLUSplit function"
+ lower, upper = Series.intLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
####################################################
### Test functions that take arrays of type UINT ###
def testUintLength(self):
@@ -468,6 +528,12 @@
Series.uintZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testUintEOSplit(self):
+ "Test uintEOSplit function"
+ even, odd = Series.uintEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testUintDet(self):
"Test uintDet function"
matrix = [[7,6],[9,8]]
@@ -509,6 +575,12 @@
Series.uintCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,2],[5,5]]))
+ def testUintLUSplit(self):
+ "Test uintLUSplit function"
+ lower, upper = Series.uintLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
####################################################
### Test functions that take arrays of type LONG ###
def testLongLength(self):
@@ -549,6 +621,12 @@
Series.longZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testLongEOSplit(self):
+ "Test longEOSplit function"
+ even, odd = Series.longEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testLongDet(self):
"Test longDet function"
matrix = [[6,7],[8,9]]
@@ -590,6 +668,12 @@
Series.longCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,-2],[-6,5]]))
+ def testLongLUSplit(self):
+ "Test longLUSplit function"
+ lower, upper = Series.longLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
#####################################################
### Test functions that take arrays of type ULONG ###
def testUlongLength(self):
@@ -630,6 +714,12 @@
Series.ulongZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testUlongEOSplit(self):
+ "Test ulongEOSplit function"
+ even, odd = Series.ulongEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testUlongDet(self):
"Test ulongDet function"
matrix = [[7,6],[9,8]]
@@ -671,6 +761,12 @@
Series.ulongCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,2],[5,5]]))
+ def testUlongLUSplit(self):
+ "Test ulongLUSplit function"
+ lower, upper = Series.ulongLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
########################################################
### Test functions that take arrays of type LONGLONG ###
def testLongLongLength(self):
@@ -711,6 +807,12 @@
Series.longLongZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testLongLongEOSplit(self):
+ "Test longLongEOSplit function"
+ even, odd = Series.longLongEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testLongLongDet(self):
"Test longLongDet function"
matrix = [[6,7],[8,9]]
@@ -752,6 +854,12 @@
Series.longLongCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,-2],[-6,5]]))
+ def testLongLongLUSplit(self):
+ "Test longLongLUSplit function"
+ lower, upper = Series.longLongLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
#########################################################
### Test functions that take arrays of type ULONGLONG ###
def testUlongLongLength(self):
@@ -792,6 +900,12 @@
Series.ulongLongZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testUlongLongEOSplit(self):
+ "Test ulongLongEOSplit function"
+ even, odd = Series.ulongLongEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testUlongLongDet(self):
"Test ulongLongDet function"
matrix = [[7,6],[9,8]]
@@ -833,6 +947,12 @@
Series.ulongLongCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,2],[5,5]]))
+ def testUlongLongLUSplit(self):
+ "Test ulongLongLUSplit function"
+ lower, upper = Series.ulongLongLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
#####################################################
### Test functions that take arrays of type FLOAT ###
def testFloatLength(self):
@@ -882,6 +1002,12 @@
Series.floatZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testFloatEOSplit(self):
+ "Test floatEOSplit function"
+ even, odd = Series.floatEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testFloatMax(self):
"Test floatMax function"
matrix = [[-6,5,-4],[3.14,-2.718,1]]
@@ -918,6 +1044,12 @@
Series.floatCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,-2],[-6,5]]))
+ def testFloatLUSplit(self):
+ "Test floatLUSplit function"
+ lower, upper = Series.floatLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
######################################################
### Test functions that take arrays of type DOUBLE ###
def testDoubleLength(self):
@@ -962,6 +1094,12 @@
Series.doubleZeros(myArray)
N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+ def testDoubleEOSplit(self):
+ "Test doubleEOSplit function"
+ even, odd = Series.doubleEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
def testDoubleDet(self):
"Test doubleDet function"
matrix = [[6,7],[8,9]]
@@ -1003,6 +1141,12 @@
Series.doubleCeil(matrix,5)
N.testing.assert_array_equal(matrix, N.array([[5,-2],[-6,5]]))
+ def testDoubleLUSplit(self):
+ "Test doubleLUSplit function"
+ lower, upper = Series.doubleLUSplit([[1,2,3],[4,5,6],[7,8,9]])
+ self.assertEquals((lower == [[1,0,0],[4,5,0],[7,8,9]]).all(), True)
+ self.assertEquals((upper == [[0,2,3],[0,0,6],[0,0,0]]).all(), True)
+
######################################################################
if __name__ == "__main__":
More information about the Numpy-svn
mailing list