<div dir="ltr">Hey Ben,<div><br></div><div>Side note: I've had to do the same thing for stitching curvilinear model grid coordinates together. Usings pandas DataFrames indexed by `i` and `j` is really good for this. You can offset the indices directly, unstack the DF, and the pandas will align for you.</div><div><br></div><div>Happy to send an example along if you're curious.</div><div>-p</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 8, 2014 at 9:55 AM, Benjamin Root <span dir="ltr"><<a href="mailto:ben.root@ou.edu" target="_blank">ben.root@ou.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>A use case would be "image stitching" or even data tiling. I have had to implement something like this at work (so, I can't share it, unfortunately) and it even goes so far as to allow the caller to specify how much the tiles can overlap and such. The specification is ungodly hideous and I doubt I would be willing to share it even if I could lest I release code-thulu upon the world...<br><br></div>I think just having this generalize stack feature would be nice start. Tetris could be built on top of that later. (Although, I do vote for at least 3 or 4 dimensional stacking, if possible).<br><br></div>Cheers!<br>Ben Root<br><br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 8, 2014 at 12:41 PM, Eelco Hoogendoorn <span dir="ltr"><<a href="mailto:hoogendoorn.eelco@gmail.com" target="_blank">hoogendoorn.eelco@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Sturla: im not sure if the intention is always unambiguous, for such more flexible arrangements.<br><br>Also, I doubt such situations arise often in practice; if the arrays arnt a grid, they are probably a nested grid, and the code would most naturally concatenate them with nested calls to a stacking function.<br><br>However, some form of nd-stack function would be neat in my opinion.</div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Mon, Sep 8, 2014 at 6:10 PM, Jaime Fernández del Río <span dir="ltr"><<a href="mailto:jaime.frio@gmail.com" target="_blank">jaime.frio@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div>On Mon, Sep 8, 2014 at 7:41 AM, Sturla Molden <span dir="ltr"><<a href="mailto:sturla.molden@gmail.com" target="_blank">sturla.molden@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><span>Stefan Otte <<a href="mailto:stefan.otte@gmail.com" target="_blank">stefan.otte@gmail.com</a>> wrote:<br>
<br>
>     stack([[a, b], [c, d]])<br>
><br>
> In my case `stack` replaced `hstack` and `vstack` almost completely.<br>
><br>
> If you're interested in including it in numpy I created a pull request<br>
> [1]. I'm looking forward to getting some feedback!<br>
<br>
</span>As far as I can see, it uses hstack and vstack. But that means a and b have<br>
to have the same number of rows, c and d must have the same rumber of rows,<br>
and hstack((a,b)) and hstack((c,d)) must have the same number of columns.<br>
<br>
Thus it requires a regularity like this:<br>
<br>
AAAABB<br>
AAAABB<br>
CCCDDD<br>
CCCDDD<br>
CCCDDD<br>
CCCDDD<br>
<br>
What if we just ignore this constraint, and only require the output to be<br>
rectangular? Now we have a 'tetris game':<br>
<br>
AAAABB<br>
AAAABB<br>
CCCCBB<br>
CCCCBB<br>
CCCCDD<br>
CCCCDD<br>
<br>
or<br>
<br>
AAAABB<br>
AAAABB<br>
CCCCBB<br>
CCCCBB<br>
CCCCBB<br>
CCCCBB<br>
<br>
This should be 'stackable', yes? Or perhaps we need another stacking<br>
function for this, say numpy.tetris?<br>
<br>
And while we're at it, what about higher dimensions? should there be an<br>
ndstack function too?<br></blockquote><div><br></div></div></div><div>This is starting to look like the second time in a row Stefan tries to extend numpy with a simple convenience function, and he gets tricked into implementing some sophisticated algorithm...</div><div><br></div><div>For his next PR I expect nothing less than an NP-complete problem. ;-)</div><span><font color="#888888"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid">
<span><font color="#888888"></font></span></blockquote></font></span></div><span><font color="#888888"><div class="gmail_extra">Jaime</div><div><br></div>-- <br>(\__/)<br>( O.o)<br>( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
</font></span></div></div>
<br></div></div><span>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></span></blockquote></div><br></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>