summaryrefslogtreecommitdiff
path: root/numpy/doc
diff options
context:
space:
mode:
authorwfspotz@sandia.gov <wfspotz@sandia.gov@localhost>2007-03-25 03:04:27 +0000
committerwfspotz@sandia.gov <wfspotz@sandia.gov@localhost>2007-03-25 03:04:27 +0000
commit78f4e519a5bf7ee4bb4a23ea8b658272a365f45c (patch)
treea9fb85a16f78d95940e5e3c42c7b8a43f5d71f8e /numpy/doc
parente3a18285c362ebe8bdab2bcdefa8b94557f7b93b (diff)
downloadnumpy-78f4e519a5bf7ee4bb4a23ea8b658272a365f45c.tar.gz
Added typemaps for signatures (TYPE INPLACE_ARRAY1[ANY]) and (TYPE INPLACE_ARRAY2[ANY][ANY])
Diffstat (limited to 'numpy/doc')
-rw-r--r--numpy/doc/swig/Series.i6
-rw-r--r--numpy/doc/swig/numpy.i50
-rw-r--r--numpy/doc/swig/numpy_swig.html11
-rw-r--r--numpy/doc/swig/numpy_swig.pdfbin115362 -> 115707 bytes
-rw-r--r--numpy/doc/swig/numpy_swig.txt12
-rw-r--r--numpy/doc/swig/series.cxx35
-rw-r--r--numpy/doc/swig/series.h46
-rwxr-xr-xnumpy/doc/swig/testSeries.py144
8 files changed, 262 insertions, 42 deletions
diff --git a/numpy/doc/swig/Series.i b/numpy/doc/swig/Series.i
index b35377ca8..bd068dc7d 100644
--- a/numpy/doc/swig/Series.i
+++ b/numpy/doc/swig/Series.i
@@ -15,14 +15,16 @@
%define %apply_numpy_typemaps(TYPE)
-%apply (TYPE IN_ARRAY1[ANY]) {(TYPE vector[ANY])};
+%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[ANY][ANY])};
+%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 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)};
diff --git a/numpy/doc/swig/numpy.i b/numpy/doc/swig/numpy.i
index b70da225f..f19b4b0ef 100644
--- a/numpy/doc/swig/numpy.i
+++ b/numpy/doc/swig/numpy.i
@@ -303,18 +303,18 @@ int require_size(PyArrayObject* ary, npy_intp* size, int n) {
* arguments of the form
*
* (DATA_TYPE IN_ARRAY1[ANY])
- *
* (DATA_TYPE* IN_ARRAY1, DIM_TYPE DIM1)
* (DIM_TYPE DIM1, DATA_TYPE* IN_ARRAY1)
*
* (DATA_TYPE IN_ARRAY2[ANY][ANY])
- *
* (DATA_TYPE* IN_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
* (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* IN_ARRAY2)
*
+ * (DATA_TYPE INPLACE_ARRAY1[ANY])
* (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
* (DIM_TYPE DIM1, DATA_TYPE* INPLACE_ARRAY1)
*
+ * (DATA_TYPE IN_ARRAY2[ANY][ANY])
* (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
* (DIM_TYPE DIM1, DIM_TYPE DIM2, DATA_TYPE* INPLACE_ARRAY2)
*
@@ -350,12 +350,18 @@ int require_size(PyArrayObject* ary, npy_intp* size, int n) {
* %apply (int DIM1, int DIM2, double* IN_ARRAY2) {(int rows, int cols, double* matrix)}
* double min(int length, double* series)
*
+ * %apply (double INPLACE_ARRAY1[ANY]) {(double vector[3])};
+ * void reverse(double vector[3]);
+ *
* %apply (double* INPLACE_ARRAY1, int DIM1) {(double* series, int length)};
* void ones(double* series, int length);
*
* %apply (int DIM1, double* INPLACE_ARRAY1) {(int length, double* series)}
* double zeros(int length, double* series)
*
+ * %apply (double INPLACE_ARRAY2[ANY][ANY]) {(double matrix[3][3])};
+ * void scale(double matrix[3][3]);
+ *
* %apply (double* INPLACE_ARRAY2, int DIM1, int DIM2) {(double* matrix, int rows, int cols)};
* void floor(double* matrix, int rows, int cols);
*
@@ -370,19 +376,19 @@ int require_size(PyArrayObject* ary, npy_intp* size, int n) {
*
* or directly with
*
- * double length(double IN_ARRAY[ANY]);
- *
+ * double length(double IN_ARRAY1[ANY]);
* double prod(double* IN_ARRAY1, int DIM1);
* double sum( int DIM1, double* IN_ARRAY1)
*
* double det(double IN_ARRAY2[ANY][ANY]);
- *
* double max(double* IN_ARRAY2, int DIM1, int DIM2);
* double min(int DIM1, int DIM2, double* IN_ARRAY2)
*
+ * void reverse(double INPLACE_ARRAY1[ANY]);
* void ones( double* INPLACE_ARRAY1, int DIM1);
* void zeros(int DIM1, double* INPLACE_ARRAY1)
*
+ * void scale(double INPLACE_ARRAY2[ANY][ANY]);
* void floor(double* INPLACE_ARRAY2, int DIM1, int DIM2, double floor);
* void ceil( int DIM1, int DIM2, double* INPLACE_ARRAY2, double ceil );
*
@@ -501,6 +507,23 @@ int require_size(PyArrayObject* ary, npy_intp* size, int n) {
if (is_new_object$argnum && array$argnum) Py_DECREF(array$argnum);
}
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY1[ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY)
+ (DATA_TYPE INPLACE_ARRAY1[ANY])
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),DATA_TYPECODE);
+}
+%typemap(in)
+ (DATA_TYPE INPLACE_ARRAY1[ANY])
+ (PyArrayObject* temp=NULL)
+{
+ temp = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ npy_intp size[1] = { $1_dim0 };
+ if (!temp || !require_dimensions(temp,1) || !require_size(temp, size, 1)) SWIG_fail;
+ $1 = ($1_ltype) temp->data;
+}
+
/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY1, DIM_TYPE DIM1)
*/
%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY)
@@ -537,6 +560,23 @@ int require_size(PyArrayObject* ary, npy_intp* size, int n) {
$2 = (DATA_TYPE*) temp->data;
}
+/* Typemap suite for (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ */
+%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY)
+ (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+{
+ $1 = is_array($input) && PyArray_EquivTypenums(array_type($input),DATA_TYPECODE);
+}
+%typemap(in)
+ (DATA_TYPE INPLACE_ARRAY2[ANY][ANY])
+ (PyArrayObject* temp=NULL)
+{
+ temp = obj_to_array_no_conversion($input, DATA_TYPECODE);
+ npy_intp size[2] = { $1_dim0, $1_dim1 };
+ if (!temp || !require_dimensions(temp,2) || !require_size(temp, size, 2)) SWIG_fail;
+ $1 = ($1_ltype) temp->data;
+}
+
/* Typemap suite for (DATA_TYPE* INPLACE_ARRAY2, DIM_TYPE DIM1, DIM_TYPE DIM2)
*/
%typecheck(SWIG_TYPECHECK_DOUBLE_ARRAY)
diff --git a/numpy/doc/swig/numpy_swig.html b/numpy/doc/swig/numpy_swig.html
index 3d2e15428..cf9a621a6 100644
--- a/numpy/doc/swig/numpy_swig.html
+++ b/numpy/doc/swig/numpy_swig.html
@@ -485,14 +485,17 @@ sequence (such as a list) that can be converted to the requested type
of array. The input array signatures are</p>
<blockquote>
<ul class="simple">
-<li><tt class="docutils literal"><span class="pre">(DATA_TYPE</span> <span class="pre">IN_ARRAY[ANY])</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">(DATA_TYPE</span> <span class="pre">IN_ARRAY1[ANY])</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(DATA_TYPE*</span> <span class="pre">IN_ARRAY1,</span> <span class="pre">int</span> <span class="pre">DIM1)</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(int</span> <span class="pre">DIM1,</span> <span class="pre">DATA_TYPE*</span> <span class="pre">IN_ARRAY1)</span></tt></li>
-<li><tt class="docutils literal"><span class="pre">(DATA_TYPE</span> <span class="pre">IN_ARRAY[ANY])</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">(DATA_TYPE</span> <span class="pre">IN_ARRAY2[ANY][ANY])</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(DATA_TYPE*</span> <span class="pre">IN_ARRAY2,</span> <span class="pre">int</span> <span class="pre">DIM1,</span> <span class="pre">int</span> <span class="pre">DIM2)</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(int</span> <span class="pre">DIM1,</span> <span class="pre">int</span> <span class="pre">DIM2,</span> <span class="pre">DATA_TYPE*</span> <span class="pre">IN_ARRAY2)</span></tt></li>
</ul>
</blockquote>
+<p>The first signature listed, <tt class="docutils literal"><span class="pre">(DATA_TYPE</span> <span class="pre">IN_ARRAY[ANY])</span></tt> is for
+hard-coded one-dimensional arrays. Likewise, <tt class="docutils literal"><span class="pre">(DATA_TYPE</span>
+<span class="pre">IN_ARRAY2[ANY][ANY])</span></tt> is for two-dimensional arrays.</p>
</div>
<div class="section">
<h2><a class="toc-backref" href="#id5" id="in-place-arrays" name="in-place-arrays">In-Place Arrays</a></h2>
@@ -503,8 +506,10 @@ must therefore be a <a class="reference" href="http://numpy.scipy.org">NumPy</a>
signatures are</p>
<blockquote>
<ul class="simple">
+<li><tt class="docutils literal"><span class="pre">(DATA_TYPE</span> <span class="pre">INPLACE_ARRAY1[ANY])</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(DATA_TYPE*</span> <span class="pre">INPLACE_ARRAY1,</span> <span class="pre">int</span> <span class="pre">DIM1)</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(int</span> <span class="pre">DIM1,</span> <span class="pre">DATA_TYPE*</span> <span class="pre">INPLACE_ARRAY1)</span></tt></li>
+<li><tt class="docutils literal"><span class="pre">(DATA_TYPE</span> <span class="pre">INPLACE_ARRAY2[ANY][ANY])</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(DATA_TYPE*</span> <span class="pre">INPLACE_ARRAY2,</span> <span class="pre">int</span> <span class="pre">DIM1,</span> <span class="pre">int</span> <span class="pre">DIM2)</span></tt></li>
<li><tt class="docutils literal"><span class="pre">(int</span> <span class="pre">DIM1,</span> <span class="pre">int</span> <span class="pre">DIM2,</span> <span class="pre">DATA_TYPE*</span> <span class="pre">INPLACE_ARRAY2)</span></tt></li>
</ul>
@@ -710,7 +715,7 @@ result possible.</p>
</div>
<div class="footer">
<hr class="footer" />
-Generated on: 2007-03-24 20:29 UTC.
+Generated on: 2007-03-25 03:02 UTC.
Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
</div>
diff --git a/numpy/doc/swig/numpy_swig.pdf b/numpy/doc/swig/numpy_swig.pdf
index e02bc3ed8..91204fd88 100644
--- a/numpy/doc/swig/numpy_swig.pdf
+++ b/numpy/doc/swig/numpy_swig.pdf
Binary files differ
diff --git a/numpy/doc/swig/numpy_swig.txt b/numpy/doc/swig/numpy_swig.txt
index 8d4cc60bc..2e03e798b 100644
--- a/numpy/doc/swig/numpy_swig.txt
+++ b/numpy/doc/swig/numpy_swig.txt
@@ -4,7 +4,7 @@ numpy.i: a SWIG Interface File for NumPy
:Author: Bill Spotz
:Institution: Sandia National Laboratories
-:Date: 18 March, 2007
+:Date: 24 March, 2007
.. contents::
@@ -174,13 +174,17 @@ routine but are not altered in-place or returned to the user. The
sequence (such as a list) that can be converted to the requested type
of array. The input array signatures are
- * ``(DATA_TYPE IN_ARRAY[ANY])``
+ * ``(DATA_TYPE IN_ARRAY1[ANY])``
* ``(DATA_TYPE* IN_ARRAY1, int DIM1)``
* ``(int DIM1, DATA_TYPE* IN_ARRAY1)``
- * ``(DATA_TYPE IN_ARRAY[ANY])``
+ * ``(DATA_TYPE IN_ARRAY2[ANY][ANY])``
* ``(DATA_TYPE* IN_ARRAY2, int DIM1, int DIM2)``
* ``(int DIM1, int DIM2, DATA_TYPE* IN_ARRAY2)``
+The first signature listed, ``(DATA_TYPE IN_ARRAY[ANY])`` is for
+hard-coded one-dimensional arrays. Likewise, ``(DATA_TYPE
+IN_ARRAY2[ANY][ANY])`` is for two-dimensional arrays.
+
In-Place Arrays
---------------
@@ -190,8 +194,10 @@ function returns are significant. The provided `python`_ argument
must therefore be a `NumPy`_ array of the required type. The in-place
signatures are
+ * ``(DATA_TYPE INPLACE_ARRAY1[ANY])``
* ``(DATA_TYPE* INPLACE_ARRAY1, int DIM1)``
* ``(int DIM1, DATA_TYPE* INPLACE_ARRAY1)``
+ * ``(DATA_TYPE INPLACE_ARRAY2[ANY][ANY])``
* ``(DATA_TYPE* INPLACE_ARRAY2, int DIM1, int DIM2)``
* ``(int DIM1, int DIM2, DATA_TYPE* INPLACE_ARRAY2)``
diff --git a/numpy/doc/swig/series.cxx b/numpy/doc/swig/series.cxx
index 04f3b1670..e0adb5108 100644
--- a/numpy/doc/swig/series.cxx
+++ b/numpy/doc/swig/series.cxx
@@ -5,15 +5,18 @@
// The following macro defines a family of functions with the forms
//
-// TYPE SNAMELength(TYPE vector[3]);
-// TYPE SNAMEProd( TYPE * series, int size);
-// void SNAMEOnes( TYPE * array, int size);
-// TYPE SNAMEMax( TYPE * matrix, int rows, int cols);
-// void SNAMEFloor(TYPE * array, int rows, int cols, TYPE floor);
-// TYPE SNAMESum( int size, TYPE * series);
-// void SNAMEZeros(int size, TYPE * array);
-// TYPE SNAMEMin( int rows, int cols, TYPE * matrix);
-// 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);
+// 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);
//
// for any specified type TYPE (for example: short, unsigned int, long
// long, etc.) with given short name SNAME (for example: short, uint,
@@ -24,11 +27,13 @@
// * 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
// * 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
//
@@ -52,6 +57,12 @@ TYPE SNAME ## Sum(int size, TYPE * series) { \
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; \
} \
@@ -88,6 +99,12 @@ TYPE SNAME ## Min(int rows, int cols, TYPE * matrix) { \
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) { \
diff --git a/numpy/doc/swig/series.h b/numpy/doc/swig/series.h
index 73b744127..249232996 100644
--- a/numpy/doc/swig/series.h
+++ b/numpy/doc/swig/series.h
@@ -4,16 +4,18 @@
// 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 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 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);
+// 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 );
//
// for any specified type TYPE (for example: short, unsigned int, long
// long, etc.) with given short name SNAME (for example: short, uint,
@@ -24,26 +26,30 @@
// * 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
// * 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
//
#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 ## 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 ## 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); \
+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 );
TEST_FUNC_PROTOS(signed char , schar )
TEST_FUNC_PROTOS(unsigned char , uchar )
diff --git a/numpy/doc/swig/testSeries.py b/numpy/doc/swig/testSeries.py
index fb1e00e11..79483682d 100755
--- a/numpy/doc/swig/testSeries.py
+++ b/numpy/doc/swig/testSeries.py
@@ -44,6 +44,12 @@ class SeriesTestCase(unittest.TestCase):
"Test scharSum function"
self.assertEquals(Series.scharSum([-5,6,-7,8]), 2)
+ def testScharReverse(self):
+ "Test scharReverse function"
+ vector = N.array([1,2,4],'b')
+ Series.scharReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testScharOnes(self):
"Test scharOnes function"
myArray = N.zeros(5,'b')
@@ -79,6 +85,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -113,6 +125,12 @@ class SeriesTestCase(unittest.TestCase):
"Test ucharSum function"
self.assertEquals(Series.ucharSum([5,6,7,8]), 26)
+ def testUcharReverse(self):
+ "Test ucharReverse function"
+ vector = N.array([1,2,4],'B')
+ Series.ucharReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testUcharOnes(self):
"Test ucharOnes function"
myArray = N.zeros(5,'B')
@@ -148,6 +166,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -182,6 +206,12 @@ class SeriesTestCase(unittest.TestCase):
"Test shortSum function"
self.assertEquals(Series.shortSum([-5,6,-7,8]), 2)
+ def testShortReverse(self):
+ "Test shortReverse function"
+ vector = N.array([1,2,4],'h')
+ Series.shortReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testShortOnes(self):
"Test shortOnes function"
myArray = N.zeros(5,'h')
@@ -217,6 +247,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -251,6 +287,12 @@ class SeriesTestCase(unittest.TestCase):
"Test ushortSum function"
self.assertEquals(Series.ushortSum([5,6,7,8]), 26)
+ def testUshortReverse(self):
+ "Test ushortReverse function"
+ vector = N.array([1,2,4],'H')
+ Series.ushortReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testUshortOnes(self):
"Test ushortOnes function"
myArray = N.zeros(5,'H')
@@ -286,6 +328,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -326,6 +374,12 @@ class SeriesTestCase(unittest.TestCase):
Series.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)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testIntZeros(self):
"Test intZeros function"
myArray = N.ones(5,'i')
@@ -355,6 +409,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -390,6 +450,12 @@ class SeriesTestCase(unittest.TestCase):
"Test uintSum function"
self.assertEquals(Series.uintSum([5,6,7,8]), 26)
+ def testUintReverse(self):
+ "Test uintReverse function"
+ vector = N.array([1,2,4],'I')
+ Series.uintReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testUintOnes(self):
"Test uintOnes function"
myArray = N.zeros(5,'I')
@@ -425,6 +491,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -459,6 +531,12 @@ class SeriesTestCase(unittest.TestCase):
"Test longSum function"
self.assertEquals(Series.longSum([-5,6,-7,8]), 2)
+ def testLongReverse(self):
+ "Test longReverse function"
+ vector = N.array([1,2,4],'l')
+ Series.longReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testLongOnes(self):
"Test longOnes function"
myArray = N.zeros(5,'l')
@@ -494,6 +572,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -528,6 +612,12 @@ class SeriesTestCase(unittest.TestCase):
"Test ulongSum function"
self.assertEquals(Series.ulongSum([5,6,7,8]), 26)
+ def testUlongReverse(self):
+ "Test ulongReverse function"
+ vector = N.array([1,2,4],'L')
+ Series.ulongReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testUlongOnes(self):
"Test ulongOnes function"
myArray = N.zeros(5,'L')
@@ -563,6 +653,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -597,6 +693,12 @@ class SeriesTestCase(unittest.TestCase):
"Test longLongSum function"
self.assertEquals(Series.longLongSum([-5,6,-7,8]), 2)
+ def testLongLongReverse(self):
+ "Test longLongReverse function"
+ vector = N.array([1,2,4],'q')
+ Series.longLongReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testLongLongOnes(self):
"Test longLongOnes function"
myArray = N.zeros(5,'q')
@@ -632,6 +734,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -666,6 +774,12 @@ class SeriesTestCase(unittest.TestCase):
"Test ulongLongSum function"
self.assertEquals(Series.ulongLongSum([5,6,7,8]), 26)
+ def testUlongLongReverse(self):
+ "Test ulongLongReverse function"
+ vector = N.array([1,2,4],'Q')
+ Series.ulongLongReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testUlongLongOnes(self):
"Test ulongLongOnes function"
myArray = N.zeros(5,'Q')
@@ -701,6 +815,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -735,6 +855,12 @@ class SeriesTestCase(unittest.TestCase):
"Test floatSum function"
self.assertEquals(Series.floatSum([-5,6,-7,8]), 2)
+ def testFloatReverse(self):
+ "Test floatReverse function"
+ vector = N.array([1,2,4],'f')
+ Series.floatReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testFloatOnes(self):
"Test floatOnes function"
myArray = N.zeros(5,'f')
@@ -774,6 +900,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')
@@ -808,6 +940,12 @@ class SeriesTestCase(unittest.TestCase):
"Test doubleSum function"
self.assertEquals(Series.doubleSum([-5,6,-7,8]), 2)
+ def testDoubleReverse(self):
+ "Test doubleReverse function"
+ vector = N.array([1,2,4],'d')
+ Series.doubleReverse(vector)
+ self.assertEquals((vector == [4,2,1]).all(), True)
+
def testDoubleOnes(self):
"Test doubleOnes function"
myArray = N.zeros(5,'d')
@@ -847,6 +985,12 @@ class SeriesTestCase(unittest.TestCase):
matrix = [[9,8],[7,6],[5,4]]
self.assertEquals(Series.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)
+ 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')