[Numpy-discussion] ANN: PyQwt3D-0.1.6 released

2007-08-07 Thread Gerard Vermeulen
What is PyQwt3D ( http://pyqwt3d.sourceforge.net) ?

- it is a set of Python bindings for the QwtPlot3D C++ class library
  which extends the Qt framework with widgets for 3D data visualization.
  PyQwt3D inherits the snappy feel from QwtPlot3D.
  The examples at http://pyqwt.sourceforge.net/pyqwt3d-examples.html
  show how easy it is to make a 3D plot and how to save a 3D plot to
  an image or an (E)PS/PDF/PGF/SVG file.

- it requires and extends PyQt, a set of Python bindings for Qt.

- it supports the use of PyQt, Qt, QwtPlot3D, and NumPy or SciPy in a
  GUI Python application or in an interactive Python session.

- it runs on POSIX, Mac OS X and Windows platforms (practically any
  platform supported by Qt and Python).

- it is licensed under the GPL with an exception to allow dynamic linking
  with non-free releases of Qt and PyQt. 

The home page of PyQwt3D is http://pyqwt.sourceforge.net.

PyQwt3D-0.1.6 is a bug fix release:
- Improved text display on screen and in pixmaps with Qt-4 and X (requires
  the use of the patched QwtPlot3D-0.2.7 library included in PyQwt3D).


PyQwt3D-0.1.6 supports:
1. Python-2.5, or -2.4.
2. PyQt-4.3, -4.2, -4.1, or -3.17.
3. SIP-4.7, -4.6, or -4.5.
4. Qt-4.3, -4.2, Qt-3.3, or -3.2.
5. QwtPlot3D-0.2.7.


Enjoy -- Gerard Vermeulen
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] spurious IndexError?

2007-08-07 Thread Robert Kern
john saponara wrote:
> Using numpy-1.0.2/python-2.5/winxp pro sp2:  in the following, the only 
> array is 'a', and I'm not using it as an index, so why do I get the 
> IndexError below?
> 
> --- start python session ---
>  >>> a=array([[1,3],[2,4]])
>  >>> a
> array([[1, 3],
> [2, 4]])
>  >>> f=lambda i,j: a[i,j]
>  >>> f(1,1)
> 4
>  >>> fromfunction(f,(2,2))
> Traceback (most recent call last):
>File "", line 1, in 
>File "C:\Python25\Lib\site-packages\numpy\core\numeric.py", line 514, 
> in fromfunction
>   return function(*args,**kwargs)
>File "", line 1, in 
> IndexError: arrays used as indices must be of integer (or boolean) type
> --- end python session ---
> 
> The upstream maple is written in 'fromfunction' style, and I have no 
> control over that but want to port it to python in the most natural way 
> possible.
> 
> The session suggests that lambda has no trouble with an array, so the 
> problem seems to be related to the way 'fromfunction' works.  What am I 
> missing?

fromfunction() takes the (2, 2) and forms arrays of indices. It then calls your
function with those arrays as arguments. It does not loop. The default dtype of
these arrays is float, not int. You must use "dtype=int" in your call to
fromfunction().

def fromfunction(function, shape, **kwargs):
"""Returns an array constructed by calling a function on a tuple of number
grids.

The function should accept as many arguments as the length of shape and
work on array inputs.  The shape argument is a sequence of numbers
indicating the length of the desired output for each axis.

The function can also accept keyword arguments (except dtype), which will
be passed through fromfunction to the function itself.  The dtype argument
(default float) determines the data-type of the index grid passed to the
function.
"""

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] spurious IndexError?

2007-08-07 Thread john saponara
Using numpy-1.0.2/python-2.5/winxp pro sp2:  in the following, the only 
array is 'a', and I'm not using it as an index, so why do I get the 
IndexError below?

--- start python session ---
 >>> a=array([[1,3],[2,4]])
 >>> a
array([[1, 3],
[2, 4]])
 >>> f=lambda i,j: a[i,j]
 >>> f(1,1)
4
 >>> fromfunction(f,(2,2))
Traceback (most recent call last):
   File "", line 1, in 
   File "C:\Python25\Lib\site-packages\numpy\core\numeric.py", line 514, 
in fromfunction
return function(*args,**kwargs)
   File "", line 1, in 
IndexError: arrays used as indices must be of integer (or boolean) type
--- end python session ---

The upstream maple is written in 'fromfunction' style, and I have no 
control over that but want to port it to python in the most natural way 
possible.

The session suggests that lambda has no trouble with an array, so the 
problem seems to be related to the way 'fromfunction' works.  What am I 
missing?

Thanks!

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] numpy arrays, data allocation and SIMD alignement

2007-08-07 Thread Charles R Harris
On 8/6/07, Anne Archibald <[EMAIL PROTECTED]> wrote:
>
> On 06/08/07, David Cournapeau <[EMAIL PROTECTED]> wrote:
>
> > Well, when I proposed the SIMD extension, I was willing to implement the
> > proposal, and this was for a simple goal: enabling better integration
> > with many numeric libraries which need SIMD alignment.
> >
> > As nice as a custom allocator might be, I will certainly not implement
> > it myself. For SIMD, I think the weight adding complexity / benefit
> > worth it (since there is not much change to the API and implementation),
> > and I know more or less how to do it; for custom allocator, that's an
> > entirely different story. That's really more complex; static pools may
> > be useful in some cases (but that's not obvious, since only the data are
> > allocated with this buffer, everything else being allocated through the
> > python memory allocator, and numpy arrays have pretty simple memory
> > allocation patterns).
>
> I have to agree. I can hardly volunteer David for anything, and I
> don't have time to implement this myself, but I think a custom
> allocator is a rather special-purpose tool; if one were to implement
> one, I think the way to go would be to implement a subclass of ndarray
> (or just a constructor) that allocated the memory. This could be done
> from python, since you can make an ndarray from scratch using a given
> memory array. Of course, making temporaries be allocated with the
> correct allocator will be very complicated, since it's unclear which
> allocator should be used.


Maybe I'm missing something, but handling the temporaries is automatic. Just
return the appropriate slice from an array created in a subroutine. The
original array gets its reference count decremented when the routine exits
but the slice will still hold one. When the slice is deleted all the
allocated memory will get garbage collected.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Nils Wagner
Alan G Isaac wrote:
> On Tue, 07 Aug 2007, Nils Wagner apparently wrote:
>   
>> I have a list of integer numbers. The entries can vary between 0 and 19. 
>> How can I count the occurrence of any number. Consider 
>>  >>> data
>> [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 
>> 7, 8, 9, 8, 7, 9] 
>> Is there a better way than using, e.g. 
>> 
> shape(where(array(data)==10))[1] 
>   
>> 2
>> 
>
>
> You did not say why data.count(10) is unsatisfactory ...
>
> Cheers,
> Alan Isaac
>
>
>
>
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>   
 
Thank you for all your input. To be honest I was not aware of all these
possibilities to solve my problem.
If you distribute a task among different people you will obtain
different methods of resolution.

Nils

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Alan G Isaac
By the way, you can get all the frequencies pretty fast 
using a defaultdict:
http://docs.python.org/lib/defaultdict-examples.html

Cheers,
Alan Isaac




___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Alan G Isaac
On Tue, 07 Aug 2007, Nils Wagner apparently wrote:
> I have a list of integer numbers. The entries can vary between 0 and 19. 
> How can I count the occurrence of any number. Consider 
>  >>> data
> [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 
> 7, 8, 9, 8, 7, 9] 
> Is there a better way than using, e.g. 
 shape(where(array(data)==10))[1] 
> 2


You did not say why data.count(10) is unsatisfactory ...

Cheers,
Alan Isaac




___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain in teger in a list of integers

2007-08-07 Thread volker
Keith Goodman  gmail.com> writes:

> 
> On 8/7/07, Keith Goodman  gmail.com> wrote:
> > On 8/7/07, Nils Wagner  iam.uni-stuttgart.de> wrote:
> > > I have a list of integer numbers. The entries can vary between 0 and 19.
> > > How can I count the occurrence of any number. Consider
> > >
> > >  >>> data
> > > [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7,
9, 7, 8, 9, 8, 7, 9]
> > >
> > >
> > > Is there a better way than using, e.g.
> > >
> > > >>> shape(where(array(data)==10))[1]
> > > 2
> > >
> > >
> > > to compute the occurrence of 10 in the list which is 2 in this case ?
> >
> > Would list comprehension work?
> >
> > len([z for z in data if z == 10])
> 
> Or is this faster?
> 
> (array(x)==10).sum()
> 

Lets test ;)

In [34]: data = array(data).repeat(1e6)


In [35]: %time shape(where(array(data)==10))[1]
CPU times: user 1.27 s, sys: 0.16 s, total: 1.44 s
Wall time: 1.65


In [36]: %time ([z for z in data if z == 10])
CPU times: user 18.06 s, sys: 0.52 s, total: 18.58 s
Wall time: 18.59




In [37]: %time (array(data)==10).sum()
CPU times: user 0.68 s, sys: 0.20 s, total: 0.88 s
Wall time: 1.36




___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Robert Cimrman
Nils Wagner wrote:
> Hi all,
> 
> I have a list of integer numbers. The entries can vary between 0 and 19.
> How can I count the occurrence of any number. Consider
> 
>  >>> data
> [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 
> 7, 8, 9, 8, 7, 9]
> 
> 
> Is there a better way than using, e.g.
> 
 shape(where(array(data)==10))[1]
> 2
>  
> 
> to compute the occurrence of 10 in the list which is 2 in this case ?

Your way is ok if you want to count just a few numbers. If you want all,
you may sort the array and use searchorted:

b = sort( a )
count = searchsorted( b, 7, side = 'right' ) - searchsorted( b, 7, side
= 'left' )


r.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Keith Goodman
On 8/7/07, Keith Goodman <[EMAIL PROTECTED]> wrote:
> On 8/7/07, Nils Wagner <[EMAIL PROTECTED]> wrote:
> > I have a list of integer numbers. The entries can vary between 0 and 19.
> > How can I count the occurrence of any number. Consider
> >
> >  >>> data
> > [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 
> > 7, 8, 9, 8, 7, 9]
> >
> >
> > Is there a better way than using, e.g.
> >
> > >>> shape(where(array(data)==10))[1]
> > 2
> >
> >
> > to compute the occurrence of 10 in the list which is 2 in this case ?
>
> Would list comprehension work?
>
> len([z for z in data if z == 10])

Or is this faster?

(array(x)==10).sum()
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Keith Goodman
On 8/7/07, Nils Wagner <[EMAIL PROTECTED]> wrote:
> I have a list of integer numbers. The entries can vary between 0 and 19.
> How can I count the occurrence of any number. Consider
>
>  >>> data
> [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 
> 7, 8, 9, 8, 7, 9]
>
>
> Is there a better way than using, e.g.
>
> >>> shape(where(array(data)==10))[1]
> 2
>
>
> to compute the occurrence of 10 in the list which is 2 in this case ?

Would list comprehension work?

len([z for z in data if z == 10])
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Matthieu Brucher
You can try using hist() with the correct range and number of bins.

Matthieu

2007/8/7, Nils Wagner <[EMAIL PROTECTED]>:
>
> Hi all,
>
> I have a list of integer numbers. The entries can vary between 0 and 19.
> How can I count the occurrence of any number. Consider
>
> >>> data
> [9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7,
> 9, 7, 8, 9, 8, 7, 9]
>
>
> Is there a better way than using, e.g.
>
> >>> shape(where(array(data)==10))[1]
> 2
>
>
> to compute the occurrence of 10 in the list which is 2 in this case ?
>
> Nils
>
> ___
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Count the occurrence of a certain integer in a list of integers

2007-08-07 Thread Nils Wagner
Hi all,

I have a list of integer numbers. The entries can vary between 0 and 19.
How can I count the occurrence of any number. Consider

 >>> data
[9, 6, 9, 6, 7, 9, 9, 10, 7, 9, 9, 6, 7, 9, 8, 8, 11, 9, 6, 7, 10, 9, 7, 9, 7, 
8, 9, 8, 7, 9]


Is there a better way than using, e.g.

>>> shape(where(array(data)==10))[1]
2
 

to compute the occurrence of 10 in the list which is 2 in this case ?

Nils

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] fourier with single precision

2007-08-07 Thread Lars Friedrich
Thank you for your comments!

I will try this fftw3-scipy approach and see how much faster I can get. 
Maybe this is enough for me...?

Lars
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] ANN: PyQwt3D-0.1.5 released

2007-08-07 Thread Gerard Vermeulen
What is PyQwt3D ( http://pyqwt3d.sourceforge.net) ?

- it is a set of Python bindings for the QwtPlot3D C++ class library
  which extends the Qt framework with widgets for 3D data visualization.
  PyQwt3D inherits the snappy feel from QwtPlot3D.
  The examples at http://pyqwt.sourceforge.net/pyqwt3d-examples.html
  show how easy it is to make a 3D plot and how to save a 3D plot to
  an image or an (E)PS/PDF/PGF/SVG file.

- it requires and extends PyQt, a set of Python bindings for Qt.

- it supports the use of PyQt, Qt, QwtPlot3D, and NumPy or SciPy in a
  GUI Python application or in an interactive Python session.

- it runs on POSIX, Mac OS X and Windows platforms (practically any
  platform supported by Qt and Python).

The home page of PyQwt3D is http://pyqwt.sourceforge.net.

New features and bugfixes in PyQwt3D-0.1.5:
- Added support for QwtPlot3D-0.2.7
- Added support for SIP-4.7, PyQt-4.3 and PyQt-3.17.3.
- Added support for SVG and PGF vector output.
- Added Qwt3D.save() to facilitate saving plots to a file.
- Added Qwt3D.plot() to facilitate function plotting with nicely scaled axes.
- Fixed the type of the result of IO.outputHandler(format).
- Fixed saving to pixmap formats in qt4examples/Grab.py.

PyQwt3D-0.1.5 supports:
1. Python-2.5, or -2.4.
2. PyQt-4.3, -4.2, -4.1, or -3.17.
3. SIP-4.7, -4.6, or -4.5.
4. Qt-4.3, -4.2, Qt-3.3, or -3.2.
5. QwtPlot3D-0.2.7.


Enjoy -- Gerard Vermeulen
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion