[Numpy-discussion] David's build_with_scons branch merged!

2008-02-08 Thread Jarrod Millman
Hello,

In preparation for the upcoming NumPy 1.0.5 release, I just merged
David Cournapeau's build_with_scons branch:
http://projects.scipy.org/scipy/numpy/changeset/4773

The current build system using numpy.distutils is still the default.
NumPy does not include numscons; this merge adds scons support to
numpy.distutils, provides some scons scripts, and modifies the
configuration of numpy/core.  David has extensively tested these
changes and I did a very quick sanity check to make sure I didn't
completely break everything.

Obviously, we will need to push back the 1.0.5 release date again to
ensure that there is sufficient testing.  So please test these changes
and let us know if you have any problems (or successes).

David has been putting in a considerable effort over the last several
months in developing numscons.  If you are interested in the
advantages to Davids approach, please read the description here:
http://projects.scipy.org/scipy/numpy/wiki/NumpyScons

Thanks,

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] bug report ?

2008-02-08 Thread Matthieu Brucher
Hi,

What type is pos-dimensions in your case ? It may be long (64bits long)
instead of the expected int (32bits) or something like that ?

Matthieu

2008/2/8, Yves Revaz [EMAIL PROTECTED]:


 Dear list,

 I'm using old numarray C api with numpy.
 It seems that there is a bug when using the PyArray_FromDims function.

 for example, if I define :
 acc = (PyArrayObject *)
 PyArray_FromDims(pos-nd,pos-dimensions,pos-descr-type_num);

 where pos is PyArrayObject *pos;  (3x3 array)

 when using return PyArray_Return(acc);
 I get
 array([], shape=(3, 0), dtype=float32)


 It is possible to make everything works if I use the following lines
 instead :
 int   ld[2];
 ld[0]=pos-dimensions[0];
 ld[1]=pos-dimensions[1];
 acc = (PyArrayObject *) PyArray_FromDims(pos-nd,ld,pos-descr-type_num);

 So, the problem comes from the pos-dimensions.


 Is it a known bug ?


 (I'm working on a linux 64bits machine.)


 Cheers,


 yves








 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion




-- 
French PhD student
Website : http://matthieu-brucher.developpez.com/
Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92
LinkedIn : http://www.linkedin.com/in/matthieubrucher
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] bug report ?

2008-02-08 Thread Yves Revaz

Dear list,

I'm using old numarray C api with numpy.
It seems that there is a bug when using the PyArray_FromDims function.

for example, if I define :
acc = (PyArrayObject *)
PyArray_FromDims(pos-nd,pos-dimensions,pos-descr-type_num);

where pos is PyArrayObject *pos;  (3x3 array)

when using return PyArray_Return(acc);
I get
array([], shape=(3, 0), dtype=float32)


It is possible to make everything works if I use the following lines
instead :
int   ld[2];
ld[0]=pos-dimensions[0];
ld[1]=pos-dimensions[1];
acc = (PyArrayObject *) PyArray_FromDims(pos-nd,ld,pos-descr-type_num);

So, the problem comes from the pos-dimensions.


Is it a known bug ?


(I'm working on a linux 64bits machine.)


Cheers,


yves








___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] C-api to slicing?

2008-02-08 Thread Neal Becker
Robert Kern wrote:

 Neal Becker wrote:
 Is there a C-api to array slicing?
 
 PyObject_GetItem(), PySlice_New(), and friends, for the most part.
 
I tried PySequence_GetItem on my array, and it seems the refcount isn't
working.

inline object test_slice3 (object const in_obj, int r) {
  if (!PyArray_Check (in_obj.ptr())) {
throw std::runtime_error (test_slice3: input must be numpy::array);
  }
  
  PyArrayObject* ao = (PyArrayObject*)(in_obj.ptr());
  PyArrayObject* ro = (PyArrayObject*) PySequence_GetItem ((PyObject*)ao,
r);
  return object (handlePyArrayObject (ro));
}

In the above, object is a boost::python::object, which is just a wrapper
around a PyArrayObject*.  I extract the PyArrayObject*.

Now test:
b = array ((2,3))
print sys.getrefcount (b)
c = test_slice3(a,0)
print sys.getrefcount (b), sys.getrefcount(c)

This prints:
2
2 2

Here's what it should do:

print sys.getrefcount (b)
c = b[0]
print sys.getrefcount (b), sys.getrefcount(c)
2
3 2


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] String sort

2008-02-08 Thread Charles R Harris
On Feb 8, 2008 5:29 AM, Francesc Altet [EMAIL PROTECTED] wrote:

 Hi,

 I'm a bit confused that the sort method of a string character doesn't
 allow a mergesort:

  s = numpy.empty(10, S10)
  s.sort(kind=merge)
 TypeError: desired sort not supported for this type


I think it's an error parsing the keyword. In fact, I thought I fixed that,
but maybe I was waiting till I added the other methods.


 However, by looking at the numpy sources, it seems that the only
 implemented method for sorting array strings is merge (I presume
 because it is stable).  So, perhaps the message above should be fixed.

 Also, in the context of my work in indexing, and because of the slowness
 of the current implementation in NumPy, I've ended with an
 implementation of the quicksort method for 1-D array strings.  For
 moderately large arrays, it is about 2.5x-3x faster than the
 (supposedly) mergesort version in NumPy, not only due to the quicksort,
 but also because I've implemented a couple of macros for efficient
 string swapping and copy.  If this is of interest for NumPy developers,
 tell me and I will provide the code.


I have some code for this too and was going to merge it. Send yours along
and I'll get to it this weekend.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy-discussion Digest, Vol 17, Issue 15

2008-02-08 Thread matthew yeomans
Thanks I been trying to compile a code that uses random,pylab and numpy with
py2exe
the code of setup.py(compiles mycode.py into mycode.exe) follows

#Start here
from distutils.core import setup
import py2exe
import pylab
import numpy
import glob
import scipy
import random
import os

setup( console=['mycode.py'],options={'py2exe':
{skip_archive:1,'packages':['matplotlib','pytz']',}},data_files=[
matplotlib.get_py2exe_datafiles()])

#End here

It works well for codes that uses pylab only. But It i add more modules i
get trouble

Is there any good books on how to use py2exe?
On 2/7/08, [EMAIL PROTECTED] 
[EMAIL PROTECTED] wrote:

 Send Numpy-discussion mailing list submissions to
numpy-discussion@scipy.org

 To subscribe or unsubscribe via the World Wide Web, visit
http://projects.scipy.org/mailman/listinfo/numpy-discussion
 or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]

 You can reach the person managing the list at
[EMAIL PROTECTED]

 When replying, please edit your Subject line so it is more specific
 than Re: Contents of Numpy-discussion digest...


 Today's Topics:

   1. f2py compiled module not found by python (Chris)
   2. Re: f2py compiled module not found by python (Pearu Peterson)
   3. Re: Bug in numpy all() function (Robert Kern)
   4. Re: f2py compiled module not found by python (Chris)
   5. Re: random enhancement (Robert Kern)
   6. Re: Bug in numpy all() function (Anne Archibald)
   7. Re: Bug in numpy all() function (Robert Kern)
   8. Re: Numpy-discussion Digest, Vol 17, Issue 13 (Steven H. Rogers)
   9. isn't it a bug? (matrix multiplication) (dmitrey)
 10. Re: isn't it a bug? (matrix multiplication) (Alan G Isaac)


 --

 Message: 1
 Date: Wed, 6 Feb 2008 18:35:35 + (UTC)
 From: Chris [EMAIL PROTECTED]
 Subject: [Numpy-discussion] f2py compiled module not found by python
 To: numpy-discussion@scipy.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=utf-8

 Hello,

 I'm trying to build a package on Linux (Ubuntu) that contains a fortran
 module, built using f2py. However, despite the module building and
 installing without error, python cannot seem to see it (see log below).
 This works fine on Windows and Mac; the problem only seems to
 happen on Linux:

 In [1]: import PyMC
 ---
 exceptions.ImportError   Traceback (most
 recent call last)

 /home/tianhuil/?ipython console

 /usr/lib/python2.4/site-packages/PyMC/__init__.py

 /home/tianhuil/?string

 /usr/lib/python2.4/site-packages/PyMC/MCMC.py

 ImportError: No module named flib
 /usr/lib/python2.4/site-packages/PyMC/MCMC.py

 Notice that the module exists in the site-packages
 directory:

 tianhuil at tianhuil:/usr/lib/python2.4/site-packages/PyMC$ ll
 total 432
 drwxr-xr-x 2 root root   4096 2008-02-03 17:24 Backends
 -rwxrwx--- 1 root root 195890 2008-02-03 17:24 flib.so
 -rwxrwx--- 1 root root259 2008-02-03 17:14 __init__.py
 -rw-r--r-- 1 root root473 2008-02-03 17:24 __init__.pyc
 -rwxrwx--- 1 root root  10250 2008-02-03 17:14 Matplot.py
 -rw-r--r-- 1 root root   7516 2008-02-03 17:24 Matplot.pyc
 -rwxrwx--- 1 root root  98274 2008-02-03 17:14 MCMC.py
 -rw-r--r-- 1 root root  79039 2008-02-03 17:24 MCMC.pyc
 drwxr-xr-x 2 root root   4096 2008-02-03 17:24 Tests
 -rwxrwx--- 1 root root   6631 2008-02-03 17:14 TimeSeries.py
 -rw-r--r-- 1 root root   5043 2008-02-03 17:24 TimeSeries.pyc



 --

 Message: 2
 Date: Wed, 6 Feb 2008 20:58:07 +0200 (EET)
 From: Pearu Peterson [EMAIL PROTECTED]
 Subject: Re: [Numpy-discussion] f2py compiled module not found by
