Re: [Numpy-discussion] What is the logical value of nan?

2009-03-10 Thread Timothy Hochberg
On Tue, Mar 10, 2009 at 2:49 PM, Charles R Harris wrote: > > > On Tue, Mar 10, 2009 at 3:16 PM, Stéfan van der Walt wrote: > >> 2009/3/10 Pauli Virtanen : >> > Nonzero Python object, hence True. Moreover, it's also True in Python: >> >> Also in C: >> >> #include >> #include >> >> int main() { >

Re: [Numpy-discussion] Ticket #794 and can o' worms.

2008-07-20 Thread Timothy Hochberg
On Sun, Jul 20, 2008 at 3:47 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Sun, Jul 20, 2008 at 17:42, Charles R Harris > <[EMAIL PROTECTED]> wrote: > > Hi All, > > > > I "fixed" ticket #754, but it leads to a ton of problems. The original > > discussion is here. The problems that arise come fro

Re: [Numpy-discussion] Outputting arrays.

2008-05-21 Thread Timothy Hochberg
On Wed, May 21, 2008 at 12:32 AM, Alexandra Geddes <[EMAIL PROTECTED]> wrote: > Hi. > > 1. Is there a module or other code to write arrays to databases (they want > access databases)? If you have $$, I think you can use mxODBC. Otherwise, I believe that you have to use COM as Chris suggested. >

Re: [Numpy-discussion] Uncomfortable with matrix change

2008-05-10 Thread Timothy Hochberg
On Sat, May 10, 2008 at 1:37 PM, Anne Archibald <[EMAIL PROTECTED]> wrote: > 2008/5/10 Nathan Bell <[EMAIL PROTECTED]>: > > On Sat, May 10, 2008 at 3:05 PM, Anne Archibald > > <[EMAIL PROTECTED]> wrote: > >> > >> I don't expect my opinion to prevail, but the point is that we do not > >> even have

Re: [Numpy-discussion] Uncomfortable with matrix change

2008-05-09 Thread Timothy Hochberg
On Fri, May 9, 2008 at 6:43 AM, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > Hi all, > > I'm having trouble emailing this list from work, so I'm using a > different email address. > > After Nathan Bell's recent complaints, I'm a bit more uncomfortable with > the matrix change to scalar indexing.

Re: [Numpy-discussion] Tests for empty arrays

2008-05-06 Thread Timothy Hochberg
On Tue, May 6, 2008 at 9:53 AM, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Tue, May 6, 2008 at 9:45 AM, Anne Archibald > <[EMAIL PROTECTED]> wrote: > > In fact, if you want to use empty() down the road, it may > > make sense to initialize your array to zeros()/0., so that if you ever > > use

Re: [Numpy-discussion] Tests for empty arrays

2008-05-06 Thread Timothy Hochberg
On Tue, May 6, 2008 at 9:31 AM, Andy Cheesman <[EMAIL PROTECTED]> wrote: > Hi nice numpy people > > I was wondering if anyone could shed some light on how to distinguish an > empty array of a given shape and an zeros array of the same dimensions. An empty array is just uninitialized, while a zer

Re: [Numpy-discussion] Deprecating PyDataMem_RENEW ?

2008-05-05 Thread Timothy Hochberg
On Mon, May 5, 2008 at 5:44 AM, David Cournapeau < [EMAIL PROTECTED]> wrote: > Hi, > >While working again on the fftpack module, to clean things up and > speed some backends (in particular fftw3, which is really sub-optimal > right now), I remembered how much unaligned data pointer in numpy ar

Re: [Numpy-discussion] Faster

2008-05-04 Thread Timothy Hochberg
On Sat, May 3, 2008 at 5:31 PM, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Sat, May 3, 2008 at 5:05 PM, Christopher Barker > <[EMAIL PROTECTED]> wrote: > > Robert Kern wrote: > > > I can get a ~20% improvement with the following: > > > > > > > In [9]: def mycut(x, i): > > >...: A = x[

Re: [Numpy-discussion] untenable matrix behavior in SVN

2008-04-30 Thread Timothy Hochberg
On Wed, Apr 30, 2008 at 8:16 PM, Anne Archibald <[EMAIL PROTECTED]> wrote: > 2008/4/30 Charles R Harris <[EMAIL PROTECTED]>: > > > Some operations on stacks of small matrices are easy to get, for > instance, > > +,-,*,/, and matrix multiply. The last is the interesting one. If A and B > > are stac

Re: [Numpy-discussion] untenable matrix behavior in SVN

2008-04-29 Thread Timothy Hochberg
On Tue, Apr 29, 2008 at 2:43 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > Timothy Hochberg wrote: > > However, there is matrix related > > stuff that is at best poorly supported now, namely operations on stacks > > of arrays (or vectors). > > Tim, this is

Re: [Numpy-discussion] untenable matrix behavior in SVN

2008-04-29 Thread Timothy Hochberg
On Tue, Apr 29, 2008 at 2:07 PM, Gael Varoquaux < [EMAIL PROTECTED]> wrote: > On Tue, Apr 29, 2008 at 11:03:58PM +0200, Anne Archibald wrote: > > I am puzzled by this. What is the rationale for x[i,:] not being a 1-d > > object? > > It breaks A*B[i, :] where A and B are matrices. Shouldn't that

Re: [Numpy-discussion] untenable matrix behavior in SVN

2008-04-29 Thread Timothy Hochberg
Let me throw out a couple of more thoughts: First, there seems to be disagreement about what a row_vector and column_vector are (and even if they are sensible concepts, but let's leave that aside for moment). One school of thought is that they are one-dimensional objects that have some orientation

Re: [Numpy-discussion] prerelease proposal for matrix behavior

2008-04-28 Thread Timothy Hochberg
On Sat, Apr 26, 2008 at 7:12 AM, Alan G Isaac <[EMAIL PROTECTED]> wrote: > On Fri, 25 Apr 2008, "Travis E. Oliphant" apparently wrote: > > At this point, I'm leaning in the direction of the > > RowVector / ColumnVector approach (even if these are not > > really advertised and just used during inde

Re: [Numpy-discussion] Matrix Class [was numpy release]

2008-04-24 Thread Timothy Hochberg
have all the functionality already, indeed we have it with plain old > arrays, so I think that's really beside the point. Not entirely, there's no good way do deal with arrays of matrices at present. This could be fixed by tweaking dot, but it could also be part of a reform of

Re: [Numpy-discussion] numpy release

2008-04-23 Thread Timothy Hochberg
[CHOP] The proposals thus far don't address two of the major issues I have with the matrix class: 1. The matrices and arrays should become more alike if possible and should share more of the same code base. From what I've seen, the people who write the code (for numpy) don't actually use

Re: [Numpy-discussion] ticket #605

2008-04-09 Thread Timothy Hochberg
On Wed, Apr 9, 2008 at 7:01 AM, David Huard <[EMAIL PROTECTED]> wrote: > Hello Jarrod and co., > > here is my personal version of the histogram saga. > > The current version of histogram puts in the rightmost bin all values > larger than range, but does not put in the leftmost bin all values small

Re: [Numpy-discussion] packaging scipy (was Re: Simple financial functions for NumPy)

2008-04-07 Thread Timothy Hochberg
On Mon, Apr 7, 2008 at 10:30 AM, Gael Varoquaux < [EMAIL PROTECTED]> wrote: > On Mon, Apr 07, 2008 at 10:16:22AM -0700, Timothy Hochberg wrote: > >I prefer 'all' for this since it has the correct meaning. 'api' > assuming > >that one can

Re: [Numpy-discussion] packaging scipy (was Re: Simple financial functions for NumPy)

2008-04-07 Thread Timothy Hochberg
On Mon, Apr 7, 2008 at 9:57 AM, Gael Varoquaux < [EMAIL PROTECTED]> wrote: > On Mon, Apr 07, 2008 at 06:22:28PM +0200, Stéfan van der Walt wrote: > > You're only a beginner for a short while, and after that the lack of > > namespaces really start to bite. I am all in favour of catering for > > th

Re: [Numpy-discussion] Simple financial functions for NumPy

2008-04-04 Thread Timothy Hochberg
On Fri, Apr 4, 2008 at 3:31 PM, Anne Archibald <[EMAIL PROTECTED]> wrote: > On 04/04/2008, Alan G Isaac <[EMAIL PROTECTED]> wrote: > > On Fri, 4 Apr 2008, Gael Varoquaux apparently wrote: > > > I really thing numpy should be as thin as possible, so > > > that you can really say that it is only a

Re: [Numpy-discussion] problem with float64's str()

2008-04-04 Thread Timothy Hochberg
On Fri, Apr 4, 2008 at 12:47 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Fri, Apr 4, 2008 at 9:56 AM, Will Lee <[EMAIL PROTECTED]> wrote: > > I understand the implication for the floating point comparison and the > need > > for allclose. However, I think in a doctest context, this behavior >

Re: [Numpy-discussion] Thoughts for 1.1

2008-04-02 Thread Timothy Hochberg
[SNIP] The text is getting kind of broken up so I'm chopping it and starting from scratch. To the question of whether it's a good idea to change the default behavior of mean and friends to not reduce over the chosen axis, I have to agree with Robert: too much code breakage for to little gain, so

Re: [Numpy-discussion] On Numexpr and uint64 type

2008-03-10 Thread Timothy Hochberg
On Mon, Mar 10, 2008 at 11:50 AM, Francesc Altet <[EMAIL PROTECTED]> wrote: > A Monday 10 March 2008, Charles R Harris escrigué: > > On Mon, Mar 10, 2008 at 11:08 AM, Francesc Altet <[EMAIL PROTECTED]> > wrote: > > > Hi, > > > > > > In order to allow in-kernel queries in PyTables (www.pytables.org

Re: [Numpy-discussion] calculating weighted majority using two 3D arrays

2008-03-06 Thread Timothy Hochberg
On Thu, Mar 6, 2008 at 11:37 AM, Gregory, Matthew < [EMAIL PROTECTED]> wrote: > Eads, Damian wrote: > > You may need to be a bit more specific by what you mean by > > weighted majority. What are the range of values for values > > and weights, specifically? This sounds a lot like pixel > > classifi

Re: [Numpy-discussion] numpy.correlate with phase offset 1D data series

2008-03-03 Thread Timothy Hochberg
On Mon, Mar 3, 2008 at 2:45 PM, Ray Schumacher <[EMAIL PROTECTED]> wrote: > At 01:24 PM 3/3/2008, you wrote: > > > If you use 'same' or 'full' you'll end of with different > > >amounts of offset. I imagine that this is due to the way the data is > padded. > > >The offset should be deterministic ba

Re: [Numpy-discussion] numpy.correlate with phase offset 1D data series

2008-03-03 Thread Timothy Hochberg
On Mon, Mar 3, 2008 at 12:57 PM, Ray Schumacher <[EMAIL PROTECTED]> wrote: > I'm trying to figure out what numpy.correlate does, and, what are people > using to calculate the phase shift of 1D signals? > > (I coded on routine that uses rfft, conjugate, ratio, irfft, and argmax > based on a paper

Re: [Numpy-discussion] I,J,K Coordinates from Cell ID

2008-02-28 Thread Timothy Hochberg
On Thu, Feb 28, 2008 at 1:47 PM, Andrea Gavana <[EMAIL PROTECTED]> wrote: > Hi All, > >I have some problems in figuring out a solution for an issue I am > trying to solve. I have a 3D grid of dimension Nx, Ny, Nz; for every > cell of this grid, I calculate the cell centroids (with the cell > c

Re: [Numpy-discussion] Handling of numpy.power(0, )

2008-02-28 Thread Timothy Hochberg
On Wed, Feb 27, 2008 at 4:10 PM, Stuart Brorson <[EMAIL PROTECTED]> wrote: > I have been poking at the limits of NumPy's handling of powers of > zero. I find some results which are disturbing, at least to me. > Here they are: [SNIP] > > ** 0^(x+y*i): This one is tricky; please bear with me

Re: [Numpy-discussion] numerical noise for simple calcululations

2008-02-10 Thread Timothy Hochberg
On Sun, Feb 10, 2008 at 4:23 AM, dmitrey <[EMAIL PROTECTED]> wrote: > hi all, > I need a good estimation of noise value for simple calculations. > > I.e. when I calculate something like sin(15)+cos(80) I get a solution > with precision, for example, 1e-11. > > I guess the precision depends on syst

Re: [Numpy-discussion] round, fix, ceil, and floor for complex args

2008-02-04 Thread Timothy Hochberg
On Mon, Feb 4, 2008 at 11:59 AM, Stuart Brorson <[EMAIL PROTECTED]> wrote: >round -> works fine. >ceil -> throws exception: 'complex' object has no attribute 'ceil' >floor -> throws exception: 'complex' object has no attribute 'floor' >fix -> throws exception: 'complex' object h

Re: [Numpy-discussion] numpy.asarray( iterator )

2008-02-04 Thread Timothy Hochberg
On Mon, Feb 4, 2008 at 6:56 AM, Sebastian Haase <[EMAIL PROTECTED]> wrote: > Hi, > > Can this be changed: > If I have a list L the usual N.asarray( L ) works well -- however I > just discovered that N.asarray( reversed( L ) ) breaks my code > > Apparently reversed( L ) returns an iterator ob

Re: [Numpy-discussion] round, fix, ceil, and floor for complex args

2008-02-04 Thread Timothy Hochberg
On Mon, Feb 4, 2008 at 10:34 AM, Stuart Brorson <[EMAIL PROTECTED]> wrote: > Hi -- > > I'm fiddling with NumPy's chopping and truncating operators: round, > fix, ceil, and floor. In the case where they are passed real args, > they work just fine. However, I find that when they are passed > comp

Re: [Numpy-discussion] Can not update a submatrix

2008-01-30 Thread Timothy Hochberg
On Jan 30, 2008 12:43 PM, Anne Archibald <[EMAIL PROTECTED]> wrote: > On 30/01/2008, Francesc Altet <[EMAIL PROTECTED]> wrote: > > A Wednesday 30 January 2008, Nadav Horesh escrigué: > > > In the following piece of code: > > > >>> import numpy as N > > > >>> R = N.arange(9).reshape(3,3) > > > >>>

Re: [Numpy-discussion] Vectorizing a function

2008-01-30 Thread Timothy Hochberg
On Jan 30, 2008 10:10 AM, Charles R Harris <[EMAIL PROTECTED]> wrote: [SNIP] > > IIRC, the way to do closures in Python is something like > > In [5]: def factory(x) : >...: def f() : >...: print x >...: f.x = x >...: return f >...: > > In [6]: f = factory(

Re: [Numpy-discussion] Median again

2008-01-30 Thread Timothy Hochberg
On Jan 29, 2008 5:48 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Joris De Ridder wrote: > > On 30 Jan 2008, at 00:32, Travis E. Oliphant wrote: > > > > > >> Matthew Brett wrote: > >> > >>> Hi, > >>> > >>> > >>> median moved mediandim0 > >>> implementation of medianwithaxis or simil

Re: [Numpy-discussion] RFC: out of range slice indexes

2008-01-14 Thread Timothy Hochberg
On Jan 14, 2008 12:37 PM, Neal Becker <[EMAIL PROTECTED]> wrote: > I've never liked that python silently ignores slices with out of range > indexes. I believe this is a source of bugs (it has been for me). It > goes > completely counter to the python philosophy. > > I vote to ban them from numpy

Re: [Numpy-discussion] subclassing matrix

2008-01-11 Thread Timothy Hochberg
On Jan 11, 2008 9:59 PM, Basilisk96 <[EMAIL PROTECTED]> wrote: > On Jan 11, 2008, Colin J. Williams wrote: > > > You make a good case that it's good not > > to need to ponder what sort of > > vector you are dealing with. > > > > My guess is that the answer to your > > question is "no" but I would

Re: [Numpy-discussion] Setting WRITEABLE flag on array scalar

2008-01-10 Thread Timothy Hochberg
On Jan 10, 2008 8:53 AM, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > Hi all, > > We currently use an array scalar of value False as the mask in > MaskedArray. I would like to make sure that the mask value cannot be > modified, but when I try > > import numpy as np > x = np.bool_(False) > x.f

Re: [Numpy-discussion] CASTABLE flag

2008-01-07 Thread Timothy Hochberg
On Jan 7, 2008 2:00 PM, Charles R Harris <[EMAIL PROTECTED]> wrote: > Hi, > > On Jan 7, 2008 1:16 PM, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > > Another possible approach is to treat downcasting similar to underflow. > > That is give it it

Re: [Numpy-discussion] CASTABLE flag

2008-01-07 Thread Timothy Hochberg
Another possible approach is to treat downcasting similar to underflow. That is give it it's own flag in the errstate and people can set it to ignore, warn or raise on downcasting as desired. One could potentially have two flags, one for downcasting across kinds (float->int, int->bool) and one for

Re: [Numpy-discussion] Nasty bug using pre-initialized arrays

2008-01-04 Thread Timothy Hochberg
On Jan 4, 2008 3:28 PM, Scott Ransom <[EMAIL PROTECTED]> wrote: > On Friday 04 January 2008 05:17:56 pm Stuart Brorson wrote: > > >> I realize NumPy != Matlab, but I'd wager that most users would > > >> think that this is the natural behavior.. > > > > > > Well, that behavior won't happen. We

Re: [Numpy-discussion] how do I list all combinations

2007-12-26 Thread Timothy Hochberg
Here's a baroque way to do it using generated code: def cg_combinations(seqs): n = len(seqs) chunks = ["def f(%s):" % ', '.join('s%s' % i for i in range(n))] for i in reversed(range(n)): chunks.append(" " * (n -i) + "for x%s in s%s:" % (i, i)) chunks

Re: [Numpy-discussion] assign a variable to each column of an array

2007-12-16 Thread Timothy Hochberg
On Dec 16, 2007 7:58 PM, elfnor <[EMAIL PROTECTED]> wrote: > Is there a more concise way of assigning a variable to each column of an > array? > > This works > > x,y,z = X[:,0],X[:,1],X[:,2] > > but seems clumsy. You could try: x, y, z = X.T Although some people might think that's a little obs

Re: [Numpy-discussion] numpy large arrays?

2007-12-12 Thread Timothy Hochberg
On Dec 12, 2007 7:29 AM, Søren Dyrsting <[EMAIL PROTECTED]> wrote: > Hi all > > I need to perform computations involving large arrays. A lot of rows and > no more than e.g. 34 columns. My first choice is python/numpy because I'm > already used to code in matlab. > > However I'm experiencing memory

Re: [Numpy-discussion] resize in old Numeric

2007-12-12 Thread Timothy Hochberg
On Dec 12, 2007 11:39 AM, Christian Meesters <[EMAIL PROTECTED]> wrote: > Hi, > > For compatibility reasons (work with Biopython) I would like to use to > Numeric in some code of mine. (Of course, I could make a little detour > converting into numpy.array, but first I wonder whether somebody might

Re: [Numpy-discussion] ndarray.clip only with lower or upper values?

2007-12-11 Thread Timothy Hochberg
On Dec 11, 2007 2:32 AM, Hans Meine <[EMAIL PROTECTED]> wrote: > Am Montag, 10. Dezember 2007 23:46:17 schrieb Timothy Hochberg: > > > TypeError: function takes at least 2 arguments (1 given) > > > > > > (I could simulate that by passing max = maximum_value_of(

Re: [Numpy-discussion] ndarray.clip only with lower or upper values?

2007-12-10 Thread Timothy Hochberg
On Dec 10, 2007 7:21 AM, Hans Meine <[EMAIL PROTECTED]> wrote: > Hi again, > > I noticed that clip() needs two parameters, but wouldn't it be nice and > straightforward to just pass min= or max= as keyword arg? > > In [2]: a = arange(10) > > In [3]: a.clip(min = 2, max = 5) > Out[3]: array([2, 2,

Re: [Numpy-discussion] Loading a > GB file into array

2007-12-04 Thread Timothy Hochberg
On Dec 4, 2007 3:05 AM, David Cournapeau <[EMAIL PROTECTED]> wrote: > Gael Varoquaux wrote: > > On Tue, Dec 04, 2007 at 02:13:53PM +0900, David Cournapeau wrote: > > > >> With recent kernels, you can get really good latency if you do it right > >> (around 1-2 ms worst case under high load, includi

Re: [Numpy-discussion] How can I constrain linear_least_squares to integer solutions?

2007-11-28 Thread Timothy Hochberg
On Nov 28, 2007 12:59 AM, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > On Tue, Nov 27, 2007 at 11:07:30PM -0700, Charles R Harris wrote: > > This is not a trivial problem, as you can see by googling mixed integer > least > > squares (MILS). Much will depend on the nature of the parameters, the

Re: [Numpy-discussion] how do I speed up this?

2007-11-27 Thread Timothy Hochberg
. > I guess if I can get rid of the iteration too and use some internal > function I'd probably get even faster. > Could .flat() help me somehow? I doubt it. I'll look at this a little later if I can find some time and see what I can come up with. > > > Timothy Hochberg w

Re: [Numpy-discussion] How to remove loops over inner()

2007-11-27 Thread Timothy Hochberg
On Nov 26, 2007 2:30 PM, Hans-Andreas Engel <[EMAIL PROTECTED]> wrote: > Dear all: > > After using numpy for several weeks, I am very happy about it and > deeply impressed about the performance improvements it brings in my > python code. Now I have stumbled upon a problem, where I cannot use > nu

Re: [Numpy-discussion] how do I speed up this?

2007-11-27 Thread Timothy Hochberg
On Nov 27, 2007 11:38 AM, Giorgio F. Gilestro <[EMAIL PROTECTED]> wrote: > Hello everyone, > > ma and new_ma are bi-dimensional array with shape (a1, a2) on which I am > performing the following iteration: > > for fd in range(a1): > new_ma[fd] = [( ma[fd][i-5:i+5].sum() == 0 )*1 for i in range

Re: [Numpy-discussion] array allocation using tuples gives views of same array

2007-11-15 Thread Timothy Hochberg
On Nov 15, 2007 9:11 AM, Hans Meine <[EMAIL PROTECTED]> wrote: > Am Donnerstag, 15. November 2007 16:29:12 schrieb Warren Focke: > > On Thu, 15 Nov 2007, George Nurser wrote: > > > It looks to me like > > > a,b = (zeros((2,)),)*2 > > > is equivalent to > > > x= zeros((2,)) > > > a,b=(x,)*2 > > > >

Re: [Numpy-discussion] how to assign to a "sub set" of an array

2007-11-14 Thread Timothy Hochberg
On Nov 14, 2007 9:08 AM, Sebastian Haase <[EMAIL PROTECTED]> wrote: > Hi, > First here is some test I ran, where I think the last command shows a bug: > > >>> a = N.arange(4); a.shape=2,2; a > [[0 1] > [2 3]] > >>> aa = N.array((a,a,a)); aa > [[[0 1] > [2 3]] > > [[0 1] > [2 3]] > > [[0 1] >

Re: [Numpy-discussion] Warnings as exceptions?

2007-11-13 Thread Timothy Hochberg
On Nov 13, 2007 11:48 AM, Michael McNeil Forbes <[EMAIL PROTECTED]> wrote: > On 13 Nov 2007, at 8:46 AM, Travis E. Oliphant wrote: > > > Michael McNeil Forbes wrote: > >> Why are numpy warnings printed rather than issued using the standard > >> warnings library? ... in util.py ... > > The "warn" o

Re: [Numpy-discussion] Warnings as exceptions?

2007-11-13 Thread Timothy Hochberg
On Nov 10, 2007 3:33 PM, Michael McNeil Forbes <[EMAIL PROTECTED]> wrote: > Why are numpy warnings printed rather than issued using the standard > warnings library? I know that the behaviour can be controlled by > seterr(), but it seem rather unpythonic not to use the warnings library. > > Is the

Re: [Numpy-discussion] Using arr.dtype.type to check byteorder-independed dtype fails for bool

2007-11-13 Thread Timothy Hochberg
On Nov 13, 2007 6:57 AM, Sebastian Haase <[EMAIL PROTECTED]> wrote: > On Nov 13, 2007 2:18 PM, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > > Hi Sebastian > > > > On Tue, Nov 13, 2007 at 01:11:33PM +0100, Sebastian Haase wrote: > > > Hi, > > > I need to check the array dtype in a way that it i

Re: [Numpy-discussion] SWIGed function does not like my boolean array

2007-11-08 Thread Timothy Hochberg
On Nov 8, 2007 3:28 AM, Sebastian Haase <[EMAIL PROTECTED]> wrote: > On Nov 7, 2007 6:46 PM, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > > > > > > > On Nov 7, 2007 10:35 AM, Sebastian Haase <[EMAIL PROTECTED]> wrote: > > > >

Re: [Numpy-discussion] SWIGed function does not like my boolean array

2007-11-07 Thread Timothy Hochberg
On Nov 7, 2007 10:35 AM, Sebastian Haase <[EMAIL PROTECTED]> wrote: > On Nov 7, 2007 5:23 PM, Matthieu Brucher <[EMAIL PROTECTED]> > wrote: > > > > > I don't understand. I'm thinking of most math functions in the > > > C-library. In C a boolean is just an integer of 0 or 1 (quasi, by > > > defini

Re: [Numpy-discussion] boolean masks & lists

2007-11-06 Thread Timothy Hochberg
On Nov 6, 2007 7:22 AM, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: > Mmm... > It looks as it 'mask' is being inernally converted from > [True, False, False, False, True] > to > [1, 0, 0, 0, 1] > > so your are finally getting > > x[1], x[0], x[0], x[0], x[1] That would be my guess as well. And, i

Re: [Numpy-discussion] vectorizing loops

2007-11-01 Thread Timothy Hochberg
On Nov 1, 2007 7:14 AM, David M. Cooke <[EMAIL PROTECTED]> wrote: > On Nov 1, 2007, at 08:56 , Francesc Altet wrote: > > > A Wednesday 31 October 2007, Timothy Hochberg escrigué: > >> On Oct 31, 2007 3:18 AM, Francesc Altet <[EMAIL PROTECTED]> wrote: > >>

Re: [Numpy-discussion] matrix problem: float to matrix power

2007-11-01 Thread Timothy Hochberg
On Nov 1, 2007 12:20 PM, Alan G Isaac <[EMAIL PROTECTED]> wrote: > On Wed, 31 Oct 2007, Timothy Hochberg apparently wrote: > > because M**n results in the matrix power of n. It would be > > confusing if n**M did a broadcast element wise power. > > > > In an at

Re: [Numpy-discussion] vectorizing loops

2007-10-31 Thread Timothy Hochberg
On Oct 31, 2007 3:18 AM, Francesc Altet <[EMAIL PROTECTED]> wrote: [SNIP] > Incidentally, all the improvements of the PyTables flavor of numexpr > have been reported to the original authors, but, for the sake of > keeping numexpr simple, they decided to implement only some of them. > However, peo

Re: [Numpy-discussion] matrix problem: float to matrix power

2007-10-31 Thread Timothy Hochberg
On Oct 30, 2007 11:40 PM, Alan G Isaac <[EMAIL PROTECTED]> wrote: > >>> 1.0**numpy.array([1,2,3]) > array([ 1., 1., 1.]) > >>> 1.0**numpy.mat([1,2,3]) > Traceback (most recent call last): > File "", line 1, in > TypeError: unsupported operand type(s) for ** or pow(): 'float' and 'matrix' > > W

Re: [Numpy-discussion] vectorizing loops

2007-10-29 Thread Timothy Hochberg
On 10/29/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > > >> (incidently, the kind of things 'we' are doing seem like the most > > simple things to JIT). > > Wouldn't a numpy-aware psyco be cool then? > > Oh well, I'm not going to write it! > > (though as I think about it, for the special case

Re: [Numpy-discussion] Getting an item in an array with its coordinates given by another array

2007-10-29 Thread Timothy Hochberg
On 10/28/07, Matthieu Brucher <[EMAIL PROTECTED]> wrote: > > > Little correction, only c[(2,3)] gives me what I expect, not c[[2,3]], > > which > > > is even stranger. > > > > c[(2,3)] is the same as c[2,3] and obviously works as you expected. > > > > Well, this is not indicated in the documentatio

Re: [Numpy-discussion] Request for advice: project to get NumPy working in IronPython

2007-10-26 Thread Timothy Hochberg
On 10/26/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > On 10/26/07, dmitrey <[EMAIL PROTECTED]> wrote: > > Travis E. Oliphant wrote: > > > Giles Thomas wrote: > > > > > >> Hi, > > >> > > >> At Resolver Systems, we have a product that is written in IronPython > - > > >> the .NET Python impleme

Re: [Numpy-discussion] vectorizing loops

2007-10-26 Thread Timothy Hochberg
On 10/26/07, Sebastian Haase <[EMAIL PROTECTED]> wrote: > > On 10/26/07, David Cournapeau <[EMAIL PROTECTED]> wrote: > > P.S: IMHO, this is one of the main limitation of numpy (or any language > > using arrays for speed; and this is really difficult to optimize: you > > need compilation, JIT or sim

Re: [Numpy-discussion] C-API for non-contiguous arrays

2007-10-25 Thread Timothy Hochberg
On 10/25/07, Oliver Kranz <[EMAIL PROTECTED]> wrote: > > Hi, > > I am working on a Python extension module using of the NumPy C-API. The > extension module is an interface to an image processing and analysis > library written in C++. The C++ functions are exported with > boos::python. Currently I a

Re: [Numpy-discussion] A basic question on the dot function

2007-10-16 Thread Timothy Hochberg
On 10/16/07, Julien Hillairet <[EMAIL PROTECTED]> wrote: > > 2007/10/16, Bill Baxter <[EMAIL PROTECTED]>: > > > > dot() also serves as Numpy's matrix multiply function. So it's trying > > to interpret that as a (3,N) matrix times a (3,N) matrix. > > > > See examples here: > > > > http://www.scipy.

Re: [Numpy-discussion] appending extra items to arrays

2007-10-11 Thread Timothy Hochberg
On 10/10/07, Anne Archibald <[EMAIL PROTECTED]> wrote: > > On 11/10/2007, Robert Kern <[EMAIL PROTECTED]> wrote: > > > Appending to a list then converting the list to an array is the most > > straightforward way to do it. If the performance of this isn't a > problem, I > > recommend leaving it alon

Re: [Numpy-discussion] indexing bug?

2007-10-03 Thread Timothy Hochberg
On 10/3/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > > Stefan van der Walt wrote: > >> The current behavior is consistent and well > >>> defined: > >>> a[x] == a[int(x)] > > This is all possible because of PEP 357: I think that the current behavior has always been possible; arbitrary objec

Re: [Numpy-discussion] adopting Python Style Guide for classes

2007-10-02 Thread Timothy Hochberg
On 10/2/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > > Jarrod Millman wrote: > > I am hoping that most of you agree with the general principle of > > bringing NumPy and SciPy into compliance with the standard naming > > conventions. > > +1 > > > 3. When we release NumPy 1.1, we will convert

Re: [Numpy-discussion] Naming a slice index?

2007-10-01 Thread Timothy Hochberg
On 10/1/07, Eagle Jones <[EMAIL PROTECTED]> wrote: > > New to python and numpy; hopefully I'm missing something obvious. I'd > like to be able to slice an array with a name. For example: > > _T = 6:10 > _R = 10:15 > A = identity(20) > foo = A[_T, _R] > > This doesn't work. Nor does _T=range(6:10);

Re: [Numpy-discussion] What approach is used in linalg.solve ?

2007-09-21 Thread Timothy Hochberg
If you take a look at the source of numpy's linalg.py, you'll see that solves uses dgesv /zgesv for real /complex solves. If you Google dgesv, you get: DGESV computes the solution to a real system of linear equations A * X = B, where A is an N-by-N matrix and X and B are N-by-NRHS m

Re: [Numpy-discussion] Is this a bug?

2007-09-16 Thread Timothy Hochberg
On 9/16/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > I note a small inconsistency in the use of the out keyword in some > functions: > > >>> a=array(0) > >>> sometrue([1],out=a).shape > () > >>> a=array([0]) > >>> sometrue([1],out=a).shape > (1,) > >>> a=array([[0]]) > >>> sometrue([1],out=a

Re: [Numpy-discussion] arange and floating point arguments

2007-09-14 Thread Timothy Hochberg
On 9/14/07, Joris De Ridder <[EMAIL PROTECTED]> wrote: > > > > > the question is how to reduce user astonishment. > > IMHO this is exactly the point. There seems to be two questions here: > 1) do we want to reduce user astonishment, and 2) if yes, how could > we do this? Not everyone seems to be co

Re: [Numpy-discussion] Slicing/selection in multiple dimensions simultaneously

2007-09-11 Thread Timothy Hochberg
On 9/11/07, Robert Kern <[EMAIL PROTECTED]> wrote: > > Mike Ressler wrote: > > The following seems to be a wart: is it expected? > > > > Set up a 10x10 array and some indexing arrays: > > > > a=arange(100) > > a.shape=(10,10) > > q=array([0,2,4,6,8]) > > r=array([0,5]) > > > > Suppose I want to ext

Re: [Numpy-discussion] odd behavior for numpy.ndarray index?

2007-09-09 Thread Timothy Hochberg
On 9/9/07, Orest Kozyar <[EMAIL PROTECTED]> wrote: > > In the following output (see below), why would x[1,None] work, but > x[1,None,2] or even x[1,2,None] not work? None is the same thing as newaxis (newaxis is just an alias for None). Armed with that tidbit, a little perusing of the docs should

Re: [Numpy-discussion] 2-d in-place operation performance vs 1-d non in-place

2007-09-06 Thread Timothy Hochberg
On 9/6/07, George Sakkis <[EMAIL PROTECTED]> wrote: > > On Sep 5, 12:29 pm, Francesc Altet <[EMAIL PROTECTED]> wrote: > > A Wednesday 05 September 2007, George Sakkis escrigué: > > > > > > > > > I was surprised to see that an in-place modification of a 2-d array > > > turns out to be slower from th

Re: [Numpy-discussion] Bug in resize method?

2007-08-29 Thread Timothy Hochberg
On 8/29/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > I still don't see why the method is needed at all. Given the conditions on > the array, the only thing it buys you over the resize function or a reshape > is the automatic deletion of the old memory if new memory is allocated. > Can you

Re: [Numpy-discussion] Bug in resize method?

2007-08-29 Thread Timothy Hochberg
On 8/29/07, Anne Archibald <[EMAIL PROTECTED]> wrote: > > On 29/08/2007, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > The main inconsistency I see above is that resize appears to only > require > > ownership of the data if in fact the number of items

Re: [Numpy-discussion] Bug in resize method?

2007-08-29 Thread Timothy Hochberg
On 8/29/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > On 8/29/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > > > > Charles R Harris wrote: > > > What *should* the resize method do? It looks like > > > it is equivalent to assigning a shape tuple to a.shape, > > > > No, that's what res

Re: [Numpy-discussion] comparing arrays with NaN in them.

2007-08-24 Thread Timothy Hochberg
On 8/24/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > On 8/24/07, Christopher Barker <[EMAIL PROTECTED]> wrote: > [SNIP] > > > > You can have several different NaN, > > > > You can? I thought NaN was defined by IEEE 754 as a particu

Re: [Numpy-discussion] comparing arrays with NaN in them.

2007-08-24 Thread Timothy Hochberg
On 8/24/07, Christopher Barker <[EMAIL PROTECTED]> wrote: [SNIP] > You can have several different NaN, > > You can? I thought NaN was defined by IEEE 754 as a particular bit > pattern (one for each precision, anyway). There's more than one way to spell NaN in binary and they tend to mean diffe

Re: [Numpy-discussion] "Extended" Outer Product

2007-08-21 Thread Timothy Hochberg
On 8/21/07, Anne Archibald <[EMAIL PROTECTED]> wrote: > > On 21/08/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > This is just a general comment on recent threads of this type and not > > directed specifically at Chuck or anyone else. > > > > I

Re: [Numpy-discussion] "Extended" Outer Product

2007-08-21 Thread Timothy Hochberg
On 8/21/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > > On 8/21/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > > > > > On 8/21/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > > > > > > >

Re: [Numpy-discussion] "Extended" Outer Product

2007-08-21 Thread Timothy Hochberg
On 8/21/07, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > On 8/20/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > > > > Hi Everyone, > > > > I am wondering if there is an "extended" outer product. Take the > > example in "Guide to Numpy." Instead of doing an multiplication, I > > want to call a

Re: [Numpy-discussion] numpy.array does not take generators

2007-08-17 Thread Timothy Hochberg
On 8/17/07, Barry Wark <[EMAIL PROTECTED]> wrote: > > Is there a reason not to add an argument to fromiter that specifies > the final size of the n-d array? Reading this discussion, I realized > that there are several places in my code where I create 2-D arrays > like this: > > arr = N.array([d.dat

Re: [Numpy-discussion] vectorized function inside a class

2007-08-08 Thread Timothy Hochberg
On 8/8/07, mark <[EMAIL PROTECTED]> wrote: > > I am trying to figure out a way to define a vectorized function inside > a class. > This is what I tried: > > class test: > def __init__(self): > self.x = 3.0 > def func(self,y): > rv = self.x >

Re: [Numpy-discussion] How to implement a 'pivot table?'

2007-08-06 Thread Timothy Hochberg
Nicely done Travis. Working code is always better than theory. I copied your interface and used the brute-force, non-numpy approach to construct the pivot table. On the one hand, it doesn't preserve the order that the entires are discovered in as the original does. On the other hand, it's about 40%

Re: [Numpy-discussion] reference leacks in numpy.asarray

2007-08-02 Thread Timothy Hochberg
On 8/2/07, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: > > using numpy-1.0.3, I believe there are a reference leak somewhere. > Using a debug build of Python 2.5.1 (--with-pydebug), I get the > following > > import sys, gc > import numpy > > def testleaks(func, args=(), kargs={}, repeats=5): > f

Re: [Numpy-discussion] Unpleasant behavior with poly1d and numpy scalar multiplication

2007-07-31 Thread Timothy Hochberg
On 7/31/07, Fernando Perez <[EMAIL PROTECTED]> wrote: > > Hi all, > > consider this little script: > > from numpy import poly1d, float, float32 > p=poly1d([1.,2.]) > three=float(3) > three32=float32(3) > > print 'three*p:',three*p > print 'three32*p:',three32*p > print 'p*three32:',p*three32 > > >

Re: [Numpy-discussion] simple problem with arange / roundoff

2007-07-31 Thread Timothy Hochberg
On 7/31/07, Eric Emsellem <[EMAIL PROTECTED]> wrote: > > Hi, > > I discovered a bug in one of my program probably due to a round-off > problem in a "arange" statement. > I use something like: > > step = (end - start) / (npix - 1.) > gridX = num.arange(start-step/2., end+step/2., step) > > where I w

Re: [Numpy-discussion] How to implement a 'pivot table?'

2007-07-31 Thread Timothy Hochberg
On 7/30/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > > Hi Timothy, > > On 7/30/07, Timothy Hochberg <[EMAIL PROTECTED]> wrote: > > > > > > On 7/30/07, Geoffrey Zhu <[EMAIL PROTECTED] > wrote: > > > Hi Everyone, > > > > >

Re: [Numpy-discussion] How to implement a 'pivot table?'

2007-07-30 Thread Timothy Hochberg
On 7/30/07, Geoffrey Zhu <[EMAIL PROTECTED]> wrote: > > Hi Everyone, > > I am wondering what is the best (and fast) way to build a pivot table > aside from the 'brute force way?' What's the brute force way? It's easier to offer an improved suggestion if we know what we're trying to beat. I want

Re: [Numpy-discussion] expm

2007-07-20 Thread Timothy Hochberg
On 7/20/07, Kevin Jacobs <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: On 7/20/07, Kevin Jacobs <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: > > On 7/20/07, Charles R Harris < [EMAIL PROTECTED]> wrote: > > > > I expect using sqrt(x) will be faster than x**.5. > > > > I did test this at one po

Re: [Numpy-discussion] expm

2007-07-20 Thread Timothy Hochberg
On 7/20/07, Charles R Harris <[EMAIL PROTECTED]> wrote: [SNIP] I expect using sqrt(x) will be faster than x**.5. You might want to check that. I believe that x**0.5 is one of the magic special cases that is optimized to run fast (by calling sqrt in this case). IIRC the full set is [-1, 0, 0

Re: [Numpy-discussion] Pickle, pytables, and sqlite - loading and saving recarray's

2007-07-20 Thread Timothy Hochberg
On 7/20/07, Vincent Nijs <[EMAIL PROTECTED]> wrote: Gael, Sounds very interesting! Would you mind sharing an example (with code if possible) of how you organize your experimental data in pytables. I have been thinking about how I might organize my data in pytables and would luv to hear how an e

Re: [Numpy-discussion] What is the different between nanmin and min ?

2007-07-18 Thread Timothy Hochberg
On 7/18/07, Robert Kern <[EMAIL PROTECTED]> wrote: Timothy Hochberg wrote: > The time is one issue. Another is that ignoring NaNs is only correct if > you are treating NaNs as missing values. If instead you are treating > them as non numbers, the results of some bogus computatio

  1   2   >