Re: [Numpy-discussion] performance of the numpy

2008-09-24 Thread David Cournapeau
On Thu, Sep 25, 2008 at 9:36 AM, frank wang <[EMAIL PROTECTED]> wrote: > Hi, All, > > I am using ipython with --pylab flag. ipython loads the numpy into the > workspace, so I do not know abs is from python or numpy. The weird thing is > if I execute the code line by line, I do not have any speed pr

[Numpy-discussion] numpy.complex* functions do not call the __complex__ method

2008-09-24 Thread jason-sage
In creating an array of type numpy.complex128, I'm having problems passing in Sage types that should be considered complex numbers since they implement the standard __complex__ method. However, numpy doesn't recognize that. Here's a minimal example: In [1]: class MyNum: ...: def __comp

Re: [Numpy-discussion] performance of the numpy

2008-09-24 Thread Matthieu Brucher
> >From my understanding, using the modulename.functionname will slow down the > python performance. For a big simulation, it may not be a good idear. The slowdown is very small (I'd say inferior to a ms), it's nothing compared to the way you're doing your computations. Matthieu -- French PhD st

Re: [Numpy-discussion] PyArray_SETITEM macro ends in semicolon

2008-09-24 Thread Charles R Harris
On Wed, Sep 24, 2008 at 9:25 PM, <[EMAIL PROTECTED]> wrote: > I'm working on getting the Sage matrices for real/complex doubles to use > numpy as a backend. In this, I'm using the PyArray_SETITEM macro from > within Cython. However, Cython wraps the macro in a function call to > convert the outp

[Numpy-discussion] PyArray_SETITEM macro ends in semicolon

2008-09-24 Thread jason-sage
I'm working on getting the Sage matrices for real/complex doubles to use numpy as a backend. In this, I'm using the PyArray_SETITEM macro from within Cython. However, Cython wraps the macro in a function call to convert the output to a Python value: __pyx_1 = PyInt_FromLong(PyArray_SETITEM(

Re: [Numpy-discussion] take a numpy

2008-09-24 Thread Robert Kern
On Wed, Sep 24, 2008 at 21:29, Dinesh B Vadhia <[EMAIL PROTECTED]> wrote: > I'm using numpy take() to pickout elements from a (1xM) array A indicated by > the index numbers in indices ie. > > B = A.take(indices = list_indexes) > > It work perfectly but as A is large the performance isn't great and

[Numpy-discussion] take a numpy

2008-09-24 Thread Dinesh B Vadhia
I'm using numpy take() to pickout elements from a (1xM) array A indicated by the index numbers in indices ie. B = A.take(indices = list_indexes) It work perfectly but as A is large the performance isn't great and was wondering if there are faster methods available or ways to improve the use of

Re: [Numpy-discussion] performance of the numpy

2008-09-24 Thread frank wang
Hi, All, I am using ipython with --pylab flag. ipython loads the numpy into the workspace, so I do not know abs is from python or numpy. The weird thing is if I execute the code line by line, I do not have any speed problem. But when I combine them together into one command, it slowdonws the

Re: [Numpy-discussion] performance of the numpy

2008-09-24 Thread Christopher Barker
Nadav Horesh wrote: > You should use absolute (a ufunc) and not abs (internal python function): > plot(absolute(fft(b))) another reason why "import *" is a bad idea: import numpy as np import pylab as plot #(what is the convention for this now?) pylab.plot(np.absolute(np.fft(b))) yes, it

Re: [Numpy-discussion] A basic question about swig and Numeric

2008-09-24 Thread Christopher Barker
Michel Dupront wrote: > I have a c++ function that take as argument a std::vector. >>From python I want to call the c++ function with an array > object. For that purpose I want to write a typemap. Have you seen the SWIG typemaps that come with numpy?: ...\site-packages\numpy\doc\swig They are de

Re: [Numpy-discussion] A basic question about swig and Numeric

2008-09-24 Thread Lisandro Dalcin
Ups! Since I´ve started to use Cython, it seems I´m starting to forget things about SWIG. Mi comments about a typecheck typemaps were a nonsese (they have another pourpose). Look at the SWIG docs, you need to use something like SWIG_arg_fail macro. On Wed, Sep 24, 2008 at 6:48 PM, Lisandro Dalcin

Re: [Numpy-discussion] A basic question about swig and Numeric

2008-09-24 Thread Lisandro Dalcin
I believe you should look at the SWIG docs and then write a typecheck typemap. Checking foir the type of and array and returning NULL is not fair play for SWIG, nor for Python. Before returning NULL, and exception should be set. For this, SWIG provides some 'SWIG_xxx_fail' macros. Typemaps and frag

Re: [Numpy-discussion] loadtxt error

2008-09-24 Thread frank wang
Thank you very much for all of you. I have downloaded the binary version 1.2rc and it fixed the problem. My special thanks to the person who created the window binary version for users who do not know or do not have the capacity to build the numpy from source. Frank> Date: Wed, 24 Sep 200

Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--

2008-09-24 Thread Jarrod Millman
On Wed, Sep 24, 2008 at 11:13 AM, Bruce Southey <[EMAIL PROTECTED]> wrote: > What is the status of NumPy 1.2 and when can we expect the final version? I hope to announce it on Friday or Saturday. The only thing I am looking into now is whether we should back port the fix to lookfor or not: http:/

Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--

2008-09-24 Thread Bruce Southey
Hi, What is the status of NumPy 1.2 and when can we expect the final version? Thanks Bruce Jarrod Millman wrote: > Hello, > > The 1.2.0rc2 is now available: > http://svn.scipy.org/svn/numpy/tags/1.2.0rc2 > > The source tarball is here: > https://cirl.berkeley.edu/numpy/numpy-1.2.0rc2.tar.gz > > H

Re: [Numpy-discussion] maskedarray: how to force mask to expand

2008-09-24 Thread Pierre GM
Vincent, You should really consider putting an example next time. I must admit that I'm not sure what you're trying to do, and where/why it fails. Yes, by default, the mask of a new MaskedArray is set to the value 'nomask', which is the boolean False. Directly setting an element of the mask in

Re: [Numpy-discussion] inserting indexes into an array

2008-09-24 Thread Tom Denniston
You could try something like: In [15]: arr = numpy.array([100,200,300]) In [16]: arr2 = numpy.empty((len(arr)*2,)) In [17]: arr2[::2]=arr In [18]: arr2[1::2]=numpy.arange(len(arr)) In [20]: arr2 Out[20]: array([ 100.,0., 200.,1., 300.,2.]) 2008/9/24 Nadav Horesh <[EMAIL PROTECTE

Re: [Numpy-discussion] loadtxt error

2008-09-24 Thread Stéfan van der Walt
2008/9/24 Joshua Lippai <[EMAIL PROTECTED]>: > And the version would be displayed on screen. Bear in mind that unlike > the release, which installs via an installer file you double click, > you will have to compile numpy from the downloaded source code > yourself. Detailed instructions for doing th

Re: [Numpy-discussion] loadtxt error

2008-09-24 Thread David Huard
Note that the fix was also backported to 1.2, for which binary builds are available: David [ copied from a recent thread ] The 1.2.0rc2 is now available: http://svn.scipy.org/svn/numpy/tags/1.2.0rc2 The source tarball is here: https://cirl.berkeley.edu/numpy/numpy-1.2.0rc2.tar.gz Here is the u

[Numpy-discussion] A basic question about swig and Numeric

2008-09-24 Thread Michel Dupront
Hello, I am trying to use Numeric and swig but it seems that there are few points that I don't understand. The only excuse I have is that I am new to these tools. I have a simple example that I cannot make work the way I would like. I have a c++ function that take as argument a std::vecto

Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-24 Thread Pauli Virtanen
Wed, 24 Sep 2008 11:18:43 +, Pauli Virtanen wrote: > Tue, 23 Sep 2008 15:48:22 -0700, joep wrote: >> A possible solution would be in >> >> http://bazaar.launchpad.net/~pauli-virtanen/scipy/pydocweb/revision/386 >> >> It seems to be possible to be used in the same way when iter_modules >> is

Re: [Numpy-discussion] python 2.4 incompatibility in numpy.lookfor in numpy 1.2.0rc2

2008-09-24 Thread Pauli Virtanen
Hi, Tue, 23 Sep 2008 15:48:22 -0700, joep wrote: > A possible solution would be in > > http://bazaar.launchpad.net/~pauli-virtanen/scipy/pydocweb/revision/386 > > It seems to be possible to be used in the same way when iter_modules is > not available. > The usage in ``_lookfor_generate_cache``

Re: [Numpy-discussion] New patch for new mgrid / ogrid functionality

2008-09-24 Thread Gael Varoquaux
On Wed, Sep 24, 2008 at 09:57:13AM +0200, David Kaplan wrote: > > > X = asarray( mgrid[ 0:4, 0:4, 0:4 ] ) > > Doesn't this force a data copy? > I am not sure if this forces a copy (asarray shouldn't for arrays, > unlike array, but I am not sure what it does for lists that can > trivially become

[Numpy-discussion] maskedarray: how to force mask to expand

2008-09-24 Thread Vincent Schut
Probably I'm just overlooking something obvious, but I'm having problems with maskedarrays (numpy.ma from svn: '1.3.0.dev5861'), the mask by default being a single bool value ('False') instead of a properly sized bool array. If I then try to mask one value by assigning values to certain mask po

Re: [Numpy-discussion] inserting indexes into an array

2008-09-24 Thread Nadav Horesh
Possibilities: column_stack((arange(len(ar)),ar)) or transpose((arange(len(ar)),ar)).ravel() Nadav. -הודעה מקורית- מאת: [EMAIL PROTECTED] בשם Thomas Heller נשלח: ד 24-ספטמבר-08 11:30 אל: numpy-discussion@scipy.org נושא: [Numpy-discussion] inserting indexes into an array I have a n

[Numpy-discussion] inserting indexes into an array

2008-09-24 Thread Thomas Heller
I have a numpy array comtaining numbers (a, b, ...), like this: array([a, b, c, d, e, f]) What is the fastest way to create another array that has the index of the element before each element of the original array? The result should look like this: array([0, a, 1, b, 2, c, 3, d, 4, e, 5, f]) -

Re: [Numpy-discussion] New patch for new mgrid / ogrid functionality

2008-09-24 Thread Robert Kern
On Wed, Sep 24, 2008 at 02:57, David Kaplan <[EMAIL PROTECTED]> wrote: > Hi, > > On Tue, 2008-09-23 at 20:54 -0500, [EMAIL PROTECTED] > wrote: >> On Tue, Sep 23, 2008 at 09:39:53AM +0200, David Kaplan wrote: >> > I would note that there is nothing in the API breakage that prevents >> > doing what G

Re: [Numpy-discussion] New patch for new mgrid / ogrid functionality

2008-09-24 Thread David Kaplan
Hi, On Tue, 2008-09-23 at 20:54 -0500, [EMAIL PROTECTED] wrote: > On Tue, Sep 23, 2008 at 09:39:53AM +0200, David Kaplan wrote: > > I would note that there is nothing in the API breakage that prevents > > doing what Gael mentions. The only change is that: > > > > > X = mgrid[0:4, 0:4, 0:4] > >