Re: [Numpy-discussion] libblas error with NumPy 1.0rc2 on Python 2.5 and Red Hat 9

2006-10-11 Thread Karol Langner
On Wednesday 11 of October 2006 05:38, Steven H. Rogers wrote:
> Is there a specific libblas required by NumPy?  I just installed 1.0rc2
> and get this error.
>
> Python 2.5 (r25:51908, Sep 21 2006, 17:18:24)
> [GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-5)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
>  >>> import numpy
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "/usr/local/lib/python2.5/site-packages/numpy/__init__.py", line
> 40, in 
> import linalg
>   File
> "/usr/local/lib/python2.5/site-packages/numpy/linalg/__init__.py", line
> 4, in 
> from linalg import *
>   File "/usr/local/lib/python2.5/site-packages/numpy/linalg/linalg.py",
> line 25, in 
> from numpy.linalg import lapack_lite
> ImportError: /usr/lib/libblas.so.3: undefined symbol: e_wsfe
>
> Regards,
> Steve

I've seen this a couple of times - e_wsfe is a Fortran I/O symbol from the gcc 
system and should be made available by libg2c. My guess if that you have 
inconsistencies in the compilers used, i .e. a different one was used for 
building the blas libraries by RH and by you for numpy.

Try adding g2c to the list of libraries. There's a comment about it in the 
scipy FAQ:
http://www.scipy.org/FAQ#head-26562f0a9e046b53eae17de300fc06408f9c91a8

Karol

-- 
written by Karol Langner
Wed Oct 11 09:35:15 CEST 2006

-
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] incrementing along a diagonal

2006-10-11 Thread David Novakovic
Hi,

i'm moving some old perl PDL code to python. I've come across a line
which changes values in a diagonal line accross a matrix.

matrix.diagonal() returns a list of values, but making changes to these
does not reflect in the original (naturally).

I'm just wondering if there is a way that i can increment all the values
along a diagonal?

Cheers

Dave


P.S i wasnt sure how to sign to the mailing list - so i'd appreciate
being CC'd in any replies ;)

-
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] incrementing along a diagonal

2006-10-11 Thread Johannes Loehnert
> I'm just wondering if there is a way that i can increment all the values
> along a diagonal?

Assume you want to change mat.

# min() only necessary for non-square matrices
index = arange(min(mat.shape[0], mat.shape[1]))
# add 1 to each diagonal element
matrix[index, index] += 1
# add some other stuff
matrix[index, index] += some_array_shaped_like_index


HTH, Johannes

-
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] select part of array using two conditions

2006-10-11 Thread Mark Bakker
Hello -I want to select part of an array using two conditions.I know how to do it with one condition (and it works great), but when I use two conditions I get an error message?This is probably easy, but I cannot figure it out.
Thanks for any help, Mark>>> a = arange(10)>>> aarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])>>> a[ a>2 ]array([3, 4, 5, 6, 7, 8, 9])>>> a[ a>2 and a<8 ]
Traceback (most recent call last):  File "", line 1, in ?    a[ a>2 and a<8 ]ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or 
a.all()
-
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] select part of array using two conditions

2006-10-11 Thread Francesc Altet
El dc 11 de 10 del 2006 a les 11:06 +0200, en/na Mark Bakker va
escriure:
> Hello -
> 
> I want to select part of an array using two conditions.
> I know how to do it with one condition (and it works great), but when
> I use two conditions I get an error message?
> This is probably easy, but I cannot figure it out. 
> Thanks for any help, Mark
> 
> >>> a = arange(10)
> >>> a
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
> >>> a[ a>2 ]
> array([3, 4, 5, 6, 7, 8, 9])
> >>> a[ a>2 and a<8 ] 
> Traceback (most recent call last):
>   File "", line 1, in ?
> a[ a>2 and a<8 ]
> ValueError: The truth value of an array with more than one element is
> ambiguous. Use a.any() or a.all()

Yeah, this is a common error on people that is not used to these kind of
selections. You have to use the boolean binary operators (and not the
logical operators) for doing this:

>>> a[(a>2) & (a<8)]

Notice the parenthesis. They are necessary because the operator & has
more precedence than < or >.

-- 
>0,0<   Francesc Altet http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 "-"



-
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] select part of array using two conditions

2006-10-11 Thread Nils Wagner
Mark Bakker wrote:
> Hello -
>
> I want to select part of an array using two conditions.
> I know how to do it with one condition (and it works great), but when
> I use two conditions I get an error message?
> This is probably easy, but I cannot figure it out.
> Thanks for any help, Mark
>
> >>> a = arange(10)
> >>> a
> array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
> >>> a[ a>2 ]
> array([3, 4, 5, 6, 7, 8, 9])
> >>> a[ a>2 and a<8 ]
> Traceback (most recent call last):
>   File "", line 1, in ?
> a[ a>2 and a<8 ]
> ValueError: The truth value of an array with more than one element is
> ambiguous. Use a.any() or a.all()
>
> 
>
> -
> 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
>   
a[ (a>2) & (a<8) ]

Nils
 

-
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] ide for python/numpy/scipy/mpl, development ?

2006-10-11 Thread humufr
Le mardi 10 octobre 2006 16:30, Darren Dale a écrit :
> On Tuesday 10 October 2006 15:41, [EMAIL PROTECTED] wrote:
> > I asked if that will be possible to use ipython instead of the python
> > console in eric4 (I know that it's not possible with eric3) but it's
> > seems that eric4 does have it's own console. So, at least for me, it's
> > not anymore an option.
>
> Why do you say that? I just installed the latest development snapshots, and
> Eric4 does have its own console. I haven't been able to set ipython as the
> custom interpretter, but I will ask the developer about it.
>
> Darren


I asked on the mail list and this is the answer from the developer:

On Tuesday 10 October 2006 17:33, [EMAIL PROTECTED] wrote:
> Hi,
>
> I would like to know if that will be possible to use ipython with eric4
> instead of the normal python console?
>
> Thanks,
>
> N.
> ___

No. Eric uses it's own console, which talks to a remote Python (or Ruby) 
interpreter via a network socket.

Regards,
Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]

-
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] warning upon running numpy rc02 tests

2006-10-11 Thread O'Keefe, Michael
Just FYI, I got the following warning while running the unittests from RC02:

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on 
win32
Type "copyright", "credits" or "license()" for more information.


Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface.  This connection is not visible on any external
interface and no data is sent to or received from the Internet.


IDLE 1.2  
>>> from numpy import test
>>> from numpy import __version__
>>> __version__
'1.0rc2'
>>> test()
  Found 5 tests for numpy.distutils.misc_util
  Found 3 tests for numpy.lib.getlimits
  Found 31 tests for numpy.core.numerictypes
  Found 32 tests for numpy.linalg
  Found 13 tests for numpy.core.umath
  Found 4 tests for numpy.core.scalarmath
  Found 9 tests for numpy.lib.arraysetops
  Found 4 tests for numpy.ctypeslib
  Found 42 tests for numpy.lib.type_check
Warning: FAILURE importing tests for 
C:\Python25\Lib\site-packages\numpy\core\tests\test_multiarray.py:355: 
ImportError: No module named test_unicode (in )
  Found 3 tests for numpy.fft.helper
  Found 36 tests for numpy.core.ma
  Found 1 tests for numpy.lib.ufunclike
  Found 12 tests for numpy.lib.twodim_base
  Found 10 tests for numpy.core.defmatrix
  Found 41 tests for numpy.lib.function_base
  Found 2 tests for numpy.lib.polynomial
  Found 8 tests for numpy.core.records
  Found 26 tests for numpy.core.numeric
  Found 4 tests for numpy.lib.index_tricks
  Found 47 tests for numpy.lib.shape_base
  Found 0 tests for __main__
.
--
Ran 333 tests in 2.687s

OK


-
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] Compile with atlas 3.7.17 fails

2006-10-11 Thread Hanno Klemm

Hi, 

I don't know if this is a bug or just me doing something wrong (I
suspect the latter). I try to compile numpy-1.0rc1 with python2.5 and
atlas 3.7.17.

I have build the atlas library myself, it doesn't give any errors
under make test or make pttest, so it seems to be okay. if I try to
build numpy I get the following error:

creating build/temp.linux-x86_64-2.5/numpy/core/blasdot
compile options: '-DATLAS_INFO="\"3.7.17\"" -Inumpy/core/blasdot
-I/scratch/python2.5/include -Inumpy/core/include
-Ibuild/src.linux-x86_64-2.5/numpy/core -Inumpy/core/src
-Inumpy/core/include -I/scratch/python2.5/include/python2.5 -c'
gcc: numpy/core/blasdot/_dotblas.c
gcc -pthread -shared
build/temp.linux-x86_64-2.5/numpy/core/blasdot/_dotblas.o
-L/scratch/python2.5/lib -lcblas -latlas -o
build/lib.linux-x86_64-2.5/numpy/core/_dotblas.so
/usr/bin/ld: /scratch/python2.5/lib/libcblas.a(cblas_dgemm.o):
relocation R_X86_64_32 can not be used when making a shared object;
recompile with -fPIC
/scratch/python2.5/lib/libcblas.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
/usr/bin/ld: /scratch/python2.5/lib/libcblas.a(cblas_dgemm.o):
relocation R_X86_64_32 can not be used when making a shared object;
recompile with -fPIC
/scratch/python2.5/lib/libcblas.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error: Command "gcc -pthread -shared
build/temp.linux-x86_64-2.5/numpy/core/blasdot/_dotblas.o
-L/scratch/python2.5/lib -lcblas -latlas -o
build/lib.linux-x86_64-2.5/numpy/core/_dotblas.so" failed with exit
status 1

I then tried to recompile atlas with the configure options as:

configure --cflags=-fPIC
--with-netlib-lapack=/scratch/src/python_dist/LAPACK
--prefix=/scratch/python2.5

but the error still remains. I'm on a 2 CPU Intel Xeon machine with
gcc 3.2.3.

Any hints?

Hanno

-- 
Hanno Klemm
[EMAIL PROTECTED]



-
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] naive RNG question

2006-10-11 Thread Alan G Isaac
Python's MT documentation exmphasize the period of the 
MT19937 algorithm but discusses not at all the seed size.
The numpy documentation contains no commentary (I believe).
Speaking from a position of utter RNG ignorance, seed size
seems really important too: why is it not discussed?
I noticed this algorithm
http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
provides explicitly for seed size choice, which suggests
that some documentation in this area would not be irrelevant
(and also addresses some other interesting technical issues).

Just trying to understand a bit better.
Thanks in advance for any helpful comments or URLs,
Alan Isaac



-
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] asmatrix and asarray exception

2006-10-11 Thread Keith Goodman
This works:

>> M.asmatrix(['a', 'b', None])
matrix([[a, b, None]], dtype=object)

But this doesn't:

>> M.asmatrix(['a', 'b', None, 'c'])
TypeError: expected a readable buffer object

>> M.__version__
'1.0rc1'

It also doesn't work for asarray and for tuples.

-
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] asmatrix and asarray exception

2006-10-11 Thread Keith Goodman
On 10/11/06, Keith Goodman <[EMAIL PROTECTED]> wrote:
> This works:
>
> >> M.asmatrix(['a', 'b', None])
> matrix([[a, b, None]], dtype=object)
>
> But this doesn't:
>
> >> M.asmatrix(['a', 'b', None, 'c'])
> TypeError: expected a readable buffer object
>
> >> M.__version__
> '1.0rc1'
>
> It also doesn't work for asarray and for tuples.
>

Here's a workaround:

>> M.asmatrix(['a', 'b', None, 'c'], dtype=object)
matrix([[a, b, None, c]], dtype=object)

-
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] naive RNG question

2006-10-11 Thread Charles R Harris
On 10/11/06, Alan G Isaac <[EMAIL PROTECTED]> wrote:
Python's MT documentation exmphasize the period of theMT19937 algorithm but discusses not at all the seed size.The numpy documentation contains no commentary (I believe).Speaking from a position of utter RNG ignorance, seed size
seems really important too: why is it not discussed?I noticed this algorithmhttp://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html
provides explicitly for seed size choice, which suggeststhat some documentation in this area would not be irrelevant(and also addresses some other interesting technical issues).The maximum seed size is 624 32bit words. No doubt the documentation should mention this.
Chuck
-
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] asmatrix and asarray exception

2006-10-11 Thread Travis Oliphant
Keith Goodman wrote:

>On 10/11/06, Keith Goodman <[EMAIL PROTECTED]> wrote:
>  
>
>>This works:
>>
>>
>>
M.asmatrix(['a', 'b', None])


>>matrix([[a, b, None]], dtype=object)
>>
>>But this doesn't:
>>
>>
>>
M.asmatrix(['a', 'b', None, 'c'])


>>TypeError: expected a readable buffer object
>>
>>
>>
M.__version__


>>'1.0rc1'
>>
>>It also doesn't work for asarray and for tuples.
>>
>>
>>
>
>  
>
It is pretty fragile to rely on NumPy's "detection" of object arrays.  
The problem is that with the introduction of string, unicode, and record 
array styles, what is supposed to be an object array is harder to detect. 

The type-error propagates up from trying to create a record-array 
(apparently that's what was detected).  You can only create record-array 
items from tuples or objects exposing the buffer interface. 

It's interesting that the detection algorithm gets thrown off by the 
addition of an other element.  There may be an easy fix there.

-Travis


-
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] cannot import Numeric

2006-10-11 Thread Carl Wenrich
The installation of Numpy went well, and numeric.py is in the python site-packages/numpy/core directory. But when I run python, and enter import Numeric, it says no module named Numeric. Please advise.  Carl  -
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] Compile with atlas 3.7.17 fails

2006-10-11 Thread Travis Oliphant
Hanno Klemm wrote:

>Hi, 
>
>I don't know if this is a bug or just me doing something wrong (I
>suspect the latter). I try to compile numpy-1.0rc1 with python2.5 and
>atlas 3.7.17.
>
>I have build the atlas library myself, it doesn't give any errors
>under make test or make pttest, so it seems to be okay. if I try to
>build numpy I get the following error:
>
>creating build/temp.linux-x86_64-2.5/numpy/core/blasdot
>compile options: '-DATLAS_INFO="\"3.7.17\"" -Inumpy/core/blasdot
>-I/scratch/python2.5/include -Inumpy/core/include
>-Ibuild/src.linux-x86_64-2.5/numpy/core -Inumpy/core/src
>-Inumpy/core/include -I/scratch/python2.5/include/python2.5 -c'
>gcc: numpy/core/blasdot/_dotblas.c
>gcc -pthread -shared
>build/temp.linux-x86_64-2.5/numpy/core/blasdot/_dotblas.o
>-L/scratch/python2.5/lib -lcblas -latlas -o
>build/lib.linux-x86_64-2.5/numpy/core/_dotblas.so
>/usr/bin/ld: /scratch/python2.5/lib/libcblas.a(cblas_dgemm.o):
>relocation R_X86_64_32 can not be used when making a shared object;
>recompile with -fPIC
>  
>

This may be part of your problem.  It's looks like the linker is having 
a hard time making use of your compiled extension in a shared library.  
Perhaps you should make sure -fPIC is on when you compile atlas (I'm not 
sure how to do that --- perhaps setting CCFLAGS environment variable to 
include -fPIC would help).

-Travis


-
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] cannot import Numeric

2006-10-11 Thread Darren Dale
On Wednesday 11 October 2006 12:48, Carl Wenrich wrote:
> The installation of Numpy went well, and numeric.py is in the python
> site-packages/numpy/core directory. But when I run python, and enter import
> Numeric, it says no module named Numeric. Please advise.

import numpy

-
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] asmatrix and asarray exception

2006-10-11 Thread Charles R Harris
On 10/11/06, Keith Goodman <[EMAIL PROTECTED]> wrote:
On 10/11/06, Keith Goodman <[EMAIL PROTECTED]> wrote:> This works:>> >> M.asmatrix(['a', 'b', None])> matrix([[a, b, None]], dtype=object)
>> But this doesn't:>> >> M.asmatrix(['a', 'b', None, 'c'])> TypeError: expected a readable buffer object>As a side observation, I note that the 'None' is also non-printing:
>>> a = asarray(['a', 'b', None, 'c'], dtype=object)>>> a[2]>>> str(a[2])'None'I wonder if this should be changed?Chuck
-
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] cannot import Numeric

2006-10-11 Thread Carl Wenrich
thanks, but actually it's the other applications i want to use that have the 'import Numeric' line in them. i'm sure others have noted this before. what's the normal procedure?Darren Dale <[EMAIL PROTECTED]> wrote: On Wednesday 11 October 2006 12:48, Carl Wenrich wrote:> The installation of Numpy went well, and numeric.py is in the python> site-packages/numpy/core directory. But when I run python, and enter import> Numeric, it says no module named Numeric. Please advise.import numpy-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 easierDownload IBM WebSphere Application Server v.1.0.1 based on Apache
 Geronimohttp://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___Numpy-discussion mailing listNumpy-discussion@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/numpy-discussion-
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] asmatrix and asarray exception

2006-10-11 Thread Travis Oliphant
Charles R Harris wrote:

>
>
> On 10/11/06, *Keith Goodman* <[EMAIL PROTECTED] 
> > wrote:
>
> On 10/11/06, Keith Goodman <[EMAIL PROTECTED]
> > wrote:
> > This works:
> >
> > >> M.asmatrix(['a', 'b', None])
> > matrix([[a, b, None]], dtype=object)
> >
> > But this doesn't:
> >
> > >> M.asmatrix(['a', 'b', None, 'c'])
> > TypeError: expected a readable buffer object
> >
>
>
> As a side observation, I note that the 'None' is also non-printing:
>
> >>> a = asarray(['a', 'b', None, 'c'], dtype=object)
> >>> a[2]
> >>> str(a[2])
> 'None'
>
> I wonder if this should be changed?

That's Python's decision.  You are getting back the None object when you 
access element a[2].  Thus, there is no way to change it.

-Travis


-
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] cannot import Numeric

2006-10-11 Thread Travis Oliphant
Carl Wenrich wrote:

> thanks, but actually it's the other applications i want to use that 
> have the 'import Numeric' line in them. i'm sure others have noted 
> this before. what's the normal procedure?


You must install Numeric if a package needs Numeric.  As far as Python 
is concerned NumPy is a separate package. Packages must be "ported" to 
use numpy.  Please encourage the package author to port.  Help is 
available for open source packages.  Just ask on the list.

-Travis


-
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] cannot import Numeric

2006-10-11 Thread Carl Wenrich
thanks.Travis Oliphant <[EMAIL PROTECTED]> wrote: Carl Wenrich wrote:> thanks, but actually it's the other applications i want to use that > have the 'import Numeric' line in them. i'm sure others have noted > this before. what's the normal procedure?You must install Numeric if a package needs Numeric.  As far as Python is concerned NumPy is a separate package. Packages must be "ported" to use numpy.  Please encourage the package author to port.  Help is available for open source packages.  Just ask on the list.-Travis-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 easierDownload IBM
 WebSphere Application Server v.1.0.1 based on Apache Geronimohttp://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___Numpy-discussion mailing listNumpy-discussion@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/numpy-discussion-
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] select part of array using two conditions

2006-10-11 Thread Bill Baxter
On 10/11/06, Nils Wagner <[EMAIL PROTECTED]> wrote:
> Mark Bakker wrote:
> > Hello -
> >
> > I want to select part of an array using two conditions.
> > I know how to do it with one condition (and it works great), but when
> > I use two conditions I get an error message?
> > This is probably easy, but I cannot figure it out.
> > Thanks for any help, Mark
> >
> > >>> a = arange(10)
> > >>> a
> > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
> > >>> a[ a>2 ]
> > array([3, 4, 5, 6, 7, 8, 9])
> > >>> a[ a>2 and a<8 ]
> > Traceback (most recent call last):
> >   File "", line 1, in ?
> > a[ a>2 and a<8 ]
> > ValueError: The truth value of an array with more than one element is
> > ambiguous. Use a.any() or a.all()
> >
> > 
> >
> a[ (a>2) & (a<8) ]
>

& is bitwiase and which works fine for the booleans you get back from
comparisons like (a>2).  So in this case & is ok.

For arrays with non-boolean values (any non-zero is True) use logical_and:

a[ logical_and(c, d) ]

Logical_and works always to give you the boolean result.
'&' gives you the bitwise result, which is sometimes equivalent to the
boolean result.

--bb

-
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] Things to address for Py3K

2006-10-11 Thread Travis Oliphant

Hi all,

Py3K is undergoing active development.  This gives us an opportunity to 
discuss more significant changes to the language that might improve the 
experience of NumPy users. 

We should form a list and start commenting on the py3k mailing lists 
about what changes would be most  helpful for our community.

Please provide examples of changes to Python that you think might help us.

A couple on my short list

1) Adding a *few* new infix operators.

   a) an extra multiplication operator to distinguish between 
element-by-element and dot
   b) extending 'and' and 'or' to allow element-by-element logical 
operations or adding && and ||

2) Lowering the precedence of & so that a > 8 & a < 10  works as you 
would expect.




-
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] Things to address for Py3K

2006-10-11 Thread Christopher Barker
Travis Oliphant wrote:
> A couple on my short list
> 
> 1) Adding a *few* new infix operators.
> 
>a) an extra multiplication operator to distinguish between 
> element-by-element and dot
>b) extending 'and' and 'or' to allow element-by-element logical 
> operations or adding && and ||
> 
> 2) Lowering the precedence of & so that a > 8 & a < 10  works as you 
> would expect.

Maybe this goes without saying, but:

3) Inclusion of an nd-array type in the standard lib!

(or at the very least, an nd-array protocol)

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
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] Things to address for Py3K

2006-10-11 Thread Travis Oliphant
Christopher Barker wrote:

>Travis Oliphant wrote:
>  
>
>>A couple on my short list
>>
>>1) Adding a *few* new infix operators.
>>
>>   a) an extra multiplication operator to distinguish between 
>>element-by-element and dot
>>   b) extending 'and' and 'or' to allow element-by-element logical 
>>operations or adding && and ||
>>
>>2) Lowering the precedence of & so that a > 8 & a < 10  works as you 
>>would expect.
>>
>>
>
>Maybe this goes without saying, but:
>
>3) Inclusion of an nd-array type in the standard lib!
>
>(or at the very least, an nd-array protocol)
>  
>
Work on an nd-array protocol to extend the buffer protocol is occurring 
right now.  It think this will be better in the end then a standard 
nd-array type. 

I think a multi-dimensional object array would at least be a nice step.

There are enough differences between lists and 1-d arrays though, that 
I'm not sure the accepted multi-dimensional object array would just be 
the NumPy version.  

-Travis


-
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] Things to address for Py3K

2006-10-11 Thread Charles R Harris
On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
Hi all,Py3K is undergoing active development.  This gives us an opportunity todiscuss more significant changes to the language that might improve theexperience of NumPy users.We should form a list and start commenting on the py3k mailing lists
about what changes would be most  helpful for our community.Please provide examples of changes to Python that you think might help us.A couple on my short list1) Adding a *few* new infix operators.
   a) an extra multiplication operator to distinguish betweenelement-by-element and dot   b) extending 'and' and 'or' to allow element-by-element logicaloperations or adding && and ||2) Lowering the precedence of & so that a > 8 & a < 10  works as you
would expect.Yes on the extra operators. No on changing the precedence of &, that would just confuse the heck out of all us c/c++ programmers; && and || would be good. Yes to something that improves on the buffer interface, although it is certainly usable right now.
Speaking long term, what about data types? The basic 80 bit extended precision float now occurs in 80, 96, and 128 bit versions depending on alignment. So what happens when quad precision, which will probably be in the next IEEE standard, comes down the pike and is 128 bits long? The length of a float will no longer be sufficient to distinguish the various types.
Chuck
-
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] sheet wizard create truly

2006-10-11 Thread Our Partners



Here log in you are raquo Magazine Home Todays 
Compact din Rail.Just anything in several skins choose between own style 
Creating takes few seconds click get.Create truly unique layout Change every 
of image Template system Thread a count Total.Modules Devices Embedded 
Systems Displays Packaging Passive Discrete Power Sources ics is Sensors or 
Actuators Test or Search Welcome.

Charts Webcasts or Tools ecards Search Reviews 
Infolink Events Peer rss Contact us for.Reviews Infolink Events Peer rss 
Contact is us for Boards amp Modules is.Sector but recognize they in must 
meet of stringent Slightly Semi a Forecast With signs of major dropoff 
this?Profile page Exco simple message advanced features Your hosted 
by.Archives Related Links web Exclusive Wall Charts Webcasts Tools ecards 
Search Reviews Infolink in Events in Peer a.Hosted by dontt worry about am 
backups bandwidth a usage community building is customize just anything several 
skins in choose between own style.Extras Articles or Plus Features Rohs 
Central Robust Data key Success ada Managing Complex Clock Networks Satellite 
Readers.Template system Thread count a Total visitors Whos a online number 
or users Last Member Personal gallery of images account profile page a 
Exco.Difficult sector but recognize is they must meet stringent Slightly 
Semi Forecast With a signs major dropoff a this market research.Made Simple 
of Rising energy prices focusing consumers design features home operation 
or.Open door of entry is into difficult is sector but recognize they is must 
meet stringent Slightly is Semi Forecast With signs is.For Boards amp am 
Modules Devices Embedded Systems Displays Packaging Passive Discrete in Power 
Sources or.Made Simple Rising is energy am prices focusing consumers design 
features home operation a such Consumers Lift Finger many years 
writers.Message advanced features Your hosted is by of dontt worry or about 
backups bandwidth usage community building or customize is just 
anything.Satellite Readers Most or Accessed with or low in Frequency am 
Usbee Extractor users Visualize bus Macbased Software Designed 
Loggers.
-
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


[Numpy-discussion] round

2006-10-11 Thread Greg Willden
Hi All,I've read discussions in the archives about how round() "rounds to even" and how that is supposedly better.But what I haven't been able to find is "What do I use if I want the regular old round that you learn in school?"
Sorry for the likely FAQ.Greg-- Linux.  Because rebooting is for adding hardware.
-
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] round

2006-10-11 Thread Charles R Harris
On 10/11/06, Greg Willden <[EMAIL PROTECTED]> wrote:
Hi All,I've read discussions in the archives about how round() "rounds to even" and how that is supposedly better.But what I haven't been able to find is "What do I use if I want the regular old round that you learn in school?"
Perhaps you could explain *why* you want the schoolbook round? Given that floating point is inherently inaccurate you would have to expect to produce a lot of numbers exactly of the form x.5 *without errors*, which means you probably don't need round to deal with it. Anyway, absent a flag somewhere, you can do something like (x + sign(x)*.5).astype(int).
Chuck
-
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] Library problem on installation

2006-10-11 Thread Michael Subotin
Hi,

I know that it's a perennial topic on the list, but I haven't been able
to find my answer in the archives. After running the installation on a
RedHat Linux machine, I'm getting the import error:
"/usr/lib/libblas.so.3: undefined symbol: e_wsfe". Judging from earlier
exchanges here, it seems that I need to add libg2c (which this machine
does have in /usr/lib, unlike g2c) somewhere between 'f77blas' and
'cblas', but I'm not sure where I should make this change. Not being
well versed in Python distributions, I tried my luck with a few
candidates and the import error remains. The machine should be running
gcc.

Thanks for any help.

Michael 
-
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] round

2006-10-11 Thread Greg Willden
On 10/11/06, Charles R Harris <[EMAIL PROTECTED]> wrote:
Perhaps you could explain *why* you want the schoolbook round? Given that floating point is inherently inaccurate you would have to expect to produce a lot of numbers exactly of the form x.5 *without errors*, which means you probably don't need round to deal with it. Anyway, absent a flag somewhere, you can do something like (x + sign(x)*.5).astype(int).
Yeah.  Forget it.  That was stupid of me to step into that one.This has obviously been discussed before and you have good reasons for doing it the way you do it.Carry on.
Greg-- Linux.  Because rebooting is for adding hardware.
-
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] round

2006-10-11 Thread Bill Baxter
Hmm. I learned "round to even" in school...

But another formula that should get you what you want is:
   floor(x + 0.5).astype(int)

--bb

On 10/12/06, Greg Willden <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I've read discussions in the archives about how round() "rounds to even" and
> how that is supposedly better.
>
> But what I haven't been able to find is "What do I use if I want the regular
> old round that you learn in school?"
>
> Sorry for the likely FAQ.
> Greg
> --
> Linux.  Because rebooting is for adding hardware.
> -
> 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
>
>
>

-
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 Travis Oliphant
[EMAIL PROTECTED] wrote:

>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".
>  
>
This was a consequence of moving scipy_base into NumPy but not exposing 
the scimath library in NumPy.   It would be a very easy thing to put 
from numpy.lib.scimath import *
into the scipy name-space.

I'm supportive of that as a backward-compatibility measure.

>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?
>  
>
Because that is backwards compatible.  You have to construct a 
function-wrapper in order to handle the negative case correctly.  The 
function wrapper is going to be slower.  Thus, it is placed in a 
separate library.

>Could sqrt(-1) made to return 1j again? 
>
Not in NumPy.  But, in scipy it could.

>If not, shouldn't
>  
>
>numpy.sqrt(-1) raise a ValueError instead of returning silently nan?
>  
>
This is user adjustable.  You change the error mode to raise on 
'invalid' instead of pass silently which is now the default.

-Travis



-
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 Sven Schreiber
Travis Oliphant schrieb:

> 
>> If not, shouldn't
>>  
>>
>> numpy.sqrt(-1) raise a ValueError instead of returning silently nan?
>>  
>>
> This is user adjustable.  You change the error mode to raise on 
> 'invalid' instead of pass silently which is now the default.
> 
> -Travis
> 

Could you please explain how this adjustment is done, or point to the
relevant documentation.
Thank you,
Sven

-
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 Travis Oliphant
Sven Schreiber wrote:

>>This is user adjustable.  You change the error mode to raise on 
>>'invalid' instead of pass silently which is now the default.
>>
>>-Travis
>>
>>
>>
>
>Could you please explain how this adjustment is done, or point to the
>relevant documentation.
>  
>

numpy.sqrt(-1)

old = seterr(invalid='raise')
numpy.sqrt(-1)  # should raise an error

seterr(**old)  # restores error-modes for current thread
numpy.sqrt(-1)





-
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] Things to address for Py3K

2006-10-11 Thread Christopher Barker
Travis Oliphant wrote:
>> 3) Inclusion of an nd-array type in the standard lib!
>> (or at the very least, an nd-array protocol)
>>
> Work on an nd-array protocol to extend the buffer protocol is occurring 
> right now.  It think this will be better in the end then a standard 
> nd-array type. 

Well, yes, if you have to choose just one. I'd like to see both.

> I think a multi-dimensional object array would at least be a nice step.

Me too. n-d slicing is so handy.

> There are enough differences between lists and 1-d arrays though, that 
> I'm not sure the accepted multi-dimensional object array would just be 
> the NumPy version.  

I guess the question is whether the goal is an n-d list or an n-d array. 
The key difference that I see is that numpy arrays are not re-sizable. 
But I have to wonder how practical it is to make an nd-array re-sizable, 
and, indeed, how that would work. I'm not sure what the n-d version of 
append() would be.

Numpy provides three things that I think are key:

1) An n-d array data structure. These are very useful for lots of things 
where an multi-dimensional data structure just makes sense. For these 
cases, you need the object array type (class?), and  n-d slicing.

2) array arithmetic: I'm a big fan of list comprehensions, but:

A = [x * 2 for x in B]

really is a LOT klunkier, and far less clear, than:

A = 2 * B

or even worse:

A = []
for x in B:
 A.append(2*x)

While array arithmetic is often seen primarily as a performance 
advantage (which, of course, it is) I also think it is a real boon to 
clear, error-free coding, and Python could use that.

3) A bunch of other really "mathy" or "scientific" functions:
(looking in the numpy book here)

polynomial functions
set operations (hmm -- there is a Python set type)
bessel functions
smoothing windows
fft
llinalg
etc.
etc.

These really do belong in numpy (scipy?), rather than the standard lib.

However this turn out, thanks for keeping numpy in the py3k loop.

-Chris










-- 
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
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 Fernando Perez
On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:

> [EMAIL PROTECTED] wrote:
> >Could sqrt(-1) made to return 1j again?
> >
> Not in NumPy.  But, in scipy it could.

Without taking sides on which way to go, I'd like to -1 the idea of a
difference in behavior between numpy and scipy.

IMHO, scipy should be within reason a strict superset of numpy.
Gratuitious differences in behavior like this one are going to drive
us all mad.

There are people who import scipy for everything, others distinguish
between numpy and scipy, others use numpy alone and at some point in
their life's code they do

import numpy as N -> import scipy as N

because they start needing stuff not in plain numpy.  Having different
APIs and behaviors appear there is, I think, a Seriously Bad Idea
(TM).

Just my 1e-2j,

Cheers,

f

-
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] Things to address for Py3K

2006-10-11 Thread A. M. Archibald
On 11/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote:

> Speaking long term, what about data types? The basic 80 bit extended
> precision float now occurs in 80, 96, and 128 bit versions depending on
> alignment. So what happens when quad precision, which will probably be in
> the next IEEE standard, comes down the pike and is 128 bits long? The length
> of a float will no longer be sufficient to distinguish the various types.

This doesn't require python 3K; it can happn in numpy with no language
support. But perhaps python 3K can be viewed as a chance to ditch
backwards-compatibility baggage? (cough, Numeric compatibility, cough)

Would it be of interest to have numeric datatypes integrated with
python datatypes? How about IEEE floats in python proper, at least? It
can be rather confusing when doing a calculation yields different
results for arrays than for ordinary scalars...

A. M. Archibald

-
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] Things to address for Py3K

2006-10-11 Thread Christopher Barker
A. M. Archibald wrote:
> IEEE floats in python proper

+1

-CHB

-- 
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]

-
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 Travis Oliphant
Fernando Perez wrote:

>On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
>
>  
>
>>[EMAIL PROTECTED] wrote:
>>
>>
>>>Could sqrt(-1) made to return 1j again?
>>>
>>>  
>>>
>>Not in NumPy.  But, in scipy it could.
>>
>>
>
>Without taking sides on which way to go, I'd like to -1 the idea of a
>difference in behavior between numpy and scipy.
>
>IMHO, scipy should be within reason a strict superset of numpy.
>  
>
This was not the relationship of scipy to Numeric.

For me, it's the fact that scipy *used* to have the behavior that

scipy.sqrt(-1) return 1j

and now doesn't  that is the kicker. 

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.

So, I committed a change to scipy to bring it back into compatibility 
with 0.3.2



>Gratuitious differences in behavior like this one are going to drive
>us all mad.
>
>There are people who import scipy for everything, others distinguish
>between numpy and scipy, others use numpy alone and at some point in
>their life's code they do
>
>import numpy as N -> import scipy as N
>
>because they start needing stuff not in plain numpy.  Having different
>APIs and behaviors appear there is, I think, a Seriously Bad Idea
>(TM).
>  
>
I think the SBI is mixing numpy and scipy gratuitously  (which I admit I 
have done in the past).  I'm trying to repent

-Travis



-
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 Tim Hochberg
Travis Oliphant wrote:
> Sven Schreiber wrote:
>
>   
>>> This is user adjustable.  You change the error mode to raise on 
>>> 'invalid' instead of pass silently which is now the default.
>>>
>>> -Travis
>>>
>>>
>>>
>>>   
>> Could you please explain how this adjustment is done, or point to the
>> relevant documentation.
>>  
>>
>> 
>
> numpy.sqrt(-1)
>
> old = seterr(invalid='raise')
> numpy.sqrt(-1)  # should raise an error
>
> seterr(**old)  # restores error-modes for current thread
> numpy.sqrt(-1)
>
>   
With python 2.5 out now, perhaps it's time to come up with a with 
statement context manager. Something like:

from __future__ import with_statement
import numpy

class errstate(object):
def __init__(self, **kwargs):
self.kwargs = kwargs
def __enter__(self):
self.oldstate = numpy.seterr(**self.kwargs)
def __exit__(self, *exc_info):
numpy.seterr(**self.oldstate)
   
a = numpy.arange(10)
a/a # ignores divide by zero
with errstate(divide='raise'):
a/a # raise exception on divide by zer
# Would ignore divide by zero again if we got here.

-tim




-
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] Things to address for Py3K

2006-10-11 Thread Eric Firing
Charles R Harris wrote:
[...]
>b) extending 'and' and 'or' to allow element-by-element logical
> operations or adding && and ||
> 
> 2) Lowering the precedence of & so that a > 8 & a < 10  works as you
> would expect.
> 
> 
> Yes on the extra operators. No on changing the precedence of &, that 
> would just confuse the heck out of all us c/c++ programmers; && and || 
> would be good. 

Travis's suggestion 2 is consistent with c/c++, where precedence 
increases from logical to bitwise to relational. (e.g., 
http://www.cs.niu.edu/~duffin/csci241/precedence.html).

Python precedence now increases from logical to relational to bitwise, 
so it is inconsistent with c/c++. 
(http://docs.python.org/ref/summary.html#l2h-456)

Eric

-
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 Fernando Perez
On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> Fernando Perez wrote:

> >IMHO, scipy should be within reason a strict superset of numpy.
> >
> >
> This was not the relationship of scipy to Numeric.
>
> For me, it's the fact that scipy *used* to have the behavior that
>
> scipy.sqrt(-1) return 1j
>
> and now doesn't  that is the kicker.

That's fine, my only point was that we should really strive for
consitency between the two.  I think most users should be able to
expect that

numpy.foo(x) == scipy.foo(x)

for all cases where foo exists in both.  The scipy.foo() call might be
faster, or take extra arguments for flexibility, and the above might
only be true within floating point accuracy (since a different
algorithm may be used), but hopefully functions with the same name do
the same thing in both.

I really think breaking this will send quite a few potential users
running for the hills, and this is what I meant by 'superset'. Perhaps
I wasn't clear enough.

Cheers,

f

-
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 Fernando Perez
On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> Fernando Perez wrote:

> >There are people who import scipy for everything, others distinguish
> >between numpy and scipy, others use numpy alone and at some point in
> >their life's code they do
> >
> >import numpy as N -> import scipy as N
> >
> >because they start needing stuff not in plain numpy.  Having different
> >APIs and behaviors appear there is, I think, a Seriously Bad Idea
> >(TM).
> >
> >
> I think the SBI is mixing numpy and scipy gratuitously  (which I admit I
> have done in the past).  I'm trying to repent

Well, the problem is that it may not be so easy not to do so, esp. for
new users.  The fact that scipy absorbs and exposes many numpy
functions makes this a particularly easy trap for anyone to fall into.
The fact that even seasoned users do it should be an indicator that
the 'right thing to do' is anything but obvious, IMHO.

Once the dust settles on numpy 1.0, I think that the issues of how
scipy plays with it, API consistency, coding best practices, etc, will
need serious attention.  But let's cross one bridge at a time :)

Cheers,

f

-
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 Stefan van der Walt
On Wed, Oct 11, 2006 at 03:37:34PM -0600, Fernando Perez wrote:
> On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> 
> > [EMAIL PROTECTED] wrote:
> > >Could sqrt(-1) made to return 1j again?
> > >
> > Not in NumPy.  But, in scipy it could.
> 
> Without taking sides on which way to go, I'd like to -1 the idea of a
> difference in behavior between numpy and scipy.
> 
> IMHO, scipy should be within reason a strict superset of numpy.
> Gratuitious differences in behavior like this one are going to drive
> us all mad.
> 
> There are people who import scipy for everything, others distinguish
> between numpy and scipy, others use numpy alone and at some point in
> their life's code they do
> 
> import numpy as N -> import scipy as N
> 
> because they start needing stuff not in plain numpy.  Having different
> APIs and behaviors appear there is, I think, a Seriously Bad Idea
> (TM).

I agree with Fernando on this one.

Further, if I understand correctly, changing sqrt and power to give
the right answer by default will slow things down somewhat.  But is it
worth sacrificing intuitive usage for speed?

N.power(2,-2) == 0

and

N.sqrt(-1) == nan

just doesn't feel right.  Why not then have

N.power(2,-2) == 0.24
N.sqrt(-1) == 1j

and write a special function that does fast calculation of
square-roots for positive values?

Cheers
Stéfan

-
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


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

2006-10-11 Thread Travis Oliphant
Stefan van der Walt wrote:

>I agree with Fernando on this one.
>
>Further, if I understand correctly, changing sqrt and power to give
>the right answer by default will slow things down somewhat.  But is it
>worth sacrificing intuitive usage for speed?
>  
>
For NumPy, yes. 

This is one reason that NumPy by itself is not a MATLAB replacement. 

>N.power(2,-2) == 0
>
>and
>
>N.sqrt(-1) == nan
>
>just doesn't feel right.  
>

Only because your expectations are that NumPy *be* a MATLAB 
replacement.  The problem is that it sacrifices too much for that to be 
the case.   And we all realize that NumPy needs more stuff added to it 
to be like IDL/MATLAB such as SciPy, Matplotlib, IPython, etc.

>Why not then have
>
>N.power(2,-2) == 0.24
>N.sqrt(-1) == 1j
>
>and write a special function that does fast calculation of
>square-roots for positive values?
>  
>

We've already done this.  The special functions are called

numpy.power
numpy.sqrt

(notice that if you do numpy.sqrt(-1+0j) you get the "expected" answer 
emphasizing that numpy does no "argument" checking to determine the output).

The "intuitive" functions (which must do argument checking) are (in 
numpy.lib.scimath) but exported as

scipy.power (actually I need to check that one...)
scipy.sqrt

What could be simpler?  ;-)

-Travis



-
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 Travis Oliphant
[EMAIL PROTECTED] wrote:

>
>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
>  
>

This is the one that concerns me.  Slowing everybody down who knows they 
have positive values just for people that don't seems problematic.

>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,
>  
>
Yeah, they do.   This actually makes the case for masked arrays, rather 
than using NAN's.


-Travis


-
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] RC2 - f2py no workee

2006-10-11 Thread Mathew Yeates
I'm running the following
python c:\Python24\Scripts\f2py.py  --fcompiler=absoft -c foo.pyf  foo.f

and it seems that the compiler info isn't being passed down. When 
distutils tries to compile I get the error

---
  File 
"C:\Python24\Lib\site-packages\numpy\distutils\command\build_ext.py", li
e 260, in build_extension
f_objects += self.fcompiler.compile(f_sources,
AttributeError: 'NoneType' object has no attribute 'compile'


so the fcompiler isn't being set. Any help?
Mathew

Here is the complete stack trace
Traceback (most recent call last):
  File "c:\Python24\Scripts\f2py.py", line 26, in ?
main()
  File "C:\Python24\Lib\site-packages\numpy\f2py\f2py2e.py", line 552, 
in main
run_compile()
  File "C:\Python24\Lib\site-packages\numpy\f2py\f2py2e.py", line 539, 
in run_co
mpile
setup(ext_modules = [ext])
  File "C:\Python24\Lib\site-packages\numpy\distutils\core.py", line 
174, in set
up
return old_setup(**new_attr)
  File "C:\Python24\lib\distutils\core.py", line 149, in setup
dist.run_commands()
  File "C:\Python24\lib\distutils\dist.py", line 946, in run_commands
self.run_command(cmd)
  File "C:\Python24\lib\distutils\dist.py", line 966, in run_command
cmd_obj.run()
  File "C:\Python24\lib\distutils\command\build.py", line 112, in run
self.run_command(cmd_name)
  File "C:\Python24\lib\distutils\cmd.py", line 333, in run_command
self.distribution.run_command(command)
  File "C:\Python24\lib\distutils\dist.py", line 966, in run_command
cmd_obj.run()
  File 
"C:\Python24\Lib\site-packages\numpy\distutils\command\build_ext.py", lin
e 121, in run
self.build_extensions()
  File "C:\Python24\lib\distutils\command\build_ext.py", line 405, in 
build_exte
nsions
self.build_extension(ext)
  File 
"C:\Python24\Lib\site-packages\numpy\distutils\command\build_ext.py", lin
e 260, in build_extension
f_objects += self.fcompiler.compile(f_sources,
AttributeError: 'NoneType' object has no attribute 'compile'




-
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] incrementing along a diagonal

2006-10-11 Thread David Novakovic
Johannes Loehnert wrote:
>> I'm just wondering if there is a way that i can increment all the values
>> along a diagonal?
>> 
>
> Assume you want to change mat.
>
> # min() only necessary for non-square matrices
> index = arange(min(mat.shape[0], mat.shape[1]))
> # add 1 to each diagonal element
> matrix[index, index] += 1
> # add some other stuff
> matrix[index, index] += some_array_shaped_like_index
>
>
> HTH, Johannes
>
>   
Thank you very much for the prompt reply, I'm just having a problem with
this method:
This method appears to only work if the matrix is mxm for example:

>>> zeros((5,5))
array([[0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0]])
>>> x = zeros((5,5))
>>> index = arange(min(x.shape[0],x.shape[1]))
>>> x[index,index] += 1
>>> x
array([[1, 0, 0, 0, 0],
   [0, 1, 0, 0, 0],
   [0, 0, 1, 0, 0],
   [0, 0, 0, 1, 0],
   [0, 0, 0, 0, 1]])
>>>

This is very nice, exactly what i want, but it doesnt work for mxn
matricies:

>>> x = zeros((5,3))
>>> x
array([[0, 0, 0],
   [0, 0, 0],
   [0, 0, 0],
   [0, 0, 0],
   [0, 0, 0]])
>>> index = arange(min(x.shape[0],x.shape[1]))
>>> x[index,index] += 1
>>> x
array([[1, 0, 0],
   [0, 1, 0],
   [0, 0, 1],
   [0, 0, 0],
   [0, 0, 0]])
>>>

So the min part is right for mxn matrices - but perhaps there is a way
to use the index differently. I'm very new to numpy, so excuse my
noobness :)

Just for reference, this is the line of perl i'm trying to port:


(my $dummy = $ones->diagonal(0,1))++;  # ones is a matrix created with
zeroes()

Yes, i know it is horribly ugly, but in this case, diagonal returns a
list of references to the values in the original matrix, so values can
be changed in place. I much prefer python - hence the port, but it seems
like a hard thing to replicate. Perhaps there could be a function that
returns an iterator over the values in a matrix and returns the index's.

like:

for index in diag_iter(matrix,*axes):
matrix[index] +=1


Once again, cheers - i hope we can figure something out :)

Dave Novakovic

PS: If anyone would care to link me to the subscription page for the
mailing list so you dont have to CC me all the time :)

-
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 Travis Oliphant
Tim Hochberg wrote:

>With python 2.5 out now, perhaps it's time to come up with a with 
>statement context manager. Something like:
>
>from __future__ import with_statement
>import numpy
>
>class errstate(object):
>def __init__(self, **kwargs):
>self.kwargs = kwargs
>def __enter__(self):
>self.oldstate = numpy.seterr(**self.kwargs)
>def __exit__(self, *exc_info):
>numpy.seterr(**self.oldstate)
>   
>a = numpy.arange(10)
>a/a # ignores divide by zero
>with errstate(divide='raise'):
>a/a # raise exception on divide by zer
># Would ignore divide by zero again if we got here.
>
>-tim
>
>  
>

This looks great.  I think most people aren't aware of the with 
statement and what it can do (I'm only aware because of your posts, for 
example). 

So, what needs to be added to your example in order to just add it to 
numpy?

-Travis


-
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] incrementing along a diagonal

2006-10-11 Thread Bill Baxter
On 10/12/06, David Novakovic <[EMAIL PROTECTED]> wrote:
> Johannes Loehnert wrote:
> This is very nice, exactly what i want, but it doesnt work for mxn
> matricies:
>
> >>> x = zeros((5,3))
> >>> x
> array([[0, 0, 0],
>[0, 0, 0],
>[0, 0, 0],
>[0, 0, 0],
>[0, 0, 0]])
> >>> index = arange(min(x.shape[0],x.shape[1]))
> >>> x[index,index] += 1
> >>> x
> array([[1, 0, 0],
>[0, 1, 0],
>[0, 0, 1],
>[0, 0, 0],
>[0, 0, 0]])

Exactly what output are you expecting?  That is the definition of the
'diagonal' for a non-square matrix.  If you're expecting something
else then what you want is not the diagonal.

> Just for reference, this is the line of perl i'm trying to port:
>
>
> like:
>
> for index in diag_iter(matrix,*axes):
> matrix[index] +=1

That's not going to change the mathematical definition of the diagonal
of a non-square matrix.

> PS: If anyone would care to link me to the subscription page for the
> mailing list so you dont have to CC me all the time :)

Check the bottom of this message.

> ___
> Numpy-discussion mailing list
> Numpy-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>

--bb

-
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 Pierre GM

> >nan's are making things really slow,
>
> Yeah, they do.   This actually makes the case for masked arrays, rather
> than using NAN's.

Travis,
Talking about masked arrays, I'm about being done rewriting numpy.core.ma, 
mainly transforming MaskedArray as a subclass of ndarray (it should be OK by 
the end of the week), and allowing for an easy subclassing of MaskedArrays 
(which is far from being the case right now)

What would be the best procedure to submit it ? Ticket on SVN ? Wiki on 
scipy.org ?

Thanks again for your time !

Pierre

-
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 Stefan van der Walt
On Wed, Oct 11, 2006 at 05:21:44PM -0600, Travis Oliphant wrote:
> Stefan van der Walt wrote:
> 
> >I agree with Fernando on this one.
> >
> >Further, if I understand correctly, changing sqrt and power to give
> >the right answer by default will slow things down somewhat.  But is it
> >worth sacrificing intuitive usage for speed?
> >  
> >
> For NumPy, yes. 
> 
> This is one reason that NumPy by itself is not a MATLAB
> replacement. 

Intuitive usage is hopefully not a MATLAB-only feature.

> >N.power(2,-2) == 0
> >
> >and
> >
> >N.sqrt(-1) == nan
> >
> >just doesn't feel right.  
> >
> 
> Only because your expectations are that NumPy *be* a MATLAB 
> replacement.  The problem is that it sacrifices too much for that to be 
> the case.   And we all realize that NumPy needs more stuff added to it 
> to be like IDL/MATLAB such as SciPy, Matplotlib, IPython, etc.

I have none such expectations -- I havn't used MATLAB in over 5 years.
All I'm saying is that, since the value of the square-root of -1 is
not nan and 2^(-2) is not 0, it doesn't surprise me that this
behaviour confuses people.

> The "intuitive" functions (which must do argument checking) are (in 
> numpy.lib.scimath) but exported as
> 
> scipy.power (actually I need to check that one...)
> scipy.sqrt
> 
> What could be simpler?  ;-)

I'm sure this is going to come back and haunt us.  We have two
libraries, one depends on and exposes the API of the other, yet it
also overrides some functions with its own behaviour, while keeping
the same names.

I'll shut up now :)

Cheers
Stéfan

-
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] incrementing along a diagonal

2006-10-11 Thread David Novakovic
Thanks for the help, i've learnt a lot and also figured out something
that does what I want,  i'll paste  an interactive session below:

 x = zeros((4,7))
 x
array([[0, 0, 0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0, 0, 0],
   [0, 0, 0, 0, 0, 0, 0]])
 index = arange(min(x.shape[0], x.shape[1]))
 index2 = copy.deepcopy(index) #deep copy may be overkill
 for a,b in enumerate(index):
...   index2[a] += a
...
 if len(x[:,0]) > len(x[0]):
...   x[index2,index] +=1
... else:
...   x[index,index2] +=1
...
 x
array([[1, 0, 0, 0, 0, 0, 0],
   [0, 0, 1, 0, 0, 0, 0],
   [0, 0, 0, 0, 1, 0, 0],
   [0, 0, 0, 0, 0, 0, 1]])


Thanks for the tips

Dave Novakovic

P.S. subscribed to the list now

Bill Baxter wrote:
> Forgot to CC you...
>
> -- Forwarded message --
> From: Bill Baxter <[EMAIL PROTECTED]>
> Date: Oct 12, 2006 8:58 AM
> Subject: Re: [Numpy-discussion] incrementing along a diagonal
> To: Discussion of Numerical Python
> 
>
>
> On 10/12/06, David Novakovic <[EMAIL PROTECTED]> wrote:
>> Johannes Loehnert wrote:
>> This is very nice, exactly what i want, but it doesnt work for mxn
>> matricies:
>>
>> >>> x = zeros((5,3))
>> >>> x
>> array([[0, 0, 0],
>>[0, 0, 0],
>>[0, 0, 0],
>>[0, 0, 0],
>>[0, 0, 0]])
>> >>> index = arange(min(x.shape[0],x.shape[1]))
>> >>> x[index,index] += 1
>> >>> x
>> array([[1, 0, 0],
>>[0, 1, 0],
>>[0, 0, 1],
>>[0, 0, 0],
>>[0, 0, 0]])
>
> Exactly what output are you expecting?  That is the definition of the
> 'diagonal' for a non-square matrix.  If you're expecting something
> else then what you want is not the diagonal.
>
>> Just for reference, this is the line of perl i'm trying to port:
>>
>>
>> like:
>>
>> for index in diag_iter(matrix,*axes):
>> matrix[index] +=1
>
> That's not going to change the mathematical definition of the diagonal
> of a non-square matrix.
>
>> PS: If anyone would care to link me to the subscription page for the
>> mailing list so you dont have to CC me all the time :)
>
> Check the bottom of this message.
>
>> ___
>> Numpy-discussion mailing list
>> Numpy-discussion@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>>
>
> --bb
>


-
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 A. M. Archibald
On 11/10/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

> """
> 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?

What is the desired behaviour of sqrt?

Should sqrt always return a complex array, regardless of the type of
its input? This will be extremely surprising to many users, whose
memory usage suddenly doubles and for whom many functions no longer
work the way they're accustomed to.

Should it return a complex array only when any entry in its input is
negative? This will be even *more* surprising when a negative (perhaps
even -0) value appears in their matrix (for example, does a+min(a)
yield -0s in the minimal values?) and suddenly it's complex.

A ValueError is also surprising, and it forces the user to sanitize
her array before taking the square root, instead of whenever
convenient.

If you want MATLAB behaviour, use only complex arrays.

If the problem is backward incompatibility, there's a reason 1.0
hasn't been released yet...

A. M. Archibald

-
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] SPAM-LOW: Re: incrementing along a diagonal

2006-10-11 Thread David Novakovic
David Novakovic wrote:
> Thanks for the help, i've learnt a lot and also figured out something
> that does what I want,  i'll paste  an interactive session below:
>
>  x = zeros((4,7))
>  x
> array([[0, 0, 0, 0, 0, 0, 0],
>[0, 0, 0, 0, 0, 0, 0],
>[0, 0, 0, 0, 0, 0, 0],
>[0, 0, 0, 0, 0, 0, 0]])
>  index = arange(min(x.shape[0], x.shape[1]))
>  index2 = copy.deepcopy(index) #deep copy may be overkill
>  for a,b in enumerate(index):
> ...   index2[a] += a
>   
Turns out this is not good at all. I guess I'm still open to suggestions
then :(

Dave
> ...
>  if len(x[:,0]) > len(x[0]):
> ...   x[index2,index] +=1
> ... else:
> ...   x[index,index2] +=1
> ...
>  x
> array([[1, 0, 0, 0, 0, 0, 0],
>[0, 0, 1, 0, 0, 0, 0],
>[0, 0, 0, 0, 1, 0, 0],
>[0, 0, 0, 0, 0, 0, 1]])
>
>
> Thanks for the tips
>
> Dave Novakovic
>
> P.S. subscribed to the list now
>
> Bill Baxter wrote:
>   
>> Forgot to CC you...
>>
>> -- Forwarded message --
>> From: Bill Baxter <[EMAIL PROTECTED]>
>> Date: Oct 12, 2006 8:58 AM
>> Subject: Re: [Numpy-discussion] incrementing along a diagonal
>> To: Discussion of Numerical Python
>> 
>>
>>
>> On 10/12/06, David Novakovic <[EMAIL PROTECTED]> wrote:
>> 
>>> Johannes Loehnert wrote:
>>> This is very nice, exactly what i want, but it doesnt work for mxn
>>> matricies:
>>>
>>>   
>> x = zeros((5,3))
>> x
>> 
>>> array([[0, 0, 0],
>>>[0, 0, 0],
>>>[0, 0, 0],
>>>[0, 0, 0],
>>>[0, 0, 0]])
>>>   
>> index = arange(min(x.shape[0],x.shape[1]))
>> x[index,index] += 1
>> x
>> 
>>> array([[1, 0, 0],
>>>[0, 1, 0],
>>>[0, 0, 1],
>>>[0, 0, 0],
>>>[0, 0, 0]])
>>>   
>> Exactly what output are you expecting?  That is the definition of the
>> 'diagonal' for a non-square matrix.  If you're expecting something
>> else then what you want is not the diagonal.
>>
>> 
>>> Just for reference, this is the line of perl i'm trying to port:
>>>
>>>
>>> like:
>>>
>>> for index in diag_iter(matrix,*axes):
>>> matrix[index] +=1
>>>   
>> That's not going to change the mathematical definition of the diagonal
>> of a non-square matrix.
>>
>> 
>>> PS: If anyone would care to link me to the subscription page for the
>>> mailing list so you dont have to CC me all the time :)
>>>   
>> Check the bottom of this message.
>>
>> 
>>> ___
>>> Numpy-discussion mailing list
>>> Numpy-discussion@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>>>
>>>   
>> --bb
>>
>> 
>
>
> -
> 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
>
>   


-
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 Stefan van der Walt
On Wed, Oct 11, 2006 at 08:24:01PM -0400, A. M. Archibald wrote:
> What is the desired behaviour of sqrt?

[...]

> Should it return a complex array only when any entry in its input is
> negative? This will be even *more* surprising when a negative (perhaps
> even -0) value appears in their matrix (for example, does a+min(a)
> yield -0s in the minimal values?) and suddenly it's complex.

Luckily sqrt(-0.) gives -0.0 and not nan ;)

Regards
Stéfan

-
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 Paul Dubois
This is a meta-statement about this argument.We already had it. Repeatedly. Whether you choose it one way or the other, for Numeric the community chose it the way it did for a reason. It is a good reason. It isn't stupid. There were good reasons for the other way. Those reasons weren't stupid. It was a 'choice amongst equals'.
Being compatible with some other package is all very nice but it is simply a different choice and the choice was already made 10 years ago. If scipy chose to do this differently then you now have an intractable problem; somebody is going to get screwed. 
So, next time somebody tells you that some different choice amongst equals should be made for this and that good reason, just say no.This is why having a project leader who is mean like me is better than having a nice guy like Travis. (:->

-
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 Tim Hochberg
Travis Oliphant wrote:
> Tim Hochberg wrote:
>
>   
>> With python 2.5 out now, perhaps it's time to come up with a with 
>> statement context manager. Something like:
>>
>>from __future__ import with_statement
>>import numpy
>>
>>class errstate(object):
>>def __init__(self, **kwargs):
>>self.kwargs = kwargs
>>def __enter__(self):
>>self.oldstate = numpy.seterr(**self.kwargs)
>>def __exit__(self, *exc_info):
>>numpy.seterr(**self.oldstate)
>>   
>>a = numpy.arange(10)
>>a/a # ignores divide by zero
>>with errstate(divide='raise'):
>>a/a # raise exception on divide by zer
>># Would ignore divide by zero again if we got here.
>>
>> -tim
>>
>>  
>>
>> 
>
> This looks great.  I think most people aren't aware of the with 
> statement and what it can do (I'm only aware because of your posts, for 
> example). 
>
> So, what needs to be added to your example in order to just add it to 
> numpy?
>   
As far as I know, just testing  and documentation -- however testing was 
so minimal that I may find some other stuff. I'll try to clean it up 
tomorrow so that I'm a little more confident that it works correctly and 
I'll send another note out then.


-tim



-
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] incrementing along a diagonal

2006-10-11 Thread Travis Oliphant
David Novakovic wrote:
> Hi,
>
> i'm moving some old perl PDL code to python. I've come across a line
> which changes values in a diagonal line accross a matrix.
>
> matrix.diagonal() returns a list of values, but making changes to these
> does not reflect in the original (naturally).
>
> I'm just wondering if there is a way that i can increment all the values
> along a diagonal?
>   

You can refer to a diagonal using flattened index with a element-skip 
equal to the number of columns+1.

Thus,

a.flat[::a.shape[1]+1] += 1

will increment the elements of a along the main diagonal.

-Travis




-
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 Greg Willden
On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
Stefan van der Walt wrote:>Further, if I understand correctly, changing sqrt and power to give>the right answer by default will slow things down somewhat.  But is it>worth sacrificing intuitive usage for speed?
>For NumPy, yes.This is one reason that NumPy by itself is not a MATLAB replacement.This is not about being a Matlab replacement.This is about correctness.Numpy purports to handle complex numbers.
Mathematically, sqrt(-1) is a complex number.Therefore Numpy *must* return a complex number.Speed should not take precedence over correctness.
If Numpy doesn't return a complex number then it shouldn't pretend to support complex numbers.Greg-- Linux.  Because rebooting is for adding hardware.
-
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 Bill Baxter
On 10/12/06, Greg Willden <[EMAIL PROTECTED]> wrote:
> On 10/11/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> > Stefan van der Walt wrote:
> > >Further, if I understand correctly, changing sqrt and power to give
> > >the right answer by default will slow things down somewhat.  But is it
> > >worth sacrificing intuitive usage for speed?
> > >
> > For NumPy, yes.
> >
> > This is one reason that NumPy by itself is not a MATLAB replacement.
>
> This is not about being a Matlab replacement.
> This is about correctness.
> Numpy purports to handle complex numbers.
> Mathematically, sqrt(-1) is a complex number.
> Therefore Numpy *must* return a complex number.
> Speed should not take precedence over correctness.

Unless your goal is speed.  Then speed should take precedence over correctness.

And unless you're a fan of quaternions, in which case *which* square
root of -1 should it return?

It's interesting to note that although python has had complex numbers
pretty much from the beginning, math.sqrt(-1) returns an error.  If
you want to work with complex square roots you need to use
cmath.sqrt().  Basically you have to tell python that compex numbers
are something you care about by using the module designed for complex
math.  This scimath module is a similar deal.

But perhaps the name could be a little more obvious / short?  Right
now it seems it only deals with complex numbers, so maybe having
"complex" or "cmath" in the name would make it clearer.  Hmm there is
a numpy.math, why not a numpy.cmath.

> If Numpy doesn't return a complex number then it shouldn't pretend to
> support complex numbers.

That's certainly being overdramatic.  Lot's of folks are doing nifty
stuff with complex FFTs every day using numpy/scipy.  And I'm sure
they will continue to no matter what numpy.sqrt(-1) returns.

--bb

-
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 Travis Oliphant
Greg Willden wrote:
> On 10/11/06, *Travis Oliphant* <[EMAIL PROTECTED] 
> > wrote:
>
> Stefan van der Walt wrote:
> >Further, if I understand correctly, changing sqrt and power to give
> >the right answer by default will slow things down somewhat.  But
> is it
> >worth sacrificing intuitive usage for speed?
> >
> For NumPy, yes.
>
> This is one reason that NumPy by itself is not a MATLAB replacement.
>
>
> This is not about being a Matlab replacement.
> This is about correctness.
I disagree.   NumPy does the "correct" thing when you realize that sqrt 
is a function that returns the same type as it's input.   The field 
over-which the operation takes place is defined by the input data-type 
and not the input "values".  Either way can be considered correct 
mathematically.   As Paul said it was a design decision not to go 
searching through the array to determine whether or not there are 
negative numbers in the array.

Of course you can do that if you want and that's what scipy.sqrt does. 
> Numpy purports to handle complex numbers.
> Mathematically, sqrt(-1) is a complex number.
Or, maybe it's undefined if you are in the field of real numbers.  It 
all depends.
> Therefore Numpy *must* return a complex number.
Only if the input is complex.  That is a reasonable alternative to your 
specification.
>
> If Numpy doesn't return a complex number then it shouldn't pretend to 
> support complex numbers.
Of course it supports complex numbers, it just doesn't support automatic 
conversion to complex numbers.It supports complex numbers the same 
way Python supports them (i.e. you have to use cmath to get sqrt(-1) == 1j)

People can look at this many ways without calling the other way of 
looking at it unreasonable. 

I don't see a pressing need to change this in NumPy, and in fact see 
many reasons to leave it the way it is.   This discussion should move to 
the scipy list because that is the only place where a change could occur.

-Travis.



-
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 Tim Hochberg
Greg Willden wrote:
> On 10/11/06, *Travis Oliphant* <[EMAIL PROTECTED] 
> > wrote:
>
> Stefan van der Walt wrote:
> >Further, if I understand correctly, changing sqrt and power to give
> >the right answer by default will slow things down somewhat.  But
> is it
> >worth sacrificing intuitive usage for speed?
> >
> For NumPy, yes.
>
> This is one reason that NumPy by itself is not a MATLAB replacement.
>
>
> This is not about being a Matlab replacement.
> This is about correctness.
> Numpy purports to handle complex numbers.
> Mathematically, sqrt(-1) is a complex number.
That's vastly oversimplified. If you are working with the reals, then 
sqrt(-1) is undefined (AKA nan). If you are working in the complex 
plane, then sqrt(-1) is indeed *a* complex number; of course you don't 
know *which* complex number it is unless you also specify the branch.
> Therefore Numpy *must* return a complex number.
No I don't think that it must. I've found it a very useful tool for the 
past decade plus without it returning complex numbers from sqrt.
> Speed should not take precedence over correctness.
The current behavior is not incorrect.
>
> If Numpy doesn't return a complex number then it shouldn't pretend to 
> support complex numbers.
Please relax.

Personally I think that the default error mode should be tightened up. 
Then people would only see these sort of things if they really care 
about them. Using Python 2.5 and the errstate class I posted earlier:

# This is what I like for the default error state
numpy.seterr(invalid='raise', divide='raise', over='raise',
under='ignore')

a = -numpy.arange(10)
with errstate(invalid='ignore'):
print numpy.sqrt(a) # This happily returns a bunch of NANs; and
one zero.
print numpy.sqrt(a.astype(complex)) # This returns a bunch of
complex values
print numpy.sqrt(a) # This raise a floating point error. No silent
NANs returned

This same error state make the vagaries of dividing by zero less 
surprising as well.

-tim





-
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 Charles R Harris
On 10/11/06, Tim Hochberg <[EMAIL PROTECTED]> wrote:
Greg Willden wrote:> On 10/11/06, *Travis Oliphant* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote:
>> Stefan van der Walt wrote:> >Further, if I understand correctly, changing sqrt and power to give> >the right answer by default will slow things down somewhat.  But> is it
> >worth sacrificing intuitive usage for speed?> >> For NumPy, yes.>> This is one reason that NumPy by itself is not a MATLAB replacement.>>> This is not about being a Matlab replacement.
> This is about correctness.> Numpy purports to handle complex numbers.> Mathematically, sqrt(-1) is a complex number.That's vastly oversimplified. If you are working with the reals, thensqrt(-1) is undefined (AKA nan). If you are working in the complex
plane, then sqrt(-1) is indeed *a* complex number;And if you are working over the rationals, sqrt(-1) and sqrt(-2) lead to different field extensions ;) Of course, numpy doesn't *have* rationals, so I'm just being cute. 
 Personally I think that the default error mode should be tightened up.
Then people would only see these sort of things if they really careabout them. Using Python 2.5 and the errstate class I posted earlier:# This is what I like for the default error statenumpy.seterr
(invalid='raise', divide='raise', over='raise',under='ignore')I like these choices too. Overflow, division by zero, and sqrt(-x) are usually errors, indicating bad data or programming bugs. Underflowed floats, OTOH, are just really, really small numbers and can be treated as zero. An exception might be if the result is used in division and no error is raised, resulting in a loss of accuracy.
If complex results are *expected*, then this should be made explicit by using complex numbers. Numpy allows finegrained control of data types and array ordering, it is a bit closer to the metal than Matlab. This extra control allows greater efficiency, both in speed and in storage, at the cost of a bit more care on the programmers side.
Chuck
-
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] round

2006-10-11 Thread David Goldsmith
Charles R Harris wrote:
>
>
> On 10/11/06, *Greg Willden* <[EMAIL PROTECTED] 
> > wrote:
>
> Hi All,
>
> I've read discussions in the archives about how round() "rounds to
> even" and how that is supposedly better.
>
> But what I haven't been able to find is "What do I use if I want
> the regular old round that you learn in school?" 
>
>
> Perhaps you could explain *why* you want the schoolbook round? Given 
> that floating point is inherently inaccurate you would have to expect 
> to produce a lot of numbers exactly of the form x.5 *without errors*, 
> which means you probably don't need round to deal with it. Anyway, 
> absent a flag somewhere, you can do something like (x + 
> sign(x)*.5).astype(int).
>
> Chuck
Also, where did you go to school?  In Fairfax County, VA in the 80's at 
least, they were teaching "round to even"; since that time, I've taught 
math in a variety of locations and settings and with a variety of texts, 
and where I have seen the issue addressed, it's always "round to even" 
(or, as I learned it, "the rule of fives").

DG
>
> 
>
> -
> 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
>   


-
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 David Goldsmith
Travis Oliphant wrote:
> [EMAIL PROTECTED] wrote:
>
>   
>> Could sqrt(-1) made to return 1j again? 
>>
>> 
> Not in NumPy.  But, in scipy it could.
>
>   
Ohmigod!!!  You are definitely going to scare away many, many potential 
users - if I wasn't obliged to use open source at work, you'd be scaring 
me away.  I was thinking about translating all my personal 
fractal-generating Matlab code into Python, but I certainly won't be 
doing that now!


-
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 David Goldsmith
Sven Schreiber wrote:
> Travis Oliphant schrieb:
>
>   
>>> If not, shouldn't
>>>  
>>>
>>> numpy.sqrt(-1) raise a ValueError instead of returning silently nan?
>>>  
>>>
>>>   
>> This is user adjustable.  You change the error mode to raise on 
>> 'invalid' instead of pass silently which is now the default.
>>
>> -Travis
>>
>> 
>
> Could you please explain how this adjustment is done, or point to the
> relevant documentation.
> Thank you,
> Sven
>   
I'm glad you asked this, Sven, 'cause I was thinking that if making this 
"user adjustment" is this advanced (I too have no idea what you're 
talking about, Travis), then this would be another significant strike 
against numpy (but I was holding my tongue, since I'd just let fly in my 
previous email).

DG

-
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 Travis Oliphant
David Goldsmith wrote:
> Travis Oliphant wrote:
>   
>> [EMAIL PROTECTED] wrote:
>>
>>   
>> 
>>> Could sqrt(-1) made to return 1j again? 
>>>
>>> 
>>>   
>> Not in NumPy.  But, in scipy it could.
>>
>>   
>> 
> Ohmigod!!!  You are definitely going to scare away many, many potential 
> users - if I wasn't obliged to use open source at work, you'd be scaring 
> me away.
Why in the world does it scare you away.  This makes no sense to me.   
If you don't like the scipy version don't use it.   NumPy and SciPy are 
not the same thing.

The problem we have is that the scipy version (0.3.2) already had this 
feature (and Numeric didn't).   What is so new here that is so scary ?


-Travis


-
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 David Goldsmith
Travis Oliphant wrote:
> What could be simpler? ;-)
Having sqrt(-1) return 1j (without having to remember that in order to 
get this, you have to write sqrt(-1+0j) instead).

DG


-
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 David Goldsmith
Travis Oliphant wrote:
>
> This is the one that concerns me.  Slowing everybody down who knows they 
> have positive values just for people that don't seems problematic.
>
>   
Then have a "sqrtp" function for those users who are fortunate enough to 
know ahead of time that they'll only be talking square roots of 
nonnegatives.

DG


-
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 David Cournapeau
David Goldsmith wrote:
> Travis Oliphant wrote:
>   
>> What could be simpler? ;-)
>> 
> Having sqrt(-1) return 1j (without having to remember that in order to 
> get this, you have to write sqrt(-1+0j) instead).
>
>   
But this can sometimes lead to confusing errors hard to track when you 
don't want to treat complex numbers. That's one of the thing I hated in 
matlab, actually: if you don't want to handle complex numbers, you have 
to check regularly for it. So I don't think this is simpler.

David

-
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] Please test the SVN branch

2006-10-11 Thread Travis Oliphant

I made some fixes to the "asbuffer" code which let me feel better about 
exposing it in NumPy (where it is now named int_asbuffer).

This code takes a Python integer and a size and returns a buffer object 
that points to that memory.  A little test is performed by trying to 
read (and possibly write if a writeable buffer is requested) to the 
first and last elements of the buffer.  Any segfault is trapped and used 
to raise a Python error indicating you can't use that area of memory. 

It doesn't guarantee you won't shoot yourself, but it does make it more 
difficult to segfault Python.  Previously a simple int_asbuffer(3423423, 
5) would have segfaulted (unless by chance you the memory area 3423423 
happens to be owned by Python).

I have not tested the code on other platforms to make sure it works as 
expected, so please try and compiled it.

-Travis


-
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 David Goldsmith
Stefan van der Walt wrote:
>> This is one reason that NumPy by itself is not a MATLAB
>> replacement. 
>> 
> Intuitive usage is hopefully not a MATLAB-only feature.
>   
Here, here! (Or is it Hear, hear!  I don't think I've ever seen it written out 
before.  :-) )

> I'll shut up now :)
But why?  To my mind, you're making a lot more sense than Travis.

DG
> Cheers
> Stéfan
>
> -
> 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
>   



-
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 Travis Oliphant
David Goldsmith wrote:
> Travis Oliphant wrote:
>   
>> What could be simpler? ;-)
>> 
> Having sqrt(-1) return 1j (without having to remember that in order to 
> get this, you have to write sqrt(-1+0j) instead).
>
>   
That's exactly what scipy.sqrt(-1) does.  That was my point.

-Travis


-
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] incrementing along a diagonal

2006-10-11 Thread Johannes Loehnert
Hi,

I absolutely do not know perl, so I do not know what the expression you posted 
does.

However, the key is just to understand indexing in numpy:

if you have a matrix mat and index arrays index1, index2 with, lets say,

index1 = array([ 17, 19, 29])
index2 = array([ 12, 3,  9])

then the entries of the index arrays are used as row and column indices 
respectively, and the result will be an array shaped like the index arrays.

So doing

mat[index1, index2]

will give you

--> array([ mat[17, 12], mat[19, 3], mat[29, 9]]).

Now if you want the diagonal of a 3x3-mat, you need 

index1=index2=array([ 0, 1, 2]).
mat[index1, index2] --> array([ mat[0,0], mat[1,1], mat[2,2]])

That is what my code does. If you need other, arbitrary subsets of mat, you 
just have to fill the index arrays accordingly.


Johannes

-
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 Fernando Perez
On 10/12/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:

> Why in the world does it scare you away.  This makes no sense to me.
> If you don't like the scipy version don't use it.   NumPy and SciPy are
> not the same thing.

I'd like to pitch in (again) on this issue, but I'll try to make sure
that it's clear that I'm NOT arguing about sqrt() in particular, one
way or another.

It's perfectly clear that numpy != scipy to all of us.  And yet, I
think it is equally clear that the two are /very/ tightly related.
Scipy builds on top of numpy and it directly exposes a LOT of the
numpy API as scipy functions:

In [21]: import numpy as n, scipy as s

In [22]: common_names = set(dir(n)) & set(dir(s))

In [23]: [getattr(n,x) is getattr(s,x) for x in common_names ].count(True)
Out[23]: 450

In [24]: len(common_names)
Out[24]: 462

That's 450 objects from numpy which are directly exposed in Scipy,
while only 12 names are in both top-level namespaces and yet are
different objects.  Put another way, scipy is a direct wrap of 97% of
the numpy top-level namespace.  While /we/ know they are distinct
entities, to the casual user a 97% match looks pretty close to being
the same, especially when the non-identical things are all
non-numerical:

In [27]: [x for x in common_names if getattr(n,x) is not getattr(s,x)]
Out[27]:
['pkgload',
 'version',
 '__config__',
 '__file__',
 '__all__',
 '__doc__',
 'show_config',
 '__version__',
 '__path__',
 '__name__',
 'info',
 'test']

In [32]: n.__version__,s.__version__
Out[32]: ('1.0.dev3306', '0.5.2.dev2252')

Basically, at least for these versions, the top-level API of scipy is
a strict superset of the numpy one for all practical purposes.

I think it's fair to say that if we start sprinkling special cases
where certain objects happen to have the same name but produce
different results for the same inputs, confusion will arise.

Please note that I see a valid reason for scipy.foo != numpy.foo when
the scipy version uses code with extra features, is faster, has
additional options, etc.  But as I said in a previous message, I think
that /for the same input/, we should really try to satisfy that

numpy.foo(x) == scipy.foo(x) (which is NOT the same as 'numpy.foo is scipy.foo')

within reason.  Obviously the scipy version may succeed where the
numpy one fails due to better algorithms, or be faster, etc.  I'm
talking about a general principle here.

I doubt I'll be able to state my point with any more clarity, so I'll
stop now.  But I really believe that this particular aspect of
consistency between numpy and scipy is a /very/ important one for its
adoption in wider communities.

Best,

f

-
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] Please test the SVN branch

2006-10-11 Thread Nils Wagner
Travis Oliphant wrote:
> I made some fixes to the "asbuffer" code which let me feel better about 
> exposing it in NumPy (where it is now named int_asbuffer).
>
> This code takes a Python integer and a size and returns a buffer object 
> that points to that memory.  A little test is performed by trying to 
> read (and possibly write if a writeable buffer is requested) to the 
> first and last elements of the buffer.  Any segfault is trapped and used 
> to raise a Python error indicating you can't use that area of memory. 
>
> It doesn't guarantee you won't shoot yourself, but it does make it more 
> difficult to segfault Python.  Previously a simple int_asbuffer(3423423, 
> 5) would have segfaulted (unless by chance you the memory area 3423423 
> happens to be owned by Python).
>
> I have not tested the code on other platforms to make sure it works as 
> expected, so please try and compiled it.
>
> -Travis
>
>
> -
> 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 version 1.0.dev3315
Scipy version 0.5.2.dev2254

Works fine here. All tests passed !
x86_64 x86_64 x86_64 GNU/Linux

Nils


 


-
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