[Numpy-svn] r3665 - trunk/numpy/doc/swig
numpy-svn at scipy.org
numpy-svn at scipy.org
Wed Apr 4 15:57:49 EDT 2007
Author: wfspotz at sandia.gov
Date: 2007-04-04 14:57:37 -0500 (Wed, 04 Apr 2007)
New Revision: 3665
Added:
trunk/numpy/doc/swig/Matrix.cxx
trunk/numpy/doc/swig/Matrix.h
trunk/numpy/doc/swig/Matrix.i
trunk/numpy/doc/swig/Vector.cxx
trunk/numpy/doc/swig/Vector.h
trunk/numpy/doc/swig/Vector.i
Removed:
trunk/numpy/doc/swig/Series.i
trunk/numpy/doc/swig/series.cxx
trunk/numpy/doc/swig/series.h
Modified:
trunk/numpy/doc/swig/Makefile
trunk/numpy/doc/swig/setup.py
trunk/numpy/doc/swig/test1D.py
trunk/numpy/doc/swig/test2D.py
Log:
Split Series header/code/interface tests into Vector and Matrix components
Modified: trunk/numpy/doc/swig/Makefile
===================================================================
--- trunk/numpy/doc/swig/Makefile 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Makefile 2007-04-04 19:57:37 UTC (rev 3665)
@@ -1,5 +1,5 @@
# SWIG
-INTERFACES = Series.i
+INTERFACES = Vector.i Matrix.i
WRAPPERS = $(INTERFACES:.i=_wrap.cxx)
PROXIES = $(INTERFACES:.i=.py )
@@ -23,7 +23,7 @@
# List all of the subdirectories here for recursive make
SUBDIRS =
-all: $(WRAPPERS) series.cxx series.h
+all: $(WRAPPERS) Vector.cxx Vector.h Matrix.cxx Matrix.h
./setup.py build
test: all
@@ -32,7 +32,7 @@
doc: html pdf
-%_wrap.cxx: %.i numpy.i series.h
+%_wrap.cxx: %.i %.h numpy.i
swig -c++ -python $<
html: $(WEB_PAGES)
@@ -56,6 +56,6 @@
$(RM) $(WRAPPERS)
$(RM) $(PROXIES)
$(RM) $(LATEX_FILES)
- $(RM) *.aux *.dvi *.log *.out *~
+ $(RM) *.pyc *.aux *.dvi *.log *.out *~
.PHONY : all test doc html tex pdf clean
Added: trunk/numpy/doc/swig/Matrix.cxx
===================================================================
--- trunk/numpy/doc/swig/Matrix.cxx 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Matrix.cxx 2007-04-04 19:57:37 UTC (rev 3665)
@@ -0,0 +1,112 @@
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+#include "Matrix.h"
+
+// The following macro defines a family of functions that work with 2D
+// arrays with the forms
+//
+// 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,
+// longLong, etc.). The macro is then expanded for the given
+// TYPE/SNAME pairs. The resulting functions are for testing numpy
+// interfaces, respectively, for:
+//
+// * 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) \
+\
+TYPE SNAME ## Det(TYPE matrix[2][2]) { \
+ return matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]; \
+} \
+\
+TYPE SNAME ## Max(TYPE * matrix, int rows, int cols) { \
+ int i, j, index; \
+ TYPE result = matrix[0]; \
+ for (j=0; j<cols; ++j) { \
+ for (i=0; i<rows; ++i) { \
+ index = j*rows + i; \
+ if (matrix[index] > result) result = matrix[index]; \
+ } \
+ } \
+ return result; \
+} \
+\
+TYPE SNAME ## Min(int rows, int cols, TYPE * matrix) { \
+ int i, j, index; \
+ TYPE result = matrix[0]; \
+ for (j=0; j<cols; ++j) { \
+ for (i=0; i<rows; ++i) { \
+ index = j*rows + i; \
+ if (matrix[index] < result) result = matrix[index]; \
+ } \
+ } \
+ return result; \
+} \
+\
+void SNAME ## Scale(TYPE array[3][3], TYPE val) { \
+ for (int i=0; i<3; ++i) \
+ for (int j=0; j<3; ++j) \
+ array[i][j] *= val; \
+} \
+\
+void SNAME ## Floor(TYPE * array, int rows, int cols, TYPE floor) { \
+ int i, j, index; \
+ for (j=0; j<cols; ++j) { \
+ for (i=0; i<rows; ++i) { \
+ index = j*rows + i; \
+ if (array[index] < floor) array[index] = floor; \
+ } \
+ } \
+} \
+\
+void SNAME ## Ceil(int rows, int cols, TYPE * array, TYPE ceil) { \
+ int i, j, index; \
+ for (j=0; j<cols; ++j) { \
+ for (i=0; i<rows; ++i) { \
+ index = j*rows + i; \
+ 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 )
+TEST_FUNCS(unsigned char , uchar )
+TEST_FUNCS(short , short )
+TEST_FUNCS(unsigned short , ushort )
+TEST_FUNCS(int , int )
+TEST_FUNCS(unsigned int , uint )
+TEST_FUNCS(long , long )
+TEST_FUNCS(unsigned long , ulong )
+TEST_FUNCS(long long , longLong )
+TEST_FUNCS(unsigned long long, ulongLong)
+TEST_FUNCS(float , float )
+TEST_FUNCS(double , double )
Added: trunk/numpy/doc/swig/Matrix.h
===================================================================
--- trunk/numpy/doc/swig/Matrix.h 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Matrix.h 2007-04-04 19:57:37 UTC (rev 3665)
@@ -0,0 +1,52 @@
+#ifndef MATRIX_H
+#define MATRIX_H
+
+// The following macro defines the prototypes for a family of
+// functions that work with 2D arrays with the forms
+//
+// 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 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,
+// longLong, etc.). The macro is then expanded for the given
+// TYPE/SNAME pairs. The resulting functions are for testing numpy
+// interfaces, respectively, for:
+//
+// * 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 ## 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 )
+TEST_FUNC_PROTOS(short , short )
+TEST_FUNC_PROTOS(unsigned short , ushort )
+TEST_FUNC_PROTOS(int , int )
+TEST_FUNC_PROTOS(unsigned int , uint )
+TEST_FUNC_PROTOS(long , long )
+TEST_FUNC_PROTOS(unsigned long , ulong )
+TEST_FUNC_PROTOS(long long , longLong )
+TEST_FUNC_PROTOS(unsigned long long, ulongLong)
+TEST_FUNC_PROTOS(float , float )
+TEST_FUNC_PROTOS(double , double )
+
+#endif
Added: trunk/numpy/doc/swig/Matrix.i
===================================================================
--- trunk/numpy/doc/swig/Matrix.i 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Matrix.i 2007-04-04 19:57:37 UTC (rev 3665)
@@ -0,0 +1,45 @@
+// -*- c++ -*-
+%module Matrix
+
+%{
+#define SWIG_FILE_WITH_INIT
+#include "Matrix.h"
+%}
+
+// Get the NumPy typemaps
+%include "numpy.i"
+
+%init %{
+ import_array();
+%}
+
+%define %apply_numpy_typemaps(TYPE)
+
+%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 )
+%apply_numpy_typemaps(unsigned char )
+%apply_numpy_typemaps(short )
+%apply_numpy_typemaps(unsigned short )
+%apply_numpy_typemaps(int )
+%apply_numpy_typemaps(unsigned int )
+%apply_numpy_typemaps(long )
+%apply_numpy_typemaps(unsigned long )
+%apply_numpy_typemaps(long long )
+%apply_numpy_typemaps(unsigned long long)
+%apply_numpy_typemaps(float )
+%apply_numpy_typemaps(double )
+
+// Include the header file to be wrapped
+%include "Matrix.h"
Deleted: trunk/numpy/doc/swig/Series.i
===================================================================
--- trunk/numpy/doc/swig/Series.i 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Series.i 2007-04-04 19:57:37 UTC (rev 3665)
@@ -1,58 +0,0 @@
-// -*- c++ -*-
-%module Series
-
-%{
-#define SWIG_FILE_WITH_INIT
-#include "series.h"
-%}
-
-// Get the NumPy typemaps
-%include "numpy.i"
-
-%init %{
- import_array();
-%}
-
-%define %apply_numpy_typemaps(TYPE)
-
-%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 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* ARGOUT_ARRAY1, int DIM1) {(TYPE* twoVec, int size)};
-%apply (int DIM1, TYPE* ARGOUT_ARRAY1) {(int size, TYPE* threeVec)};
-
-%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 )
-%apply_numpy_typemaps(unsigned char )
-%apply_numpy_typemaps(short )
-%apply_numpy_typemaps(unsigned short )
-%apply_numpy_typemaps(int )
-%apply_numpy_typemaps(unsigned int )
-%apply_numpy_typemaps(long )
-%apply_numpy_typemaps(unsigned long )
-%apply_numpy_typemaps(long long )
-%apply_numpy_typemaps(unsigned long long)
-%apply_numpy_typemaps(float )
-%apply_numpy_typemaps(double )
-
-// Include the header file to be wrapped
-%include "series.h"
Added: trunk/numpy/doc/swig/Vector.cxx
===================================================================
--- trunk/numpy/doc/swig/Vector.cxx 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Vector.cxx 2007-04-04 19:57:37 UTC (rev 3665)
@@ -0,0 +1,100 @@
+#include <stdlib.h>
+#include <math.h>
+#include <iostream>
+#include "Vector.h"
+
+// The following macro defines a family of functions that work with 1D
+// arrays 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);
+// void SNAMEEOSplit(TYPE vector[3], TYPE even[3], odd[3]);
+// void SNAMETwos( TYPE * twoVec, int size);
+// void SNAMEThrees( int size, TYPE * threeVec);
+//
+// for any specified type TYPE (for example: short, unsigned int, long
+// long, etc.) with given short name SNAME (for example: short, uint,
+// longLong, etc.). The macro is then expanded for the given
+// TYPE/SNAME pairs. The resulting functions are for testing numpy
+// interfaces, respectively, for:
+//
+// * 1D input arrays, hard-coded length
+// * 1D input arrays
+// * 1D input arrays, data last
+// * 1D in-place arrays, hard-coded length
+// * 1D in-place arrays
+// * 1D in-place arrays, data last
+// * 1D argout arrays, hard-coded length
+// * 1D argout arrays
+// * 1D argout arrays, data last
+//
+#define TEST_FUNCS(TYPE, SNAME) \
+\
+TYPE SNAME ## Length(TYPE vector[3]) { \
+ double result = 0; \
+ for (int i=0; i<3; ++i) result += vector[i]*vector[i]; \
+ return (TYPE)sqrt(result); \
+} \
+\
+TYPE SNAME ## Prod(TYPE * series, int size) { \
+ TYPE result = 1; \
+ for (int i=0; i<size; ++i) result *= series[i]; \
+ return result; \
+} \
+\
+TYPE SNAME ## Sum(int size, TYPE * series) { \
+ TYPE result = 0; \
+ for (int i=0; i<size; ++i) result += series[i]; \
+ return result; \
+} \
+\
+void SNAME ## Reverse(TYPE array[3]) { \
+ TYPE temp = array[0]; \
+ array[0] = array[2]; \
+ array[2] = temp; \
+} \
+\
+void SNAME ## Ones(TYPE * array, int size) { \
+ for (int i=0; i<size; ++i) array[i] = 1; \
+} \
+\
+void SNAME ## Zeros(int size, TYPE * array) { \
+ 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]; \
+ } \
+ } \
+} \
+\
+void SNAME ## Twos(TYPE* twoVec, int size) { \
+ for (int i=0; i<size; ++i) twoVec[i] = 2; \
+} \
+\
+void SNAME ## Threes(int size, TYPE* threeVec) { \
+ for (int i=0; i<size; ++i) threeVec[i] = 3; \
+}
+
+TEST_FUNCS(signed char , schar )
+TEST_FUNCS(unsigned char , uchar )
+TEST_FUNCS(short , short )
+TEST_FUNCS(unsigned short , ushort )
+TEST_FUNCS(int , int )
+TEST_FUNCS(unsigned int , uint )
+TEST_FUNCS(long , long )
+TEST_FUNCS(unsigned long , ulong )
+TEST_FUNCS(long long , longLong )
+TEST_FUNCS(unsigned long long, ulongLong)
+TEST_FUNCS(float , float )
+TEST_FUNCS(double , double )
Added: trunk/numpy/doc/swig/Vector.h
===================================================================
--- trunk/numpy/doc/swig/Vector.h 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Vector.h 2007-04-04 19:57:37 UTC (rev 3665)
@@ -0,0 +1,58 @@
+#ifndef VECTOR_H
+#define VECTOR_H
+
+// The following macro defines the prototypes for a family of
+// functions that work with 1D arrays 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);
+// void SNAMEEOSplit(TYPE vector[3], TYPE even[3], TYPE odd[3]);
+// void SNAMETwos( TYPE * twoVec, int size);
+// void SNAMEThrees( int size, TYPE * threeVec);
+//
+// for any specified type TYPE (for example: short, unsigned int, long
+// long, etc.) with given short name SNAME (for example: short, uint,
+// longLong, etc.). The macro is then expanded for the given
+// TYPE/SNAME pairs. The resulting functions are for testing numpy
+// interfaces, respectively, for:
+//
+// * 1D input arrays, hard-coded length
+// * 1D input arrays
+// * 1D input arrays, data last
+// * 1D in-place arrays, hard-coded length
+// * 1D in-place arrays
+// * 1D in-place arrays, data last
+// * 1D argout arrays, hard-coded length
+// * 1D argout arrays
+// * 1D argout arrays, data last
+//
+#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); \
+void SNAME ## EOSplit(TYPE vector[3], TYPE even[3], TYPE odd[3]); \
+void SNAME ## Twos( TYPE * twoVec, int size); \
+void SNAME ## Threes( int size, TYPE * threeVec); \
+
+TEST_FUNC_PROTOS(signed char , schar )
+TEST_FUNC_PROTOS(unsigned char , uchar )
+TEST_FUNC_PROTOS(short , short )
+TEST_FUNC_PROTOS(unsigned short , ushort )
+TEST_FUNC_PROTOS(int , int )
+TEST_FUNC_PROTOS(unsigned int , uint )
+TEST_FUNC_PROTOS(long , long )
+TEST_FUNC_PROTOS(unsigned long , ulong )
+TEST_FUNC_PROTOS(long long , longLong )
+TEST_FUNC_PROTOS(unsigned long long, ulongLong)
+TEST_FUNC_PROTOS(float , float )
+TEST_FUNC_PROTOS(double , double )
+
+#endif
Added: trunk/numpy/doc/swig/Vector.i
===================================================================
--- trunk/numpy/doc/swig/Vector.i 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/Vector.i 2007-04-04 19:57:37 UTC (rev 3665)
@@ -0,0 +1,47 @@
+// -*- c++ -*-
+%module Vector
+
+%{
+#define SWIG_FILE_WITH_INIT
+#include "Vector.h"
+%}
+
+// Get the NumPy typemaps
+%include "numpy.i"
+
+%init %{
+ import_array();
+%}
+
+%define %apply_numpy_typemaps(TYPE)
+
+%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 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* ARGOUT_ARRAY1, int DIM1) {(TYPE* twoVec, int size)};
+%apply (int DIM1, TYPE* ARGOUT_ARRAY1) {(int size, TYPE* threeVec)};
+
+%enddef /* %apply_numpy_typemaps() macro */
+
+%apply_numpy_typemaps(signed char )
+%apply_numpy_typemaps(unsigned char )
+%apply_numpy_typemaps(short )
+%apply_numpy_typemaps(unsigned short )
+%apply_numpy_typemaps(int )
+%apply_numpy_typemaps(unsigned int )
+%apply_numpy_typemaps(long )
+%apply_numpy_typemaps(unsigned long )
+%apply_numpy_typemaps(long long )
+%apply_numpy_typemaps(unsigned long long)
+%apply_numpy_typemaps(float )
+%apply_numpy_typemaps(double )
+
+// Include the header file to be wrapped
+%include "Vector.h"
Deleted: trunk/numpy/doc/swig/series.cxx
===================================================================
--- trunk/numpy/doc/swig/series.cxx 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/series.cxx 2007-04-04 19:57:37 UTC (rev 3665)
@@ -1,181 +0,0 @@
-#include <stdlib.h>
-#include <math.h>
-#include <iostream>
-#include "series.h"
-
-// 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);
-// void SNAMEEOSplit( TYPE vector[3], TYPE even[3], odd[3]);
-// void SNAMETwos( TYPE * twoVec, int size);
-// void SNAMEThrees( int size, TYPE * threeVec);
-// 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,
-// longLong, etc.). The macro is then expanded for the given
-// TYPE/SNAME pairs. The resulting functions are for testing numpy
-// interfaces, respectively, for:
-//
-// * 1D input arrays, hard-coded length
-// * 1D input arrays
-// * 1D input arrays, data last
-// * 1D in-place arrays, hard-coded length
-// * 1D in-place arrays
-// * 1D in-place arrays, data last
-// * 1D argout arrays, hard-coded length
-// * 1D argout arrays
-// * 1D argout arrays, data last
-// * 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) \
-\
-TYPE SNAME ## Length(TYPE vector[3]) { \
- double result = 0; \
- for (int i=0; i<3; ++i) result += vector[i]*vector[i]; \
- return (TYPE)sqrt(result); \
-} \
-\
-TYPE SNAME ## Prod(TYPE * series, int size) { \
- TYPE result = 1; \
- for (int i=0; i<size; ++i) result *= series[i]; \
- return result; \
-} \
-\
-TYPE SNAME ## Sum(int size, TYPE * series) { \
- TYPE result = 0; \
- for (int i=0; i<size; ++i) result += series[i]; \
- return result; \
-} \
-\
-void SNAME ## Reverse(TYPE array[3]) { \
- TYPE temp = array[0]; \
- array[0] = array[2]; \
- array[2] = temp; \
-} \
-\
-void SNAME ## Ones(TYPE * array, int size) { \
- for (int i=0; i<size; ++i) array[i] = 1; \
-} \
-\
-void SNAME ## Zeros(int size, TYPE * array) { \
- 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]; \
- } \
- } \
-} \
-\
-void SNAME ## Twos(TYPE* twoVec, int size) { \
- for (int i=0; i<size; ++i) twoVec[i] = 2; \
-} \
-\
-void SNAME ## Threes(int size, TYPE* threeVec) { \
- for (int i=0; i<size; ++i) threeVec[i] = 3; \
-} \
-\
-TYPE SNAME ## Det(TYPE matrix[2][2]) { \
- return matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0]; \
-} \
-\
-TYPE SNAME ## Max(TYPE * matrix, int rows, int cols) { \
- int i, j, index; \
- TYPE result = matrix[0]; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (matrix[index] > result) result = matrix[index]; \
- } \
- } \
- return result; \
-} \
-\
-TYPE SNAME ## Min(int rows, int cols, TYPE * matrix) { \
- int i, j, index; \
- TYPE result = matrix[0]; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (matrix[index] < result) result = matrix[index]; \
- } \
- } \
- return result; \
-} \
-\
-void SNAME ## Scale(TYPE array[3][3], TYPE val) { \
- for (int i=0; i<3; ++i) \
- for (int j=0; j<3; ++j) \
- array[i][j] *= val; \
-} \
-\
-void SNAME ## Floor(TYPE * array, int rows, int cols, TYPE floor) { \
- int i, j, index; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- if (array[index] < floor) array[index] = floor; \
- } \
- } \
-} \
-\
-void SNAME ## Ceil(int rows, int cols, TYPE * array, TYPE ceil) { \
- int i, j, index; \
- for (j=0; j<cols; ++j) { \
- for (i=0; i<rows; ++i) { \
- index = j*rows + i; \
- 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 )
-TEST_FUNCS(unsigned char , uchar )
-TEST_FUNCS(short , short )
-TEST_FUNCS(unsigned short , ushort )
-TEST_FUNCS(int , int )
-TEST_FUNCS(unsigned int , uint )
-TEST_FUNCS(long , long )
-TEST_FUNCS(unsigned long , ulong )
-TEST_FUNCS(long long , longLong )
-TEST_FUNCS(unsigned long long, ulongLong)
-TEST_FUNCS(float , float )
-TEST_FUNCS(double , double )
Deleted: trunk/numpy/doc/swig/series.h
===================================================================
--- trunk/numpy/doc/swig/series.h 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/series.h 2007-04-04 19:57:37 UTC (rev 3665)
@@ -1,79 +0,0 @@
-#ifndef SERIES_H
-#define SERIES_H
-
-// 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);
-// void SNAMEEOSplit( TYPE vector[3], TYPE even[3], TYPE odd[3]);
-// void SNAMETwos( TYPE * twoVec, int size);
-// void SNAMEThrees( int size, TYPE * threeVec);
-// 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,
-// longLong, etc.). The macro is then expanded for the given
-// TYPE/SNAME pairs. The resulting functions are for testing numpy
-// interfaces, respectively, for:
-//
-// * 1D input arrays, hard-coded length
-// * 1D input arrays
-// * 1D input arrays, data last
-// * 1D in-place arrays, hard-coded length
-// * 1D in-place arrays
-// * 1D in-place arrays, data last
-// * 1D argout arrays, hard-coded length
-// * 1D argout arrays
-// * 1D argout arrays, data last
-// * 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); \
-void SNAME ## EOSplit( TYPE vector[3], TYPE even[3], TYPE odd[3]); \
-void SNAME ## Twos( TYPE * twoVec, int size); \
-void SNAME ## Threes( int size, TYPE * threeVec); \
-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 )
-TEST_FUNC_PROTOS(short , short )
-TEST_FUNC_PROTOS(unsigned short , ushort )
-TEST_FUNC_PROTOS(int , int )
-TEST_FUNC_PROTOS(unsigned int , uint )
-TEST_FUNC_PROTOS(long , long )
-TEST_FUNC_PROTOS(unsigned long , ulong )
-TEST_FUNC_PROTOS(long long , longLong )
-TEST_FUNC_PROTOS(unsigned long long, ulongLong)
-TEST_FUNC_PROTOS(float , float )
-TEST_FUNC_PROTOS(double , double )
-
-#endif
Modified: trunk/numpy/doc/swig/setup.py
===================================================================
--- trunk/numpy/doc/swig/setup.py 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/setup.py 2007-04-04 19:57:37 UTC (rev 3665)
@@ -13,17 +13,24 @@
except AttributeError:
numpy_include = numpy.get_numpy_include()
-# _Series extension module
-_Series = Extension("_Series",
- ["Series_wrap.cxx",
- "series.cxx"],
+# _Vector extension module
+_Vector = Extension("_Vector",
+ ["Vector_wrap.cxx",
+ "vector.cxx"],
include_dirs = [numpy_include],
)
-# Series setup
-setup(name = "Series",
- description = "Functions that work on series",
+# _Matrix extension module
+_Matrix = Extension("_Matrix",
+ ["Matrix_wrap.cxx",
+ "matrix.cxx"],
+ include_dirs = [numpy_include],
+ )
+
+# NumyTypemapTests setup
+setup(name = "NumpyTypemapTests",
+ description = "Functions that work on arrays",
author = "Bill Spotz",
- py_modules = ["Series"],
- ext_modules = [_Series]
+ py_modules = ["Vector", "Matrix"],
+ ext_modules = [_Vector , _Matrix ]
)
Modified: trunk/numpy/doc/swig/test1D.py
===================================================================
--- trunk/numpy/doc/swig/test1D.py 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/test1D.py 2007-04-04 19:57:37 UTC (rev 3665)
@@ -16,669 +16,691 @@
# import the extension module
libDir = "lib.%s-%s" % (get_platform(), sys.version[:3])
sys.path.insert(0,os.path.join("build", libDir))
-import Series
+import Vector
######################################################################
-class SeriesTestCase(unittest.TestCase):
+class VectorTestCase(unittest.TestCase):
####################################################
### Test functions that take arrays of type BYTE ###
def testScharLength(self):
"Test scharLength function"
- self.assertEquals(Series.scharLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.scharLength([5, 12, 0]), 13)
def testScharLengthBad(self):
"Test scharLength function for wrong size"
- self.assertRaises(TypeError, Series.scharLength, [5, 12])
+ self.assertRaises(TypeError, Vector.scharLength, [5, 12])
def testScharProd(self):
"Test scharProd function"
- self.assertEquals(Series.scharProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.scharProd([1,2,3,4]), 24)
def testScharProdNonContainer(self):
"Test scharProd function with None"
- self.assertRaises(TypeError, Series.scharProd, None)
+ self.assertRaises(TypeError, Vector.scharProd, None)
def testScharSum(self):
"Test scharSum function"
- self.assertEquals(Series.scharSum([-5,6,-7,8]), 2)
+ self.assertEquals(Vector.scharSum([-5,6,-7,8]), 2)
def testScharReverse(self):
"Test scharReverse function"
vector = N.array([1,2,4],'b')
- Series.scharReverse(vector)
+ Vector.scharReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testScharOnes(self):
"Test scharOnes function"
myArray = N.zeros(5,'b')
- Series.scharOnes(myArray)
+ Vector.scharOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testScharZeros(self):
"Test scharZeros function"
myArray = N.ones(5,'b')
- Series.scharZeros(myArray)
+ Vector.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])
+ even, odd = Vector.scharEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testScharTwos(self):
"Test scharTwos function"
- twos = Series.scharTwos(5)
+ twos = Vector.scharTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testScharThrees(self):
"Test scharThrees function"
- threes = Series.scharThrees(6)
+ threes = Vector.scharThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
#####################################################
### Test functions that take arrays of type UBYTE ###
def testUcharLength(self):
"Test ucharLength function"
- self.assertEquals(Series.ucharLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.ucharLength([5, 12, 0]), 13)
def testUcharLengthBad(self):
"Test ucharLength function for wrong size"
- self.assertRaises(TypeError, Series.ucharLength, [5, 12])
+ self.assertRaises(TypeError, Vector.ucharLength, [5, 12])
def testUcharProd(self):
"Test ucharProd function"
- self.assertEquals(Series.ucharProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.ucharProd([1,2,3,4]), 24)
def testUcharProdNonContainer(self):
"Test ucharProd function with None"
- self.assertRaises(TypeError, Series.ucharProd, None)
+ self.assertRaises(TypeError, Vector.ucharProd, None)
def testUcharSum(self):
"Test ucharSum function"
- self.assertEquals(Series.ucharSum([5,6,7,8]), 26)
+ self.assertEquals(Vector.ucharSum([5,6,7,8]), 26)
def testUcharReverse(self):
"Test ucharReverse function"
vector = N.array([1,2,4],'B')
- Series.ucharReverse(vector)
+ Vector.ucharReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testUcharOnes(self):
"Test ucharOnes function"
myArray = N.zeros(5,'B')
- Series.ucharOnes(myArray)
+ Vector.ucharOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testUcharZeros(self):
"Test ucharZeros function"
myArray = N.ones(5,'B')
- Series.ucharZeros(myArray)
+ Vector.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])
+ even, odd = Vector.ucharEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testUcharTwos(self):
"Test ucharTwos function"
- twos = Series.ucharTwos(5)
+ twos = Vector.ucharTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testUcharThrees(self):
"Test ucharThrees function"
- threes = Series.ucharThrees(6)
+ threes = Vector.ucharThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
#####################################################
### Test functions that take arrays of type SHORT ###
def testShortLength(self):
"Test shortLength function"
- self.assertEquals(Series.shortLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.shortLength([5, 12, 0]), 13)
def testShortLengthBad(self):
"Test shortLength function for wrong size"
- self.assertRaises(TypeError, Series.shortLength, [5, 12])
+ self.assertRaises(TypeError, Vector.shortLength, [5, 12])
def testShortProd(self):
"Test shortProd function"
- self.assertEquals(Series.shortProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.shortProd([1,2,3,4]), 24)
def testShortProdNonContainer(self):
"Test shortProd function with None"
- self.assertRaises(TypeError, Series.shortProd, None)
+ self.assertRaises(TypeError, Vector.shortProd, None)
def testShortSum(self):
"Test shortSum function"
- self.assertEquals(Series.shortSum([-5,6,-7,8]), 2)
+ self.assertEquals(Vector.shortSum([-5,6,-7,8]), 2)
def testShortReverse(self):
"Test shortReverse function"
vector = N.array([1,2,4],'h')
- Series.shortReverse(vector)
+ Vector.shortReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testShortOnes(self):
"Test shortOnes function"
myArray = N.zeros(5,'h')
- Series.shortOnes(myArray)
+ Vector.shortOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testShortZeros(self):
"Test shortZeros function"
myArray = N.ones(5,'h')
- Series.shortZeros(myArray)
+ Vector.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])
+ even, odd = Vector.shortEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testShortTwos(self):
"Test shortTwos function"
- twos = Series.shortTwos(5)
+ twos = Vector.shortTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testShortThrees(self):
"Test shortThrees function"
- threes = Series.shortThrees(6)
+ threes = Vector.shortThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
######################################################
### Test functions that take arrays of type USHORT ###
def testUshortLength(self):
"Test ushortLength function"
- self.assertEquals(Series.ushortLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.ushortLength([5, 12, 0]), 13)
def testUshortLengthBad(self):
"Test ushortLength function for wrong size"
- self.assertRaises(TypeError, Series.ushortLength, [5, 12])
+ self.assertRaises(TypeError, Vector.ushortLength, [5, 12])
def testUshortProd(self):
"Test ushortProd function"
- self.assertEquals(Series.ushortProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.ushortProd([1,2,3,4]), 24)
def testUshortProdNonContainer(self):
"Test ushortProd function with None"
- self.assertRaises(TypeError, Series.ushortProd, None)
+ self.assertRaises(TypeError, Vector.ushortProd, None)
def testUshortSum(self):
"Test ushortSum function"
- self.assertEquals(Series.ushortSum([5,6,7,8]), 26)
+ self.assertEquals(Vector.ushortSum([5,6,7,8]), 26)
def testUshortReverse(self):
"Test ushortReverse function"
vector = N.array([1,2,4],'H')
- Series.ushortReverse(vector)
+ Vector.ushortReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testUshortOnes(self):
"Test ushortOnes function"
myArray = N.zeros(5,'H')
- Series.ushortOnes(myArray)
+ Vector.ushortOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testUshortZeros(self):
"Test ushortZeros function"
myArray = N.ones(5,'H')
- Series.ushortZeros(myArray)
+ Vector.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])
+ even, odd = Vector.ushortEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testUshortTwos(self):
"Test ushortTwos function"
- twos = Series.ushortTwos(5)
+ twos = Vector.ushortTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testUshortThrees(self):
"Test ushortThrees function"
- threes = Series.ushortThrees(6)
+ threes = Vector.ushortThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
###################################################
### Test functions that take arrays of type INT ###
def testIntLength(self):
"Test intLength function"
- self.assertEquals(Series.intLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.intLength([5, 12, 0]), 13)
def testIntLengthBad(self):
"Test intLength function for wrong size"
- self.assertRaises(TypeError, Series.intLength, [5, 12])
+ self.assertRaises(TypeError, Vector.intLength, [5, 12])
def testIntProd(self):
"Test intProd function"
- self.assertEquals(Series.intProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.intProd([1,2,3,4]), 24)
def testIntProdNonContainer(self):
"Test intProd function with None"
- self.assertRaises(TypeError, Series.intProd, None)
+ self.assertRaises(TypeError, Vector.intProd, None)
def testIntSum(self):
"Test intSum function"
- self.assertEquals(Series.intSum([-5,6,-7,8]), 2)
+ self.assertEquals(Vector.intSum([-5,6,-7,8]), 2)
def testIntOnes(self):
"Test intOnes function"
myArray = N.zeros(5,'i')
- Series.intOnes(myArray)
+ Vector.intOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testIntReverse(self):
"Test intReverse function"
vector = N.array([1,2,4],'i')
- Series.intReverse(vector)
+ Vector.intReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testIntZeros(self):
"Test intZeros function"
myArray = N.ones(5,'i')
- Series.intZeros(myArray)
+ Vector.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])
+ even, odd = Vector.intEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testIntTwos(self):
"Test intTwos function"
- twos = Series.intTwos(5)
+ twos = Vector.intTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testIntThrees(self):
"Test intThrees function"
- threes = Series.intThrees(6)
+ threes = Vector.intThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
####################################################
### Test functions that take arrays of type UINT ###
def testUintLength(self):
"Test uintLength function"
- self.assertEquals(Series.uintLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.uintLength([5, 12, 0]), 13)
def testUintLengthBad(self):
"Test uintLength function for wrong size"
- self.assertRaises(TypeError, Series.uintLength, [5, 12])
+ self.assertRaises(TypeError, Vector.uintLength, [5, 12])
def testUintProd(self):
"Test uintProd function"
- self.assertEquals(Series.uintProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.uintProd([1,2,3,4]), 24)
def testUintProdNonContainer(self):
"Test uintProd function with None"
- self.assertRaises(TypeError, Series.uintProd, None)
+ self.assertRaises(TypeError, Vector.uintProd, None)
def testUintSum(self):
"Test uintSum function"
- self.assertEquals(Series.uintSum([5,6,7,8]), 26)
+ self.assertEquals(Vector.uintSum([5,6,7,8]), 26)
def testUintReverse(self):
"Test uintReverse function"
vector = N.array([1,2,4],'I')
- Series.uintReverse(vector)
+ Vector.uintReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testUintOnes(self):
"Test uintOnes function"
myArray = N.zeros(5,'I')
- Series.uintOnes(myArray)
+ Vector.uintOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testUintZeros(self):
"Test uintZeros function"
myArray = N.ones(5,'I')
- Series.uintZeros(myArray)
+ Vector.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])
+ even, odd = Vector.uintEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testUintTwos(self):
"Test uintTwos function"
- twos = Series.uintTwos(5)
+ twos = Vector.uintTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testUintThrees(self):
"Test uintThrees function"
- threes = Series.uintThrees(6)
+ threes = Vector.uintThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
####################################################
### Test functions that take arrays of type LONG ###
def testLongLength(self):
"Test longLength function"
- self.assertEquals(Series.longLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.longLength([5, 12, 0]), 13)
def testLongLengthBad(self):
"Test longLength function for wrong size"
- self.assertRaises(TypeError, Series.longLength, [5, 12])
+ self.assertRaises(TypeError, Vector.longLength, [5, 12])
def testLongProd(self):
"Test longProd function"
- self.assertEquals(Series.longProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.longProd([1,2,3,4]), 24)
def testLongProdNonContainer(self):
"Test longProd function with None"
- self.assertRaises(TypeError, Series.longProd, None)
+ self.assertRaises(TypeError, Vector.longProd, None)
def testLongSum(self):
"Test longSum function"
- self.assertEquals(Series.longSum([-5,6,-7,8]), 2)
+ self.assertEquals(Vector.longSum([-5,6,-7,8]), 2)
def testLongReverse(self):
"Test longReverse function"
vector = N.array([1,2,4],'l')
- Series.longReverse(vector)
+ Vector.longReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testLongOnes(self):
"Test longOnes function"
myArray = N.zeros(5,'l')
- Series.longOnes(myArray)
+ Vector.longOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testLongZeros(self):
"Test longZeros function"
myArray = N.ones(5,'l')
- Series.longZeros(myArray)
+ Vector.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])
+ even, odd = Vector.longEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testLongTwos(self):
"Test longTwos function"
- twos = Series.longTwos(5)
+ twos = Vector.longTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testLongThrees(self):
"Test longThrees function"
- threes = Series.longThrees(6)
+ threes = Vector.longThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
#####################################################
### Test functions that take arrays of type ULONG ###
def testUlongLength(self):
"Test ulongLength function"
- self.assertEquals(Series.ulongLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.ulongLength([5, 12, 0]), 13)
def testUlongLengthBad(self):
"Test ulongLength function for wrong size"
- self.assertRaises(TypeError, Series.ulongLength, [5, 12])
+ self.assertRaises(TypeError, Vector.ulongLength, [5, 12])
def testUlongProd(self):
"Test ulongProd function"
- self.assertEquals(Series.ulongProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.ulongProd([1,2,3,4]), 24)
def testUlongProdNonContainer(self):
"Test ulongProd function with None"
- self.assertRaises(TypeError, Series.ulongProd, None)
+ self.assertRaises(TypeError, Vector.ulongProd, None)
def testUlongSum(self):
"Test ulongSum function"
- self.assertEquals(Series.ulongSum([5,6,7,8]), 26)
+ self.assertEquals(Vector.ulongSum([5,6,7,8]), 26)
def testUlongReverse(self):
"Test ulongReverse function"
vector = N.array([1,2,4],'L')
- Series.ulongReverse(vector)
+ Vector.ulongReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testUlongOnes(self):
"Test ulongOnes function"
myArray = N.zeros(5,'L')
- Series.ulongOnes(myArray)
+ Vector.ulongOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testUlongZeros(self):
"Test ulongZeros function"
myArray = N.ones(5,'L')
- Series.ulongZeros(myArray)
+ Vector.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])
+ even, odd = Vector.ulongEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testUlongTwos(self):
"Test ulongTwos function"
- twos = Series.ulongTwos(5)
+ twos = Vector.ulongTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testUlongThrees(self):
"Test ulongThrees function"
- threes = Series.ulongThrees(6)
+ threes = Vector.ulongThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
########################################################
### Test functions that take arrays of type LONGLONG ###
def testLongLongLength(self):
"Test longLongLength function"
- self.assertEquals(Series.longLongLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.longLongLength([5, 12, 0]), 13)
def testLongLongLengthBad(self):
"Test longLongLength function for wrong size"
- self.assertRaises(TypeError, Series.longLongLength, [5, 12])
+ self.assertRaises(TypeError, Vector.longLongLength, [5, 12])
def testLongLongProd(self):
"Test longLongProd function"
- self.assertEquals(Series.longLongProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.longLongProd([1,2,3,4]), 24)
def testLongLongProdNonContainer(self):
"Test longLongProd function with None"
- self.assertRaises(TypeError, Series.longLongProd, None)
+ self.assertRaises(TypeError, Vector.longLongProd, None)
def testLongLongSum(self):
"Test longLongSum function"
- self.assertEquals(Series.longLongSum([-5,6,-7,8]), 2)
+ self.assertEquals(Vector.longLongSum([-5,6,-7,8]), 2)
def testLongLongReverse(self):
"Test longLongReverse function"
vector = N.array([1,2,4],'q')
- Series.longLongReverse(vector)
+ Vector.longLongReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testLongLongOnes(self):
"Test longLongOnes function"
myArray = N.zeros(5,'q')
- Series.longLongOnes(myArray)
+ Vector.longLongOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testLongLongZeros(self):
"Test longLongZeros function"
myArray = N.ones(5,'q')
- Series.longLongZeros(myArray)
+ Vector.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])
+ even, odd = Vector.longLongEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testLongLongTwos(self):
"Test longLongTwos function"
- twos = Series.longLongTwos(5)
+ twos = Vector.longLongTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testLongLongThrees(self):
"Test longLongThrees function"
- threes = Series.longLongThrees(6)
+ threes = Vector.longLongThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
#########################################################
### Test functions that take arrays of type ULONGLONG ###
def testUlongLongLength(self):
"Test ulongLongLength function"
- self.assertEquals(Series.ulongLongLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.ulongLongLength([5, 12, 0]), 13)
def testUlongLongLengthBad(self):
"Test ulongLongLength function for wrong size"
- self.assertRaises(TypeError, Series.ulongLongLength, [5, 12])
+ self.assertRaises(TypeError, Vector.ulongLongLength, [5, 12])
def testUlonglongProd(self):
"Test ulongLongProd function"
- self.assertEquals(Series.ulongLongProd([1,2,3,4]), 24)
+ self.assertEquals(Vector.ulongLongProd([1,2,3,4]), 24)
def testUlongLongProdNonContainer(self):
"Test ulongLongProd function with None"
- self.assertRaises(TypeError, Series.ulongLongProd, None)
+ self.assertRaises(TypeError, Vector.ulongLongProd, None)
def testUlongLongSum(self):
"Test ulongLongSum function"
- self.assertEquals(Series.ulongLongSum([5,6,7,8]), 26)
+ self.assertEquals(Vector.ulongLongSum([5,6,7,8]), 26)
def testUlongLongReverse(self):
"Test ulongLongReverse function"
vector = N.array([1,2,4],'Q')
- Series.ulongLongReverse(vector)
+ Vector.ulongLongReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testUlongLongOnes(self):
"Test ulongLongOnes function"
myArray = N.zeros(5,'Q')
- Series.ulongLongOnes(myArray)
+ Vector.ulongLongOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1,1,1,1,1]))
def testUlongLongZeros(self):
"Test ulongLongZeros function"
myArray = N.ones(5,'Q')
- Series.ulongLongZeros(myArray)
+ Vector.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])
+ even, odd = Vector.ulongLongEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testUlongLongTwos(self):
"Test ulongLongTwos function"
- twos = Series.ulongLongTwos(5)
+ twos = Vector.ulongLongTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testUlongLongThrees(self):
"Test ulongLongThrees function"
- threes = Series.ulongLongThrees(6)
+ threes = Vector.ulongLongThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
#####################################################
### Test functions that take arrays of type FLOAT ###
def testFloatLength(self):
"Test floatLength function"
- self.assertEquals(Series.floatLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.floatLength([5, 12, 0]), 13)
def testFloatLengthBad(self):
"Test floatLength function for wrong size"
- self.assertRaises(TypeError, Series.floatLength, [5, 12])
+ self.assertRaises(TypeError, Vector.floatLength, [5, 12])
def testFloatProd(self):
"Test floatProd function (to 5 decimal places)"
- self.assertAlmostEquals(Series.floatProd((1,2.718,3,4)), 32.616, 5)
+ self.assertAlmostEquals(Vector.floatProd((1,2.718,3,4)), 32.616, 5)
def testFloatProdBadContainer(self):
"Test floatProd function with an invalid list"
- self.assertRaises(BadListError, Series.floatProd, [3.14, "pi"])
+ self.assertRaises(BadListError, Vector.floatProd, [3.14, "pi"])
def testFloatSum(self):
"Test floatSum function"
- self.assertEquals(Series.floatSum([-5,6,-7,8]), 2)
+ self.assertEquals(Vector.floatSum([-5,6,-7,8]), 2)
def testFloatReverse(self):
"Test floatReverse function"
vector = N.array([1,2,4],'f')
- Series.floatReverse(vector)
+ Vector.floatReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testFloatOnes(self):
"Test floatOnes function"
myArray = N.zeros(5,'f')
- Series.floatOnes(myArray)
+ Vector.floatOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1.,1.,1.,1.,1.]))
def testFloatOnesNonArray(self):
"Test floatOnes function with a list"
- self.assertRaises(TypeError, Series.floatOnes, [True, 0, 2.718, "pi"])
+ self.assertRaises(TypeError, Vector.floatOnes, [True, 0, 2.718, "pi"])
+ def testFloatZeros(self):
+ "Test floatZeros function"
+ myArray = N.ones(5,'f')
+ Vector.floatZeros(myArray)
+ N.testing.assert_array_equal(myArray, N.array([0,0,0,0,0]))
+
+ def testFloatEOSplit(self):
+ "Test floatEOSplit function"
+ even, odd = Vector.floatEOSplit([1,2,3])
+ self.assertEquals((even == [1,0,3]).all(), True)
+ self.assertEquals((odd == [0,2,0]).all(), True)
+
+ def testFloatTwos(self):
+ "Test floatTwos function"
+ twos = Vector.floatTwos(5)
+ self.assertEquals((twos == [2,2,2,2,2]).all(), True)
+
+ def testFloatThrees(self):
+ "Test floatThrees function"
+ threes = Vector.floatThrees(6)
+ self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
+
######################################################
### Test functions that take arrays of type DOUBLE ###
def testDoubleLength(self):
"Test doubleLength function"
- self.assertEquals(Series.doubleLength([5, 12, 0]), 13)
+ self.assertEquals(Vector.doubleLength([5, 12, 0]), 13)
def testDoubleLengthBad(self):
"Test doubleLength function for wrong size"
- self.assertRaises(TypeError, Series.doubleLength, [5, 12])
+ self.assertRaises(TypeError, Vector.doubleLength, [5, 12])
def testDoubleProd(self):
"Test doubleProd function"
- self.assertEquals(Series.doubleProd((1,2.718,3,4)), 32.616)
+ self.assertEquals(Vector.doubleProd((1,2.718,3,4)), 32.616)
def testDoubleProdBadContainer(self):
"Test doubleProd function with an invalid list"
- self.assertRaises(BadListError, Series.doubleProd, [3.14, "pi"])
+ self.assertRaises(BadListError, Vector.doubleProd, [3.14, "pi"])
def testDoubleSum(self):
"Test doubleSum function"
- self.assertEquals(Series.doubleSum([-5,6,-7,8]), 2)
+ self.assertEquals(Vector.doubleSum([-5,6,-7,8]), 2)
def testDoubleReverse(self):
"Test doubleReverse function"
vector = N.array([1,2,4],'d')
- Series.doubleReverse(vector)
+ Vector.doubleReverse(vector)
self.assertEquals((vector == [4,2,1]).all(), True)
def testDoubleOnes(self):
"Test doubleOnes function"
myArray = N.zeros(5,'d')
- Series.doubleOnes(myArray)
+ Vector.doubleOnes(myArray)
N.testing.assert_array_equal(myArray, N.array([1.,1.,1.,1.,1.]))
def testDoubleOnesNonArray(self):
"Test doubleOnes function with a list"
- self.assertRaises(TypeError, Series.doubleOnes, [True, 0, 2.718, "pi"])
+ self.assertRaises(TypeError, Vector.doubleOnes, [True, 0, 2.718, "pi"])
def testDoubleZeros(self):
"Test doubleZeros function"
myArray = N.ones(5,'d')
- Series.doubleZeros(myArray)
+ Vector.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])
+ even, odd = Vector.doubleEOSplit([1,2,3])
self.assertEquals((even == [1,0,3]).all(), True)
self.assertEquals((odd == [0,2,0]).all(), True)
def testDoubleTwos(self):
"Test doubleTwos function"
- twos = Series.doubleTwos(5)
+ twos = Vector.doubleTwos(5)
self.assertEquals((twos == [2,2,2,2,2]).all(), True)
def testDoubleThrees(self):
"Test doubleThrees function"
- threes = Series.doubleThrees(6)
+ threes = Vector.doubleThrees(6)
self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
######################################################################
@@ -687,10 +709,10 @@
# Build the test suite
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(SeriesTestCase))
+ suite.addTest(unittest.makeSuite(VectorTestCase))
# Execute the test suite
- print "Testing 1D Functions of Module Series"
+ print "Testing 1D Functions of Module Vector"
print "NumPy version", N.__version__
print
result = unittest.TextTestRunner(verbosity=2).run(suite)
Modified: trunk/numpy/doc/swig/test2D.py
===================================================================
--- trunk/numpy/doc/swig/test2D.py 2007-04-04 18:10:30 UTC (rev 3664)
+++ trunk/numpy/doc/swig/test2D.py 2007-04-04 19:57:37 UTC (rev 3665)
@@ -16,58 +16,58 @@
# import the extension module
libDir = "lib.%s-%s" % (get_platform(), sys.version[:3])
sys.path.insert(0,os.path.join("build", libDir))
-import Series
+import Matrix
######################################################################
-class SeriesTestCase(unittest.TestCase):
+class MatrixTestCase(unittest.TestCase):
####################################################
### Test functions that take arrays of type BYTE ###
def testScharDet(self):
"Test scharDet function"
matrix = [[6,7],[8,9]]
- self.assertEquals(Series.scharDet(matrix), -2)
+ self.assertEquals(Matrix.scharDet(matrix), -2)
def testScharMax(self):
"Test scharMax function"
matrix = [[-6,5,-4],[3,-2,1]]
- self.assertEquals(Series.scharMax(matrix), 5)
+ self.assertEquals(Matrix.scharMax(matrix), 5)
def testScharMaxNonContainer(self):
"Test scharMax function with None"
- self.assertRaises(TypeError, Series.scharMax, None)
+ self.assertRaises(TypeError, Matrix.scharMax, None)
def testScharMaxWrongDim(self):
"Test scharMax function with a 1D array"
- self.assertRaises(TypeError, Series.scharMax, [0, -1, 2, -3])
+ self.assertRaises(TypeError, Matrix.scharMax, [0, -1, 2, -3])
def testScharMin(self):
"Test scharMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.scharMin(matrix), 4)
+ self.assertEquals(Matrix.scharMin(matrix), 4)
def testScharScale(self):
"Test scharScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'b')
- Series.scharScale(matrix,4)
+ Matrix.scharScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testScharFloor(self):
"Test scharFloor function"
matrix = N.array([[10,-2],[-6,7]],'b')
- Series.scharFloor(matrix,0)
+ Matrix.scharFloor(matrix,0)
N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]]))
def testScharCeil(self):
"Test scharCeil function"
matrix = N.array([[10,-2],[-6,7]],'b')
- Series.scharCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -76,47 +76,47 @@
def testUcharDet(self):
"Test ucharDet function"
matrix = [[7,6],[9,8]]
- self.assertEquals(Series.ucharDet(matrix), 2)
+ self.assertEquals(Matrix.ucharDet(matrix), 2)
def testUcharMax(self):
"Test ucharMax function"
matrix = [[6,5,4],[3,2,1]]
- self.assertEquals(Series.ucharMax(matrix), 6)
+ self.assertEquals(Matrix.ucharMax(matrix), 6)
def testUcharMaxNonContainer(self):
"Test ucharMax function with None"
- self.assertRaises(TypeError, Series.ucharMax, None)
+ self.assertRaises(TypeError, Matrix.ucharMax, None)
def testUcharMaxWrongDim(self):
"Test ucharMax function with a 1D array"
- self.assertRaises(TypeError, Series.ucharMax, [0, 1, 2, 3])
+ self.assertRaises(TypeError, Matrix.ucharMax, [0, 1, 2, 3])
def testUcharMin(self):
"Test ucharMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.ucharMin(matrix), 4)
+ self.assertEquals(Matrix.ucharMin(matrix), 4)
def testUcharScale(self):
"Test ucharScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'B')
- Series.ucharScale(matrix,4)
+ Matrix.ucharScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testUcharFloor(self):
"Test ucharFloor function"
matrix = N.array([[10,2],[6,7]],'B')
- Series.ucharFloor(matrix,7)
+ Matrix.ucharFloor(matrix,7)
N.testing.assert_array_equal(matrix, N.array([[10,7],[7,7]]))
def testUcharCeil(self):
"Test ucharCeil function"
matrix = N.array([[10,2],[6,7]],'B')
- Series.ucharCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -125,47 +125,47 @@
def testShortDet(self):
"Test shortDet function"
matrix = [[6,7],[8,9]]
- self.assertEquals(Series.shortDet(matrix), -2)
+ self.assertEquals(Matrix.shortDet(matrix), -2)
def testShortMax(self):
"Test shortMax function"
matrix = [[-6,5,-4],[3,-2,1]]
- self.assertEquals(Series.shortMax(matrix), 5)
+ self.assertEquals(Matrix.shortMax(matrix), 5)
def testShortMaxNonContainer(self):
"Test shortMax function with None"
- self.assertRaises(TypeError, Series.shortMax, None)
+ self.assertRaises(TypeError, Matrix.shortMax, None)
def testShortMaxWrongDim(self):
"Test shortMax function with a 1D array"
- self.assertRaises(TypeError, Series.shortMax, [0, -1, 2, -3])
+ self.assertRaises(TypeError, Matrix.shortMax, [0, -1, 2, -3])
def testShortMin(self):
"Test shortMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.shortMin(matrix), 4)
+ self.assertEquals(Matrix.shortMin(matrix), 4)
def testShortScale(self):
"Test shortScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'h')
- Series.shortScale(matrix,4)
+ Matrix.shortScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testShortFloor(self):
"Test shortFloor function"
matrix = N.array([[10,-2],[-6,7]],'h')
- Series.shortFloor(matrix,0)
+ Matrix.shortFloor(matrix,0)
N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]]))
def testShortCeil(self):
"Test shortCeil function"
matrix = N.array([[10,-2],[-6,7]],'h')
- Series.shortCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -174,47 +174,47 @@
def testUshortDet(self):
"Test ushortDet function"
matrix = [[7,6],[9,8]]
- self.assertEquals(Series.ushortDet(matrix), 2)
+ self.assertEquals(Matrix.ushortDet(matrix), 2)
def testUshortMax(self):
"Test ushortMax function"
matrix = [[6,5,4],[3,2,1]]
- self.assertEquals(Series.ushortMax(matrix), 6)
+ self.assertEquals(Matrix.ushortMax(matrix), 6)
def testUshortMaxNonContainer(self):
"Test ushortMax function with None"
- self.assertRaises(TypeError, Series.ushortMax, None)
+ self.assertRaises(TypeError, Matrix.ushortMax, None)
def testUshortMaxWrongDim(self):
"Test ushortMax function with a 1D array"
- self.assertRaises(TypeError, Series.ushortMax, [0, 1, 2, 3])
+ self.assertRaises(TypeError, Matrix.ushortMax, [0, 1, 2, 3])
def testUshortMin(self):
"Test ushortMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.ushortMin(matrix), 4)
+ self.assertEquals(Matrix.ushortMin(matrix), 4)
def testUshortScale(self):
"Test ushortScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'H')
- Series.ushortScale(matrix,4)
+ Matrix.ushortScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testUshortFloor(self):
"Test ushortFloor function"
matrix = N.array([[10,2],[6,7]],'H')
- Series.ushortFloor(matrix,7)
+ Matrix.ushortFloor(matrix,7)
N.testing.assert_array_equal(matrix, N.array([[10,7],[7,7]]))
def testUshortCeil(self):
"Test ushortCeil function"
matrix = N.array([[10,2],[6,7]],'H')
- Series.ushortCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -223,47 +223,47 @@
def testIntDet(self):
"Test intDet function"
matrix = [[6,7],[8,9]]
- self.assertEquals(Series.intDet(matrix), -2)
+ self.assertEquals(Matrix.intDet(matrix), -2)
def testIntMax(self):
"Test intMax function"
matrix = [[-6,5,-4],[3,-2,1]]
- self.assertEquals(Series.intMax(matrix), 5)
+ self.assertEquals(Matrix.intMax(matrix), 5)
def testIntMaxNonContainer(self):
"Test intMax function with None"
- self.assertRaises(TypeError, Series.intMax, None)
+ self.assertRaises(TypeError, Matrix.intMax, None)
def testIntMaxWrongDim(self):
"Test intMax function with a 1D array"
- self.assertRaises(TypeError, Series.intMax, [0, -1, 2, -3])
+ self.assertRaises(TypeError, Matrix.intMax, [0, -1, 2, -3])
def testIntMin(self):
"Test intMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.intMin(matrix), 4)
+ self.assertEquals(Matrix.intMin(matrix), 4)
def testIntScale(self):
"Test intScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'i')
- Series.intScale(matrix,4)
+ Matrix.intScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testIntFloor(self):
"Test intFloor function"
matrix = N.array([[10,-2],[-6,7]],'i')
- Series.intFloor(matrix,0)
+ Matrix.intFloor(matrix,0)
N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]]))
def testIntCeil(self):
"Test intCeil function"
matrix = N.array([[10,-2],[-6,7]],'i')
- Series.intCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -272,47 +272,47 @@
def testUintDet(self):
"Test uintDet function"
matrix = [[7,6],[9,8]]
- self.assertEquals(Series.uintDet(matrix), 2)
+ self.assertEquals(Matrix.uintDet(matrix), 2)
def testUintMax(self):
"Test uintMax function"
matrix = [[6,5,4],[3,2,1]]
- self.assertEquals(Series.uintMax(matrix), 6)
+ self.assertEquals(Matrix.uintMax(matrix), 6)
def testUintMaxNonContainer(self):
"Test uintMax function with None"
- self.assertRaises(TypeError, Series.uintMax, None)
+ self.assertRaises(TypeError, Matrix.uintMax, None)
def testUintMaxWrongDim(self):
"Test uintMax function with a 1D array"
- self.assertRaises(TypeError, Series.uintMax, [0, 1, 2, 3])
+ self.assertRaises(TypeError, Matrix.uintMax, [0, 1, 2, 3])
def testUintMin(self):
"Test uintMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.uintMin(matrix), 4)
+ self.assertEquals(Matrix.uintMin(matrix), 4)
def testUintScale(self):
"Test uintScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'I')
- Series.uintScale(matrix,4)
+ Matrix.uintScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testUintFloor(self):
"Test uintFloor function"
matrix = N.array([[10,2],[6,7]],'I')
- Series.uintFloor(matrix,7)
+ Matrix.uintFloor(matrix,7)
N.testing.assert_array_equal(matrix, N.array([[10,7],[7,7]]))
def testUintCeil(self):
"Test uintCeil function"
matrix = N.array([[10,2],[6,7]],'I')
- Series.uintCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -321,47 +321,47 @@
def testLongDet(self):
"Test longDet function"
matrix = [[6,7],[8,9]]
- self.assertEquals(Series.longDet(matrix), -2)
+ self.assertEquals(Matrix.longDet(matrix), -2)
def testLongMax(self):
"Test longMax function"
matrix = [[-6,5,-4],[3,-2,1]]
- self.assertEquals(Series.longMax(matrix), 5)
+ self.assertEquals(Matrix.longMax(matrix), 5)
def testLongMaxNonContainer(self):
"Test longMax function with None"
- self.assertRaises(TypeError, Series.longMax, None)
+ self.assertRaises(TypeError, Matrix.longMax, None)
def testLongMaxWrongDim(self):
"Test longMax function with a 1D array"
- self.assertRaises(TypeError, Series.longMax, [0, -1, 2, -3])
+ self.assertRaises(TypeError, Matrix.longMax, [0, -1, 2, -3])
def testLongMin(self):
"Test longMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.longMin(matrix), 4)
+ self.assertEquals(Matrix.longMin(matrix), 4)
def testLongScale(self):
"Test longScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'l')
- Series.longScale(matrix,4)
+ Matrix.longScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testLongFloor(self):
"Test longFloor function"
matrix = N.array([[10,-2],[-6,7]],'l')
- Series.longFloor(matrix,0)
+ Matrix.longFloor(matrix,0)
N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]]))
def testLongCeil(self):
"Test longCeil function"
matrix = N.array([[10,-2],[-6,7]],'l')
- Series.longCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -370,47 +370,47 @@
def testUlongDet(self):
"Test ulongDet function"
matrix = [[7,6],[9,8]]
- self.assertEquals(Series.ulongDet(matrix), 2)
+ self.assertEquals(Matrix.ulongDet(matrix), 2)
def testUlongMax(self):
"Test ulongMax function"
matrix = [[6,5,4],[3,2,1]]
- self.assertEquals(Series.ulongMax(matrix), 6)
+ self.assertEquals(Matrix.ulongMax(matrix), 6)
def testUlongMaxNonContainer(self):
"Test ulongMax function with None"
- self.assertRaises(TypeError, Series.ulongMax, None)
+ self.assertRaises(TypeError, Matrix.ulongMax, None)
def testUlongMaxWrongDim(self):
"Test ulongMax function with a 1D array"
- self.assertRaises(TypeError, Series.ulongMax, [0, 1, 2, 3])
+ self.assertRaises(TypeError, Matrix.ulongMax, [0, 1, 2, 3])
def testUlongMin(self):
"Test ulongMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.ulongMin(matrix), 4)
+ self.assertEquals(Matrix.ulongMin(matrix), 4)
def testUlongScale(self):
"Test ulongScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'L')
- Series.ulongScale(matrix,4)
+ Matrix.ulongScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testUlongFloor(self):
"Test ulongFloor function"
matrix = N.array([[10,2],[6,7]],'L')
- Series.ulongFloor(matrix,7)
+ Matrix.ulongFloor(matrix,7)
N.testing.assert_array_equal(matrix, N.array([[10,7],[7,7]]))
def testUlongCeil(self):
"Test ulongCeil function"
matrix = N.array([[10,2],[6,7]],'L')
- Series.ulongCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -419,47 +419,47 @@
def testLongLongDet(self):
"Test longLongDet function"
matrix = [[6,7],[8,9]]
- self.assertEquals(Series.longLongDet(matrix), -2)
+ self.assertEquals(Matrix.longLongDet(matrix), -2)
def testLongLongMax(self):
"Test longLongMax function"
matrix = [[-6,5,-4],[3,-2,1]]
- self.assertEquals(Series.longLongMax(matrix), 5)
+ self.assertEquals(Matrix.longLongMax(matrix), 5)
def testLongLongMaxNonContainer(self):
"Test longLongMax function with None"
- self.assertRaises(TypeError, Series.longLongMax, None)
+ self.assertRaises(TypeError, Matrix.longLongMax, None)
def testLongLongMaxWrongDim(self):
"Test longLongMax function with a 1D array"
- self.assertRaises(TypeError, Series.longLongMax, [0, -1, 2, -3])
+ self.assertRaises(TypeError, Matrix.longLongMax, [0, -1, 2, -3])
def testLongLongMin(self):
"Test longLongMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.longLongMin(matrix), 4)
+ self.assertEquals(Matrix.longLongMin(matrix), 4)
def testLongLongScale(self):
"Test longLongScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'q')
- Series.longLongScale(matrix,4)
+ Matrix.longLongScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testLongLongFloor(self):
"Test longLongFloor function"
matrix = N.array([[10,-2],[-6,7]],'q')
- Series.longLongFloor(matrix,0)
+ Matrix.longLongFloor(matrix,0)
N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]]))
def testLongLongCeil(self):
"Test longLongCeil function"
matrix = N.array([[10,-2],[-6,7]],'q')
- Series.longLongCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -468,47 +468,47 @@
def testUlongLongDet(self):
"Test ulongLongDet function"
matrix = [[7,6],[9,8]]
- self.assertEquals(Series.ulongLongDet(matrix), 2)
+ self.assertEquals(Matrix.ulongLongDet(matrix), 2)
def testUlongLongMax(self):
"Test ulongLongMax function"
matrix = [[6,5,4],[3,2,1]]
- self.assertEquals(Series.ulongLongMax(matrix), 6)
+ self.assertEquals(Matrix.ulongLongMax(matrix), 6)
def testUlongLongMaxNonContainer(self):
"Test ulongLongMax function with None"
- self.assertRaises(TypeError, Series.ulongLongMax, None)
+ self.assertRaises(TypeError, Matrix.ulongLongMax, None)
def testUlongLongMaxWrongDim(self):
"Test ulongLongMax function with a 1D array"
- self.assertRaises(TypeError, Series.ulongLongMax, [0, 1, 2, 3])
+ self.assertRaises(TypeError, Matrix.ulongLongMax, [0, 1, 2, 3])
def testUlongLongMin(self):
"Test ulongLongMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.ulongLongMin(matrix), 4)
+ self.assertEquals(Matrix.ulongLongMin(matrix), 4)
def testUlongLongScale(self):
"Test ulongLongScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'Q')
- Series.ulongLongScale(matrix,4)
+ Matrix.ulongLongScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testUlongLongFloor(self):
"Test ulongLongFloor function"
matrix = N.array([[10,2],[6,7]],'Q')
- Series.ulongLongFloor(matrix,7)
+ Matrix.ulongLongFloor(matrix,7)
N.testing.assert_array_equal(matrix, N.array([[10,7],[7,7]]))
def testUlongLongCeil(self):
"Test ulongLongCeil function"
matrix = N.array([[10,2],[6,7]],'Q')
- Series.ulongLongCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -517,69 +517,47 @@
def testFloatDet(self):
"Test floatDet function"
matrix = [[6,7],[8,9]]
- self.assertEquals(Series.floatDet(matrix), -2)
+ self.assertEquals(Matrix.floatDet(matrix), -2)
- def testFloatZeros(self):
- "Test floatZeros function"
- myArray = N.ones(5,'f')
- 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 testFloatTwos(self):
- "Test floatTwos function"
- twos = Series.floatTwos(5)
- self.assertEquals((twos == [2,2,2,2,2]).all(), True)
-
- def testFloatThrees(self):
- "Test floatThrees function"
- threes = Series.floatThrees(6)
- self.assertEquals((threes == [3,3,3,3,3,3]).all(), True)
-
def testFloatMax(self):
"Test floatMax function"
matrix = [[-6,5,-4],[3.14,-2.718,1]]
- self.assertEquals(Series.floatMax(matrix), 5.0)
+ self.assertEquals(Matrix.floatMax(matrix), 5.0)
def testFloatMaxNonContainer(self):
"Test floatMax function with None"
- self.assertRaises(TypeError, Series.floatMax, None)
+ self.assertRaises(TypeError, Matrix.floatMax, None)
def testFloatMaxWrongDim(self):
"Test floatMax function with a 1D array"
- self.assertRaises(TypeError, Series.floatMax, [0.0, -1, 2.718, -3.14])
+ self.assertRaises(TypeError, Matrix.floatMax, [0.0, -1, 2.718, -3.14])
def testFloatMin(self):
"Test floatMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.floatMin(matrix), 4)
+ self.assertEquals(Matrix.floatMin(matrix), 4)
def testFloatScale(self):
"Test floatScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'f')
- Series.floatScale(matrix,4)
+ Matrix.floatScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testFloatFloor(self):
"Test floatFloor function"
matrix = N.array([[10,-2],[-6,7]],'f')
- Series.floatFloor(matrix,0)
+ Matrix.floatFloor(matrix,0)
N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]]))
def testFloatCeil(self):
"Test floatCeil function"
matrix = N.array([[10,-2],[-6,7]],'f')
- Series.floatCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -588,47 +566,47 @@
def testDoubleDet(self):
"Test doubleDet function"
matrix = [[6,7],[8,9]]
- self.assertEquals(Series.doubleDet(matrix), -2)
+ self.assertEquals(Matrix.doubleDet(matrix), -2)
def testDoubleMax(self):
"Test doubleMax function"
matrix = [[-6,5,-4],[3.14,-2.718,1]]
- self.assertEquals(Series.doubleMax(matrix), 5.0)
+ self.assertEquals(Matrix.doubleMax(matrix), 5.0)
def testDoubleMaxNonContainer(self):
"Test doubleMax function with None"
- self.assertRaises(TypeError, Series.doubleMax, None)
+ self.assertRaises(TypeError, Matrix.doubleMax, None)
def testDoubleMaxWrongDim(self):
"Test doubleMax function with a 1D array"
- self.assertRaises(TypeError, Series.doubleMax, [0.0, -1, 2.718, -3.14])
+ self.assertRaises(TypeError, Matrix.doubleMax, [0.0, -1, 2.718, -3.14])
def testDoubleMin(self):
"Test doubleMin function"
matrix = [[9,8],[7,6],[5,4]]
- self.assertEquals(Series.doubleMin(matrix), 4)
+ self.assertEquals(Matrix.doubleMin(matrix), 4)
def testDoubleScale(self):
"Test doubleScale function"
matrix = N.array([[1,2,3],[2,1,2],[3,2,1]],'d')
- Series.doubleScale(matrix,4)
+ Matrix.doubleScale(matrix,4)
self.assertEquals((matrix == [[4,8,12],[8,4,8],[12,8,4]]).all(), True)
def testDoubleFloor(self):
"Test doubleFloor function"
matrix = N.array([[10,-2],[-6,7]],'d')
- Series.doubleFloor(matrix,0)
+ Matrix.doubleFloor(matrix,0)
N.testing.assert_array_equal(matrix, N.array([[10,0],[0,7]]))
def testDoubleCeil(self):
"Test doubleCeil function"
matrix = N.array([[10,-2],[-6,7]],'d')
- Series.doubleCeil(matrix,5)
+ Matrix.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]])
+ lower, upper = Matrix.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)
@@ -638,10 +616,10 @@
# Build the test suite
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(SeriesTestCase))
+ suite.addTest(unittest.makeSuite(MatrixTestCase))
# Execute the test suite
- print "Testing 2D Functions of Module Series"
+ print "Testing 2D Functions of Module Matrix"
print "NumPy version", N.__version__
print
result = unittest.TextTestRunner(verbosity=2).run(suite)
More information about the Numpy-svn
mailing list