memoryview shape/strides representation for ndim = 0
Hello, Numpy arrays and memoryview currently have different representations for shape and strides if ndim = 0:
from numpy import * x = array(9, int32) x.ndim 0 x.shape () x.strides () m = memoryview(x) m.ndim 0L m.shape is None True m.strides is None True
I think the Numpy representation is nicer. Also, I think that memoryviews should attempt to mimic the underlying object as closely as possible. Since the ndim = 0 case probably only occurs in Numpy, it might be possible to change the representation in memoryview. Travis, was the "shape is None" representation used for compatibility with ctypes? Would it be possible or advisable to use the Numpy representation? Stefan Krah
On Mon, Aug 22, 2011 at 1:30 PM, Stefan Krah <stefan-usenet@bytereef.org> wrote:
Numpy arrays and memoryview currently have different representations for shape and strides if ndim = 0:
from numpy import * x = array(9, int32) x.ndim 0 x.shape () x.strides () m = memoryview(x) m.ndim 0L m.shape is None True m.strides is None True
I think the Numpy representation is nicer. Also, I think that memoryviews should attempt to mimic the underlying object as closely as possible.
Agreed on both points. If there's no good reason for m.shape and m.strides to be None, I think it should be changed. Mark
Mark Dickinson <mdickinson@enthought.com> wrote:
On Mon, Aug 22, 2011 at 1:30 PM, Stefan Krah <stefan-usenet@bytereef.org> wrote:
Numpy arrays and memoryview currently have different representations for shape and strides if ndim = 0: [...] I think the Numpy representation is nicer. Also, I think that memoryviews should attempt to mimic the underlying object as closely as possible.
Agreed on both points. If there's no good reason for m.shape and m.strides to be None, I think it should be changed.
Excellent, I'll go ahead with it then (in the feature repo). Stefan Krah
On Aug 22, 2011, at 7:35 AM, Mark Dickinson wrote:
On Mon, Aug 22, 2011 at 1:30 PM, Stefan Krah <stefan-usenet@bytereef.org> wrote:
Numpy arrays and memoryview currently have different representations for shape and strides if ndim = 0:
from numpy import * x = array(9, int32) x.ndim 0 x.shape () x.strides () m = memoryview(x) m.ndim 0L m.shape is None True m.strides is None True
I think the Numpy representation is nicer. Also, I think that memoryviews should attempt to mimic the underlying object as closely as possible.
Agreed on both points. If there's no good reason for m.shape and m.strides to be None, I think it should be changed.
I can't think of any good reason not to change it to use the NumPy defaults. This sounds right to me. -Travis
Mark _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
--- Travis Oliphant Enthought, Inc. oliphant@enthought.com 1-512-536-1057 http://www.enthought.com
participants (3)
-
Mark Dickinson
-
Stefan Krah
-
Travis Oliphant