[Numpy-discussion] azip
I'm floating this thought even though it is not fleshed out. On occasion, I run into the following problem: I have a rectangular array A to which I want to append a (probably) one dimensional vector b to make [A|b]. Of course this can be done as np.hstack((x,b[:,None])) (or obscurely np.r_['1,2,0',x,b]), but this has the following issues: - what if ``b`` turns out to be a list? - what if ``b`` turns out to be 2d (e.g., a column vector)? - it's a bit ugly - it is not obvious when read by others (e.g., students) (The last is a key motivation for me to talk about this.) All of which leads me to wonder if there might be profit in a numpy.azip function that takes as arguments - a tuple of arraylike iterables - an axis along which to concatenate (say, like r_ does) iterated items To make that a little clearer (but not to provide a suggested implementation), it might behave something like def azip(alst, axis=1): results = [] for tpl in zip(*alst): results.append(np.r_[tpl]) return np.rollaxis(np.array(results), axis-1) Alan Isaac ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
On Thu, Jul 18, 2013 at 5:57 PM, Alan G Isaac alan.is...@gmail.com wrote: I'm floating this thought even though it is not fleshed out. On occasion, I run into the following problem: I have a rectangular array A to which I want to append a (probably) one dimensional vector b to make [A|b]. Of course this can be done as np.hstack((x,b[:,None])) (or obscurely np.r_['1,2,0',x,b]), but this has the following issues: - what if ``b`` turns out to be a list? - what if ``b`` turns out to be 2d (e.g., a column vector)? - it's a bit ugly - it is not obvious when read by others (e.g., students) np.column_stack([x, b]) does everything you need. -- Robert Kern ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
On 7/18/2013 1:03 PM, Robert Kern wrote: np.column_stack([x, b]) does everything you need. So it does. It's not referenced from the hstack or concatenate documentation. Thanks! Alan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
On Thu, Jul 18, 2013 at 7:06 PM, Alan G Isaac alan.is...@gmail.com wrote: On 7/18/2013 1:03 PM, Robert Kern wrote: np.column_stack([x, b]) does everything you need. So it does. It's not referenced from the hstack or concatenate documentation. A pull request would fix all of that in seconds! GitHub now allows online editing, and provides a one-click option for creating the PR. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
Forgive my ignorance, but has numpy and scipy stopped doing that weird doc editing thing that existed back in the days of Trac? I have actually held back on submitting doc edits because I hated using that thing so much. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
Hi Ben On Thu, Jul 18, 2013 at 7:18 PM, Benjamin Root ben.r...@ou.edu wrote: Forgive my ignorance, but has numpy and scipy stopped doing that weird doc editing thing that existed back in the days of Trac? I have actually held back on submitting doc edits because I hated using that thing so much. That thing helps people without hacking experience to contribute, but you are welcome to issue pull-requests instead. Stéfan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
On 7/18/2013 1:03 PM, Robert Kern wrote: np.column_stack([x, b]) does everything you need. I am curious: why is column_stack in numpy/lib/shape_base.py while hstack and vstack are in numpy/core/shape_base.py ? Thanks, Alan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
18.07.2013 20:18, Benjamin Root kirjoitti: Forgive my ignorance, but has numpy and scipy stopped doing that weird doc editing thing that existed back in the days of Trac? I have actually held back on submitting doc edits because I hated using that thing so much. You were never required to use it. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
Well, that's nice to know now. However, I distinctly remember being told that any changes made to the docstrings directly in the source would end up getting replaced by whatever was in the doc edit system whenever a merge from it happens. Therefore, if one wanted their edits to be persistent, they had to submit it through the doc edit system. Note, much of my animosity towards the doc edit system was due to issues with the scipy.org being so sluggish back then, and the length of time it took for any edits to finally make it down to the docstrings. Now that scipy.org is much more responsive, and that numpy and scipy has moved on to git, perhaps those two issues are gone now? Sorry for hijacking the thread, this is just the first I am hearing that one can submit documentation edits via PRs and was surprised. Cheers! Ben Root On Thu, Jul 18, 2013 at 1:51 PM, Pauli Virtanen p...@iki.fi wrote: 18.07.2013 20:18, Benjamin Root kirjoitti: Forgive my ignorance, but has numpy and scipy stopped doing that weird doc editing thing that existed back in the days of Trac? I have actually held back on submitting doc edits because I hated using that thing so much. You were never required to use it. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] azip
18.07.2013 21:11, Benjamin Root kirjoitti: Well, that's nice to know now. However, I distinctly remember being told that any changes made to the docstrings directly in the source would end up getting replaced by whatever was in the doc edit system whenever a merge from it happens. Therefore, if one wanted their edits to be persistent, they had to submit it through the doc edit system. I think there must have been some misunderstanding here: the doc editor works similarly to VCS, in that it will detect merge conflicts and require someone to manually resolve conflicts if the docstring in the source code has been changed. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion