Howdy, On 7/22/06, Sven Schreiber <[EMAIL PROTECTED]> wrote: > Hi, > > Summary: Slicing seems to be broken with matrices now. > > ... > Example: > > >>> import numpy as n > >>> n.__version__ > '1.0b1' > >>> import numpy.matlib as m > >>> a = n.zeros((2,3)) > >>> b = m.zeros((2,3)) > >>> a[:1,:].shape > (1, 3) > >>> b[:1,:].shape > (3, 1) > >>> > > Note the array slicing works correct, but the equivalent thing with the > matrix does not.
Looks like it happened in rev 2698 of defmatrix.py, matrix.__getitem__ method: if isscalar(index[1]): if isscalar(index[0]): retscal = True elif out.shape[0] == 1: sh = out.shape out.shape = (sh[1], sh[0]) ==> elif isinstance(index[1], (slice, types.EllipsisType)): ==> if out.shape[0] == 1 and not isscalar(index[0]): It behaves like array if you remove the 'not' in the last line. But maybe that breaks some other cases? Maybe you can try making that change in your numpy/core/defmatrix.py (around line 140) and see if anything else breaks for you. > I also noticed the following (in a new python session) import strangeness: > > >>> import numpy > >>> numpy.matlib.zeros((2,3)) > Traceback (most recent call last): > File "<interactive input>", line 1, in ? > AttributeError: 'module' object has no attribute 'matlib' > >>> > > Why is the direct access to matlib impossible? Maybe the thinking is that since it's a compatibily module, if you want it you should explicity import it. Like you have to do with oldnumeric. --bb ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion