Re: [Numpy-discussion] concatenate an array with a number

2008-08-04 Thread Pierre GM
On Monday 04 August 2008 10:58:00 Nicolas Chopin wrote:
> Hi list,
> I want to do this:
>
> y = concatenate(x[0],x)
>
> where x is a 1d array.
> However, the only way I managed to make this work is:
>
> y = concatenate( array((x[0],),ndmin=1), x)
>
> which is kind of cryptic. (If I remove ndmin, numpy still complains.)
>
> 1. Is there a better way?

y = np.concatenate([x[0]], x)

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] concatenate an array with a number

2008-08-04 Thread Robin
On Mon, Aug 4, 2008 at 3:58 PM, Nicolas Chopin
<[EMAIL PROTECTED]> wrote:
> Hi list,
> I want to do this:
>
> y = concatenate(x[0],x)
>
> where x is a 1d array.
> However, the only way I managed to make this work is:
>
> y = concatenate( array((x[0],),ndmin=1), x)
>
> which is kind of cryptic. (If I remove ndmin, numpy still complains.)

I think r_[x[0],x] will do you what you want...

Robin
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] concatenate an array with a number

2008-08-04 Thread Robert Kern
On Mon, Aug 4, 2008 at 09:58, Nicolas Chopin <[EMAIL PROTECTED]> wrote:
> Hi list,
> I want to do this:
>
> y = concatenate(x[0],x)
>
> where x is a 1d array.
> However, the only way I managed to make this work is:
>
> y = concatenate( array((x[0],),ndmin=1), x)
>
> which is kind of cryptic. (If I remove ndmin, numpy still complains.)
>
> 1. Is there a better way?

atleast_1d()

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] concatenate an array with a number

2008-08-04 Thread Nicolas Chopin
Hi list, 
I want to do this: 

y = concatenate(x[0],x)

where x is a 1d array. 
However, the only way I managed to make this work is: 

y = concatenate( array((x[0],),ndmin=1), x)

which is kind of cryptic. (If I remove ndmin, numpy still complains.)

1. Is there a better way?
2. Would it be possible to allow numbers as arguments for concatenate?

Many thanks
NC

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion