Revision: 366
http://rpy.svn.sourceforge.net/rpy/?rev=366&view=rev
Author: warnes
Date: 2007-11-12 22:27:31 -0800 (Mon, 12 Nov 2007)
Log Message:
-----------
Fix array test to explicitly check elements of 3 dimensional objects for
equality.
Modified Paths:
--------------
trunk/rpy/tests/test_array.py
trunk/rpy/tests/test_numeric.py
Modified: trunk/rpy/tests/test_array.py
===================================================================
--- trunk/rpy/tests/test_array.py 2007-11-13 06:26:05 UTC (rev 365)
+++ trunk/rpy/tests/test_array.py 2007-11-13 06:27:31 UTC (rev 366)
@@ -15,9 +15,23 @@
idx.autoconvert(BASIC_CONVERSION)
return o
-def all(vec):
- for i in range(len(vec)):
- if not vec[i]: return False
+def all_equal_3d(vec1, vec2):
+
+ if len(vec1) != len(vec2): return False
+
+ for i in range(len(vec1)):
+
+ if len(vec1[i]) != len(vec2[i]): return False
+
+ for j in range( len(vec1[i]) ):
+
+ if len(vec1[i][j])!=len(vec2[i][j]): return False
+
+ for k in range( len(vec1[i][j]) ):
+
+ if vec1[i][j][k] != vec2[i][j][k]: return False
+
+
return True
@@ -34,7 +48,7 @@
r.array.autoconvert(BASIC_CONVERSION)
def testConversionToPy(self):
- self.failUnless(all(self.py == self.ra.as_py()),
+ self.failUnless(all_equal_3d(self.py,self.ra.as_py()),
'wrong conversion to Python')
def testConversionToR(self):
Modified: trunk/rpy/tests/test_numeric.py
===================================================================
--- trunk/rpy/tests/test_numeric.py 2007-11-13 06:26:05 UTC (rev 365)
+++ trunk/rpy/tests/test_numeric.py 2007-11-13 06:27:31 UTC (rev 366)
@@ -79,7 +79,7 @@
def testROutOfBounds(self):
self.failUnlessRaises(RPyException, lambda: idx(self.ra_c, 5,5,5))
- def test64BitIntArrays(self):
+ def test64BitIntArray(self):
# 64 bit ints
try:
@@ -91,10 +91,9 @@
print "\nInt64 Not found. Skipping this test.\n"
return
- b = r.c(a[1])
b = r.c(a)
- def test32BitIntArrays(self):
+ def test32BitIntArray(self):
# 32 bit ints
try:
@@ -102,10 +101,9 @@
except:
a = array( [1,2,3], Int32 )
- b = r.c(a[1])
b = r.c(a)
- def test16BitIntArrays(self):
+ def test16BitIntArray(self):
# 16 bit ints
try:
@@ -113,21 +111,31 @@
except:
a = array( [1,2,3], Int16 )
- b = r.c(a[1])
b = r.c(a)
- def test8BitIntArrays(self):
+ def test8BitIntArray(self):
# 8 bit ints
try:
a = array( [1,2,3], 'Int8' )
except:
a = array( [1,2,3], Int8 )
- b = r.c(a[1])
+
b = r.c(a)
- def test64BitFloatArrays(self):
+ def testBoolArray(self):
+ # 8 bit ints
+ try:
+ a = array( [1,2,3], 'Bool' )
+ except:
+ print "Bool arrays not supported by Numeric, skipping"
+ return
+
+ b = r.c(a)
+
+ def test64BitFloatArray(self):
+
# 64 bit ints
try:
a = array( [1,2,3], 'Float64' )
@@ -138,10 +146,9 @@
print "Float64 Not found. Skipping this test."
return
- b = r.c(a[1])
b = r.c(a)
- def test32BitFloatArrays(self):
+ def test32BitFloatArray(self):
# 32 bit ints
try:
@@ -149,27 +156,160 @@
except:
a = array( [1,2,3], Float32 )
- b = r.c(a[1])
b = r.c(a)
- def testCharArrays(self):
+ def testCharArray(self):
try:
- a = array( ['A','B', 'C'], 'Char' )
+ a = array( ['A','B', 'C'], character )
except:
a = array( ['A','B', 'C'], Character )
self.failUnlessRaises(RPyTypeConversionException, lambda: r.c(a) )
- def testObjArrays(self):
+ def testStringArray(self):
+
try:
- a = array( ['A','B', 'C'], 'PyObject' )
+ a = array( ['ABCDEFHIJKLM','B', 'C C C'], 'S10' )
+ except: # not available on Numeric
+ print "String arrays not supported by Numeric, skipping"
+ return
+
+ self.failUnlessRaises(RPyTypeConversionException, lambda: r.c(a) )
+
+
+ def testObjArray(self):
+
+ try:
+ a = array( ['A','B', 'C'], 'object' )
except:
a = array( ['A','B', 'C'], PyObject )
self.failUnlessRaises(RPyTypeConversionException, lambda: r.c(a) )
+
+
+ def test64BitIntScalar(self):
+
+ # 64 bit ints
+ try:
+ a = array( [1,2,3], 'Int64' )
+ except:
+ try:
+ a = array( [1,2,3], Int64 )
+ except:
+ print "\nInt64 Not found. Skipping this test.\n"
+ return
+
+ b = r.c(a[0])
+
+ def test32BitIntScalar(self):
+
+ # 32 bit ints
+ try:
+ a = array( [1,2,3], 'Int32' )
+ except:
+ a = array( [1,2,3], Int32 )
+
+ b = r.c(a[0])
+
+ def test16BitIntScalar(self):
+
+ # 16 bit ints
+ try:
+ a = array( [1,2,3], 'Int16' )
+ except:
+ a = array( [1,2,3], Int16 )
+
+ b = r.c(a[0])
+
+ def test8BitIntScalar(self):
+
+ # 8 bit ints
+ try:
+ a = array( [1,2,3], 'Int8' )
+ except:
+ a = array( [1,2,3], Int8 )
+
+ b = r.c(a[0])
+
+ def testBoolScalar(self):
+
+ # 8 bit ints
+ try:
+ a = array( [1,2,3], 'Bool' )
+ except:
+ print "Bool arrays not supported by Numeric, skipping"
+ return
+
+ b = r.c(a[0])
+
+ def test64BitFloatScalar(self):
+
+ # 64 bit ints
+ try:
+ a = array( [1,2,3], 'Float64' )
+ except:
+ try:
+ a = array( [1,2,3], Float64 )
+ except:
+ print "Float64 Not found. Skipping this test."
+ return
+
+ b = r.c(a[0])
+
+ def test32BitFloatScalar(self):
+
+ # 32 bit ints
+ try:
+ a = array( [1,2,3], 'Float32' )
+ except:
+ a = array( [1,2,3], Float32 )
+
+ b = r.c(a[0])
+
+ def testCharScalar(self):
+
+ try:
+ a = array( ['A','B', 'C'], character )
+ except:
+ a = array( ['A','B', 'C'], Character )
+
+ self.failUnless( r.c(a[0])=='A' )
+
+
+ def testStringScalar(self):
+
+ try:
+ a = array( ['ABCDEFHIJKLM','B', 'C C C'], 'S10' )
+ except: # not available on Numeric
+ print "String arrays not supported by Numeric, skipping"
+ return
+
+ self.failUnless( r.c(a[0])=='ABCDEFHIJK' )
+
+
+ def testObjScalar(self):
+
+ try:
+ a = array( ['A','B', 'C'], 'object' )
+ except:
+ a = array( ['A','B', 'C'], PyObject )
+
+ self.failUnless( r.c(a[0])=='A' )
+
+
+
+
+
+
+
+
+
+
+
+
if __name__ == '__main__':
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
rpy-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rpy-list