[Numpy-discussion] Keyword argument support for vectorize.

2012-04-06 Thread Michael McNeil Forbes
Hi, I added a simple enhancement patch to provide vectorize with simple keyword argument support. (I added a new kwvectorize decorator, but suspect this could/should easily be rolled into the existing vectorize.) http://projects.scipy.org/numpy/ticket/2100 This just reorders any kwargs

Re: [Numpy-discussion] Keyword argument support for vectorize.

2012-04-09 Thread Michael McNeil Forbes
as well. http://mail.scipy.org/pipermail/numpy-discussion/2010-September/052642.html Michael. On Sat, Apr 7, 2012 at 12:18 AM, Michael McNeil Forbes michael.for...@gmail.com wrote: Hi, I added a simple enhancement patch to provide vectorize with simple keyword argument support. (I added

Re: [Numpy-discussion] Keyword argument support for vectorize.

2012-04-13 Thread Michael McNeil Forbes
On 9 Apr 2012, at 3:02 AM, Nathaniel Smith wrote: functools was added in Python 2.5, and so far numpy is still trying to maintain 2.4 compatibility. Thanks: I forgot about that. I have attached a 2.4 compatible patch, updated docs, and tests for review to ticket #2100. This also includes

[Numpy-discussion] Arguments silently ignored (kwargs) in meshgrid etc.

2014-05-28 Thread Michael McNeil Forbes
I just noticed that meshgrid() silently ignore extra arguments. It just burned me (I forgot that it is meshgrid(indexing='ij') and tried meshgrid(indices='ij') which subtly broke my code.) Is this intentional? I don't see why `meshgrid` does not have explicit arguments. If this is not a

Re: [Numpy-discussion] Arguments silently ignored (kwargs) in meshgrid etc.

2014-05-29 Thread Michael McNeil Forbes
On May 29, 2014, at 1:41 AM, Ralf Gommers ralf.gomm...@gmail.com wrote: On Thu, May 29, 2014 at 5:35 AM, Michael McNeil Forbes michael.forbes+pyt...@gmail.com wrote: I just noticed that meshgrid() silently ignore extra arguments. It just burned me (I forgot that it is meshgrid(indexing='ij

Re: [Numpy-discussion] Arguments silently ignored (kwargs) in meshgrid etc.

2014-05-29 Thread Michael McNeil Forbes
On May 29, 2014, at 3:16 PM, Michael McNeil Forbes michael.forbes+pyt...@gmail.com wrote: On May 29, 2014, at 1:41 AM, Ralf Gommers ralf.gomm...@gmail.com wrote: On Thu, May 29, 2014 at 5:35 AM, Michael McNeil Forbes michael.forbes+pyt...@gmail.com wrote: I just noticed that meshgrid

[Numpy-discussion] take semantics (bug?)

2006-12-03 Thread Michael McNeil Forbes
What are the semantics of the take function? I would have expected that the following have the same shape and size: a = array([1,2,3]) inds = a.nonzero() a[inds] array([1, 2, 3]) a.take(inds) array([[1, 2, 3]]) Is there a bug somewhere here or is this intentional? Michael.

[Numpy-discussion] Suppressing nesting (recursion, descent) in array construction.

2007-06-20 Thread Michael McNeil Forbes
Hi, I have a list of tuples that I am using as keys and I would like to sort this along with some other arrays using argsort. How can I do this? I would like to do something like: # These are constructed using lists because they accumulate using append() data = [1.0, 3,0] keys =

Re: [Numpy-discussion] Suppressing nesting (recursion, descent) in array construction.

2007-06-20 Thread Michael McNeil Forbes
) key_array[:] = keys[:] inds = argsort(data) data_array[:] = data[inds] key_array[:] = keys[inds] Thanks! Michael. On 20 Jun 2007, at 4:57 AM, Francesc Altet wrote: El dc 20 de 06 del 2007 a les 01:38 -0700, en/na Michael McNeil Forbes va escriure: Hi, I have a list of tuples that I am using

Re: [Numpy-discussion] Suppressing nesting (recursion, descent) in array construction.

2007-06-20 Thread Michael McNeil Forbes
. The problem can be solved by creating an empty array first, then copying. Thanks, Michael. On 6/20/07, Michael McNeil Forbes [EMAIL PROTECTED] wrote: Hi, I have a list of tuples that I am using as keys and I would like to sort this along with some other arrays using argsort. How can I do

[Numpy-discussion] Warning or error on conversion from complex to float.

2007-11-08 Thread Michael McNeil Forbes
Hi, Is it possible or easy to add a warning and/or error when array assignments are made that lose information? I just got caught with the following type of code: def f(): return numpy.array([1j,2.0]) x = numpy.empty((2,),dtype=float) x[:] = f() I am pre-allocating arrays for speed,

[Numpy-discussion] Warnings as exceptions?

2007-11-10 Thread Michael McNeil Forbes
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 there an explicit reason for this choice? (It seems like a pretty trivial

Re: [Numpy-discussion] Warnings as exceptions?

2007-11-13 Thread Michael McNeil Forbes
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 option explicitly allows you to use the warnings library. There is already the print mode

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2007-11-15 Thread Michael McNeil Forbes
On 15 Nov 2007, at 2:45 AM, David Cournapeau wrote: Which fortran compiler are you using ? GNU Fortran (GCC) 3.4.6 20060404 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2007-11-15 Thread Michael McNeil Forbes
On 13 Nov 2007, at 9:43 AM, Geoffrey Zhu wrote: On Nov 13, 2007 2:37 AM, David Cournapeau [EMAIL PROTECTED] u.ac.jp wrote: Geoffrey Zhu wrote: Pointer problems are usually random... ... The original MSI version hangs on numpy.test() if I open IDLE and type import numpy numpy.test() If I

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2007-11-15 Thread Michael McNeil Forbes
I have also been having random problems with the latest numpy from svn built on an Intel core 2 Duo Linux box running in 64 bit mode under Red Hat 3.4.6-8 with the gcc 3.4.6 20060404 and ATLAS 3.8.0. Could you try without atlas ? Also, how did you configure atlas when building it ? It seems

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2007-11-16 Thread Michael McNeil Forbes
On 15 Nov 2007, at 8:23 PM, David Cournapeau wrote: Could you try without atlas ? Also, how did you configure atlas when building it ? It seems that atlas is definitely part of the problem (everybody having the problem does use atlas), and that it involves Core 2 duo. David It seems to

[Numpy-discussion] Should array iterate over a set?

2007-11-17 Thread Michael McNeil Forbes
My expectation was that array would iterate over a set. This is incorrect: array(set([1,2,3])) array(set([1, 2, 3]), dtype=object) Is this the intended behaviour? A trivial work-around that does what I need is array(list(set([1,2,3]))) array([1, 2, 3]) but I was wondering if this was

Re: [Numpy-discussion] Problem with numpy.linalg.eig?

2008-04-04 Thread Michael McNeil Forbes
On 16 Nov 2007, at 1:46 AM, Michael McNeil Forbes wrote: On 15 Nov 2007, at 8:23 PM, David Cournapeau wrote: Could you try without atlas ? Also, how did you configure atlas when building it ? It seems that atlas is definitely part of the problem (everybody having the problem does use atlas

Re: [Numpy-discussion] Code samples in docstrings mistaken as doctests

2008-06-23 Thread Michael McNeil Forbes
On 23 Jun 2008, at 12:37 PM, Alan McIntyre wrote: Ugh. That just seems like a lot of unreadable ugliness to me. If this comment magic is the only way to make that stuff execute properly under doctest, I think I'd rather just skip it in favor of clean, uncluttered, non-doctestable code

Re: [Numpy-discussion] Code samples in docstrings mistaken as doctests

2008-06-23 Thread Michael McNeil Forbes
On 23 Jun 2008, at 1:28 PM, Anne Archibald wrote: 2008/6/23 Michael McNeil Forbes [EMAIL PROTECTED]: Thus, one can argue that all examples should also be doctests. This generally makes things a little more ugly, but much less ambiguous. This is a bit awkward. How do you give an example

Re: [Numpy-discussion] slow import of numpy modules

2008-07-02 Thread Michael McNeil Forbes
On 2 Jul 2008, at 3:59 PM, Robert Kern wrote: On Wed, Jul 2, 2008 at 17:43, Nathan Jensen [EMAIL PROTECTED] wrote: Hi, I was wondering if there was any way to speed up the global import of numpy modules. For a simple import numpy, it takes ~250 ms. In comparison, importing Numeric is

Re: [Numpy-discussion] Infinity definitions

2008-07-15 Thread Michael McNeil Forbes
On 15 Jul 2008, at 6:33 AM, Bruce Southey wrote: Hi, Following Travis's suggestion below, I would like to suggest that the following definitions be depreciated or removed in this forthcoming release: numpy.Inf numpy.Infinity numpy.infty numpy.PINF numpy.NAN numpy.NaN ... While this

Re: [Numpy-discussion] sum of positive values in an array

2008-09-07 Thread Michael McNeil Forbes
On Sep 5, 2008, at 8:52 AM, Keith Goodman wrote: Here's another difference: a = np.random.randn(10) timeit np.sum(a[np.where(a0)]) 100 loops, best of 3: 3.44 ms per loop timeit a[a 0].sum() 100 loops, best of 3: 2.21 ms per loop Here is an even faster method (but much more ugly!):

Re: [Numpy-discussion] sum of positive values in an array

2008-09-07 Thread Michael McNeil Forbes
On Sep 5, 2008, at 8:52 AM, Keith Goodman wrote: Here's another difference: a = np.random.randn(10) timeit np.sum(a[np.where(a0)]) 100 loops, best of 3: 3.44 ms per loop timeit a[a 0].sum() 100 loops, best of 3: 2.21 ms per loop Here is an even faster method (but much more ugly!):

Re: [Numpy-discussion] profiling line by line

2008-09-15 Thread Michael McNeil Forbes
The hotshot profiler used to do this, but I don't think it is really supported anymore... I have not used it in a while, but agree that a line-by-line profiler can be very nice. Michael. On Sep 15, 2008, at 6:27 AM, Robin wrote: Hi, I am using the prun feature of Ipython which is very

Re: [Numpy-discussion] array 2 string

2009-03-11 Thread Michael McNeil Forbes
On 10 Mar 2009, at 10:33 AM, Michael S. Gilbert wrote: On Tue, 10 Mar 2009 17:21:23 +0100, Mark Bakker wrote: Hello, I want to convert an array to a string. I like array2string, but it puts these annoying square brackets around the array, like [[1 2 3], [3 4 5]] Anyway we can

[Numpy-discussion] IndexExpression bug?

2009-06-05 Thread Michael McNeil Forbes
np.array([0,1,2,3])[1:-1] array([1, 2]) but np.array([0,1,2,3])[np.s_[1:-1]] array([1, 2, 3]) np.array([0,1,2,3])[np.index_exp[1:-1]] array([1, 2, 3]) Possible fix: class IndexExpression(object): ... def __len__(self): return 0 (Presently this returns sys.maxint) Does

[Numpy-discussion] Efficient ?axpy operation without copy (B += a*A)

2009-06-23 Thread Michael McNeil Forbes
Hi, Is there a way of performing vectorized ?axpy (daxpy) operations without making copies or dropping into C? i.e: I want to do big = (1,5000) A = np.ones(big,dtype=float) B = np.ones(big,dtype=float) a = 1.5 B += a*A without making any copies? (I know I could go A *= a B += A A /= a

Re: [Numpy-discussion] Efficient ?axpy operation without copy (B += a*A)

2009-06-23 Thread Michael McNeil Forbes
Thanks Pauli, On 23 Jun 2009, at 12:46 PM, Pauli Virtanen wrote: from scipy.lib.blas import get_blas_funcs axpy, = get_blas_funcs(['axpy'], [A, B]) res = axpy(A.ravel(), B.ravel(), A.size, a) res.base is B ... Works provided A and B are initially in C-order so that ravel() doesn't create

Re: [Numpy-discussion] Specifying Index Programmatically

2009-08-17 Thread Michael McNeil Forbes
There is also numpy.s_: inds = np.s_[...,2,:] z[inds] (Though there are some problems with negative indices: see for example http://www.mail-archive.com/numpy-discussion@scipy.org/msg18245.html) On 8 Aug 2009, at 10:02 PM, T J wrote: On Sat, Aug 8, 2009 at 8:54 PM, Neil

Re: [Numpy-discussion] IndexExpression bug?

2009-08-17 Thread Michael McNeil Forbes
Submitted as ticket 1196 http://projects.scipy.org/numpy/ticket/1196 On 5 Jun 2009, at 4:12 PM, Robert Kern wrote: On Fri, Jun 5, 2009 at 16:14, Michael McNeil Forbes mfor...@physics.ubc.ca wrote: np.array([0,1,2,3])[1:-1] array([1, 2]) but np.array([0,1,2,3])[np.s_[1:-1]] array([1