[Numpy-discussion] repmat

Tim Hochberg tim.hochberg at ieee.org
Thu Oct 5 20:51:50 CDT 2006


Bill Baxter wrote:
> [There seem to have been some gmail delivery problems that prevented
> my previous mail on this subject from being delivered]
>
> I've proposed that we fix repmat handle arbitrary dimensions before 1.0.
>
>    http://projects.scipy.org/scipy/numpy/ticket/292
>
> I don't think this is particularly controversial, just I'm guessing
> no-one's found the time to look at my proposed fixes.  And
> gmail/sourceforge issues haven't helped either.
>
> In short, repmat(A, M,N) is an oddball.  It only deals with 2D arrays.
>
> We should do some combination of:
> 1) change repmat(A, M,N) to repmat(A, *dims) to add multidim ability
> to it, while maintaining backwards compatibility.
>   
Doesn't repmat imply matrix and thus 2d arrays? It is pretty horrible 
though.

> 2) change repmat(A, M,N) to repmat(A, shape) to add multidim ability
> to it, and bring it into line with the "numpy standard" of shapes
> being passed as one tuple arg.
>   
I presume shape actually means number of repetitions, and not shape. If 
so, shape is the wrong name for the second argument. Anyway as long as 
your breaking backward compatibility you might as well improve the name.

> 3) add a new method like reparray(A, shape) that has the multidim
> ability, and matches numpy conventions.
>   
Same comment on the name shape.


> 4)   if 3), move repmat out of the top-level namespace to indicate deprecation
>   
I'm not completely sold on the whole reparray thing: does repmat have 
any use outside of the linear algebra convention of squashing a 3D array 
into a 2D matrix (or however that goes)? If not, perhaps it should just 
get left alone and exciled to matrix specific functions namespace. So:

+1 on deprecating, moving or otherwise getting rid of repmat.
Neutral on whether to replace it with something else, but if it is 
replaced #3 looks like the correct route, but not with a different 
argument name than 'shape'. Perhaps 'reps'.

-tim

> The tracker item has all the code necessary to implement these fixes,
> it's just a matter of deciding which one to go with.
>
> My personal preference would be a combination of 1 and 3.  Add
> reparray(A,shape) , and change repmat to repmat(A, *shape).  Then just
> implement repmat as a call to reparray.
>
> If someone will decide which route to go, I'd be happy to provide an
> actual patch against the latest SVN to implement that decision.
>
> If this is somehow controversial for some reason then let's discuss
> it.  But so far the only response has been "copying data is a bad
> idea", which is really a separate issue.
>
> --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 at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
>   






More information about the Numpy-discussion mailing list