diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-07-03 21:10:52 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-07-03 21:10:52 +0000 |
commit | fb9e2b032c62fa254bb1996e8c4e50488ab13999 (patch) | |
tree | e683f1300490d2cde50b2a1179a44ab72f1f49f6 /numpy/core/_internal.py | |
parent | dbee46ab3ef89d1f55cd72d1a61151df19009346 (diff) | |
download | numpy-fb9e2b032c62fa254bb1996e8c4e50488ab13999.tar.gz |
Fix .ctypes.strides and .ctypes.shape to return None (interpreted as NULL by ctypes) if the array is 0-d.
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r-- | numpy/core/_internal.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 35055fb64..7deed7ab2 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -195,23 +195,35 @@ class _ctypes(object): except ImportError: raise AttributeError, "ctypes not available" self._arr = array + if self._arr.ndim == 0: + self._zerod = True + else: + self._zerod = False def data_as(self, obj): return self._ctypes.cast(self._arr._as_parameter_, obj) def shape_as(self, obj): + if self._zerod: + return None return (obj*self._arr.ndim)(*self._arr.shape) def strides_as(self, obj): + if self._zerod: + return None return (obj*self._arr.ndim)(*self._arr.strides) def get_data(self): return self._ctypes.c_void_p(self._arr._as_parameter_) def get_shape(self): + if self._zerod: + return None return (_getintp_ctype()*self._arr.ndim)(*self._arr.shape) def get_strides(self): + if self._zerod: + return None return (_getintp_ctype()*self._arr.ndim)(*self._arr.strides) data = property(get_data, None, doc="c-types data") |