Tim Hochberg wrote:
I was just looking at the interface for array and asarray to see what other stuff should go in the interface of the hypothetical ascontiguous. There's 'dtype', which I knew about, and 'fortran', which I didn't, but which makes sense. However, there's also 'ndmin'. First off, it's not described in docstring for asarray, but I was able to find it in the docstring for array without a problem. Second, is it really necessary? It seems to be useful in an awfully narrow set of circumstances, particularly since when you are padding axes not everyone wants to pad to the left.
Padding to the left is "default" behavior for broadcasting and so it seems appropriate. This is how all lower-dimensional arrays are interpreted as "higher" dimensional arrays throughout the code. The ndmin is very handy as atested to by the uses of atleast_1d or atleast_2d in numpy library code. It was added later as an optimization step because of the number of library routines that were using it. I've since used it several times to simplify code. I think an ascontinguous on the Python level is appropriate since such a beast exists on the C-level. On the other hand, while Tim prefers narrow interfaces, the array_from_object interface is traditionally pretty broad. Thus, in my mind, the array call should get another flag keyword that forces a contiguous result. This translates easily to the C-domain, in much the same way as the fortran keyword does. -Travis