[Numpy-svn] r5314 - trunk/numpy/ma

numpy-svn@scip... numpy-svn@scip...
Wed Jun 25 14:43:59 CDT 2008


Author: pierregm
Date: 2008-06-25 14:43:56 -0500 (Wed, 25 Jun 2008)
New Revision: 5314

Modified:
   trunk/numpy/ma/core.py
Log:
MaskedArray.__new__ : compare data to cls and not to MaskedArray, in case __new__ is called from a subclass
MaskedArray: add the iscontiguous method.

Modified: trunk/numpy/ma/core.py
===================================================================
--- trunk/numpy/ma/core.py	2008-06-24 05:10:37 UTC (rev 5313)
+++ trunk/numpy/ma/core.py	2008-06-25 19:43:56 UTC (rev 5314)
@@ -1201,7 +1201,8 @@
         _data = np.array(data, dtype=dtype, copy=copy, subok=True, ndmin=ndmin)
         _baseclass = getattr(data, '_baseclass', type(_data))
         _basedict = getattr(data, '_basedict', getattr(data, '__dict__', {}))
-        if not isinstance(data, MaskedArray) or not subok:
+        # Careful, cls might not always be MaskedArray...
+        if not isinstance(data, cls) or not subok:
             _data = _data.view(cls)
         else:
             _data = _data.view(type(data))
@@ -2079,6 +2080,11 @@
         if self._mask is nomask:
             return (self.ctypes.data, id(nomask))
         return (self.ctypes.data, self._mask.ctypes.data)
+
+    def iscontiguous(self):
+        "Is the data contiguous?"
+        return self.flags['CONTIGUOUS']
+
     #............................................
     def all(self, axis=None, out=None):
         """a.all(axis=None, out=None)



More information about the Numpy-svn mailing list