Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Stéfan van der Walt
On 7 April 2016 at 11:17, Chris Barker wrote: > np.col_vector(arr) > > which would be a synonym for np.reshape(arr, (-1,1)) > > would that make anyone happy? I'm curious to see use cases where this doesn't solve the problem. The most common operations that I run into:

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Chris Barker
On Thu, Apr 7, 2016 at 11:31 AM, wrote: > maybe a warning? >> > > AFAIR, there is a lot of code that works correctly with .T being a noop > for 1D > e.g. covariance matrix/inner product x.T dot y as mentioned before. > oh well, then no warning, either. > write unit tests

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Nathaniel Smith
On Thu, Apr 7, 2016 at 10:00 AM, Ian Henriksen wrote: > > Here's another example that I've seen catch people now and again. > > A = np.random.rand(100, 100) > b = np.random.rand(10) > A * b.T > > In this case the user pretty clearly meant to be broadcasting

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread josef.pktd
On Thu, Apr 7, 2016 at 4:07 PM, Ian Henriksen < insertinterestingnameh...@gmail.com> wrote: > On Thu, Apr 7, 2016 at 1:53 PM wrote: > >> On Thu, Apr 7, 2016 at 3:26 PM, Ian Henriksen < >> insertinterestingnameh...@gmail.com> wrote: >> >>> On Thu, Apr 7, 2016 at 12:31 PM

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Ian Henriksen
On Thu, Apr 7, 2016 at 1:53 PM wrote: > On Thu, Apr 7, 2016 at 3:26 PM, Ian Henriksen < > insertinterestingnameh...@gmail.com> wrote: > >> On Thu, Apr 7, 2016 at 12:31 PM wrote: >> >>> write unit tests with non square 2d arrays and the exception /

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread josef.pktd
On Thu, Apr 7, 2016 at 3:26 PM, Ian Henriksen < insertinterestingnameh...@gmail.com> wrote: > On Thu, Apr 7, 2016 at 12:31 PM wrote: > >> write unit tests with non square 2d arrays and the exception / test error >> shows up fast. >> >> Josef >> >> > Absolutely, but good

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Ian Henriksen
On Thu, Apr 7, 2016 at 12:31 PM wrote: > write unit tests with non square 2d arrays and the exception / test error > shows up fast. > > Josef > > Absolutely, but good programming practices don't totally obviate helpful error messages. Best, -Ian

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Ian Henriksen
On Thu, Apr 7, 2016 at 12:18 PM Chris Barker wrote: > On Thu, Apr 7, 2016 at 10:00 AM, Ian Henriksen < > insertinterestingnameh...@gmail.com> wrote: > >> Here's another example that I've seen catch people now and again. >> >> A = np.random.rand(100, 100) >> b =

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Irvin Probst
On Thu, 7 Apr 2016 14:31:17 -0400, josef.p...@gmail.com wrote: So this discussion brings up that we also need an easy an obvious way to make a column vector --  maybe: np.col_vector(arr) FWIW I would give a +1e42 to something like np.colvect and np.rowvect (or whatever variant of these

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread josef.pktd
On Thu, Apr 7, 2016 at 2:17 PM, Chris Barker wrote: > On Thu, Apr 7, 2016 at 10:00 AM, Ian Henriksen < > insertinterestingnameh...@gmail.com> wrote: > >> Here's another example that I've seen catch people now and again. >> >> A = np.random.rand(100, 100) >> b =

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Matthew Brett
On Thu, Apr 7, 2016 at 11:17 AM, Chris Barker wrote: > On Thu, Apr 7, 2016 at 10:00 AM, Ian Henriksen > wrote: >> >> Here's another example that I've seen catch people now and again. >> >> A = np.random.rand(100, 100) >> b =

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Chris Barker
On Thu, Apr 7, 2016 at 10:00 AM, Ian Henriksen < insertinterestingnameh...@gmail.com> wrote: > Here's another example that I've seen catch people now and again. > > A = np.random.rand(100, 100) > b = np.random.rand(10) > A * b.T > typo? that was supposed to be b = np.random.rand(100). yes?

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread josef.pktd
On Thu, Apr 7, 2016 at 1:35 PM, Sebastian Berg wrote: > On Do, 2016-04-07 at 13:29 -0400, josef.p...@gmail.com wrote: > > > > > > On Thu, Apr 7, 2016 at 1:20 PM, Sebastian Berg < > > sebast...@sipsolutions.net> wrote: > > > On Do, 2016-04-07 at 11:56 -0400,

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Sebastian Berg
On Do, 2016-04-07 at 13:29 -0400, josef.p...@gmail.com wrote: > > > On Thu, Apr 7, 2016 at 1:20 PM, Sebastian Berg < > sebast...@sipsolutions.net> wrote: > > On Do, 2016-04-07 at 11:56 -0400, josef.p...@gmail.com wrote: > > > > > > > > > > > > > > > > > > I don't think numpy treats 1d arrays

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread josef.pktd
On Thu, Apr 7, 2016 at 1:20 PM, Sebastian Berg wrote: > On Do, 2016-04-07 at 11:56 -0400, josef.p...@gmail.com wrote: > > > > > > > > > > > I don't think numpy treats 1d arrays as row vectors. numpy has C > > -order for axis preference which coincides in many cases

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Sebastian Berg
On Do, 2016-04-07 at 11:56 -0400, josef.p...@gmail.com wrote: > > > > I don't think numpy treats 1d arrays as row vectors. numpy has C > -order for axis preference which coincides in many cases with row > vector behavior. > Well, broadcasting rules, are that (n,) should typically behave

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Chris Barker
On Thu, Apr 7, 2016 at 8:13 AM, Todd wrote: > First you need to turn a into a 2D array. I can think of 10 ways to do > this off the top of my head, and there may be more: > > snip Basically, my argument here is the same as the argument from pep465 for the > inclusion of the

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Ian Henriksen
On Wed, Apr 6, 2016 at 3:21 PM Nathaniel Smith wrote: > Can you elaborate on what you're doing that you find verbose and > confusing, maybe paste an example? I've never had any trouble like > this doing linear algebra with @ or dot (which have similar semantics > for 1d arrays),

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread josef.pktd
On Thu, Apr 7, 2016 at 11:42 AM, Todd wrote: > On Thu, Apr 7, 2016 at 11:35 AM, wrote: >> >> On Thu, Apr 7, 2016 at 11:13 AM, Todd wrote: >> > On Wed, Apr 6, 2016 at 5:20 PM, Nathaniel Smith wrote: >> >> >> >> On

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Todd
On Thu, Apr 7, 2016 at 11:35 AM, wrote: > On Thu, Apr 7, 2016 at 11:13 AM, Todd wrote: > > On Wed, Apr 6, 2016 at 5:20 PM, Nathaniel Smith wrote: > >> > >> On Wed, Apr 6, 2016 at 10:43 AM, Todd wrote: > >> > > >> >

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread josef.pktd
On Thu, Apr 7, 2016 at 11:13 AM, Todd wrote: > On Wed, Apr 6, 2016 at 5:20 PM, Nathaniel Smith wrote: >> >> On Wed, Apr 6, 2016 at 10:43 AM, Todd wrote: >> > >> > My intention was to make linear algebra operations easier in numpy. >> >

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Todd
On Thu, Apr 7, 2016 at 3:39 AM, Irvin Probst wrote: > On 06/04/2016 04:11, Todd wrote: > > When you try to transpose a 1D array, it does nothing. This is the > correct behavior, since it transposing a 1D array is meaningless. However, > this can often lead to

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Todd
On Thu, Apr 7, 2016 at 4:59 AM, Joseph Martinot-Lagarde < contreba...@gmail.com> wrote: > Alan Isaac gmail.com> writes: > > > But underlying the proposal is apparently the > > idea that there be an attribute equivalent to > > `atleast_2d`. Then call it `d2p`. > > You can now have `a.d2p.T`

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Todd
On Wed, Apr 6, 2016 at 5:20 PM, Nathaniel Smith wrote: > On Wed, Apr 6, 2016 at 10:43 AM, Todd wrote: > > > > My intention was to make linear algebra operations easier in numpy. With > > the @ operator available, it is now very easy to do basic linear

[Numpy-discussion] ANN: bcolz 1.0.0 (final) released

2016-04-07 Thread Francesc Alted
= Announcing bcolz 1.0.0 final = What's new == Yeah, 1.0.0 is finally here. We are not introducing any exciting new feature (just some optimizations and bug fixes), but bcolz is already 6 years old and it implements most of the

[Numpy-discussion] ANN: python-blosc 1.3.1

2016-04-07 Thread Francesc Alted
= Announcing python-blosc 1.3.1 = What is new? This is an important release in terms of stability. Now, the -O1 flag for compiling the included C-Blosc sources on Linux. This represents slower performance, but fixes the nasty

[Numpy-discussion] ANN: numexpr 2.5.2 released

2016-04-07 Thread Francesc Alted
= Announcing Numexpr 2.5.2 = Numexpr is a fast numerical expression evaluator for NumPy. With it, expressions that operate on arrays (like "3*a+4*b") are accelerated and use less memory than doing the same calculation in Python. It wears

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Joseph Martinot-Lagarde
> > For a 1D array a of shape (N,), I expect a.T2 to be of shape (N, 1), > > Why not (1,N)? -- it is not well defined, though I suppose it's not so > bad to establish a convention that a 1-D array is a "row vector" > rather than a "column vector". I like Todd's simple proposal: a.T2 should be

[Numpy-discussion] [ANN] Summer School "Advanced Scientific Programming in Python" in Reading, UK, September 5—11, 2016

2016-04-07 Thread Tiziano Zito
Advanced Scientific Programming in Python = a Summer School by the G-Node, and the Centre for Integrative Neuroscience and Neurodynamics, School of Psychology and Clinical Language Sciences, University of Reading, UK Scientists spend more and more time

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Joseph Martinot-Lagarde
Alan Isaac gmail.com> writes: > But underlying the proposal is apparently the > idea that there be an attribute equivalent to > `atleast_2d`. Then call it `d2p`. > You can now have `a.d2p.T` which is a lot > more explicit and general than say `a.T2`, > while requiring only 3 more keystrokes.

Re: [Numpy-discussion] ndarray.T2 for 2D transpose

2016-04-07 Thread Irvin Probst
On 06/04/2016 04:11, Todd wrote: When you try to transpose a 1D array, it does nothing. This is the correct behavior, since it transposing a 1D array is meaningless. However, this can often lead to unexpected errors since this is rarely what you want. You can convert the array to 2D,