Re: [Numpy-discussion] round

2006-10-12 Thread David Goldsmith
Charles R Harris wrote:


 On 10/11/06, *Greg Willden* [EMAIL PROTECTED] 
 mailto:[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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread 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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread 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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread 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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread 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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread 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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread 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=lnkkid=120709bid=263057dat=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-12 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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread 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=lnkkid=120709bid=263057dat=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-12 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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Scott Sinclair
Fernando Perez wrote:
 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.

As far as I can tell this is exactly what happens. Consider the issue 
under discussion...

--
  import numpy as np
  np.sqrt(-1)
-1.#IND
  np.sqrt(-1+0j)
1j
  a = complex(-1)
  np.sqrt(a)
1j
  import scipy as sp
  sp.sqrt(-1)
-1.#IND
  np.sqrt(-1+0j)
1j
  sp.sqrt(a)
1j
  np.__version__
'1.0rc1'
  sp.__version__
'0.5.1'
 

--

I'm sure that this hasn't changed in the development versions.

Surely the point is that when your algorithm can potentially produce a 
complex result, the logical thing to do is to use a complex data type. 
In this case Numpy and Scipy behave in a way which is intuitive. If 
complex results are surprising and unexpected then the algorithm is 
probably in error or poorly understood ;-)

Cheers,
Scott

-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread David Goldsmith
Travis Oliphant wrote:
 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.
   
I don't use scipy (and don't want to because of the overhead) but it 
sounds like I should because if I'm taking the square root of a variable 
whose value at run time happens to be real but less than zero, I *want* 
the language I'm using to return an imaginary; in other words, it's not 
the scipy behavior which scares me, its the numpy (which I do/have 
been using) behavior.  To which you might say, Well, if that's what you 
want, and you have Matlab (as you've said you do), then just use that.  
But that's precisely the point: people who don't want to be bothered 
with having to be a bit more care[ful] (as Chuck put it) - and who can 
afford it - are going to be inclined to choose Matlab over numpy.  
Perhaps one doesn't care - in the grand scheme of things, it certainly 
doesn't matter - but I think that you all should be aware that this 
numpy feature will be seen by many as more than just a nuisance.

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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread David Goldsmith
Travis Oliphant wrote:
 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.
   
But I don't want to have to use scipy (which so far I haven't needed for 
any other reason) just to get this one behavior.  But my personal 
preferences aside, I say again: if numpy doesn't behave this way, you 
*will* be scaring away many potential users.  If you can live with 
that, so be it.

DG

DG
 -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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread David Goldsmith
(Very) well said, Fernando.  Thanks!

DG

Fernando Perez wrote:
 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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Travis Oliphant

 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.
   

Fernando,

I don't disagree with you in principle.  I don't think anybody does. I 
think we should try to keep the interfaces and expectations of scipy and 
numpy the same.

Unfortunately, we have competing issues in this particular case (in the 
case of the functions in numpy.lib.scimath).   Nobody has suggested an 
alternative to the current situation in SVN that is satsifying to enough 
users. 

Here is the situation.

1) NumPy ufuncs never up-cast to complex numbers without the user 
explicitly requesting it so sqrt(-1) creates a floating-point error 
condition which is either caught or ignored according to the user's 
desires.To get complex results from sqrt you have put in complex 
numbers to begin with.  That's inherent in the way ufuncs work.

This is long-standing behavior that has good reasons for it's 
existence.  I don't see this changing.That's why I suggested to move 
the discussion over to scipy (we have the fancy functions in NumPy, they 
are just not in the top-level name-space).

Now, it would be possible to give ufuncs a dtype keyword argument that 
allowed you to specify which underlying loop was to be used for the 
calculation.  That way you wouldn't have to convert inputs to complex 
numbers before calling the ufunc, but could let the ufunc do it in 
chunks during the loop.   That is certainly a reasonable enhancement: 

sqrt(a, dtype=complex). 

This no-doubt has a library-ish-feeling, but that is what NumPy is.   
If such a change is desireable, I don't think it would be much to 
implement it.


2) In SciPy 0.3.2 the top-level math functions were overloaded with 
these fancy argument-checking versions.  So that scipy.sqrt(-1) would 
return 1j.  This was done precisely to attract users like David G. who 
don't mind data-type conversions on the fly, but prefer automatic 
conversion (funny being called non-sensical when I was the one who wrote 
those original scipy functions --- I guess I'm schizophrenic).

We changed this in SciPy 0.5.1 by accident without any discussion.  It 
was simply a by-product of moving scipy_base (including those 
special-handling functions) into NumPy and forgetting to import those 
functions again into top-level SciPy.It was an oversight that caused 
backwards compatibilty issues.  So, I simply changed it back to what 
SciPy used to be in SVN. 

If we want to change SciPy, then fine, but let's move that discussion 
over to scipy-dev.



In short, I appreciate all the comments and the differences of opinion 
they point out, but they are ultimately non-productive.  We can't just 
change top-level sqrt to be the fancy function willy-nilly.  Paul says 
I'm nice (he's not talked to my children recently), but I'm not that 
much of a push-over.  There are very good reasons that NumPy has the 
behavior it does.   

In addition, the fancy functions are already there in numpy in 
numpy.lib.scimath.  So, use them from there if you like them.  Create 
your own little mynumpy module that does

from numpy import *
from numpy.lib.scimath import *

and have a ball.  Python is flexible enough that the sky is not going to 
fall if the library doesn't do things exactly the way you would do it.   
We can still cooperate in areas that we agree on.

Again.  Put this to rest on NumPy and move the discussion over to scipy-dev.


-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Travis Oliphant
David Goldsmith wrote:
   
 
 I don't use scipy (and don't want to because of the overhead) but it 
 sounds like I should because if I'm taking the square root of a variable 
 whose value at run time happens to be real but less than zero, I *want* 
 the language I'm using to return an imaginary; in other words, it's not 
 the scipy behavior which scares me, its the numpy (which I do/have 
 been using) behavior. 

O.K.  Well the functions you want are in numpy.lib.scimath.  I should 
have directed you there.  You actually don't need scipy installed at 
all.  Just import sqrt from numpy.lib.scimath.  I'm sorry I 
misunderstood the issue.

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread pearu

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

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

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

Define numpy.sqrt as follows:

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

and define

  numpy.sqrtp

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

Pearu



-
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnkkid=120709bid=263057dat=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-12 Thread Hanno Klemm

Travis, 

thank you, setting the -fPIC option indeed solved my problem. Just for
future reference (if anybody else needs it), I added the -fPIC flag to
the compiler flags in Make.inc in the atlas build directory, as
setting CCFLAGS somehwo didn't seem to be successful. This might not
be elegant but it worked. 

Best regards,
Hanno


Travis Oliphant [EMAIL PROTECTED] said:

 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=lnkkid=120709bid=263057dat=121642
 ___
 Numpy-discussion mailing list
 Numpy-discussion@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/numpy-discussion
 



-- 
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Mark Bakker
My vote is for consistency in numpy.But it is unclear what consistency is.What is truly confusing for newbie Python users (and a source for error even after 5 years of Python programming) is that 2/3
0In that respect, I would think numpy.sqrt(2)should give 1, but it gives 1.4142135623730951So numpy does typechecking anyway (it gets an integer and makes it a float).
If that is the consistent behavior, then by all means sqrt(-1)should return 1j.Wouldn't that be the consistent thing to doMark
-
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Casting

2006-10-12 Thread Cristian Codorean
Hello list,  I got some old code that uses Scientific and Numeric. Recently, these two packages were updated to the latest versions together with python and my code started failing. The first major problem I have is when downcasting. Code that used to work now fails because the array cannot be safely cast anymore to the required type. If anyone could help me please and direct me to some documentation about when this change happened (version), why it happened, is there any other solution but using astype, can numpy help me in anyway in this situation, because I got really lost ...
Thank you in advance,Cristian
-
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Stefan van der Walt
I've summarised this thread at

http://www.scipy.org/NegativeSquareRoot

Feel free to make adjustments, in case I missed something.

Regards
Stefan

-
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=lnkkid=120709bid=263057dat=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-12 Thread Stefan van der Walt
On Thu, Oct 12, 2006 at 12:38:51AM -0600, 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).

Some argument checking and a docstring would be helpful.  I guessed
wrong the first time:

In [1]: x = N.array([1,2,3])

In [4]: y = N.int_asbuffer(x.size,x.__array_interface__['data'][0])

In [5]: y[0]

Segmentation fault

Out of curiosity, why does the following outputs differ:

In [39]: y = N.int_asbuffer(0L,x.size)
---
exceptions.SystemError   Traceback (most recent 
call last)

/home/stefan/ipython console 

SystemError: error return without exception set

In [40]: y = N.int_asbuffer(1L,x.size)
---
exceptions.ValueErrorTraceback (most recent 
call last)

/home/stefan/ipython console 

ValueError: cannot use memory location as a buffer.

Thanks for your work on this.

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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Klaipeda Narva also comes

2006-10-12 Thread National



Grocery local Traffic am Maps Greater Orange co of 
Inland Empire Ventura Diego is Weather a Rain in.Smallest Four Yearswest is 
School Recalls in Exstudent is Disputes Claim war Deada Younger Unfazed Outrage 
Over.Slipups am sam Howe in Verhovek Using cheap video cameras a they shadow 
is opposing post or gotcha moments online n?

Diego Weather Rain gtgt forecast Extreme house 
owner kindred in spirits then sue Wong restored.Byte of multibyte am auto 
indent of wheel mouse copy paste a line numbers unix format utf 
unicode?Downiraqi dreams acrobats Ryanair onto Curonian Pink girl suburbs a 
Movie or reviewout town Seventh festival in puppet.House a amp Garden Health 
Food am Culture Crossword Sudoku all Sections buy in Sell More Personals or 
Deals Stores Coupons Newspaper.Etbt Advanced newspaper This Week am Finance 
in Outlook Summer events am Cinema Cultural in agenda calendar Your Forum Todays 
Depth Budgets.Events Cinema Cultural agenda calendar Your Forum Todays Depth 
Budgets under fire increased or social Budgets offer.Seafood Stews Snapwest 
is and was Lynell George remembers Neils Words Tvcar!Guide fallen icons a 
horror Flash Most am Viewed False Choice Prompt Treason in Charge Southland am 
Mansmall of Plane am Pitcher.Athlete or theft Nokia planteu sees realistic 
date euro give military aidsenior State in official usa.Projects helping 
bridge gap of Galen Center Counts Opening Political am Trackers Capture Slipups 
sam Howe Verhovek Using cheap video cameras.Exodus a Vexes in Salinas usc 
Seeks Admission am Downtown by of Cara mia Dimassa.Mx Html Tidy of Cisco 
Rebol mirc Xslxslt Guicli a Fortran Autoit Pawl or dos Batch.Dxl Kixtart of 
Korn Shell Assembly Lisp or Maki is Script Nasm Nullsoft.Town Seventh in 
festival puppet of theatre Prima Donna Swamp Princess finally soul reviewhot 
royal enough Coolio Charity a Courses.
-
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] arraysetops update

2006-10-12 Thread Robert Cimrman
I have just added 'See also' to all docstrings in arraysetops functions,
 replaced old numpy idioms with new ones (aka modernizing) and
improved speed of numpy.unique1d, which now reflects numpy.unique.

hoping no bugs were introduced, regards,
r.

-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Compiling Numpy with py2exe

2006-10-12 Thread Charles Hanot








Hello,



Ive a program using Numpy and I would like to compile
it with Py2exe but Ive some problems. When I try to compile my program,
some modules generated by numpy are not loaded. Ive already asked to the
py2exe community if they have a solution for that and the answer was that it
was possible to compile numpy modules with py2exe but I should ask to the Numpy
community J



So my question is, is there something special to do in order
to compile a program using numpy module?



This is the setup.py file that I use





from
distutils.core import setup

import py2exe, sys



sys.path.append(tools)

sys.path.append(report)

sys.path.append(spirent)

sys.path.append(numpydir)



setup(

  console
= ['checkfile.py'],

  )





If I use this setup.py, lots of numpy file cannot be loaded.
I get the following message





copying
c:\python24\lib\site-packages\py2exe\run.exe - Y:\svn\copy\dist\checkfile.exe

The following
modules appear to be missing

['DateTime',
'FFT', 'Ft.Lib', 'Ft.Lib.DumpBgTuple', 'Ft.__init__', 'LinearAlgebra', 'MA',
'MLab', 'Matrix', 'Numeric', 'Pyrex', 'Pyrex.Compiler', 'XPathParserc'

, '_curses',
'backends.draw_if_interactive', 'backends.new_figure_manager',
'backends.pylab_setup', 'backends.show', 'core.abs', 'core.max', 'core.min',
'core.r

ound', 'ctypes',
'ext.IsDOMString', 'ext.SplitQName', 'fcompiler.FCompiler',
'fcompiler.show_fcompilers', 'lib.add_newdoc', 'mlab.amax', 'mlab.amin',
'numarray'

,
'numarray.convolve', 'numarray.fft', 'numarray.ieeespecial',
'numarray.linear_algebra', 'numarray.linear_algebra.mlab', 'numarray.ma',
'numarray.numeric', 'nu

merix.ArrayType',
'numerix.Complex', 'numerix.Complex32', 'numerix.Complex64', 'numerix.Float',
'numerix.Float32', 'numerix.Float64', 'numerix.Int', 'numerix.In

t16',
'numerix.Int32', 'numerix.Int8', 'numerix.NewAxis', 'numerix.UInt16',
'numerix.UInt32', 'numerix.UInt8', 'numerix.absolute', 'numerix.add',
'numerix.all',

'numerix.allclose',
'numerix.alltrue', 'numerix.any', 'numerix.arange', 'numerix.arccos',
'numerix.arccosh', 'numerix.arcsin', 'numerix.arcsinh', 'numerix.arct

an',
'numerix.arctan2', 'numerix.arctanh', 'numerix.argmax', 'numerix.argmin',
'numerix.argsort', 'numerix.around', 'numerix.array', 'numerix.arrayrange',
'nume

rix.asarray',
'numerix.asum', 'numerix.bitwise_and', 'numerix.bitwise_or',
'numerix.bitwise_xor', 'numerix.ceil', 'numerix.choose', 'numerix.clip',
'numerix.com

press',
'numerix.concatenate', 'numerix.conjugate', 'numerix.convolve', 'numerix.cos',
'numerix.cosh', 'numerix.cross_correlate', 'numerix.cumproduct', 'numerix

.cumsum',
'numerix.diagonal', 'numerix.divide', 'numerix.dot', 'numerix.equal',
'numerix.exp', 'numerix.fabs', 'numerix.fft.fft', 'numerix.fft.inverse_fft',
'nu

merix.floor',
'numerix.fmod', 'numerix.fromfunction', 'numerix.fromstring', 'numerix.greater',
'numerix.greater_equal', 'numerix.hypot', 'numerix.identity', 'nu

merix.indices',
'numerix.innerproduct', 'numerix.iscontiguous', 'numerix.isnan',
'numerix.less', 'numerix.less_equal', 'numerix.log', 'numerix.log10', 'numerix.

logical_and',
'numerix.logical_not', 'numerix.logical_or', 'numerix.logical_xor',
'numerix.matrixmultiply', 'numerix.maximum', 'numerix.minimum', 'numerix.mlab.

amax',
'numerix.mlab.amin', 'numerix.mlab.cov', 'numerix.mlab.diff',
'numerix.mlab.hanning', 'numerix.mlab.rand', 'numerix.mlab.std',
'numerix.mlab.svd', 'numer

ix.multiply',
'numerix.negative', 'numerix.newaxis', 'numerix.nonzero', 'numerix.not_equal',
'numerix.nx', 'numerix.ones', 'numerix.outerproduct', 'numerix.pi',

 'numerix.power',
'numerix.product', 'numerix.put', 'numerix.putmask', 'numerix.rank',
'numerix.ravel', 'numerix.repeat', 'numerix.reshape', 'numerix.resize', '

numerix.searchsorted',
'numerix.shape', 'numerix.sin', 'numerix.sinh', 'numerix.size',
'numerix.sometrue', 'numerix.sort', 'numerix.sqrt', 'numerix.subtract', '

numerix.swapaxes',
'numerix.take', 'numerix.tan', 'numerix.tanh', 'numerix.trace',
'numerix.transpose', 'numerix.typecode', 'numerix.typecodes', 'numerix.where'

, 'numerix.which',
'numerix.zeros', 'pre', 'serial', 'setuptools', 'setuptools.command',
'setuptools.command.egg_info', 'setuptools.command.install', 'testing.S

cipyTest',
'win32api', 'win32con', 'win32pdh', 'xml.xslt', 'xml.xslt.ParsedPattern',
'numpy.Complex', 'numpy.Complex32', 'numpy.Complex64', 'numpy.Float', 'nump

y.Float32', 'numpy.Float64',
'numpy.Int', 'numpy.Int16', 'numpy.Int32', 'numpy.Int8', 'numpy.UInt16',
'numpy.UInt32', 'numpy.UInt8', 'numpy.arccos', 'numpy.arcc

osh',
'numpy.arcsin', 'numpy.arcsinh', 'numpy.arctan', 'numpy.arctanh',
'numpy.bitwise_and', 'numpy.bitwise_or', 'numpy.bitwise_xor', 'numpy.ceil',
'numpy.conju

gate',
'numpy.core.add', 'numpy.core.bitwise_and', 'numpy.core.bitwise_or',
'numpy.core.bitwise_xor', 'numpy.core.cdouble', 'numpy.core.complexfloating',
'numpy

.core.conjugate',
'numpy.core.csingle', 'numpy.core.divide', 'numpy.core.double',
'numpy.core.equal', 'numpy.core.float64', 

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

2006-10-12 Thread Greg Willden
On 10/11/06, Bill Baxter [EMAIL PROTECTED] wrote:
On 10/12/06, Greg Willden [EMAIL PROTECTED] wrote: Speed should not take precedence over correctness.Unless your goal is speed.Then speed should take precedence over correctness.
Huh?Person 1: Hey you should use function X.Person 2: No, it doesn't give me the correct answer.Person 1:  Who cares? It's fast!What kind of logic is that?
I'm having serious doubts about my conversion to Numpy.Greg
-
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=lnkkid=120709bid=263057dat=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) ret urn 1j rather than nan?

2006-10-12 Thread Alan G Isaac
On Thu, 12 Oct 2006, Greg Willden apparently wrote: 
 I'm having serious doubts about my conversion to Numpy. 

That's fine, but be sure to treat the explanations you are 
receiving with the same seriousness that you treat your 
doubts.

For example, in the speed vs. correctness discussion, be 
sure to understand the problems with the word correct.
Which have been explained.

correct != expected
when expectations lack context

Cheers,
Alan Isaac
(just a happy user)


-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Tim Hochberg
Mark Bakker wrote:
 My vote is for consistency in numpy.
 But it is unclear what consistency is.

 What is truly confusing for newbie Python users (and a source for 
 error even after 5 years of Python programming) is that

  2/3
 0
I recommend that you slap from __future__ import division into site.py 
or the top of your program:

from __future__ import division

import numpy
print 3/2
a = numpy.arange(3)
print a / (a+5)
print a // a+5

 

1.5
[ 0.  0.1667  0.28571429]
[5 6 6]



 In that respect, I would think

  numpy.sqrt(2)

 should give 1, but it gives 1.4142135623730951
Is there any practical reason to return 1? If not, isn't this argument 
sort of silly?

 So numpy does typechecking anyway (it gets an integer and makes it a 
 float).

 If that is the consistent behavior, then by all means

  sqrt(-1)

 should return 1j.
Well, it could also return: -1j or as someone mentioned one of six (I 
think) different quaternion values. It all depends on what the 
domain/range of the problem is.

 Wouldn't that be the consistent thing to do

No, there's a difference. In order to do the former, all that is 
required is that sqrt switches on the *type* of it argument. sqrt return 
a float for integer and floating point args and a complex for complex 
args. In order to the latter, sqrt needs to switch on the *value* of its 
argument, which is an entirely different beast both in theory and in 
practice. In particular:

sqrt(some_big_array)

would have to scan all the values in the array to determine if any were 
negative to decide whether to return a float or an imaginary number. It 
also means that the memory usage is unpredictable -- the returned array 
is double in size if any values are negative.

In addition to the significant slowdown this introduces, the former 
approach (keeping the input and output domains the same) is somewhat 
more robust against error, particularly if one tightens up the error 
mode. I would guess that people are working the complex plane at most 
half the time, in the former case a negative square root signals a 
problem and promoting to complex is at best a nuisance and may result in 
a painful to track down error. In the latter case, it's easy enough for 
me to toss in a astype in situations where I'm mixing domains and need 
complex outputs.

Ideally numpy and scipy would have chosen different names for forgiving 
and strict powers and square roots, square_root and power versus sqrt 
and pow for example, but it's probably too late to do anything about 
that now.

Since it sounds like Travis is going to tighten up the default error 
mode, I think that this is a non issue. No ones going to run into NANs 
unexpectedly and the error when doing sqrt([1,2,3,-1]) should be 
confusing and most once.

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Tim Hochberg
Travis Oliphant wrote:
 Travis Oliphant wrote:
   
 Now, it would be possible to give ufuncs a dtype keyword argument that 
 allowed you to specify which underlying loop was to be used for the 
 calculation.  That way you wouldn't have to convert inputs to complex 
 numbers before calling the ufunc, but could let the ufunc do it in 
 chunks during the loop.   That is certainly a reasonable enhancement: 

 sqrt(a, dtype=complex). 

 This no-doubt has a library-ish-feeling, but that is what NumPy is.   
 If such a change is desireable, I don't think it would be much to 
 implement it.

   
 
 This could be implemented, but only with a version number increase in 
 the C-API (we would have to change the c-signature of the ufunc tp_call. 

 This would mean that the next release of NumPy would be binary 
 incompatible with packages built to previous NumPy releases.  

 I've really been trying to avoid doing that.  So, unless there are 
 strong requests for this feature that outweigh the negatives of 
 re-building dependent packages, then this feature will have to wait. 

 OTOH:   I suppose it could be implemented in a different way (using 
 indexing or a method call):

 sqrt[complex](a)   --- I remember Tim suggesting some use for indexing 
 on ufuncs earlier though.
   
It wouldn't surprise me if I did -- it sounds like the kind of thing I'd 
propose -- but I certainly can't remember what I was proposing.

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Stefan van der Walt
On Thu, Oct 12, 2006 at 08:58:21AM -0500, Greg Willden wrote:
 On 10/11/06, Bill Baxter [EMAIL PROTECTED] wrote:
 
 On 10/12/06, Greg Willden [EMAIL PROTECTED] wrote:
  Speed should not take precedence over correctness.
 
 Unless your goal is speed.  Then speed should take precedence over
 correctness.
 
 
 Huh?
 Person 1:  Hey you should use function X.
 Person 2:  No, it doesn't give me the correct answer.
 Person 1: Who cares?  It's fast!
 
 What kind of logic is that?

I tried to explain the argument at

http://www.scipy.org/NegativeSquareRoot

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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Tim Hochberg
Travis Oliphant wrote:
 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')


 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.

 

 I'm fine with this.  I've hesitated because error checking is by default 
 slower.  But, I can agree that it is less surprising to new-comers.  
 People that don't mind no-checking can simply set their defaults back to 
 'ignore'

   
Great.

One thing we may want to do (numarray had this), was add a pseudo 
argument 'all', that allows you to set all of the values at once. Then 
if you want the full-bore, ignore-all-errors computation (and your using 
2.5 and from __future__ import with_statement) you can just do:

with errstate(all='ignore'):
# computation here
# back to being picky

-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=lnkkid=120709bid=263057dat=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-12 Thread Tim Hochberg
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.
   
FWIW, it compiles fine and passes all tests under Visual Studio and 
Python 2.4.3. I haven't tried to use it though.

-tim


 -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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=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) ret urn 1j rather than nan?

2006-10-12 Thread Alan G Isaac
On Thu, 12 Oct 2006, Stefan van der Walt apparently wrote: 
 I tried to explain the argument at 
 http://www.scipy.org/NegativeSquareRoot 

Helpful.  But you start off by saying:
In mathematics, the above assumption is true -- that 
the square root of -1 is 1j.

Since square root is (here) a function, and part of the 
function definition is the domain and codomain, this 
statement is not correct.  If the codomain is real numbers, 
the domain must correspondingly be (a subset of) the 
nonnegative reals.  The nan output is the result of an 
**invalid** input.

So the question is really: Why is a negative real number an 
invalid input in this implementation, or Why in this 
implementation is the type of the output restricted by the 
type of the input? You get a good start on answering that.

Cheers,
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Greg Willden
I'll try to quit being a pain and just work around it.Those wiki pages are really good to capture this information. I need to read all of them to know what other gotchas are out there.Thanks and Sorry,Greg
On 10/12/06, Alan G Isaac [EMAIL PROTECTED] wrote:
That's fine, but be sure to treat the explanations you arereceiving with the same seriousness that you treat yourdoubts.For example, in the speed vs. correctness discussion, besure to understand the problems with the word correct.
Which have been explained.correct != expectedwhen expectations lack context
-
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Greg Willden
May I suggest the following change to generate_umath.py?completely untested string change'sqrt' : Ufunc(1, 1, None, 'square-root elementwise. For real x, the domain is restricted to x=0.\n\
 For complex results for x0 see numpy.scimath.sqrt', TD(inexact, f='sqrt'), TD(M, f='sqrt'), ),'When sqrt throws a ValueError would it be possible/appropriate for the error message to mention 
numpy.scimath.sqrt?I'm just trying to think of other ways to help make the transition as smooth as possible for new users.Greg
-
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Andrew Jaffe
Tim Hochberg wrote:
 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:

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.

For this particular application, why not a context manager which just 
substitutes in the appropriately-optimized version of sqrt? That is, 
don't change the error state, but actually change the value of the 
object pointed at by the name sqrt?

Andrew

-
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=lnkkid=120709bid=263057dat=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-12 Thread Rob Hetland

On Oct 11, 2006, at 1:41 PM, Travis Oliphant wrote:

a) an extra multiplication operator to distinguish between
 element-by-element and dot

One of the things I like about numpy is that element-by-element  
multiplication is default.  Really, most of what I do is element by  
element, punctuated by a few matrix multiplications (or whatever  
other matrix operations) at the end.  If I had a penny for every '.'  
I put in front of an operator in MATLAB, I would buy us all new  
computers -- expensive ones even.

I hope that, if there is another multiplication operator like .*,  
that this will be shorthand for dot(A, B), and not for elem-by-elem  
multiplication.

-Rob


Rob Hetland, Associate Professor
Dept. of Oceanography, Texas AM University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331



-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Stefan van der Walt
On Thu, Oct 12, 2006 at 10:53:12AM -0400, Alan G Isaac wrote:
 On Thu, 12 Oct 2006, Stefan van der Walt apparently wrote: 
  I tried to explain the argument at 
  http://www.scipy.org/NegativeSquareRoot 
 
 Helpful.  But you start off by saying:
 In mathematics, the above assumption is true -- that 
 the square root of -1 is 1j.
 
 Since square root is (here) a function, and part of the 
 function definition is the domain and codomain, this 
 statement is not correct.  If the codomain is real numbers, 
 the domain must correspondingly be (a subset of) the 
 nonnegative reals.  The nan output is the result of an 
 **invalid** input.
 
 So the question is really: Why is a negative real number an 
 invalid input in this implementation, or Why in this 
 implementation is the type of the output restricted by the 
 type of the input? You get a good start on answering that.

You are more than welcome to change the wiki if you can think of a
simpler way to explain the problem... In fact, I would encourage that
-- I just put it there as a starting point.

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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread David Goldsmith
Greg Willden wrote:
 May I suggest the following change to generate_umath.py?

 completely untested string change
 'sqrt' :
 Ufunc(1, 1, None,
   'square-root elementwise. For real x, the domain is 
 restricted to x=0.\n\
   For complex results for x0 see numpy.scimath.sqrt',
   TD(inexact, f='sqrt'),
   TD(M, f='sqrt'),
   ),
 '

 When sqrt throws a ValueError would it be possible/appropriate for the 
 error message to mention numpy.scimath.sqrt?

 I'm just trying to think of other ways to help make the transition as 
 smooth as possible for new users.
And helpful error messages are one of Python's best features - in 
general, numpy doesn't have enough of 'em, IMO.

DG

 Greg
 

 -
 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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=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-12 Thread Christopher Barker
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.

If I understand this correctly, maybe it should be called something like:

int_asbuffer_pointer

or something with pointer in it.

I sure didn't expect that meaning from asbuffer or in-asbuffer

Otherwise -- nice idea!

-Chris

-- 
Christopher Barker, Ph.D.
Oceanographer

NOAA/ORR/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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] Providing array interface from SWIG-wrapped C struct

2006-10-12 Thread Michele Vallisneri
Does anybody here have experience about offering the array interface  
from a SWIG-wrapped C struct?

I have tried the following, borrowing code from numpy's arrayobject.c:

%extend real_vec_t {
   PyObject *__array_struct__() {
 /* From numpy/arrayobject.c/array_struct_get */

 PyArrayInterface *inter;

 inter = (PyArrayInterface *)_pya_malloc(sizeof(PyArrayInterface));

 inter-two = 2;
 inter-nd = 1;
 inter-typekind = 'f';
 inter-itemsize = sizeof(float);
 inter-flags = (NPY_CONTIGUOUS | NPY_OWNDATA | NPY_ALIGNED |  
NPY_NOTSWAPPED);

 inter-shape = (intp *)_pya_malloc(2*sizeof(intp));
 inter-strides = inter-shape + 1;
 *(inter-shape) = self-n;
 *(inter-strides) = 1;

 inter-data = (void *)(self-d);
 inter-descr = 0;

 return PyCObject_FromVoidPtr(inter,0);
   }
%}

When passing such a SWIG real_vec_t object to numpy.array, numpy gets  
a PyArrayInterface that fails to check correctly as a Python C  
object. Three comments:

- The original numpy/arrayobject.c code actually gets its return  
value from PyCObject_FromVoidPtrAndDesc(inter,self,...); but in this  
context self does not point to a PyObject, but rather to the C  
struct, so I don't think I can use that form.

- The code above does not deal with properly destructing the  
PyArrayInterface, setting refcounts, etc. But I was going to worry  
about those later.

- My problem is probably with SWIG rather than numpy... but I thought  
the people in this forum (rather than those at the SWIG forum) would  
be most likely to have encountered a situation similar to these.

Thanks a lot for any help, or just for reading this post.

Michele

-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Christopher Barker
As someone on this list (sorry to quick with the delete button) said:

numpy is closer to the metal than MATLAB

MATLAB aside, numpy is somewhat close to the metal. I think this is 
clearly part of its design philosophy, and also something I personally 
like about out.

Getting back to MATLAB (at least version 4, the last one I used 
regularly) -- everything in MATLAB is a matrix of double precision 
Floating points. (or complex - that does get weird!). This makes things 
simpler for a lot of use, but restricts the power and flexibility 
substantially.

Everything in numpy is an array of arbitrary shape and many possible 
data types -- this is more to think about, but give you a lot of power 
and flexibility. In any case, that is what numpy is. Period.

Given that, arrays of different types behave differently -- that's 
something you'd darn well better understand pretty soon in your numpy 
career:

  a = N.array((1,2,3), dtype=N.uint8)
  a *= 200
  a
array([200, 144,  88], dtype=uint8)

Oh my gosh! 2 * 200 isn't 144! what happened?

This isn't any different than sqrt(-1) resulting in NaN or an error. In 
fact, there are all sorts of places where upcasting is not happening 
automagically -- in fact, I think that's become more consistent in the 
new numpy. So, in numpy you need to choose the datatype appropriate for 
your problem at hand. I know I always know whether I want to work in the 
complex plane or not.

Another change recently made is to make doubles the default in more 
places -- I like that change.

So, given the entire philosophy and current status of how numpy works, 
the ONLY question that is legitimate here is:

Should the default datatype be complex or double? I vote double.

Travis Oliphant wrote:
 Now, it would be possible to give ufuncs a dtype keyword argument that 
 allowed you to specify which underlying loop was to be used for the 
 calculation. 

 sqrt(a, dtype=complex). 

I like this OK, and isn't is similar to the dtype argument in the 
accumulating methods? (sum, etc.). However, it's probably not worth the 
C-api change -- is it that different than calling:

sqrt(a.astype(complex)) ?

As for scipy, I heartily agree that scipy should be a superset of numpy, 
and NOT change the behavior of numpy functions and methods. We're taking 
the opportunity at this point for numpy to break backward compatibility 
with Numeric/numarray -- this is probably the best time to   do the same 
for scipy.

couldn't we at least introduce new names?

numpy.scimath.csqrt()

for instance?

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

NOAA/ORR/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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] multiarray tests skipped under py2.5

2006-10-12 Thread Tim Hochberg

Is any one else seeing the multiarray tests all get skipped because of 
an import error when compiling under python 2.5. Everything else seems 
to work and all the tests go fine under 2.4.

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] multiarray tests skipped under py2.5

2006-10-12 Thread Gerard Vermeulen
On Thu, 12 Oct 2006 11:04:55 -0700
Tim Hochberg [EMAIL PROTECTED] wrote:

 
 Is any one else seeing the multiarray tests all get skipped because of 
 an import error when compiling under python 2.5. Everything else seems 
 to work and all the tests go fine under 2.4.

Everything looks fine here:
 sys.version
'2.5 (r25:51908, Oct  8 2006, 07:23:15) \n[GCC 4.1.1 (Gentoo 4.1.1)]'
 np.version.version
'1.0.dev3317'
 np.test()
  Found 13 tests for numpy.core.umath
  Found 9 tests for numpy.lib.arraysetops
  Found 36 tests for numpy.core.ma
  Found 3 tests for numpy.fft.helper
  Found 4 tests for numpy.ctypeslib
  Found 2 tests for numpy.lib.polynomial
  Found 8 tests for numpy.core.records
  Found 26 tests for numpy.core.numeric
  Found 5 tests for numpy.distutils.misc_util
  Found 3 tests for numpy.lib.getlimits
  Found 31 tests for numpy.core.numerictypes
  Found 4 tests for numpy.core.scalarmath
  Found 1 tests for numpy.lib.ufunclike
  Found 12 tests for numpy.lib.twodim_base
  Found 47 tests for numpy.lib.shape_base
  Found 4 tests for numpy.lib.index_tricks
  Found 32 tests for numpy.linalg.linalg
  Found 42 tests for numpy.lib.type_check
  Found 176 tests for numpy.core.multiarray
  Found 10 tests for numpy.core.defmatrix
  Found 41 tests for numpy.lib.function_base
  Found 0 tests for __main__
.
--
Ran 509 tests in 0.265s

OK
unittest.TextTestRunner object at 0x2ed6a650
 

Gerard

-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] multiarray tests skipped under py2.5

2006-10-12 Thread Tim Hochberg
Gerard Vermeulen wrote:
 On Thu, 12 Oct 2006 11:04:55 -0700
 Tim Hochberg [EMAIL PROTECTED] wrote:

   
 Is any one else seeing the multiarray tests all get skipped because of 
 an import error when compiling under python 2.5. Everything else seems 
 to work and all the tests go fine under 2.4.
 

 Everything looks fine here:
   

Thanks.

I suppose that means it's either Windows specific or I gummed up my 
build tree somehow. I'll make a clean checkout and see if it goes away.


-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] gcc/fortran compilers for building extensions with Tiger/MacPython

2006-10-12 Thread David M. Cooke
On Thu, 12 Oct 2006 14:03:31 -0400
Tom Loredo [EMAIL PROTECTED] wrote:

 Hi folks,
 
 I've just upgraded my G4 (PPC) from Pather to Tiger, and just
 installed MacPython.  I now need to build a slew of numerical extensions.
 I'm building them from source (I have lots of custom extensions
 to build from source in any case).  I see the binaries available
 for Tiger are built with gcc 3.3 for PPC and gcc 4 for Intel; I
 think they may be tied to ActivePython but I'm not sure.  When
 I start MacPython, I see it is built with gcc 4.  Is this what
 I should be using?  I'll also be compiling fortran extensions;
 I presume I should use gfortran rather than g77 for this (g77
 is what worked with gcc 3.3).  Is this correct?

For Intel, yes, you need to use gfortran, and it has to be the prelease
version (4.2): 4.1 and earlier don't build on Intel Macs. g77 (and gcc 3.x)
won't build either, unfortunately.

If you're using MacPorts (previously DarwinPorts), you'll want the gcc42
port. Or, you can grab binaries at http://hpc.sourceforge.net/

-- 
||\/|
/--\
|David M. Cooke  http://arbutus.physics.mcmaster.ca/dmc/
|[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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] numpy-1.0 problem with install --skip-build

2006-10-12 Thread Neal Becker
It appears the problem with getting a numpy-1.0 built with RPM is caused by
using 2 step process:

python setup.py build
python setup.py install --skip-build --root $RPM_BUILD_ROOT

This doesn't seem to work correctly!

If I change it to just do:
python setup.py install

it works 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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Providing array interface from SWIG-wrapped C struct

2006-10-12 Thread Lisandro Dalcin
On 10/12/06, Michele Vallisneri [EMAIL PROTECTED] wrote:
 Does anybody here have experience about offering the array interface
 from a SWIG-wrapped C struct?

I have.

 I have tried the following, borrowing code from numpy's arrayobject.c:

 %extend real_vec_t {
PyObject *__array_struct__() {
  /* From numpy/arrayobject.c/array_struct_get */

You are extending real_vec_t with a new METHOD, but what numpy
requests is an ATTRIBUTE. So, numpy simply queries your vec like:

arrstr = vec.__array_struct__

and not with a method call like this

arrstr = vec.__array_struct__()


So here is what I would do (can fail with some SWIG optimizations)

%extend Vec {

PyObject* __array_struct__ () { /* ...  */ }

  %pythoncode {
  __array_struct__ = property(__array_struct__,
 doc='Array protocol')
  }

}

Hope you got the idea.

-- 
Lisandro Dalcín
---
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Sebastian Haase
Hi,
On Thursday 12 October 2006 10:49, Christopher Barker wrote:
 As someone on this list (sorry to quick with the delete button) said:
snip

I think I might agree with everything (!) you that - very well written .

 Travis Oliphant wrote:
  Now, it would be possible to give ufuncs a dtype keyword argument that
  allowed you to specify which underlying loop was to be used for the
  calculation.
 
  sqrt(a, dtype=complex).

 I like this OK, and isn't is similar to the dtype argument in the
 accumulating methods? (sum, etc.). However, it's probably not worth the
 C-api change -- is it that different than calling:

 sqrt(a.astype(complex)) ?


It is very late in the game - obvious ! (one week before the announced final 
release).  But I think adding the dtype argument to ufuncs would be a very 
useful addition !! 
It is very nice to look at ! And it saves (temporary) memory and should be 
noticeably faster than sqrt(a.astype(complex)).

This dtype addition might address  many of the issues I have raised before on 
this list.

Travis,  be courageous  and change the C-API one last time before putting it 
in stone for 1.0 final !!!


 As for scipy, I heartily agree that scipy should be a superset of numpy,
 and NOT change the behavior of numpy functions and methods. We're taking
 the opportunity at this point for numpy to break backward compatibility
 with Numeric/numarray -- this is probably the best time to   do the same
 for scipy.

 couldn't we at least introduce new names?

 numpy.scimath.csqrt()

 for instance?

 -Chris
It has to be very well documented what the 12 functions (the last 3%) are were 
scipy and numpy differ.  --- if at all possible I would prefer a name change 
like csqrt (or better sqrtc - I always like seen things together when sorted 
alphabetically ;-) ) [by the way: I like sqrt(-1) == nan  just fine]

Thanks for the great work. 
- Sebastian

-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Paul Dubois
Historical note. When Cleve Moler first created 'matlab' as a tool for teaching at the University of New Mexico, all numbers were complex. And, in fact, there was a limit of 10,000 numbers. There was a fixed array where these 10,000 numbers were stored.
I got pretty excited about his project and wanted to use it to get eigenvalues etc. for matrices of interest from our codes. But I had a Cray 1 with an entire megaword of memory and my matrices wouldn't fit. 
So I set out to hack the code to add a memory manager so that we could use the entire memory. This was a big success. Then I decided it was sad that I had to write the matrices out of the code onto a disk and then read them into matlab, so I got the idea of making something similar as the front end of the code, only with data types (because I hated only being able to use half my Cray since my data was real, and our codes were often memory bound) and a full programming language like Fortran with array syntax for speed. This idea resulted in Basis (
basis.llnl.gov). My interest in Python (and hence numpy) evolved from that as OOP arrived.
-
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread Travis Oliphant
David Goldsmith wrote:

Got it.  And if I understand correctly, the import order you specify in 
the little mynumpy example you included in your latest response to 
Fernando will result in any overlap between numpy and 
numpy.lib.scimath to call the latter's version of things rather than the 
former's, yes?
  


Right.  The last import will be used for any common-names (variables get 
re-bound to the new functions...)

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Compiling Numpy with py2exe

2006-10-12 Thread Travis Oliphant
Charles Hanot wrote:

 Hello,

 I’ve a program using Numpy and I would like to compile it with Py2exe 
 but I’ve some problems. When I try to compile my program, some modules 
 generated by numpy are not loaded. I’ve already asked to the py2exe 
 community if they have a solution for that and the answer was that it 
 was possible to compile numpy modules with py2exe but I should ask to 
 the Numpy community J

 So my question is, is there something special to do in order to 
 compile a program using numpy module?

The only thing I remember is that you have to explicitly make sure 
_internal.py file gets copied over as it is not possible to discern that 
by looking at the import statements in .py files.

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] More SVN testing

2006-10-12 Thread Tim Hochberg

I just checked in a couple of changes to SVN. I was going to check in 
errstate, but it looks like Travis beat me to it, so I contented myself 
with adding a docstring and some tests.  These tests are only run under 
2.5; things seem to work fine here, but if someone on a Linux box whose 
running Python 2.5 could try it out I'd appreciate it. I'm suspicous of 
Linux/Windows differences right now because of my run in with them 
earlier today in the tests for test_multiarray (which I believe it now 
fixed -- at least everything is working here OK).

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] multiarray tests skipped under py2.5

2006-10-12 Thread Travis Oliphant
Tim Hochberg wrote:

  


Still there with a clean checkout. Blech! I hate weird import problems. 
I'll try to look into it, but if anyone has any good ideas, let me know
  

Show  us the errors, I may be able to help.  It's possible some recent 
changes messed things up.

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] More SVN testing

2006-10-12 Thread Albert Strasheim
Hello all

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:numpy-
 [EMAIL PROTECTED] On Behalf Of Tim Hochberg
 Sent: 12 October 2006 21:24
 To: numpy-discussion
 Subject: [Numpy-discussion] More SVN testing
 
 
 I just checked in a couple of changes to SVN. I was going to check in
 errstate, but it looks like Travis beat me to it, so I contented myself
 with adding a docstring and some tests.  These tests are only run under
 2.5; things seem to work fine here, but if someone on a Linux box whose
 running Python 2.5 could try it out I'd appreciate it. I'm suspicous of
 Linux/Windows differences right now because of my run in with them
 earlier today in the tests for test_multiarray (which I believe it now
 fixed -- at least everything is working here OK).

This probably fixes the issue I reported here:

http://projects.scipy.org/scipy/numpy/ticket/286

Maybe you can check that the test counts match up on Python 2.4 and 2.5 on
Windows on your system and close that ticket.

Cheers,

Albert


-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] More SVN testing

2006-10-12 Thread Tim Hochberg
Albert Strasheim wrote:
 Hello all

   
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:numpy-
 [EMAIL PROTECTED] On Behalf Of Tim Hochberg
 Sent: 12 October 2006 21:24
 To: numpy-discussion
 Subject: [Numpy-discussion] More SVN testing


 I just checked in a couple of changes to SVN. I was going to check in
 errstate, but it looks like Travis beat me to it, so I contented myself
 with adding a docstring and some tests.  These tests are only run under
 2.5; things seem to work fine here, but if someone on a Linux box whose
 running Python 2.5 could try it out I'd appreciate it. I'm suspicous of
 Linux/Windows differences right now because of my run in with them
 earlier today in the tests for test_multiarray (which I believe it now
 fixed -- at least everything is working here OK).
 

 This probably fixes the issue I reported here:

 http://projects.scipy.org/scipy/numpy/ticket/286

 Maybe you can check that the test counts match up on Python 2.4 and 2.5 on
 Windows on your system and close that ticket.
   
Yep, that's the same one I ran into and it's fixed now on windows. It 
sounds like it didn't occur at all on Linux. Their are now actually two 
more tests under 2.5 than under 2.4, but that's on purpose -- I can't 
test 'with errstate' under 2.4, so I skip those tests.

I went ahead and closed the ticket.

-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Polyfit

2006-10-12 Thread Charles R Harris
On 10/12/06, Greg Willden [EMAIL PROTECTED] wrote:
Hi All,I'm using numpy.polyfit and it is giving me some really strange results when evaluated near 0. So I compared it with polyfit in matplotlib and the code and docstrings are nearly identical. However the slight differences in the code make a huge difference on my data.
Here is the Numpy version with line numbers added:1 x = NX.asarray(x)+0.2  y = NX.asarray(y)+0.3 y = NX.reshape(y, (len(y), 1))4 X = vander(x, N+1)5  c, resids, rank, s = _lstsq(X, y)
6 c.shape = (N+1,)7 return cAnd here is the MPL version with line numbers added:1  x = asarray(x)+0.2 y = asarray(y)+0.3 y = reshape(y, (len(y),1))4 X = Matrix(vander(x, N+1))
5 Xt = Matrix(transpose(X))6 c = array(linear_algebra.inverse(Xt*X)*Xt*y) # convert back to array7 c.shape = (N+1,)8 return c So lines 1-4 are basically the same.The MPL version produces a much more stable representation of my data
Can someone please comment on the differences?Should these two be exactly the same?If not, what are the advantages to each algorithm?I'm guessing that the rcond number in the lstsq version (default 1e-10) is the difference. Generally the lstsq version should work better than the MPL version because at*a is not as well conditioned and vandermonde matrices are notoriously ill conditioned anyway for higher degree fits. It would help if you attached the data files in ascii form unless they happen to contain thousands of data items. Just the x will suffice, zip it up if you have to.
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] More SVN testing

2006-10-12 Thread Rob Hetland

 numpy.test(10,10)
:
:
:
Ran 512 tests in 0.995s

OK
unittest.TextTestRunner object at 0x344ded0
  numpy.__version__
'1.0.dev3320'

on Intel Mac OS X 10.4.8, macpython 2.5 [Python 2.5 (r25:51918, Sep  
19 2006, 08:49:13)]

-Rob

On Oct 12, 2006, at 2:24 PM, Tim Hochberg wrote:


 I just checked in a couple of changes to SVN. I was going to check in
 errstate, but it looks like Travis beat me to it, so I contented  
 myself
 with adding a docstring and some tests.  These tests are only run  
 under
 2.5; things seem to work fine here, but if someone on a Linux box  
 whose
 running Python 2.5 could try it out I'd appreciate it. I'm  
 suspicous of
 Linux/Windows differences right now because of my run in with them
 earlier today in the tests for test_multiarray (which I believe it now
 fixed -- at least everything is working here OK).

 -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=lnkkid=120709bid=263057dat=121642
 ___
 Numpy-discussion mailing list
 Numpy-discussion@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Rob Hetland, Associate Professor
Dept. of Oceanography, Texas AM University
http://pong.tamu.edu/~rob
phone: 979-458-0096, fax: 979-845-6331



-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Polyfit

2006-10-12 Thread Greg Willden
On 10/12/06, Charles R Harris [EMAIL PROTECTED] wrote:
I'm guessing that the rcond number in the lstsq version (default 1e-10) is the difference. Generally the lstsq version should work better than the MPL version because at*a is not as well conditioned and vandermonde matrices are notoriously ill conditioned anyway for higher degree fits. It would help if you attached the data files in ascii form unless they happen to contain thousands of data items. Just the x will suffice, zip it up if you have to.
Here are the files.Since the two algorithms behave differently and each has it place then can both be included in numpy?i.e. numpy.polyfit(x,y,N, mode='alg1')numpy.polyfit
(x,y,N, mode='alg2')replacing alg1 and alg2 with meaningful names.ThanksGreg
2
4
0
16
1
3
14
17
12
13
8
7
5
11
23
19
24
9
18
15
44
22
20
25
27
10
41
45
26
40
21
50
29
38
28
37
53
48
57
78
54
61
39
64
65
58
43
35
55
47
60
66
46
68
52
51
42
75
93
56
87
74
59
71
84
49
72
81
73
63
94
67
36
80
30
70
106
69
62
77
76
90
98
103
6
172
79
83
82
31
85
97
105
91
121
89
95
101
116
135
92
102
96
88
120
137
136
34
389
499
489
565
479
555
412
390
443
442
456
365
404
593
457
364
375
441
367
360
453
376
482
576
550
445
409
658
363
435
381
477
549
396
460
544
601
466
384
557
391
461
511
642
547
558
542
610
608
639
438
591
551
378
599
552
397
569
578
437
643
361
385
399
538
600
395
561
602
649
454
464
447
386
535
554
577
596
686
635
459
514
628
448
583
407
408
603
379
626
410
500
570
449
582
434
401
417
501
462
566
366
394
631
485
382
563
369
784
781
824
838
783
826
825
854
867
763
801
799
879
795
759
852
872
831
802
769
873
773
762
779
772
789
836
881
839
827
796
882
851
786
797
755
726
841
896
865
890
837
857
775
853
767
785
756
750
754
887
861
894
770
749
771
840
844
782
780
877
859
774
832
871
730
722
901
794
884
846
760
848
729
876
724
720
757
830
798
850
818
764
875
787
829
899
885
874
960
815
864
777
723
820
891
747
751
725
821
776
823
866
800
833
788
758
878
1411
1350
1358
1353
1362
1378
1326
1348
1321
1355
1357
1349
1352
1346
1373
1430
1408
1351
1310
1418
1281
1336
1416
1428
1423
1436
1364
1432
1419
1377
1421
1359
1279
1401
1424
1323
1340
1322
1339
1407
1438
1427
1247
1435
1290
1311
1262
1343
1307
1437
1369
1315
1288
1356
1412
1309
1327
1276
1367
1325
1425
1420
1344
1361
1337
1368
1314
1415
1335
1278
1320
1280
1382
1282
1434
1328
1273
1332
1410
1347
1284
1338
1417
1354
1360
1329
1270
1305
1375
1414
1287
1291
1429
1379
1256
1372
1370
1289
1306
1275
1342
1274
1286
1313
1271
1248
1319
1268
1479
1440
1452
1449
1441
1542
1444
1447
1645
1569
1485
1537
1527
1522
1462
1461
1554
1651
1448
1652
1538
1529
1510
1451
1639
1570
1486
1737
1481
1623
1725
1453
1458
1459
1680
1484
1445
1671
1460
1524
1673
1666
1627
1540
1564
1626
1672
1499
1674
1561
1555
1519
1472
1632
1534
1548
1650
1470
1656
1637
1648
1717
1661
1521
1724
1755
1631
1735
1517
1667
1551
1728
1566
1575
1515
1539
1531
1541
1563
1558
1643
1454
1549
1758
1483
1761
1714
1638
1505
1654
1664
1475
1556
1473
1528
1516
1552
1443
1709
1553
1794
1571
1644
1520
1718
1742
1498
1736
2149
2052
2128
2141
2019
2108
2125
1998
2055
2087
2106
2123
2029
2036
1960
2121
2049
1945
2132
2058
2035
2144
2053
2109
1963
1949
1966
2137
2060
2153
2147
1956
2126
2115
2130
2129
1808
2021
2038
1804
2064
2104
1952
2107
1911
1958
2116
1810
2031
1940
2148
2117
2150
1814
2059
1916
2010
2026
1809
1964
2103
2032
2039
2118
2151
1973
2152
1951
2084
2011
2065
2105
2028
2112
2044
2040
2122
2033
1812
1941
1946
1987
1996
2127
2113
2048
1995
1950
2155
1959
2138
1803
1970
1961
2020
2008
1811
1968
1965
1947
1819
2037
2063
1817
2133
1967
2140
2047
2185
2161
2217
2241
2163
2164
2212
2220
2247
2162
2208
2248
2225
2255
2206
2191
2218
2165
2238
2237
2166
2231
2211
2192
2258
2233
2201
2221
2239
2251
2249
2219
2186
2197
2246
2210
2199
2184
2226
2243
2188
2240
2250
2204
2205
2193
2260
2160
2236
2187
2228
2182
2223
2215
2224
2235
2213
2198
2168
2202
2195
2183
2253
2209
2234
2288
2261
2256
2254
2200
2257
2242
2167
2280
2252
2245
2207
2263
2216
2277
2284
2244
2190
2259
2266
2267
2180
2227
2196
2229
2297
2189
2169
2296
2181
2279
2281
2179
2178
2194
2287

2285
2232
2301
2264
2214
2289
2787
2714
2823
2591
2640
2717
2650
2612
2838
2630
2827
2588
2685
2684
2677
2720
2613
2872
2729
2804
2622
2841
2642
2694
2867
2693
2865
2601
2808
2870
2691
2607
2877
2620
2836
2835
2576
2596
2636
2805
2802
2603
2579
2797
2610
2577
2716
2832
2626
2676
2678
2873
2785
2632
2608
2692
2643
2726
2813
2614
2675
2791
2803
2644
2701
2801
2594
2737
2625
2826
2839
2649
2700
2799
2634
2695
2730
2592
2874
2667
2647
2683
2586
2722
2679
2669
2629
2871
2549
2733
2582
2631
2807
2606
2641
2727
2724
2652
2623
2783
2646
2821
2602
2702
2708
2589
2815
2842
3222
3230
3229
2898
3228
3214
3232
3208
3213
2931
3202
2886
2922
3205
3221
3235
3212
3204
2887
2893
3209
2907
2921
3231
2891
2914
3223
3224
2890
2911
3189
2896
3233
2909
2917
3220
3198
3207
3226
3227
2900
2889
3225
2923
2884
3203
3192
2910
2926
3210
2885
2905
2913
2895
2897
2918
2924
3200
2927
2934
3234
2912
3206
3187
3236
3196
2881
3238
3190
3219

Re: [Numpy-discussion] Polyfit

2006-10-12 Thread Charles R Harris
On 10/12/06, Greg Willden [EMAIL PROTECTED] wrote:
On 10/12/06, Charles R Harris [EMAIL PROTECTED]
 wrote:
I'm guessing that the rcond number in the lstsq version (default 1e-10) is the difference. Generally the lstsq version should work better than the MPL version because at*a is not as well conditioned and vandermonde matrices are notoriously ill conditioned anyway for higher degree fits. It would help if you attached the data files in ascii form unless they happen to contain thousands of data items. Just the x will suffice, zip it up if you have to.
Here are the files.Since the two algorithms behave differently and each has it place then can both be included in numpy?i.e. numpy.polyfit(x,y,N, mode='alg1')numpy.polyfit

(x,y,N, mode='alg2')replacing alg1 and alg2 with meaningful names.The polyfit function looks seriously busted. If I do the fits by hand I get the same results using the (not so hot) MPL version or lstsq. I don't know what the problem is. The docstring is also incorrect for the method. Hmmm...
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Polyfit

2006-10-12 Thread Charles R Harris
On 10/12/06, Charles R Harris [EMAIL PROTECTED] wrote:
On 10/12/06, Greg Willden 
[EMAIL PROTECTED] wrote:

On 10/12/06, Charles R Harris [EMAIL PROTECTED]
 wrote:
I'm guessing that the rcond number in the lstsq version (default 1e-10) is the difference. Generally the lstsq version should work better than the MPL version because at*a is not as well conditioned and vandermonde matrices are notoriously ill conditioned anyway for higher degree fits. It would help if you attached the data files in ascii form unless they happen to contain thousands of data items. Just the x will suffice, zip it up if you have to.
Here are the files.Since the two algorithms behave differently and each has it place then can both be included in numpy?i.e. numpy.polyfit(x,y,N, mode='alg1')numpy.polyfit


(x,y,N, mode='alg2')replacing alg1 and alg2 with meaningful names.The polyfit function looks seriously busted. If I do the fits by hand I get the same results using the (not so hot) MPL version or lstsq. I don't know what the problem is. The docstring is also incorrect for the method. Hmmm...
Polyfit seems overly conservative in its choice of rcond. In [101]: lin.lstsq(v,y,1e-10)[0]Out[101]: array([ 5.84304475e-07, -5.51513630e-03, 1.51465472e+01, 
3.05631361e-02])In [107]: polyfit(x,y,3)Out[108]: array([ 5.84304475e-07, -5.51513630e-03, 1.51465472e+01, 3.05631361e-02])CompareIn [112]: lin.lstsq(v,y,1e-12)[0]Out[112]: 
array([ -5.42970700e-07, 1.61425067e-03, 1.99260667e+00, 6.51889107e+03])In [113]: dot(lin.inv(vtv),dot(v.T,y))Out[113]: array([ -5.42970700e-07, 1.61425067e-03, 1.99260667e+00,
 6.51889107e+03])So the default needs to be changed somewhere. Probably polyfit shoud accept rcond as a keyword. Where the actual problem lies is a bit obscure as the normal rcond default for lin.lstsq
 is 1e-12. Maybe some sort of import error somewhere down the line.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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Polyfit

2006-10-12 Thread Charles R Harris
On 10/12/06, Charles R Harris [EMAIL PROTECTED] wrote:
On 10/12/06, Charles R Harris 
[EMAIL PROTECTED] wrote:
On 10/12/06, Greg Willden 
[EMAIL PROTECTED] wrote:

On 10/12/06, Charles R Harris [EMAIL PROTECTED]
 wrote:
I'm guessing that the rcond number in the lstsq version (default 1e-10) is the difference. Generally the lstsq version should work better than the MPL version because at*a is not as well conditioned and vandermonde matrices are notoriously ill conditioned anyway for higher degree fits. It would help if you attached the data files in ascii form unless they happen to contain thousands of data items. Just the x will suffice, zip it up if you have to.
Here are the files.Since the two algorithms behave differently and each has it place then can both be included in numpy?i.e. numpy.polyfit(x,y,N, mode='alg1')numpy.polyfit



(x,y,N, mode='alg2')replacing alg1 and alg2 with meaningful names.The polyfit function looks seriously busted. If I do the fits by hand I get the same results using the (not so hot) MPL version or lstsq. I don't know what the problem is. The docstring is also incorrect for the method. Hmmm...
Polyfit seems overly conservative in its choice of rcond. In [101]: lin.lstsq(v,y,1e-10)[0]Out[101]: array([ 5.84304475e-07, -5.51513630e-03, 1.51465472e+01
, 
3.05631361e-02])In [107]: polyfit(x,y,3)Out[108]: array([ 5.84304475e-07, -5.51513630e-03, 1.51465472e+01, 3.05631361e-02])CompareIn [112]: lin.lstsq(v,y,1e-12)[0]Out[112]: 
array([ -5.42970700e-07, 1.61425067e-03, 1.99260667e+00, 6.51889107e+03])In [113]: dot(lin.inv(vtv),dot(v.T,y))Out[113]: array([ -5.42970700e-07, 1.61425067e-03, 1.99260667e+00,

 6.51889107e+03])So the default needs to be changed somewhere. Probably polyfit shoud accept rcond as a keyword. Where the actual problem lies is a bit obscure as the normal rcond default for lin.lstsq

 is 1e-12. Maybe some sort of import error somewhere down the line.And here is the location of the problem in numpy/linalg/linalg.py :def lstsq(a, b, rcond=1.e-10):The 1e-10 is a bit conservative. On the other hand, I will note that the condition number of the dot(V^T ,V) matrix is somewhere around 1e22, which means in general terms that you need around 22 digits of accuracy. Inverting it only works sorta by accident in the current case. Generally, using Vandermonde matrices and polynomial fits it a bad idea when the dynamic range of the interval gets large and the degree gets up around 4-5 as it leads to ill conditioned sets of equations. When you really need the best start with chebychev polynomials or, bestest, compute a set of polynomials orthogonal over the sample points. Anyway, I think rcond should be something like 1e-12 or 1e-13 by default and be available as a keyword in the polyfit function. If no one complains I will make this change, although it is just a bandaid and things will fall apart again as soon as you call polyfit(x,y,4).
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] numpy on centos4.4?

2006-10-12 Thread Neal Becker
Has anyone built numpy-1.0rc2/scipy-0.5.1 on centos4.4?

It seems that a fortran90+ compiler is required, so I installed 
gcc4-gfortran-4.1.0-18.EL4
libgfortran-4.1.0-18.EL4

Didn't quite work though.  Built numpy+scipy OK, but then:
Warning: FAILURE importing tests for module 'scipy.linalg.blas'
from '...packages/scipy/linalg/blas.pyc'
/usr/lib/python2.3/site-packages/scipy/linalg/tests/test_blas.py:22:
ImportError: /usr/lib/python2.3/site-pac\
kages/scipy/linalg/fblas.so: undefined symbol: srotmg_ (in ?)

Not sure yet what's causing this.  I suspect it is because of a mixture of
different compilers/libraries?  Like, maybe blas was compiled with f77 from
gcc3, while fblas was compiled with gfortran from gcc4?


-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Providing array interface from SWIG-wrapped C struct

2006-10-12 Thread vallis . 35530053
Wonderful, it works, thanks!



Michele



--- Discussion of Numerical Python
numpy-discussion@lists.sourceforge.net wrote:

On 10/12/06, Michele Vallisneri
[EMAIL PROTECTED] wrote:

  Does anybody here have experience about offering
the array interface

  from a SWIG-wrapped C struct?

 

 I have.

 

  I have tried the following, borrowing code from numpy's arrayobject.c:

 

  %extend real_vec_t {

 PyObject *__array_struct__() {

 
 /* From numpy/arrayobject.c/array_struct_get */

 

 You are extending
real_vec_t with a new METHOD, but what numpy

 requests is an ATTRIBUTE.
So, numpy simply queries your vec like:

 

 arrstr = vec.__array_struct__

 

 and not with a method call like this

 

 arrstr = vec.__array_struct__()

 

 

 So here is what I would do (can fail with some SWIG optimizations)

 

 %extend Vec {

 

 PyObject* __array_struct__ () { /* ...  */ }

 

   %pythoncode {

   __array_struct__ = property(__array_struct__,

  doc='Array protocol')

   }

 

 }

 

 Hope you got the idea.

 

 -- 

 Lisandro Dalc�n

 ---

 Centro Internacional de M�todos Computacionales en
Ingenier�a (CIMEC)

 Instituto de Desarrollo Tecnol�gico para la Industria
Qu�mica (INTEC)

 Consejo Nacional de Investigaciones Cient�ficas y T�cnicas
(CONICET)

 PTLC - G�emes 3450, (3000) Santa Fe, Argentina

 Tel/Fax:
+54-(0)342-451.1594

 

 -

 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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] rcond in polyfit

2006-10-12 Thread Charles R Harris
Hi all,I note that polyfit looks like it should work for single and double, real and complex, polynomials. On the otherhand, the default rcond needs to depend on the underlying precision. On the other, other hand, all the svd computations are done with dgelsd or zgelsd, 
i.e., double precision. Even so problems can arise from inherent errors of the input data if it is single precision to start with. I also think the final degree of the fit should be available somewhere if wanted, as it is an indication of what is going on. Sooo, any suggestions as to what to do? My initial impulse would be to set rcond=1e-6 for single, 1e-14 for double, make rcond a keyword, and kick the can down the road on returning the actual degree of the fit.
ChuckPS, what is the best way of converting arbitrary arrays to the appropriate c data types float and double?
-
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


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

2006-10-12 Thread David Goldsmith
I find that acceptable for my purposes, but is there some way we can 
minimize the surprise(s)  for newbies?  (I know some suggestions have 
been put forward in this thread, but I don't know enough to cast a vote 
one way or another for any of those, just a vote for please do it.)  
And, in closing, I too would like to: thank you very much for all your 
work - despite my emotional outburst, I am generally very happy using 
numpy and regard it as an excellent product.

DG

Travis Oliphant wrote:
 David Goldsmith wrote:

   
 Got it.  And if I understand correctly, the import order you specify in 
 the little mynumpy example you included in your latest response to 
 Fernando will result in any overlap between numpy and 
 numpy.lib.scimath to call the latter's version of things rather than the 
 former's, yes?
  

 

 Right.  The last import will be used for any common-names (variables get 
 re-bound to the new functions...)

 -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=lnkkid=120709bid=263057dat=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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


[Numpy-discussion] How to make sqrt(-1) be 1j

2006-10-12 Thread Bill Baxter
On 10/12/06, Stefan van der Walt [EMAIL PROTECTED] wrote:
 On Thu, Oct 12, 2006 at 08:58:21AM -0500, Greg Willden wrote:
  On 10/11/06, Bill Baxter [EMAIL PROTECTED] wrote:
 I tried to explain the argument at

 http://www.scipy.org/NegativeSquareRoot


The proposed fix for those who want sqrt(-1) to return 1j is:

   from numpy.lib import scimath as SM
   SM.sqrt(-1)


But that creates a new namespace alias, different from numpy.  So I'll
call numpy.array() to create a new array, but SM.sqrt() when I want a
square root.
Am I wrong to want some simple way to change the behavior of
numpy.sqrt itself?

Seems like you can get that effect via something like:

for n in numpy.lib.scimath.__all__:
numpy.__dict__[n] = numpy.lib.scimath.__dict__[n]

If that sort of function were available as numpy.use_scimath(), then
folks who want numpy to be like scipy can achieve that with just one
line at the top of their files.   The import under a different name
doesn't quite achieve the goal of making that behavior numpy's
default.

I guess I'm thinking mostly of the educational uses of numpy, where
you may have users that haven't learned about much about numerical
computing yet.  I can just imagine the instructor starting off by
saying ok everyone we're going to learn numpy today!  First everyone
type this:  'import numpy, from numpy.lib import scimath as SM' --
Don't worry about all the things there you don't understand.
Whereas import numpy, numpy.use_scimath() seems easier to explain
and much less intimidating as your first two lines of numpy to learn.

Or is that just a bad idea for some reason?

--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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] How to make sqrt(-1) be 1j

2006-10-12 Thread Charles R Harris
On 10/12/06, Bill Baxter [EMAIL PROTECTED] wrote:
On 10/12/06, Stefan van der Walt [EMAIL PROTECTED] wrote: On Thu, Oct 12, 2006 at 08:58:21AM -0500, Greg Willden wrote:  On 10/11/06, Bill Baxter 
[EMAIL PROTECTED] wrote: I tried to explain the argument at http://www.scipy.org/NegativeSquareRootThe proposed fix for those who want sqrt(-1) to return 1j is:
 from numpy.lib import scimath as SM SM.sqrt(-1)But that creates a new namespace alias, different from numpy.So I'llcall numpy.array() to create a new array, but SM.sqrt() when I want a
square root.Am I wrong to want some simple way to change the behavior ofnumpy.sqrt itself?Seems like you can get that effect via something like:for n in numpy.lib.scimath.__all__:numpy.__dict__[n] = 
numpy.lib.scimath.__dict__[n]I don't like either of those ideas, although the second seems preferable. I think it better to make an efficient way of calling a sqrt routine that accepts negative floats and returns complex numbers. The behaviour could be chosen either by key word or by specially named routines, or maybe even some global flag, but I don't think it asking too much for the students to learn that sqrt(-1) doesn't exist as a real number and that efficient computation uses real whenever possible because it is a) smaller, and b) faster. That way we also avoid having software that only works for scimath but not for numpy.
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=lnkkid=120709bid=263057dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] How to make sqrt(-1) be 1j

2006-10-12 Thread Bill Baxter
On 10/13/06, Charles R Harris [EMAIL PROTECTED] wrote:


 On 10/12/06, Bill Baxter [EMAIL PROTECTED] wrote:
  On 10/12/06, Stefan van der Walt [EMAIL PROTECTED] wrote:
   On Thu, Oct 12, 2006 at 08:58:21AM -0500, Greg Willden wrote:
On 10/11/06, Bill Baxter  [EMAIL PROTECTED] wrote:
   I tried to explain the argument at
  
   http://www.scipy.org/NegativeSquareRoot
  
 
  The proposed fix for those who want sqrt(-1) to return 1j is:
 
 from numpy.lib import scimath as SM
 SM.sqrt(-1)
 
 
  But that creates a new namespace alias, different from numpy.  So I'll
  call numpy.array() to create a new array, but SM.sqrt() when I want a
  square root.
  Am I wrong to want some simple way to change the behavior of
  numpy.sqrt itself?
 
  Seems like you can get that effect via something like:
 
  for n in numpy.lib.scimath.__all__:
  numpy.__dict__[n] = numpy.lib.scimath.__dict__[n]

 I don't like either of those ideas, although the second seems preferable. I
 think it better to make an efficient way of calling a sqrt routine that
 accepts negative floats and returns complex numbers. The behaviour could be
 chosen either by key word or by specially named routines, or maybe even
 some global flag,

We have the specially named routines way already.  numpy.lib.scimath.sqrt

 but I don't think it asking too much for the students to
 learn that sqrt(-1) doesn't exist as a real number and that efficient
 computation uses real whenever possible because it is a) smaller, and b)
 faster. That way we also avoid having software that only works for scimath
 but not for numpy.

I think efficiency is not a very good argument for the default
behavior here, because -- lets face it -- if efficient execution was
high on your priority list, you wouldn't be using python.  And even if
you do care about efficiency, one of the top rules of optimization is
to first get it working, then get it working fast.

Really, I'm just playing the devils advocate here, because I don't
work with complex numbers (I see quaternions more often than complex
numbers).  But I would be willing to do something like
numpy.use_realmath()
in my code if it would make numpy more palatable to a wider audience.
I wouldn't like it, however, if I had to do some import thing where I
have to remember forever after that I should type 'numpy.tanh()' but
'realmath.arctanh()'.

Anyway it seems like the folks who care about performance are the ones
who will generally be more willing to make tweaks like that.

But that's about all I have to say about this, since the status quo
works fine for me.  So I'll be quiet.  Just it seems like the
non-status-quo'ers here have some good points.  I taught intro to
computer science to non-majors one semester.  I know I would not want
to have to confront all the issues with numerical computing right off
the bat if I was just trying to teach people how to do some math.

--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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Problem buliding rc2 on OS X 10.3.9/Python2.5

2006-10-12 Thread Jay Parlar
I hate bumping my own messages, but does no one have any insight into this?



On 10/9/06, Jay Parlar [EMAIL PROTECTED] wrote:
 In the process of finally switching over to Python 2.5, and am trying
 to build numpy. Unfortunately, it dies during the build:

 Jay-Computer:~/Desktop/numpy-1.0rc2 jayparlar$ python setup.py build
 Running from numpy source directory.
 F2PY Version 2_3296
 blas_opt_info:
   FOUND:
 extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
 define_macros = [('NO_ATLAS_INFO', 3)]
 extra_compile_args = ['-faltivec',
 '-I/System/Library/Frameworks/vecLib.framework/Headers']

 lapack_opt_info:
   FOUND:
 extra_link_args = ['-Wl,-framework', '-Wl,Accelerate']
 define_macros = [('NO_ATLAS_INFO', 3)]
 extra_compile_args = ['-faltivec']

 running build
 running config_fc
 running build_src
 building py_modules sources
 building extension numpy.core.multiarray sources
 Generating build/src.macosx-10.3-fat-2.5/numpy/core/config.h
 customize NAGFCompiler
 customize AbsoftFCompiler
 customize IbmFCompiler
 Could not locate executable g77
 Could not locate executable f77
 Could not locate executable gfortran
 Could not locate executable f95
 customize GnuFCompiler
 customize Gnu95FCompiler
 customize G95FCompiler
 customize GnuFCompiler
 customize Gnu95FCompiler
 customize NAGFCompiler
 customize NAGFCompiler using config
 C compiler: gcc -arch ppc -arch i386 -isysroot
 /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double
 -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3

 compile options:
 '-I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
 -Inumpy/core/src -Inumpy/core/include
 -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5
 -c'
 gcc: _configtest.c
 gcc: cannot specify -o with -c or -S and multiple compilations
 gcc: cannot specify -o with -c or -S and multiple compilations
 failure.
 removing: _configtest.c _configtest.o
 numpy/core/setup.py:50: DeprecationWarning: raising a string exception
 is deprecated
   raise ERROR: Failed to test configuration
 Traceback (most recent call last):
   File setup.py, line 89, in module
 setup_package()
   File setup.py, line 82, in setup_package
 configuration=configuration )
   File /Users/jayparlar/Desktop/numpy-1.0rc2/numpy/distutils/core.py,
 line 174, in setup
 return old_setup(**new_attr)
   File 
 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/core.py,
 line 151, in setup
 dist.run_commands()
   File 
 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py,
 line 974, in run_commands
 self.run_command(cmd)
   File 
 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py,
 line 994, in run_command
 cmd_obj.run()
   File 
 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/command/build.py,
 line 112, in run
 self.run_command(cmd_name)
   File 
 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/cmd.py,
 line 333, in run_command
 self.distribution.run_command(command)
   File 
 /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/distutils/dist.py,
 line 994, in run_command
 cmd_obj.run()
   File 
 /Users/jayparlar/Desktop/numpy-1.0rc2/numpy/distutils/command/build_src.py,
 line 87, in run
 self.build_sources()
   File 
 /Users/jayparlar/Desktop/numpy-1.0rc2/numpy/distutils/command/build_src.py,
 line 106, in build_sources
 self.build_extension_sources(ext)
   File 
 /Users/jayparlar/Desktop/numpy-1.0rc2/numpy/distutils/command/build_src.py,
 line 212, in build_extension_sources
 sources = self.generate_sources(sources, ext)
   File 
 /Users/jayparlar/Desktop/numpy-1.0rc2/numpy/distutils/command/build_src.py,
 line 270, in generate_sources
 source = func(extension, build_dir)
   File numpy/core/setup.py, line 50, in generate_config_h
 raise ERROR: Failed to test configuration
 ERROR: Failed to test configuration


 This is with the Universal 2.5 binary, and OS X 10.3.9.

 Any ideas? Sorry if this one has been asked before, but I can't seem
 to find a solution anywhere.

 Jay P.


-
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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] How to make sqrt(-1) be 1j

2006-10-12 Thread Tim Hochberg
Bill Baxter wrote:
 On 10/12/06, Stefan van der Walt [EMAIL PROTECTED] wrote:
   
 On Thu, Oct 12, 2006 at 08:58:21AM -0500, Greg Willden wrote:
 
 On 10/11/06, Bill Baxter [EMAIL PROTECTED] wrote:
   
 I tried to explain the argument at

 http://www.scipy.org/NegativeSquareRoot

 

 The proposed fix for those who want sqrt(-1) to return 1j is:

from numpy.lib import scimath as SM
SM.sqrt(-1)


 But that creates a new namespace alias, different from numpy.  So I'll
 call numpy.array() to create a new array, but SM.sqrt() when I want a
 square root.
 Am I wrong to want some simple way to change the behavior of
 numpy.sqrt itself?

 Seems like you can get that effect via something like:

 for n in numpy.lib.scimath.__all__:
 numpy.__dict__[n] = numpy.lib.scimath.__dict__[n]

 If that sort of function were available as numpy.use_scimath(), then
 folks who want numpy to be like scipy can achieve that with just one
 line at the top of their files.   The import under a different name
 doesn't quite achieve the goal of making that behavior numpy's
 default.

 I guess I'm thinking mostly of the educational uses of numpy, where
 you may have users that haven't learned about much about numerical
 computing yet.  I can just imagine the instructor starting off by
 saying ok everyone we're going to learn numpy today!  First everyone
 type this:  'import numpy, from numpy.lib import scimath as SM' --
 Don't worry about all the things there you don't understand.
 Whereas import numpy, numpy.use_scimath() seems easier to explain
 and much less intimidating as your first two lines of numpy to learn.

 Or is that just a bad idea for some reason?

   
Isn't that just going to make your students *more* confused later when 
then run into the standard behavior of numpy? For this sort of thing, I 
would just make a new module to pull together the function I want and 
use that instead. It's then easy to explain that this new module bbeconf 
(Bill Baxter's Excellent Collection Of Numeric Functions) is actually an 
amalgamation of stuff from multiple sources.

# bbeconf.py
from numpy import *
fromnumpy.scimath import sqrt
# possibly some other stuff to correctly handle subpackages...


-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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] How to make sqrt(-1) be 1j

2006-10-12 Thread Bill Baxter
On 10/13/06, Tim Hochberg [EMAIL PROTECTED] wrote:
 For this sort of thing, I
 would just make a new module to pull together the function I want and
 use that instead. It's then easy to explain that this new module bbeconf
 (Bill Baxter's Excellent Collection Of Numeric Functions) is actually an
 amalgamation of stuff from multiple sources.

 # bbeconf.py
 from numpy import *
 fromnumpy.scimath import sqrt
 # possibly some other stuff to correctly handle subpackages...

That does sound like a good way to do it.
Then you just tell your users to import 'eduNumpy'  rather than numpy,
and you're good to go.
Added that suggestion to http://www.scipy.org/NegativeSquareRoot

I'd like to ask one basic Python question related my previous
suggestion of doing things like numpy.sqrt = numpy.lib.scimath.sqrt:
In python does that make it so that any module importing numpy in the
same program will now see the altered sqrt function?  E.g. in my
program I do import A,B.  Module A alters numpy.sqrt.  Does that
also modify how module B sees numpy.sqrt?

If so then that's a very good reason not to do it that way.

I've heard people using the term monkey-patch before.  Is that what that is?

--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=lnkkid=120709bid=263057dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion