[Numpy-svn] r2945 - in trunk/numpy/core: . tests

numpy-svn at scipy.org numpy-svn at scipy.org
Wed Aug 2 16:44:50 EDT 2006


Author: stefan
Date: 2006-08-02 15:44:43 -0500 (Wed, 02 Aug 2006)
New Revision: 2945

Modified:
   trunk/numpy/core/defchararray.py
   trunk/numpy/core/tests/test_regression.py
Log:
Fix rstrip for character arrays (ticket #222).


Modified: trunk/numpy/core/defchararray.py
===================================================================
--- trunk/numpy/core/defchararray.py	2006-08-02 17:30:48 UTC (rev 2944)
+++ trunk/numpy/core/defchararray.py	2006-08-02 20:44:43 UTC (rev 2945)
@@ -135,14 +135,13 @@
         for k, val in enumerate(myiter):
             newval = []
             for chk in val[1:]:
-                if chk.dtype is object_ and chk.item() is None:
+                if not chk or (chk.dtype is object_ and chk.item() is None):
                     break
                 newval.append(chk)
             newitem = getattr(val[0],name)(*newval)
             maxsize = max(len(newitem), maxsize)
             res[k] = newitem
         newarr = chararray(myiter.shape, maxsize, self.dtype is unicode_)
-        print res, maxsize
         newarr[:] = res
         return newarr
 

Modified: trunk/numpy/core/tests/test_regression.py
===================================================================
--- trunk/numpy/core/tests/test_regression.py	2006-08-02 17:30:48 UTC (rev 2944)
+++ trunk/numpy/core/tests/test_regression.py	2006-08-02 20:44:43 UTC (rev 2945)
@@ -331,6 +331,13 @@
     def check_unique_zero_sized(self,level=rlevel):
         """Ticket #205"""
         assert_array_equal([], N.unique(N.array([])))
+        
+    def check_chararray_rstrip(self,level=rlevel):
+        """Ticket #222"""
+        x = N.chararray((1,),5)
+        x[0] = 'a   '
+        x = x.rstrip()
+        assert_equal(x[0], 'a')
 
 if __name__ == "__main__":
     NumpyTest().run()




More information about the Numpy-svn mailing list