python
 To: Discussion of Numerical Python numpy-discussion@scipy.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain;charset=iso-8859-1

 On Wed, February 6, 2008 8:35 pm, Chris wrote:
  Hello,
 
  I'm trying to build a package on Linux (Ubuntu) that contains a fortran
  module, built using f2py. However, despite the module building and
  installing without error, python cannot seem to see it (see log below).
  This works fine on Windows and Mac; the problem only seems to
  happen on Linux:

 Can you import flib module directly? That is, what happens if you
 execute
 cd .../PyMC
 PYTHONPATH=. python -c 'import flib'
 ?
 Pearu




 --

 Message: 3
 Date: Wed, 06 Feb 2008 14:03:20 -0600
 From: Robert Kern [EMAIL PROTECTED]
 Subject: Re: [Numpy-discussion] Bug in numpy all() function
 To: Discussion of Numerical Python numpy-discussion@scipy.org
 Message-ID: [EMAIL PROTECTED]
 Content-Type: text/plain; charset=UTF-8; format=flowed

 Dan Goodman wrote:
  Hi all,
 
  I think this is a bug (I'm running Numpy 1.0.3.1):
 
  from numpy import *
  def f(x): return False
 
  all(f(x) for x in range(10))
  True
 
  I guess the all function doesn't know about generators?

 Yup. It works on 

[Numpy-discussion] CVXOPT and OpenOffice

2008-02-08 Thread Guilherme Flach
Hi, I'm trying to use the CVXOPT extension for OpenOffice under
Windows, but I got this error: CVXOPT might not be installed. On the
CVXOPT plugin for OpenOffice.org Users's Guide I have seen the
warning The installation of CVXOPT must be in a location known to the
OpenOffice.org spreadsheet. On a Linux system this corresponds to a
regular system-wide installation. For other platforms installation
may vary.

So what is the right location to install CVXOPT on Windows in order to
make OpenOffice found it?

Thanks in advance.

Guilherme Flach
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] David's build_with_scons branch merged!

2008-02-08 Thread David Huard
Jarrod and David,

I am reporting a success on FC8, Xeon. Some tests don't pass, but I don't
believe it is related to the build process.

Well done,

David

2008/2/8, Jarrod Millman [EMAIL PROTECTED]:

 Hello,

 In preparation for the upcoming NumPy 1.0.5 release, I just merged
 David Cournapeau's build_with_scons branch:
 http://projects.scipy.org/scipy/numpy/changeset/4773

 The current build system using numpy.distutils is still the default.
 NumPy does not include numscons; this merge adds scons support to
 numpy.distutils, provides some scons scripts, and modifies the
 configuration of numpy/core.  David has extensively tested these
 changes and I did a very quick sanity check to make sure I didn't
 completely break everything.

 Obviously, we will need to push back the 1.0.5 release date again to
 ensure that there is sufficient testing.  So please test these changes
 and let us know if you have any problems (or successes).

 David has been putting in a considerable effort over the last several
 months in developing numscons.  If you are interested in the
 advantages to Davids approach, please read the description here:
 http://projects.scipy.org/scipy/numpy/wiki/NumpyScons

 Thanks,

 --
 Jarrod Millman
 Computational Infrastructure for Research Labs
 10 Giannini Hall, UC Berkeley
 phone: 510.643.4014
 http://cirl.berkeley.edu/
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] String sort

2008-02-08 Thread Francesc Altet
A Friday 08 February 2008, Charles R Harris escrigué:
  Also, in the context of my work in indexing, and because of the
  slowness of the current implementation in NumPy, I've ended with an
  implementation of the quicksort method for 1-D array strings.  For
  moderately large arrays, it is about 2.5x-3x faster than the
  (supposedly) mergesort version in NumPy, not only due to the
  quicksort, but also because I've implemented a couple of macros for
  efficient string swapping and copy.  If this is of interest for
  NumPy developers, tell me and I will provide the code.

 I have some code for this too and was going to merge it. Send yours
 along and I'll get to it this weekend.

Ok, great.  I'm attaching it.  Tell me if you need some clarification on 
the code.

Cheers,

-- 
0,0   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 -
/* This is a quick sort implementation for numpy strings, mainly for
   testing purposes, but could be useful in the future.  It happens to
   be between 2.5x and 3x (for long enough arrays) than the string
   sort in NumPy (based in merge sort).

   Francesc Altet 2008-02-07
 */

#define sSWAP(a,b) {		\
for (i=0; iss; i++) {	\
  ((char *)SWAP_temp)[i] = ((char *)(b))[i];		\
  ((char *)b)[i] = ((char *)(a))[i];			\
  ((char *)a)[i] = ((char *)(SWAP_temp))[i];		\
}\
  }


#define opt_memcpy(a,b,n) {\
for (i=0; i(n); i++) {\
  ((char *)a)[i] = ((char *)(b))[i];		\
}			\
  }


/* opt_strncmp is an optimized version of strncmp, mainly for easy the
   inlining by the compiler.  I'm not sure whether the inline would
   create problems with other compilers than GCC, but it can safely
   removed and let the compiler decide if it should do the inlining or
   not.  In any case, the inlining can improve the global performance
   by a 20% or more.

   This is only valid for regular strings, but adding support for UCS4
   should be a matter of replacing 'char' by 'PyArray_UCS4', I think.
 */
static inline int opt_strncmp(char *a, char *b, int n) {
  int i;
  for (i=0; in; i++) {
if (a[i]  b[i]) return i;
if (a[i]  b[i]) return -i;
  }
  return 0;
}


/* start: the address where the data for 1-D string array starts
   ss: the size of the string elements.
   num: the number of elements
  */
int quicksort_string(char *start, int ss, intp num)
{
  char *pl = start;
  char *pr = start + (num - 1) * ss;
  char *vp;
  char *SWAP_temp;
  char *stack[PYA_QS_STACK], **sptr = stack;
  char *pm, *pi, *pj, *pt;
  int i;

  vp = malloc(ss);
  SWAP_temp = malloc(ss);
  for(;;) {
while (((pr - pl)/ss)  SMALL_QUICKSORT) {
  /* quicksort partition */
  pm = pl + (((pr-pl)/ss)  1)*ss;
  if (opt_strncmp(pm, pl, ss)  0) { sSWAP(pm, pl); }
  if (opt_strncmp(pr, pm, ss)  0) { sSWAP(pr, pm); }
  if (opt_strncmp(pm, pl, ss)  0) { sSWAP(pm, pl); }
  opt_memcpy(vp, pm, ss);
  pi = pl;
  pj = pr - ss;
  sSWAP(pm, pj);
  for(;;) {
	do { pi += ss; } while (opt_strncmp(pi, vp, ss)  0);
	do { pj -= ss; } while (opt_strncmp(vp, pj, ss)  0);
	if (pi = pj)  break;
	sSWAP(pi, pj);
  }
  sSWAP(pi, pr-ss);
  /* push largest partition on stack */
  if (pi - pl  pr - pi) {
	*sptr++ = pi + ss;
	*sptr++ = pr;
	pr = pi - ss;
  }else{
	*sptr++ = pl;
	*sptr++ = pi - ss;
	pl = pi + ss;
  }
}
/* insertion sort */
for(pi = pl + ss; pi = pr;	pi += ss) {
  opt_memcpy(vp, pi, ss);
  for(pj = pi, pt = pi - ss; pj  pl  opt_strncmp(vp, pt, ss)  0;) {
	opt_memcpy(pj, pt, ss);
	pj -= ss; pt -= ss;
  }
  opt_memcpy(pj, vp, ss);
}
if (sptr == stack) break;
pr = *(--sptr);
pl = *(--sptr);
  }

  free(vp);
  free(SWAP_temp);

  return 0;
}


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] bayPIGgies meets Thursday, 2/21: Guido van Rossum on Python 3.0

2008-02-08 Thread jim stockford

* SPECIAL NOTE: because Valentine's Day is on the second
* Thursday of February (2/14) bayPIGgies has moved our
* meeting to the third Thursday of the month, 2/21.


bayPIGgies meeting Thursday 2/21:

Guido van Rossum on Python 3.0
by Guido van Rossum

Guido previews his keynote about Python 3000 at PyCon next
month. Hear all about what Python 3000 means for your code,
what tools will be available to help you in the transition,
and how to be prepared for the next millennium.


Location: Google Campus in Mountain View, CA
Building 40, the Kiev room (first floor)

bayPIGgies meeting information:
http://baypiggies.net/new/plone

* Please sign up in advance to have your google access
badge ready:
http://wiki.python.org/moin/BayPiggiesGoogleMeetings
(no later than close of business on Wednesday.)


Agenda-

. 7:30 PM ...
General hubbub, inventory end-of-meeting announcements,
any first-minute announcements.


. 7:35 PM to 8:45 PM 

The Talk (may extend a bit late)


. 8:45 PM to 9:00 PM or After The Talk 
Mapping and Random Access

Mapping is a rapid-fire audience announcement of topics the
announcers are interested in.

Random Access follows immediately to allow follow up individually
on the announcements and other topics of interest.


. The March Meeting  
TBD

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy-discussion Digest, Vol 17, Issue 15

2008-02-08 Thread Robert Kern
Matthew, please do not reply to the digests. Think of them as read-only. If you 
want to start a new thread, send your mail, with a descriptive Subject line, to 
numpy-discussion@scipy.org . If you want to reply to individual messages, 
please 
turn digest delivery *off* and receive and respond to messages normally.

Thank you.

-- 
Robert Kern

I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth.
   -- Umberto Eco
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] String sort

2008-02-08 Thread Francesc Altet
A Friday 08 February 2008, Francesc Altet escrigué:
 A Friday 08 February 2008, Charles R Harris escrigué:
   Also, in the context of my work in indexing, and because of the
   slowness of the current implementation in NumPy, I've ended with
   an implementation of the quicksort method for 1-D array strings. 
   For moderately large arrays, it is about 2.5x-3x faster than the
   (supposedly) mergesort version in NumPy, not only due to the
   quicksort, but also because I've implemented a couple of macros
   for efficient string swapping and copy.  If this is of interest
   for NumPy developers, tell me and I will provide the code.
 
  I have some code for this too and was going to merge it. Send yours
  along and I'll get to it this weekend.

 Ok, great.  I'm attaching it.  Tell me if you need some clarification
 on the code.

Ops.  I've introduced a last-minute problem in my code.  To fix this, 
just replace the flawed opt_strncmp() that I sent before by:

static int inline opt_strncmp(char *a, char *b, int n) {
  int i;
  for (i=0; in; i++) {
if (a[i]  b[i]) return i+1;
if (a[i]  b[i]) return -(i+1);
/* Another way, but seems equivalent in speed, at least here */
/* if (a[i] != b[i]) */
/*   return (((unsigned char *)a)[i] - ((unsigned char *)b)[i]); */
  }
  return 0;
}

Apparently, this version works just fine.

Cheers,

-- 
0,0   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 -
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] PySequence_GetItem on numpy array doesn't inc refcount?

2008-02-08 Thread Neal Becker
Neal Becker wrote:

 It seems that calling PySequence_GetItem on a PyArrayObject does not inc
 refcount on the original object?  That is surprising.  Then, I suppose my
 code is supposed to do that itself?

Not sure what I was doing wrong before, but seems to be working as expected
now, sorry for the noise.

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] String sort

2008-02-08 Thread Charles R Harris
On Feb 8, 2008 8:58 AM, Francesc Altet [EMAIL PROTECTED] wrote:

 A Friday 08 February 2008, Charles R Harris escrigué:
   Also, in the context of my work in indexing, and because of the
   slowness of the current implementation in NumPy, I've ended with an
   implementation of the quicksort method for 1-D array strings.  For
   moderately large arrays, it is about 2.5x-3x faster than the
   (supposedly) mergesort version in NumPy, not only due to the
   quicksort, but also because I've implemented a couple of macros for
   efficient string swapping and copy.  If this is of interest for
   NumPy developers, tell me and I will provide the code.
 
  I have some code for this too and was going to merge it. Send yours
  along and I'll get to it this weekend.

 Ok, great.  I'm attaching it.  Tell me if you need some clarification on
 the code.


I ran a few timing tests. On my machine strncmp is about 100x faster than
opt_strncmp, but  sSWAP (with some fixes), is about 10x faster then using
the memcpy in a recent compiler. Does this match with your experience.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] String sort

2008-02-08 Thread Charles R Harris
On Feb 8, 2008 10:31 AM, Francesc Altet [EMAIL PROTECTED] wrote:

 A Friday 08 February 2008, Francesc Altet escrigué:
  A Friday 08 February 2008, Charles R Harris escrigué:
Also, in the context of my work in indexing, and because of the
slowness of the current implementation in NumPy, I've ended with
an implementation of the quicksort method for 1-D array strings.
For moderately large arrays, it is about 2.5x-3x faster than the
(supposedly) mergesort version in NumPy, not only due to the
quicksort, but also because I've implemented a couple of macros
for efficient string swapping and copy.  If this is of interest
for NumPy developers, tell me and I will provide the code.
  
   I have some code for this too and was going to merge it. Send yours
   along and I'll get to it this weekend.
 
  Ok, great.  I'm attaching it.  Tell me if you need some clarification
  on the code.

 Ops.  I've introduced a last-minute problem in my code.  To fix this,
 just replace the flawed opt_strncmp() that I sent before by:

 static int inline opt_strncmp(char *a, char *b, int n) {
  int i;
  for (i=0; in; i++) {
if (a[i]  b[i]) return i+1;
if (a[i]  b[i]) return -(i+1);
/* Another way, but seems equivalent in speed, at least here */
 /* if (a[i] != b[i]) */
 /*   return (((unsigned char *)a)[i] - ((unsigned char *)b)[i]); */
  }
  return 0;
 }

 Apparently, this version works just fine.


Did you find this significantly faster than strncmp? There is also a unicode
compare, do you have thoughts about that?

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] segfault problem with numpy and pickle

2008-02-08 Thread David Bolme
I have added a valgrind report to bug 551.  The report indicates a  
problem with uninitialized values.

The segfault does seem to be related to certain configurations of  
atlas.   I can confirm that I had this same problem occurs with the  
Ubuntu 7.04 installed scipy with SSE2 optimized ATLAS.  The valgrind  
output is from a run where the code did not crash but valgrind still  
detected many errors.

On Jan 26, 2008, at 3:01 PM, David Bolme wrote:

 I think you are right.  This does seem to be the same bug as 551.  I
 will try a non optimized ATLAS to see if that helps.
 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] PySequence_GetItem on numpy array doesn't inc refcount?

2008-02-08 Thread Neal Becker
It seems that calling PySequence_GetItem on a PyArrayObject does not inc
refcount on the original object?  That is surprising.  Then, I suppose my
code is supposed to do that itself?

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] String sort

2008-02-08 Thread Francesc Altet
Hi,

I'm a bit confused that the sort method of a string character doesn't 
allow a mergesort:

 s = numpy.empty(10, S10)
 s.sort(kind=merge)
TypeError: desired sort not supported for this type

However, by looking at the numpy sources, it seems that the only 
implemented method for sorting array strings is merge (I presume 
because it is stable).  So, perhaps the message above should be fixed.

Also, in the context of my work in indexing, and because of the slowness 
of the current implementation in NumPy, I've ended with an 
implementation of the quicksort method for 1-D array strings.  For 
moderately large arrays, it is about 2.5x-3x faster than the 
(supposedly) mergesort version in NumPy, not only due to the quicksort, 
but also because I've implemented a couple of macros for efficient 
string swapping and copy.  If this is of interest for NumPy developers, 
tell me and I will provide the code.

Cheers,

-- 
0,0   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data
 -
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] svn 4777 distutils fails to find Intel MKL

2008-02-08 Thread rex
This is the 3rd time I have reported this problem and a fix.

-rex
- Forwarded message from rex [EMAIL PROTECTED] -

Date: Fri, 9 Nov 2007 11:16:17 -0800
From: rex [EMAIL PROTECTED]
To: Discussion of Numerical Python numpy-discussion@scipy.org
Subject: NumPy 1.04, MKL 10.0,  Intel 10.1 icc  ifort
Message-ID: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Disposition: inline
Status: RO
Content-Length: 4571
Lines: 126

Build was successful after a change in distutils. 

Core 2 Duo, Debian Etch-32, Python 2.5, icc 10.1, ifort 10.1,  mkl
10.0. MKL  the compilers were installed to their default
locations: /opt/intel/mkl/, /opt/intel/cc/, /opt/intel/fc/
Installation will not interfere with earlier versions.


NumPy site.cfg for MKL 10.0
==
[DEFAULT]
library_dirs=/opt/intel/mkl/10.0.011/lib/32
include_dirs=/opt/intel/mkl/10.0.011/include

[mkl]
libraries=mkl,guide

[lapack_info]
libraries=mkl_lapack,mkl,guide
==


Changes in distutils:
=
In MKL 9.1  10.0, mkl_lapack32  mkl_lapack64 no longer
exist. They were replaced by /32/mkl_lapack and
/64/mkl_lapack. As a result,
numpy-1.04/numpy/distutils/system_info.py 
needs to be changed:

#lapack_libs = self.get_libs('lapack_libs',['mkl_lapack32','mkl_lapack64'])
lapack_libs = self.get_libs('lapack_libs',['mkl_lapack'])

If the above change is not made numpy builds, but without using MKL.

In numpy-1.04/numpy/distutils/ccompiler.py change:
#cc_exe = 'icc'#works, but is suboptimal
cc_exe = 'icc -msse3 -fast'#adjust to suit your cpu
=

Running the command below (all one line) from the numpy-1.04 directory
python setup.py config --compiler=intel build_clib
  --compiler=intel build_ext --compiler=intel install
   inst.log

Gave this inst.log:
=
F2PY Version 2_4412
blas_opt_info:
blas_mkl_info:
  FOUND:
libraries = ['mkl', 'pthread', 'mkl', 'guide']
library_dirs = ['/opt/intel/mkl/10.0.011/lib/32']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.011/include']

  FOUND:
libraries = ['mkl', 'pthread', 'mkl', 'guide']
library_dirs = ['/opt/intel/mkl/10.0.011/lib/32']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.011/include']

lapack_opt_info:
lapack_mkl_info:
mkl_info:
  FOUND:
libraries = ['mkl', 'pthread', 'mkl', 'guide']
library_dirs = ['/opt/intel/mkl/10.0.011/lib/32']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.011/include']

  FOUND:
libraries = ['mkl_lapack', 'mkl', 'pthread', 'mkl', 'guide', 'mkl', 
'guide']
library_dirs = ['/opt/intel/mkl/10.0.011/lib/32']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.011/include']

  FOUND:
libraries = ['mkl_lapack', 'mkl', 'pthread', 'mkl', 'guide', 'mkl', 
'guide']
library_dirs = ['/opt/intel/mkl/10.0.011/lib/32']
define_macros = [('SCIPY_MKL_H', None)]
include_dirs = ['/opt/intel/mkl/10.0.011/include']

running config
running build_clib
running build_ext
running build_src
building py_modules sources
creating build

[...]
===

For reference, here are the respective lib/32 files for MKL 9.1
and 10.0:

c2d0:/opt/intel/mkl/9.1/lib/32# ls
libguide.a libmkl_gfortran.a libmkl_ias.so
libmkl_p3.so   libmkl_p4.so  libmkl_vml_def.so
libmkl_vml_p4p.so  libguide.so   libmkl_gfortran.so
libmkl_lapack.alibmkl_p4m.so libmkl.so
libmkl_vml_p3.so   libmkl_vml_p4.so  libmkl_def.so
libmkl_ia32.a  libmkl_lapack.so  libmkl_p4p.so
libmkl_solver.alibmkl_vml_p4m.so libvml.so


c2d0:/opt/intel/mkl/10.0.011/lib/32# ls
libguide.a libmkl_cdft_core.alibmkl_intel.a
libmkl_p4.so   libmkl_vml_ia.so  libguide.so
libmkl_core.a  libmkl_intel.so   libmkl_scalapack.a
libmkl_vml_p3.so   libiomp5.alibmkl_core.so
libmkl_intel_thread.a  libmkl_scalapack_core.a  libmkl_vml_p4m2.so
libiomp5.solibmkl_def.so libmkl_intel_thread.so
libmkl_sequential.alibmkl_vml_p4m.s olibmkl_blacs.a
libmkl_gf.alibmkl_lapack.a   libmkl_sequential.so
libmkl_vml_p4p.so  libmkl_blacs_intelmpi20.a  libmkl_gf.so
libmkl_lapack.so   libmkl.so libmkl_vml_p4.so
libmkl_blacs_intelmpi.alibmkl_gnu_thread.a   libmkl_p3.so
libmkl_solver.alibmkl_blacs_openmpi.a  libmkl_gnu_thread.so
libmkl_p4m.so  libmkl_solver_sequential.a libmkl_cdft.a
libmkl_ia32.a  libmkl_p4p.so libmkl_vml_def.so



Re: [Numpy-discussion] py2exe issues (was Numpy-discussion Digest, Vol 17, Issue 15)

2008-02-08 Thread Steven H. Rogers
matthew yeomans wrote:
 Thanks I been trying to compile a code that uses random,pylab and 
 numpy with py2exe
 the code of setup.py(compiles mycode.py into mycode.exe) follows
  
 #Start here
 from distutils.core import setup
 import py2exe
 import pylab
 import numpy
 import glob
 import scipy
 import random
 import os
  
 setup( console=['mycode.py'],options={'py2exe': 
 {skip_archive:1,'packages':['matplotlib','pytz']',}},data_files=[matplotlib.get_py2exe_datafiles()])
  
 #End here

 It works well for codes that uses pylab only. But It i add more 
 modules i get trouble
  
 Is there any good books on how to use py2exe?

Matthew:

I've only used py2exe with a couple of imports (numpy and os).  You're 
importing an awful lot.  Slimming this down to only import the things 
you really need from each module may help, e.g.

from numpy import foo
from random import bar
etc.

# Steve


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] svn 4777 fails to build with icc

2008-02-08 Thread rex
After doing the necessary fix for distutils, svn4774 builds with
gcc, but trying to build with icc with:

python setup.py config --compiler=intel build_clib --compiler=intel build_ext 
--compiler=intel install  inst.log

fails with: 

Running from numpy source directory.
/usr/local/src/numpy4777/numpy/distutils/system_info.py:1341: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
/usr/local/src/numpy4777/numpy/distutils/system_info.py:1350: UserWarning:
Blas (http://www.netlib.org/blas/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [blas]) or by setting
the BLAS environment variable.
  warnings.warn(BlasNotFoundError.__doc__)
/usr/local/src/numpy4777/numpy/distutils/system_info.py:1353: UserWarning:
Blas (http://www.netlib.org/blas/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [blas_src]) or by setting
the BLAS_SRC environment variable.
  warnings.warn(BlasSrcNotFoundError.__doc__)
/usr/local/src/numpy4777/numpy/distutils/system_info.py:1248: UserWarning:
Atlas (http://math-atlas.sourceforge.net/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [atlas]) or by setting
the ATLAS environment variable.
  warnings.warn(AtlasNotFoundError.__doc__)
/usr/local/src/numpy4777/numpy/distutils/system_info.py:1259: UserWarning:
Lapack (http://www.netlib.org/lapack/) libraries not found.
Directories to search for the libraries can be specified in the
numpy/distutils/site.cfg file (section [lapack]) or by setting
the LAPACK environment variable.
  warnings.warn(LapackNotFoundError.__doc__)
/usr/local/src/numpy4777/numpy/distutils/system_info.py:1262: UserWarning:
Lapack (http://www.netlib.org/lapack/) sources not found.
Directories to search for the sources can be specified in the
numpy/distutils/site.cfg file (section [lapack_src]) or by setting
the LAPACK_SRC environment variable.
  warnings.warn(LapackSrcNotFoundError.__doc__)

site.cfg is:

[DEFAULT]
library_dirs=/opt/intel/mkl/10.0.1.014/lib/32
include_dirs=/opt/intel/mkl/10.0.1.014/include

[mkl]
library_dirs = /opt/intel/mkl/10.0.1.014/lib/32/
lapack_libs = mkl_lapack

[lapack_src]
libraries=mkl_lapack,mkl,guide

OS is Debian Etch 4.0

I've built hundreds of programs from source over the years,
including many versions of Numpy and Scipy. NOTHING has ever been
as frustrating as these two. I often spend days trying to
build a new release. Sometimes it works. More often, it does not,
especially Scipy. I even switched from SUSE to Debian in the hope
that it would help. It did not.

I suggest that efforts to produce a product that ordinary 150
IQ mortals can install rather than add new features would grow the
user population faster. For example, distutils has been broken for
months for Intel MKL. I've posted 3x about it now.

-rex
-- 
I pray for a soroban.



___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion