Re: [Numpy-discussion] nan version of einsum

2016-04-27 Thread Chris Barber
Hi, Looks like I was a little confused. It appears that the nan* versions of functions in numpy just substitute the NaNs in a copy of the original array and so are just convenience methods. I was imagining that they were optimized and handling the NaNs at a lower level. It looks like the

[Numpy-discussion] nan version of einsum

2016-04-19 Thread Chris Barber
Is there any interest in a nan-ignoring version of einsum a la nansum, nanprod, etc? Any idea how difficult it would be to implement? - Chris ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

[Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Happyman
DEAR PYTHON USERS DO MATHEMATICAL FUNCTIONS HAVE LIMITATION IN PYTHON in comparison with other programming languages I have two mathematical functions: from scipy.special import sph_jn,  sph_jnyn 1)  sph_jn (n, z) --- n is float, z is complex number for example:  a,b=sph_jn ( 2.0 ,

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Pauli Virtanen
Happyman bahtiyor_zohidov at mail.ru writes: [clip] IF I GIVE ( it is necessary value for my program ): a , b = sph_jn ( 536 , 2513.2741228718346 + 201.0619298974676j ) The implementation of the spherical Bessel functions is through this Fortran code:

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Happyman
Thanks Pauli But I have already very shortly built  for bessel function, but the code you gave me is in Fortran.. I also used f2py but I could not manage to read fortran codes..that is why I have asked in Python what is wrong?? Пятница, 21 декабря 2012, 12:46 UTC от Pauli Virtanen

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Pauli Virtanen
Happyman bahtiyor_zohidov at mail.ru writes: Thanks Pauli But I have already very shortly built  for bessel  function, but the code you gave me is in Fortran.. I also used f2py but I could not manage to read fortran codes..that is why I have asked in Python what is wrong?? That Fortran code is

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Happyman
I have everything in C or Fortran...According to my friends recommendations I started learning Python for my research... Do you mean the functions which gave Nan result has not been developed properly yet in Python, Don't you For about 1.5 months I have been facing the same problem for

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Dag Sverre Seljebotn
On 12/21/2012 02:30 PM, Happyman wrote: I have everything in C or Fortran...According to my friends recommendations I started learning Python for my research... Do you mean the functions which gave Nan result has not been developed properly yet in Python, Don't you The way most of NumPy

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Pauli Virtanen
Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no writes: [clip] Do you have an implemention of the Bessel functions that work as you wish in C or Fortran? If so, that could be wrapped and called from Python. For spherical Bessel functions it's possible to also use the relation to Bessel

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Lev Givon
Received from Pauli Virtanen on Fri, Dec 21, 2012 at 08:59:02AM EST: Dag Sverre Seljebotn d.s.seljebotn at astro.uio.no writes: [clip] Do you have an implemention of the Bessel functions that work as you wish in C or Fortran? If so, that could be wrapped and called from Python. For

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Happyman
I think you advised about the code which is the same appearance. == Problem is not here Sir I will give you exactly what I was talking about. I have ready codes already(It would be kind of you if you checked the

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Pauli Virtanen
Hi, Your code tries to to evaluate z = 1263309.3633394379 + 101064.74910119522j jv(536, z) # - (inf+inf*j) In reality, this number is not infinite, but jv(536, z) == -2.3955170861527422e+43888 + 9.6910119847300024e+43887 These numbers (~ 10^43888) are too large for the

Re: [Numpy-discussion] NaN (Not a Number) occurs in calculation of complex number for Bessel functions

2012-12-21 Thread Happyman
Thanks But I could find for Win64 bit windows Second question: Did you mean that I have to put lens limits of those number???   Пятница, 21 декабря 2012, 15:45 UTC от Pauli Virtanen p...@iki.fi: Hi, Your code tries to to evaluate z = 1263309.3633394379 + 101064.74910119522j

[Numpy-discussion] nan result from np.linalg.lstsq()

2012-10-29 Thread Larry Paltrow
I'm having some trouble using the linalg.lstsq() function with certain data and trying to understand why. It's always returning nans when I feed it this numpy array of float64 data: data = df.close.values #coming from a pandas dataframe type(data) numpy.ndarray data.dtype dtype('float64') data

Re: [Numpy-discussion] nan result from np.linalg.lstsq()

2012-10-29 Thread Pauli Virtanen
Larry Paltrow larry.paltrow at gmail.com writes: I'm having some trouble using the linalg.lstsq() function with certain data and trying to understand why. It's always returning nans when I feed it this numpy array of float64 data: data = df.close.values #coming from a pandas dataframe

Re: [Numpy-discussion] nan result from np.linalg.lstsq()

2012-10-29 Thread Larry Paltrow
np.isnan(data) is True False On Mon, Oct 29, 2012 at 1:50 AM, Pauli Virtanen p...@iki.fi wrote: Larry Paltrow larry.paltrow at gmail.com writes: I'm having some trouble using the linalg.lstsq() function with certain data and trying to understand why. It's always returning nans when I

Re: [Numpy-discussion] nan result from np.linalg.lstsq()

2012-10-29 Thread eat
Hi, On Mon, Oct 29, 2012 at 11:01 AM, Larry Paltrow larry.palt...@gmail.comwrote: np.isnan(data) is True False Check with: np.all(~np.isnan(x)) My 2 cents, -eat On Mon, Oct 29, 2012 at 1:50 AM, Pauli Virtanen p...@iki.fi wrote: Larry Paltrow larry.paltrow at gmail.com writes: I'm

Re: [Numpy-discussion] nan result from np.linalg.lstsq()

2012-10-29 Thread Larry Paltrow
Ok thanks, I figured np.isnan(data) is True is what we want but wasn't certain. I think it should describe the same thing. np.all(~np.isnan(data)) False Seems to be all non-nan On Mon, Oct 29, 2012 at 2:12 AM, eat e.antero.ta...@gmail.com wrote: Hi, On Mon, Oct 29, 2012 at 11:01 AM, Larry

Re: [Numpy-discussion] nan result from np.linalg.lstsq()

2012-10-29 Thread Pauli Virtanen
Larry Paltrow larry.paltrow at gmail.com writes: [clip] np.all(~np.isnan(data)) False Seems to be all non-nan No, it means you have NaNs in your data. -- Pauli Virtanen ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] nan result from np.linalg.lstsq()

2012-10-29 Thread Larry Paltrow
doh! thanks On Mon, Oct 29, 2012 at 2:36 AM, Pauli Virtanen p...@iki.fi wrote: Larry Paltrow larry.paltrow at gmail.com writes: [clip] np.all(~np.isnan(data)) False Seems to be all non-nan No, it means you have NaNs in your data. -- Pauli Virtanen

[Numpy-discussion] nan division warnings

2011-08-30 Thread mdekauwe
Hi, this is probably my lack of understanding...when i set up some masks for 2 arrays and try to divide one by the other I get a runtime warning. Seemingly this is when I am asking python to divide one nan by the other, however I thought by masking the array numpy would then know to ignore these

[Numpy-discussion] NaN value processing in weave.inline code

2011-01-14 Thread Joon Ro
Hi,I was wondering if it is possible to process (in if statement - check if the given value is NaN) numpy NaN value inside the weave.inline c code.testcode = '''if (test(0)) { return_val = test(0);}'''err = weave.inline(testcode,['test'], type_converters = converters.blitz,

Re: [Numpy-discussion] NaN value processing in weave.inline code

2011-01-14 Thread Keith Goodman
On Fri, Jan 14, 2011 at 12:03 PM, Joon Ro joonp...@gmail.com wrote: Hi, I was wondering if it is possible to process (in if statement - check if the given value is NaN) numpy NaN value inside the weave.inline c code. testcode = ''' if (test(0)) {       return_val = test(0); } ''' err =

Re: [Numpy-discussion] NaN value processing in weave.inline code

2011-01-14 Thread Joon Ro
Oops .. I guess isnan() inside the weave code just works fine. Should have tried this first.By the way, is there any speed lost doing this? Should I convert all NaN values into a integer and use it inside the weave inline c code?-JoonOn Fri, 14 Jan 2011 14:03:16 -0600, Joon Ro joonp...@gmail.com

Re: [Numpy-discussion] NaN as dictionary key?

2009-04-23 Thread josef . pktd
2009/4/20 Wes McKinney wesmck...@gmail.com: I assume that, because NaN != NaN, even though both have the same hash value (hash(NaN) == -32768), that Python treats any NaN double as a distinct key in a dictionary. In [76]: a = np.repeat(nan, 10) In [77]: d = {} In [78]: for i, v in

Re: [Numpy-discussion] NaN as dictionary key?

2009-04-23 Thread Bruce Southey
josef.p...@gmail.com wrote: 2009/4/20 Wes McKinney wesmck...@gmail.com: I assume that, because NaN != NaN, even though both have the same hash value (hash(NaN) == -32768), that Python treats any NaN double as a distinct key in a dictionary. In [76]: a = np.repeat(nan, 10) In [77]: d =

[Numpy-discussion] NaN as dictionary key?

2009-04-20 Thread Wes McKinney
I assume that, because NaN != NaN, even though both have the same hash value (hash(NaN) == -32768), that Python treats any NaN double as a distinct key in a dictionary. In [76]: a = np.repeat(nan, 10) In [77]: d = {} In [78]: for i, v in enumerate(a): : d[v] = i : : In

Re: [Numpy-discussion] NaN as dictionary key?

2009-04-20 Thread David Cournapeau
On Mon, Apr 20, 2009 at 11:42 PM, Wes McKinney wesmck...@gmail.com wrote: I assume that, because NaN != NaN, even though both have the same hash value (hash(NaN) == -32768), that Python treats any NaN double as a distinct key in a dictionary. I think that strictly speaking, nan should not be

[Numpy-discussion] nan, sign, and all that

2008-10-02 Thread Charles R Harris
Hi All, I've added ufuncs fmin and fmax that behave as follows: In [3]: a = array([NAN, 0, NAN, 1]) In [4]: b = array([0, NAN, NAN, 0]) In [5]: fmax(a,b) Out[5]: array([ 0., 0., NaN, 1.]) In [6]: fmin(a,b) Out[6]: array([ 0., 0., NaN, 0.]) In [7]: fmax.reduce(a) Out[7]: 1.0 In

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread Stéfan van der Walt
Hi Charles, 2008/10/2 Charles R Harris [EMAIL PROTECTED]: In [3]: a = array([NAN, 0, NAN, 1]) In [4]: b = array([0, NAN, NAN, 0]) In [5]: fmax(a,b) Out[5]: array([ 0., 0., NaN, 1.]) In [6]: fmin(a,b) Out[6]: array([ 0., 0., NaN, 0.]) These are great, many thanks! My only

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread Robert Kern
On Thu, Oct 2, 2008 at 02:37, Stéfan van der Walt [EMAIL PROTECTED] wrote: Hi Charles, 2008/10/2 Charles R Harris [EMAIL PROTECTED]: In [3]: a = array([NAN, 0, NAN, 1]) In [4]: b = array([0, NAN, NAN, 0]) In [5]: fmax(a,b) Out[5]: array([ 0., 0., NaN, 1.]) In [6]: fmin(a,b)

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread Stéfan van der Walt
2008/10/2 Robert Kern [EMAIL PROTECTED]: My only gripe is that they have the same NaN-handling as amin and friends, which I consider to be broken. No, these follow well-defined C99 semantics of the fmin() and fmax() functions in libm. If exactly one of the arguments is a NaN, the non-NaN

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread David Cournapeau
On Thu, Oct 2, 2008 at 4:37 PM, Stéfan van der Walt [EMAIL PROTECTED] wrote: These are great, many thanks! My only gripe is that they have the same NaN-handling as amin and friends, which I consider to be broken. Others also mentioned that this should be changed, and I think David C wrote a

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread Pete Forman
Stéfan van der Walt [EMAIL PROTECTED] writes: Let me rephrase: I'm not convinced that these C99 semantics provide an optimal user experience. It worries me greatly that NaN's pop up in operations and then disappear again. It is entirely possible for a script to run without failure and

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread Charles R Harris
On Thu, Oct 2, 2008 at 1:42 AM, Robert Kern [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 02:37, Stéfan van der Walt [EMAIL PROTECTED] wrote: Hi Charles, 2008/10/2 Charles R Harris [EMAIL PROTECTED]: In [3]: a = array([NAN, 0, NAN, 1]) In [4]: b = array([0, NAN, NAN, 0]) In [5]:

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread David Cournapeau
Charles R Harris wrote: Yes. If there is any agreement on this I would like to go ahead and do it. It does change the current behavior of maximum and minimum. If you do it, please do it with as many tests as possible (it should not be difficult to have a comprehensive test with *all* float

Re: [Numpy-discussion] nan, sign, and all that

2008-10-02 Thread Robert Kern
On Thu, Oct 2, 2008 at 08:22, Charles R Harris [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 1:42 AM, Robert Kern [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 02:37, Stéfan van der Walt [EMAIL PROTECTED] wrote: Hi Charles, 2008/10/2 Charles R Harris [EMAIL PROTECTED]: In [3]: a =

[Numpy-discussion] NaN

2007-12-10 Thread Jean-Luc Régnier
Hello, I switched from numarray to numpy and I have now some NaN in my matrix. What that means ? None a numeric ? regards Jean-Luc REGNIER ACR Mimarlik Ltd. Sti Savas Cad. 26/B Sirinyali ANTALYA, TURKEY Tel. Fax: 0090-(0).242.316.08.09 GSM: 0090-0.532.303.36.21

[Numpy-discussion] nan, warning and error modes

2007-02-26 Thread David Cournapeau
Hi, I am developing some numpy code, which sometimes fail because of nan. This is likely to be due to some bad coding on my side, and as such any NaN is a bug for this particular piece of code. Is there a way to get a warning when the first Nan is detected in the code (or even a faulty

Re: [Numpy-discussion] nan, warning and error modes

2007-02-26 Thread Robert Kern
David Cournapeau wrote: Hi, I am developing some numpy code, which sometimes fail because of nan. This is likely to be due to some bad coding on my side, and as such any NaN is a bug for this particular piece of code. Is there a way to get a warning when the first Nan is detected

Re: [Numpy-discussion] nan, warning and error modes

2007-02-26 Thread Robert Kern
On 2/27/07, Robert Kern [EMAIL PROTECTED] wrote: David Cournapeau wrote: Hi, I am developing some numpy code, which sometimes fail because of nan. This is likely to be due to some bad coding on my side, and as such any NaN is a bug for this particular piece of code. Is there a

Re: [Numpy-discussion] NaN, min, and max

2007-02-07 Thread Christian
Keith Goodman kwgoodman at gmail.com writes: matrix([[ 0.94425407, 0.02216611, 0.999475 ], [ 0.40444129, nan, 0.23264341], [ 0.24202372, 0.05344269, 0.37967564]]) x.max() 0.379675636032 Wrong (for me) x[1,1] = 0 x.max() 0.999474999444 -

Re: [Numpy-discussion] nan functions convert matrix to array

2006-12-03 Thread Pierre GM
On Friday 01 December 2006 17:56, Keith Goodman wrote: ... Would it break anything to change the first line of the nan functions from a = array(a) to a = asanyarray(a) ? Seeing what the nan functions do, I don't think that would be a problem. An expception would be raised if the operation