Re: [Numpy-discussion] Funny business with 'is' operator?

2013-09-06 Thread James Bergstra
: On Fri, Sep 6, 2013 at 10:19 AM, James Bergstra bergs...@iro.umontreal.ca wrote: Hi, could someone help me understand why this assertion fails? def test_is(self): a = np.empty(1) b = np.empty(1) if a.data is not b.data: assert id(a.data) != id(b.data) # -- fail I'm

[Numpy-discussion] Funny business with 'is' operator?

2013-09-06 Thread James Bergstra
Hi, could someone help me understand why this assertion fails? def test_is(self): a = np.empty(1) b = np.empty(1) if a.data is not b.data: assert id(a.data) != id(b.data) # -- fail I'm trying to write an alternate may_share_memory function. Thanks, - James

Re: [Numpy-discussion] Funny business with 'is' operator?

2013-09-06 Thread James Bergstra
wrote: On Fri, Sep 6, 2013 at 5:58 PM, James Bergstra bergs...@iro.umontreal.ca wrote: I'm stumped. I can't figure out how to extract from e.g. view = A[:, 3] that the view starts at element 3 of A. I was planning to make a may_share_memory implementation based on the idea of swapping

Re: [Numpy-discussion] Funny business with 'is' operator?

2013-09-06 Thread James Bergstra
at 12:48 PM, James Bergstra bergs...@iro.umontreal.cawrote: Thanks for the tips! FWIW my guess is that since '.data' is dynamically generated property rather than an attribute, it is being freed and re-allocated in the loop, and once for each of my id() expressions. On Fri, Sep 6, 2013 at 12

Re: [Numpy-discussion] automatic differentiation with PyAutoDiff

2012-06-14 Thread James Bergstra
On Thu, Jun 14, 2012 at 4:00 AM, Olivier Grisel olivier.gri...@ensta.org wrote: 2012/6/13 James Bergstra bergs...@iro.umontreal.ca: Further to the recent discussion on lazy evaluation numba, I moved what I was doing into a new project: PyAutoDiff: https://github.com/jaberg/pyautodiff

Re: [Numpy-discussion] automatic differentiation with PyAutoDiff

2012-06-14 Thread James Bergstra
On Thu, Jun 14, 2012 at 3:38 PM, Nathaniel Smith n...@pobox.com wrote: On Thu, Jun 14, 2012 at 7:53 PM, James Bergstra bergs...@iro.umontreal.ca wrote: On Thu, Jun 14, 2012 at 11:01 AM, Nathaniel Smith n...@pobox.com wrote: Indeed that would be great as sympy already has already excellent

Re: [Numpy-discussion] automatic differentiation with PyAutoDiff

2012-06-14 Thread James Bergstra
On Thu, Jun 14, 2012 at 4:22 PM, srean srean.l...@gmail.com wrote: For example, I wrote a library routine for doing log-linear regression. Doing this required computing the derivative of the likelihood function, which was a huge nitpicky hassle; took me a few hours to work out and debug. But

Re: [Numpy-discussion] automatic differentiation with PyAutoDiff

2012-06-14 Thread James Bergstra
On Thu, Jun 14, 2012 at 5:53 PM, Nathaniel Smith n...@pobox.com wrote: On Thu, Jun 14, 2012 at 9:22 PM, srean srean.l...@gmail.com wrote: No, I'm saying I totally see the advantages. Here's the code I'm talking about:    def _loglik(self, params):        alpha, beta =

[Numpy-discussion] automatic differentiation with PyAutoDiff

2012-06-13 Thread James Bergstra
Further to the recent discussion on lazy evaluation numba, I moved what I was doing into a new project: PyAutoDiff: https://github.com/jaberg/pyautodiff It currently works by executing CPython bytecode with a numpy-aware engine that builds a symbolic expression graph with Theano... so you can

Re: [Numpy-discussion] lazy evaluation

2012-06-11 Thread James Bergstra
On Mon, Jun 11, 2012 at 12:03 AM, James Bergstra bergs...@iro.umontreal.ca wrote: If anyone is interested in my ongoing API bytecode adventure in why / how lazy computing could be useful, I've put together a few tiny hypothetically-runnable examples here: https://github.com/jaberg/numba/tree

Re: [Numpy-discussion] lazy evaluation

2012-06-10 Thread James Bergstra
Hi all, (sorry for missing the debate, I don't often check my numpy-list folder.) I agree that an official numpy solution to this problem is premature, but at the same time I think the failure to approach anything remotely resembling a consensus on how to deal with lazy evaluation is really

[Numpy-discussion] bincount([], minlength=2) should work right?

2012-02-25 Thread James Bergstra
bincount([]) makes no sense, but if a minlength argument is provided, then the routine should succeed. It fails in 1.6.1, has it been fixed in master? - James -- http://www-etud.iro.umontreal.ca/~bergstrj ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] bincount([], minlength=2) should work right?

2012-02-25 Thread James Bergstra
On Sat, Feb 25, 2012 at 5:13 PM, Alan G Isaac alan.is...@gmail.com wrote: On 2/25/2012 4:44 PM, James Bergstra wrote: bincount([]) makes no sense, I disagree: http://permalink.gmane.org/gmane.comp.python.numeric.general/42041 gmane is down to me at the moment, but if this argues

Re: [Numpy-discussion] ndarray and lazy evaluation

2012-02-20 Thread James Bergstra
# re-run the compiled expression on the new value a, b = expr.run() - JB -- James Bergstra, Ph.D. Research Scientist Rowland Institute, Harvard University ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo

Re: [Numpy-discussion] ndarray and lazy evaluation

2012-02-20 Thread James Bergstra
On Mon, Feb 20, 2012 at 1:01 PM, James Bergstra james.bergs...@gmail.comwrote: On Mon, Feb 20, 2012 at 12:28 PM, Francesc Alted franc...@continuum.iowrote: On Feb 20, 2012, at 6:18 PM, Dag Sverre Seljebotn wrote: You need at least a slightly different Python API to get anywhere, so numexpr

Re: [Numpy-discussion] Proposed Roadmap Overview

2012-02-20 Thread James Bergstra
Looks like Dag forked the discussion of lazy evaluation to a new thread ([Numpy-discussion] ndarray and lazy evaluation). There are actually several projects inspired by this sort of design: off the top of my head I can think of Theano, copperhead, numexpr, arguably sympy, and some non-public

Re: [Numpy-discussion] ndarray and lazy evaluation

2012-02-20 Thread James Bergstra
On Mon, Feb 20, 2012 at 2:57 PM, Lluís xscr...@gmx.net wrote: James Bergstra writes: [...] I should add that the biggest benefit of expressing things as compound expressions in this way is not in saving temporaries (though that is nice) it's being able to express enough computation work

Re: [Numpy-discussion] potential bug in PyArray_MoveInto and PyArray_CopyInto?

2011-07-08 Thread James Bergstra
On Thu, Jul 7, 2011 at 4:59 PM, James Bergstra bergs...@iro.umontreal.ca wrote: On Thu, Jul 7, 2011 at 1:10 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Thu, Jul 7, 2011 at 11:03 AM, James Bergstra bergs...@iro.umontreal.ca wrote: In numpy 1.5.1,  the functions PyArray_MoveInto

[Numpy-discussion] potential bug in PyArray_MoveInto and PyArray_CopyInto?

2011-07-07 Thread James Bergstra
In numpy 1.5.1,  the functions PyArray_MoveInto and PyArray_CopyInto don't appear to treat strides correctly. Evidence: PyNumber_InPlaceAdd(dst, src), and modifies the correct subarray to which dst points. In the same context, PyArray_MoveInto(dst, src) modifies the first two rows of the

Re: [Numpy-discussion] potential bug in PyArray_MoveInto and PyArray_CopyInto?

2011-07-07 Thread James Bergstra
On Thu, Jul 7, 2011 at 1:10 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Thu, Jul 7, 2011 at 11:03 AM, James Bergstra bergs...@iro.umontreal.ca wrote: In numpy 1.5.1,  the functions PyArray_MoveInto and PyArray_CopyInto don't appear to treat strides correctly. Evidence

[Numpy-discussion] numpy.max(0, 1e-6) == 0 (!?)

2011-01-18 Thread James Bergstra
I find that numpy.max(0, 1e-6) == 0 is confusing, because it makes bugs hard to spot. The doc says that the second argument to max is an optional integer. My bad. But could the function raise an error if it is passed an invalid 'axis' argument? That would have helped. James --

Re: [Numpy-discussion] Math Library

2010-04-14 Thread James Bergstra
On Tue, Apr 6, 2010 at 10:08 AM, David Cournapeau wrote: could be put out of multiarray proper. Also, exposing an API for things like fancy indexing would be very useful, but I don't know if it even makes sense - I think a pure python implementation of fancy indexing as a reference would be

Re: [Numpy-discussion] [OT] Starving CPUs article featured in IEEE's ComputingNow portal

2010-03-22 Thread James Bergstra
and it will instead use an available CUDA- capable Nvidia GPU instead of the CPU. I'll admit, when James Bergstra initially told me about this plan to make it possible to transparently switch to running stuff on the GPU, I thought it was so ambitious that it would never happen. Then it did

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-03 Thread James Bergstra
Thanks all for your help, I think I'm on my way again. The catch in the first place was not being confident that a PyArray_Scalar was the thing I needed. I grep'd the code for uint8, int8 and so on and could not find their definitions. On first reading I overlooked the PyArray_Scalar link in

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Mon, Mar 1, 2010 at 1:44 AM, David Cournapeau courn...@gmail.com wrote: On Mon, Mar 1, 2010 at 1:35 PM, James Bergstra bergs...@iro.umontreal.ca wrote: Could someone point me to documentation (or even numpy src) that shows how to allocate a numpy.int8 in C, or check to see if a PyObject

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker chris.bar...@noaa.gov wrote: James Bergstra wrote: Maybe I'm missing something... but I don't think I want to create an array. In [3]: import numpy In [4]: type(numpy.int8()) Out[4]: type 'numpy.int8' In [5]: isinstance(numpy.int8

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Tue, Mar 2, 2010 at 7:18 PM, Warren Weckesser warren.weckes...@enthought.com wrote: James Bergstra wrote: On Tue, Mar 2, 2010 at 3:09 PM, Christopher Barker chris.bar...@noaa.gov wrote: James Bergstra wrote: Maybe I'm missing something... but I don't think I want to create an array

Re: [Numpy-discussion] how to work with numpy.int8 in c

2010-03-02 Thread James Bergstra
On Tue, Mar 2, 2010 at 7:32 PM, David Warde-Farley d...@cs.toronto.edu wrote: On 2-Mar-10, at 7:23 PM, James Bergstra wrote: Sorry... again... how do I make such a scalar... *in C* ?  What would be the recommended C equivalent of this python code?  Are there C type-checking functions

[Numpy-discussion] how to work with numpy.int8 in c

2010-02-28 Thread James Bergstra
Could someone point me to documentation (or even numpy src) that shows how to allocate a numpy.int8 in C, or check to see if a PyObject is a numpy.int8? Thanks, James -- http://www-etud.iro.umontreal.ca/~bergstrj ___ NumPy-Discussion mailing list

[Numpy-discussion] problem w 32bit binomial?

2010-02-25 Thread James Bergstra
In case this hasn't been solved in more recent numpy... I've tried the following lines on two installations of numpy 1.3 with python 2.6  numpy.random.binomial(n=numpy.asarray([2,3,4], dtype='int64'), p=numpy.asarray([.1, .2, .3], dtype='float64')) A 64bit computer gives an output of array

Re: [Numpy-discussion] convert strides/shape/offset into nd index?

2009-11-30 Thread James Bergstra
Your question involves a few concepts: - an integer vector describing the position of an element - the logical shape (another int vector) - the physical strides (another int vector) Ignoring the case of negative offsets, a physical offset is the inner product of the physical strides with the

Re: [Numpy-discussion] Unexpected attribute error

2009-11-18 Thread James Bergstra
On Tue, Nov 17, 2009 at 9:53 PM, Robert Kern robert.k...@gmail.com wrote: On Tue, Nov 17, 2009 at 20:48, James Bergstra bergs...@iro.umontreal.ca wrote: Is it by design that  numpy.sqrt(None) raises an AttributeError: sqrt? Yes. numpy.sqrt() is a ufunc. Ufuncs take their arguments and try

[Numpy-discussion] Unexpected attribute error

2009-11-17 Thread James Bergstra
Is it by design that  numpy.sqrt(None) raises an AttributeError: sqrt? This was confusing because there was an attribute lookup of 'sqrt' in numpy right there in the expression I typed, but that was not the attribute that python was complaining about.  I presume that numpy.sqrt didn't know what

Re: [Numpy-discussion] finding close together points.

2009-11-10 Thread James Bergstra
On Tue, Nov 10, 2009 at 7:07 PM, Christopher Barker chris.bar...@noaa.gov wrote: Hi all, I have a bunch of points in 2-d space, and I need to find out which pairs of points are within a certain distance of one-another (regular old Euclidean norm). scipy.spatial.KDTree.query_ball_tree()

Re: [Numpy-discussion] finding close together points.

2009-11-10 Thread James Bergstra
On Tue, Nov 10, 2009 at 8:17 PM, Christopher Barker chris.bar...@noaa.gov wrote: James Bergstra wrote: In some cases a brute-force approach is also good. true. If r is a matrix of shape Nx2: (r*r).sum(axis=1) -2 * numpy.dot(r, r.T) + (r*r).sum(axis=1).reshape((r.shape[0], 1)) thresh**2

Re: [Numpy-discussion] type 'numpy.int64' unhashable

2009-10-30 Thread James Bergstra
On Fri, Oct 30, 2009 at 7:23 AM, Gael Varoquaux gael.varoqu...@normalesup.org wrote: On Fri, Oct 30, 2009 at 08:21:16PM +0900, David Cournapeau wrote: On Fri, Oct 30, 2009 at 8:04 PM, Sebastian Haase seb.ha...@gmail.com wrote: I understand where this error comes from, however what I was

Re: [Numpy-discussion] Fwd: GPU Numpy

2009-09-09 Thread James Bergstra
On Wed, Sep 9, 2009 at 10:41 AM, Francesc Alted fal...@pytables.org wrote: Numexpr mainly supports functions that are meant to be used element-wise, so the operation/element ratio is normally 1 (or close to 1). In these scenarios is where improved memory access is much more important than CPU

Re: [Numpy-discussion] Accelerating NumPy computations [Was: GPU Numpy]

2009-08-21 Thread James Bergstra
On Fri, Aug 21, 2009 at 2:51 PM, Matthew Brettmatthew.br...@gmail.com wrote: I can imagine Numpy being useful for scripting in this C-and-assembler-centric world, making it easier to write automated testers, or even generate C code. Is anyone out there working on this kind of stuff?  I ask

[Numpy-discussion] Fwd: GPU Numpy

2009-08-06 Thread James Bergstra
David Warde-Farley dwf at cs.toronto.edu writes: It did inspire some of our colleagues in Montreal to create this, though:      http://code.google.com/p/cuda-ndarray/ I gather it is VERY early in development, but I'm sure they'd love contributions! Hi David, That does look quite close to

Re: [Numpy-discussion] Fwd: GPU Numpy

2009-08-06 Thread James Bergstra
On Thu, Aug 6, 2009 at 1:19 PM, Charles R Harrischarlesr.har...@gmail.com wrote: I almost looks like you are reimplementing numpy, in c++ no less. Is there any reason why you aren't working with a numpy branch and just adding ufuncs? I don't know how that would work. The Ufuncs need a

Re: [Numpy-discussion] Fwd: GPU Numpy

2009-08-06 Thread James Bergstra
On Thu, Aug 6, 2009 at 4:57 PM, Sturla Moldenstu...@molden.no wrote: Now linear algebra or FFTs on a GPU would probably be a huge boon, I'll admit - especially if it's in the form of a drop-in replacement for the numpy or scipy versions. NumPy generate temporary arrays for expressions