Re: [Numpy-discussion] reading tiff images

2011-04-26 Thread Daniel Lepage
You need PIL no matter what; scipy.misc.imread, scipy.ndimage.imread, and scikits.image.io.imread all call PIL. Theoretically there's no difference between any of them, although in actuality some use "import Image" and others use "from PIL import Image"; one of these may fail depending on how you

Re: [Numpy-discussion] Suggestion: Add the unsqueeze function to numpy

2011-04-20 Thread Daniel Lepage
You can also insert new axes when you slice an array via np.newaxis, fwiw: >>> import numpy as np >>> x = np.random.random((3,4,5)) >>> y = x.mean(axis=1) >>> y.shape (3, 5) >>> y[:,np.newaxis,:].shape (3, 1, 5) -- Dan Lepage On Wed, Apr 20, 2011 at 1:24 PM, Yannick Copin wrote: >   gmail.com>

Re: [Numpy-discussion] random number genration

2011-03-29 Thread Daniel Lepage
On Tue, Mar 29, 2011 at 5:00 AM, Alex Ter-Sarkissov wrote: > If I want to generate a string of random bits with equal probability I run > > random.randint(0,2,size). > > What if I want a specific proportion of bits? In other words, each bit is 1 > with probability p<1/2 and 0 with probability q=1-

Re: [Numpy-discussion] Make array uncopyable

2011-03-23 Thread Daniel Lepage
On Wed, Mar 23, 2011 at 3:54 PM, Dag Sverre Seljebotn wrote: > On 03/23/2011 08:05 PM, Daniel Lepage wrote: >> Hi all, >>     Is there a way to mark an array as uncopyable? If you have very >> large data arrays some numpy functions will cause MemoryErrors because >>

[Numpy-discussion] Make array uncopyable

2011-03-23 Thread Daniel Lepage
Hi all, Is there a way to mark an array as uncopyable? If you have very large data arrays some numpy functions will cause MemoryErrors because behind the scenes they e.g. transpose the arrays into Fortran order to feed them into Fortran libraries (numpy.linalg.svd is an example of this). It woul

Re: [Numpy-discussion] newbie question about boolean testing of array equality result

2011-03-23 Thread Daniel Lepage
On Wed, Mar 23, 2011 at 10:29 AM, Jonathan Hartley wrote: > Hey people, > > I'm writing an application in which we evaluate user-supplied Python > expressions. > > Sometimes, we want to do an equality test on the result of the evaluation, > eg: > >     result = eval(...) >     if result == float('