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

[Numpy-discussion] loadtxt

2008-10-02 Thread Nils Wagner
Hi all, how can I load ASCII data if the file contains characters instead of floats Traceback (most recent call last): File test_csv.py, line 2, in module A = loadtxt('ca6_sets.csv',dtype=char ,delimiter=';') NameError: name 'char' is not defined Nils

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] complex numpy.ndarray dtypes

2008-10-02 Thread Francesc Alted
A Thursday 02 October 2008, John Gu escrigué: Hello, I am using numpy in conjunction with pyTables. The data that I read in from pyTables seem to have the following dtype: p = hdf5.root.myTable.read() p.__class__ type 'numpy.ndarray' p[0].__class__ type 'numpy.void' p.dtype

Re: [Numpy-discussion] loadtxt

2008-10-02 Thread Francesc Alted
A Thursday 02 October 2008, Nils Wagner escrigué: Hi all, how can I load ASCII data if the file contains characters instead of floats Traceback (most recent call last): File test_csv.py, line 2, in module A = loadtxt('ca6_sets.csv',dtype=char ,delimiter=';') NameError: name 'char'

Re: [Numpy-discussion] Portable functions for nans, signbit, etc.

2008-10-02 Thread David Cournapeau
On Thu, Oct 2, 2008 at 11:41 AM, Charles R Harris [EMAIL PROTECTED] wrote: Which is rather clever. I think binary_cast will require some pointer abuse. Yep (the funny thing is that the bit twiddling will likely end up more readable than this C++ stuff) cheers, David

Re: [Numpy-discussion] loadtxt

2008-10-02 Thread Stéfan van der Walt
2008/10/2 Francesc Alted [EMAIL PROTECTED]: how can I load ASCII data if the file contains characters instead of floats You would need to specify the length of your strings. Try with dtype=SN, where N is the expected length of the strings. Other options include: - using converters to

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] Portable functions for nans, signbit, etc.

2008-10-02 Thread Charles R Harris
On Thu, Oct 2, 2008 at 2:41 AM, David Cournapeau [EMAIL PROTECTED] wrote: On Thu, Oct 2, 2008 at 11:41 AM, Charles R Harris [EMAIL PROTECTED] wrote: Which is rather clever. I think binary_cast will require some pointer abuse. Yep (the funny thing is that the bit twiddling will likely

Re: [Numpy-discussion] Help to process a large data file

2008-10-02 Thread David Huard
Frank, How about that: x = np.loadtxt('file') z = x.sum(1) # Reduce data to an array of 0,1,2 rz = z[z0] # Remove all 0s since you don't want to count those. loc = np.where(rz==2)[0] # The location of the (1,1)s count = np.diff(loc) - 1 # The spacing between those (1,1)s, ie, the

Re: [Numpy-discussion] Help to process a large data file

2008-10-02 Thread orionbelt2
Frank, I would imagine that you cannot get a much better performance in python than this, which avoids string conversions: c = [] count = 0 for line in open('foo'): if line == '1 1\n': c.append(count) count = 0 else: if '1' in line: count += 1 One could do some

Re: [Numpy-discussion] Help to process a large data file

2008-10-02 Thread frank wang
Thans David and Chris for providing the nice solution. Both method works gread. I could not tell the speed difference between the two solutions. My data size is 1048577 lines. I did not try the second solution from Chris since it is too slow as Chris stated. Frank Date: Thu, 2 Oct 2008

Re: [Numpy-discussion] Texas Python Regional Unconference Reminders

2008-10-02 Thread Travis Vaught
Hey Steve, I'll bring my camera and try to recruit a volunteer. No guarantees, but we should at least be able to record things (any volunteers to transcode a pile of scipy videos? ;-) ). Best, Travis On Oct 1, 2008, at 7:56 PM, Steve Lianoglou wrote: Hi, Are there any plans to tape

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 =

Re: [Numpy-discussion] Proposal: scipy.spatial

2008-10-02 Thread David Bolme
I also like the idea of a scipy.spatial library. For the research I do in machine learning and computer vision we are often interested in specifying different distance measures. It would be nice to have a way to specify the distance measure. I would like to see a standard set included:

Re: [Numpy-discussion] Proposal: scipy.spatial

2008-10-02 Thread Matthieu Brucher
2008/10/2 David Bolme [EMAIL PROTECTED]: I also like the idea of a scipy.spatial library. For the research I do in machine learning and computer vision we are often interested in specifying different distance measures. It would be nice to have a way to specify the distance measure. I would

[Numpy-discussion] f2py IS NOW WORKING

2008-10-02 Thread Blubaugh, David A.
To all, I have now been able to develop a stable file via f2py!! However, I had to execute the following: 1.) First, I had to copy all required library files from my selected Compaq visual Fortran compiler under python's scripts directory along with f2py itself. 2.) I also had to include

Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--

2008-10-02 Thread Chris Barker
Jarrod Millman wrote: The 1.2.0rc2 is now available: http://svn.scipy.org/svn/numpy/tags/1.2.0rc2 what's the status of this? Here are the Window's binaries: http://www.ar.media.kyoto-u.ac.jp/members/david/archives/numpy/numpy-1.2.0rc2-win32-superpack-python2.5.exe this appears to be a dead

Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--

2008-10-02 Thread Robert Kern
On Thu, Oct 2, 2008 at 16:45, Chris Barker [EMAIL PROTECTED] wrote: Jarrod Millman wrote: The 1.2.0rc2 is now available: http://svn.scipy.org/svn/numpy/tags/1.2.0rc2 what's the status of this? Superceded by the 1.2.0 release. See the thread ANN: NumPy 1.2.0. Here are the Window's binaries:

Re: [Numpy-discussion] Proposal: scipy.spatial

2008-10-02 Thread David Bolme
It may be useful to have an interface that handles both cases: similarity and dissimilarity. Often I have seen Nearest Neighbor algorithms that look for maximum similarity instead of minimum distance. In my field (biometrics) we often deal with very specialized distance or similarity

Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--

2008-10-02 Thread Chris Barker
Robert Kern wrote: Superceded by the 1.2.0 release. See the thread ANN: NumPy 1.2.0. I thought I'd seen that, but when I went to: http://www.scipy.org/Download And I still got 1.1 Superceded by

Re: [Numpy-discussion] Proposal: scipy.spatial

2008-10-02 Thread Anne Archibald
2008/10/2 David Bolme [EMAIL PROTECTED]: It may be useful to have an interface that handles both cases: similarity and dissimilarity. Often I have seen Nearest Neighbor algorithms that look for maximum similarity instead of minimum distance. In my field (biometrics) we often deal with very

Re: [Numpy-discussion] numpy.random.hypergeometric - strange results

2008-10-02 Thread joep
see http://scipy.org/scipy/numpy/ticket/921 I think I found the error http://scipy.org/scipy/numpy/browser/trunk/numpy/random/mtrand/distributions.c {{{ 805 /* this is a correction to HRUA* by Ivan Frohne in rv.py */ 806 if (good bad) Z = m - Z; }}} Quickly looking at the

Re: [Numpy-discussion] 1.2.0rc2 tagged! --PLEASE TEST--

2008-10-02 Thread Jarrod Millman
On Thu, Oct 2, 2008 at 4:29 PM, Chris Barker [EMAIL PROTECTED] wrote: Robert Kern wrote: Superceded by the 1.2.0 release. See the thread ANN: NumPy 1.2.0. I thought I'd seen that, but when I went to: http://www.scipy.org/Download And I still got 1.1 I updated the page to point to the

Re: [Numpy-discussion] numpy.random.logseries - incorrect convergence for k=1, k=2

2008-10-02 Thread joep
Filed as http://scipy.org/scipy/numpy/ticket/923 and I think i finally tracked down the source of the incorrect random numbers, a reversed inequality in http://scipy.org/scipy/numpy/browser/trunk/numpy/random/mtrand/distributions.c line 871, see my last comment to the trac ticket. Josef On Sep