Re: [Numpy-discussion] pyaudio, a module to make noise from numpy arrays

2006-10-27 Thread pearu


On Fri, 27 Oct 2006, Travis Oliphant wrote:

> David Cournapeau wrote:
> > Hi,
> >I announce the first release of pyaudio, a module to make noise from 
> > numpy arrays (read, write and play audio files with numpy arrays).
> >   
> 
> Very nice.   Thank you.  I'd like to see exactly this kind of thing for 
> video files too.  We can get a lot of mileage out of ctypes. 
> 
> By the way.  I noticed your setup.py file is missing a .todict()  to 
> convert the configuration object into a dictionary that setup(** ) can 
> handle.
> 
> if __name__ == "__main__":
> from numpy.distutils.core import setup
> setup(**configuration(top_path='').todict())

Actually, one should use here

  setup(configuration=configuration)

Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] f2py g3 question

2006-10-25 Thread pearu

On Wed, 25 Oct 2006, Brian Granger wrote:

> HI,
> 
> I have noticed that Pearu has been doing lots of work on f2py g3.  I
> have heard that this will have support for derived types.  What is the
> status of this work?  Is is ready for public use?  Are the derived
> types implemented?  Thanks!

At the moment derived types support is implemented for types that have
only scalar components. Work on the array component support is going
on. If you would like to try out f2py g3, use --3g-numpy option:

  f2py --3g-numpy ...

See numpy/f2py/lib/test_*.py files for examples that currently work with
f2py g3.

Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Conditional tests for test classes derived from NumpyTest

2006-10-19 Thread pearu

On Thu, 19 Oct 2006, David Cournapeau wrote:

> Hi,
> 
> Is there a simple way to execute tests inherited from NumpyTest 
> conditionally ? I have something like that for now:
> 
> class test_c_implementation(NumpyTestCase):
> def _check(self, level, decimal = 12):
> try:
> from foo import bar
> Y   = bar()
> except ImportError, inst:
> print "Error while importing bar, not tested"
> print " -> (Import error was %s)" % inst
> 
> And all checking functions of the class call _check. The problem is 
> that if there are 10 check functions, there are 10 errors reported, 
> which is a bit stupid,

One approach is demonstrated in scipy/Lib/lib/blas/tests/test_fblas.py.
In your case:

class base_test_c_implementation:
def check_bar(self, level, decimal=12):
Y = bar()

try:
from foo import bar
class test_c_implementation(base_test_c_implementation,NumpyTestCase):
pass
except ImportError, inst:
print "Error while importing bar, not tested"
print " -> (Import error was %s)" % inst


Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Testing numpy without doing an installation?

2006-10-17 Thread pearu

On Tue, 17 Oct 2006, Stefan van der Walt wrote:

> On Tue, Oct 17, 2006 at 10:03:03AM +0200, Francesc Altet wrote:
> > A Divendres 13 Octubre 2006 22:20, Lisandro Dalcin va escriure:
> > > On 10/13/06, Francesc Altet <[EMAIL PROTECTED]> wrote:
> > > > Is it possible to test a numpy version directly from the source
> > > > directory without having to install it?
> > >
> > > I usually do:
> > >
> > > $ python setup.py build
> > > $ python setup.py install --home=/tmp
> > > $ export PYTHONPATH=/tmp/lib/python
> > 
> > Thanks for your answer Lisandro, but what I want is to completely avoid an 
> > installation. The idea is to be able to test the local copy version of 
> > numpy 
> > in the development directory while doing small changes on it. Having to do 
> > the install step slows down the testing phase when doing small
> > changes.
> 
> It would be great if we could get this to work.  One problem is that
> distutils won't build the C-modules in place.  Does anyone know of a
> workaround?

Actually numpy.distutils supports in place builds of C modules.
However, its rather difficult to make numpy inplace to work for the
following reasons:
- to build a numpy based C extension, you'll need numpy header files
- numpy header files are generated during numpy build
So it is a chicken-egg problem.

One workaround for testing a numpy subpackage would be installing 
numpy and then doing inplace build in numpy subpackage directory. For
example:
  
  cd svn/numpy
  python setup.py install
  cd numpy/fft
  python setup.py build build_ext --inplace

Another workaround would be to install only numpy.core (that contains
numpy headers) and then doing inplace builds in numpy source directory ---
this, however, requires some setup.py modifications.

IMO, doing inplace builds has side effects that can easily lead to
shooting to a leg. While developing numpy, I would recommend always
installing numpy to some place, setting PYTHONPATH accordingly, write
unittests, and run them for testing. When test_*.py files are set up
properly then you don't need to install everytime you modify unittests,
they can be run inplace.

Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Should numpy.sqrt(-1) return 1j rather than nan?

2006-10-12 Thread pearu

PS: I am still sending this message to numpy list only because the
proposal below affects numpy code, not scipy one.

I think Fernando points make sense, numpy.foo(x) != scipy.foo(x) can
cause confusion and frustration both among new numpy/scipy users and
developers (who need to find explanations for the choises made).

So, let me propose the following solution so that all parties will get
the same results without sacrifying numpy.sqrt speed on non-negative input
and scipy.sqrt backward compatibility:

Define numpy.sqrt as follows:

def sqrt(x): 
r = nx.sqrt(x)
if nx.nan in r:
i = nx.where(nx.isnan(r))
r = _tocomplex(r)
r[i] = nx.sqrt(_tocomplex(x[i]))
return r

and define

  numpy.sqrtp

that takes only non-negative input, this is for those users who expect
sqrt to fail on negative input (as Numeric.sqrt and math.sqrt do).

Pearu



-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Should numpy.sqrt(-1) return 1j rather than nan?

2006-10-11 Thread pearu

On Wed, 11 Oct 2006, Travis Oliphant wrote:

> >Interestingly, in worst cases numpy.sqrt is approximately ~3 times slower
> >than scipy.sqrt on negative input but ~2 times faster on positive input:
> >
> >In [47]: pos_input = numpy.arange(1,100,0.001)
> >
> >In [48]: %timeit -n 1000 b=numpy.sqrt(pos_input)
> >1000 loops, best of 3: 4.68 ms per loop
> >
> >In [49]: %timeit -n 1000 b=scipy.sqrt(pos_input)
> >1000 loops, best of 3: 10 ms per loop
> >  
> >
> 
> This is the one that concerns me.  Slowing everybody down who knows they 
> have positive values just for people that don't seems problematic.

I think the code in scipy.sqrt can be optimized from

  def _fix_real_lt_zero(x):
  x = asarray(x)
  if any(isreal(x) & (x<0)):
  x = _tocomplex(x)
  return x

  def sqrt(x):
  x = _fix_real_lt_zero(x)
  return nx.sqrt(x)

to (untested)

  def _fix_real_lt_zero(x):
  x = asarray(x)
  if not isinstance(x,(nt.csingle,nt.cdouble)) and any(x<0):
  x = _tocomplex(x)
  return x

  def sqrt(x):
  x = _fix_real_lt_zero(x)
  return nx.sqrt(x)

or

  def sqrt(x):
  old = nx.seterr(invalid='raises')
  try:
  r = nx.sqrt(x)
  except FloatingPointError:
  x = _tocomplex(x)
  r = nx.sqrt(x)
  nx.seterr(**old)
  return r

I haven't timed these cases yet..

Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Should numpy.sqrt(-1) return 1j rather than nan?

2006-10-11 Thread pearu



On Wed, 11 Oct 2006, Travis Oliphant wrote:

> On the other hand requiring all calls to numpy.sqrt to go through an 
> "argument-checking" wrapper is a bad idea as it will slow down other uses.

Interestingly, in worst cases numpy.sqrt is approximately ~3 times slower
than scipy.sqrt on negative input but ~2 times faster on positive input:

In [47]: pos_input = numpy.arange(1,100,0.001)

In [48]: %timeit -n 1000 b=numpy.sqrt(pos_input)
1000 loops, best of 3: 4.68 ms per loop

In [49]: %timeit -n 1000 b=scipy.sqrt(pos_input)
1000 loops, best of 3: 10 ms per loop

In [50]: neg_input = -pos_input

In [52]: %timeit -n 1000 b=numpy.sqrt(neg_input)
1000 loops, best of 3: 99.3 ms per loop

In [53]: %timeit -n 1000 b=scipy.sqrt(neg_input)
1000 loops, best of 3: 29.2 ms per loop

nan's are making things really slow,
Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Should numpy.sqrt(-1) return 1j rather than nan?

2006-10-11 Thread pearu

Hi,

I have recieved the following note from a user:

"""
In SciPy 0.3.x the ufuncs were overloaded by more "intelligent" versions.
A very attractive feature was that sqrt(-1) would yield 1j as in Matlab.
Then you can program formulas directly (e.g., roots of a 2nd order
polynomial) and the right answer is always achieved. In the Matlab-Python
battle in mathematics education, this feature is important.

Now in SciPy 0.5.x sqrt(-1) yields nan. A lot of code we have, especially
for introductory numerics and physics courses, is now broken.
This has already made my colleagues at the University skeptical to
Python as "this lack of backward compatibility would never happen in Matlab".

Another problem related to Numeric and numpy is that in these courses we
use ScientificPython several places, which applies Numeric and will
continue to do so. You then easily get a mix of numpy and Numeric
in scripts, which may cause problems and at least extra overhead.
Just converting to numpy in your own scripts isn't enough if you call
up libraries using and returning Numeric.
"""

I wonder, what are the reasons that numpy.sqrt(-1) returns nan?
Could sqrt(-1) made to return 1j again? If not, shouldn't
numpy.sqrt(-1) raise a ValueError instead of returning silently nan?

Thanks,
Pearu


-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy fails to build with Python 2.5

2006-09-19 Thread Pearu Peterson
On 9/19/06, William Grant <[EMAIL PROTECTED]> wrote:
> mg wrote:
> > Hi,
> >
> > I have the same problem with Python-2.5 and Python-2.6a with which i can
> > not compile Numpy-1.0b5 and Numpy from svn. (I suppose your version of
> > Scipy is based on one of these Numpy.)
> > I posted my problem yesterday. The answer from Travis was it will be
> > corrected in Numpy-1.0rc1 which will come soon.
> >
> > regards,
> > Mathieu.
>
> Yes, numpy 1.0b5 is the one... Approximately how soon is soon? Before or
> after the 28th?

I have the corresponding fixed compiler errors in numpy svn.

Regards,
Pearu

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Distutils problem with g95

2006-05-31 Thread Pearu Peterson



On Wed, 31 May 2006, James Graham wrote:


Pearu Peterson wrote:


Could you send me the output of

  g95 --version

for reference?


$ g95 --version

G95 (GCC 4.0.3 (g95!) May 22 2006)


Thanks, I have applied the patch with modifications to numpy svn.
Let me know if it fails to work.

Pearu


---
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Distutils problem with g95

2006-05-31 Thread Pearu Peterson



On Wed, 31 May 2006, James Graham wrote:

numpy.distutils seems to have difficulties detecting the current version of 
the g95 compiler. I believe this is because the output of `g95 --version` has 
changed. The patch below seems to correct the problem (i.e. it now works with 
the latest g95) but my regexp foo is very weak so it may not be 
correct/optimal.


Could you send me the output of

  g95 --version

for reference?

Thanks,
Pearu


---
All the advantages of Linux Managed Hosting--Without the Cost and Risk!
Fully trained technicians. The highest number of Red Hat certifications in
the hosting industry. Fanatical Support. Click to learn more
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion