Re: [Numpy-discussion] ndimage.label - howto force SWIG to use int32 - even on 64bit Linux ?

2010-04-28 Thread Bill Spotz
Both types of typemaps are enabled, so you just need to do you %apply directives correctly: %apply (npy_intp* IN_ARRAY1, int DIM1) {(npy_intp* seq, int n)}; etc SWIG should be able to figure it out from there. On Apr 28, 2010, at 12:58 PM, Charles R Harris wrote: > On Tue, Apr 27, 2

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread David Warde-Farley
On 2010-04-28, at 2:30 PM, Alan G Isaac wrote: > Please let us not have this discussion all over again. Agreed. See my preface to this discussion. My main objection is that it's not easy to explain to a newcomer what the difference precisely is, how they interact, why two of them exist, how the

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Skipper Seabold
On Wed, Apr 28, 2010 at 2:12 PM, Alan G Isaac wrote: > On 4/28/2010 12:05 PM, Travis Oliphant wrote: >> A proposal was made to allow "calling a NumPy array" to infer dot >> product: >> >> a(b) is equivalent to dot(a,b) >> >> a(b)(c) would be equivalent to dot(dot(a,b),c) > > > Here is a related ti

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Robert Kern
On Wed, Apr 28, 2010 at 15:50, Travis Oliphant wrote: > > On Apr 28, 2010, at 11:19 AM, Robert Kern wrote: > >> On Wed, Apr 28, 2010 at 11:05, Travis Oliphant >> wrote: >>> >>> On Apr 26, 2010, at 7:19 PM, David Warde-Farley wrote: >>> Trying to debug code written by an undergrad working for

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Anne Archibald
On 28 April 2010 14:30, Alan G Isaac wrote: > On 4/28/2010 12:08 PM, Dag Sverre Seljebotn wrote: >> it would be good to deprecate the matrix class >> from NumPy > > Please let us not have this discussion all over again. I think you may be too late on this, but it's worth a try. > The matrix clas

[Numpy-discussion] Fwd: Advice for grouping recarrays

2010-04-28 Thread Tom Denniston
Someone inquired about this one today and I wanted to clarify there is now a better way to do this that I didn't know about when I posted the original: >>> ind = numpy.array([0,0,0,0,1,1,1,2,2,2,]) >>> data = numpy.arange(10) >>> borders = numpy.arange(len(ind)).compress(numpy.hstack([[1], >>> in

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Alan G Isaac
On 4/28/2010 12:08 PM, Dag Sverre Seljebotn wrote: > it would be good to deprecate the matrix class > from NumPy Please let us not have this discussion all over again. The matrix class is very useful for teaching. In economics for example, the use of matrix algebra is widespread, while algebra w

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread David Warde-Farley
josef.p...@gmail.com wrote: > On Wed, Apr 28, 2010 at 1:30 PM, David Warde-Farley > wrote: > >> On 2010-04-28, at 12:05 PM, Travis Oliphant wrote: >> >> >>> a(b) is equivalent to dot(a,b) >>> >>> a(b)(c) would be equivalent to dot(dot(a,b),c) >>> >>> This seems rather reasonable. >>>

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Travis Oliphant
On Apr 28, 2010, at 11:50 AM, Nikolaus Rath wrote: > Robert Kern writes: >>> Overloading '*' and '**' while convenient does have >>> consequences. It >>> would be nice if we could have a few more infix operators in >>> Python to >>> allow separation of element-by-element calculations and

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Travis Oliphant
On Apr 28, 2010, at 11:19 AM, Robert Kern wrote: > On Wed, Apr 28, 2010 at 11:05, Travis Oliphant > wrote: >> >> On Apr 26, 2010, at 7:19 PM, David Warde-Farley wrote: >> >>> Trying to debug code written by an undergrad working for a colleague >>> of >>> mine who ported code over from MATLAB,

Re: [Numpy-discussion] Recommended way to add Cython extension using numpy.distutils?

2010-04-28 Thread Matthew Brett
Hi, Thanks a lot for the suggestion - I appreciate it. >> Is there a recommended way to plumb Cython into the numpy build >> machinery?  Should I try and patch numpy distutils to use Cython if >> present? >> > > Here is the monkey-patch I'm using in my project: > def evil_numpy_monkey_patch(): >

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Alan G Isaac
On 4/28/2010 12:05 PM, Travis Oliphant wrote: > A proposal was made to allow "calling a NumPy array" to infer dot > product: > > a(b) is equivalent to dot(a,b) > > a(b)(c) would be equivalent to dot(dot(a,b),c) Here is a related ticket that proposes a more explicit alternative: adding a ``dot`` m

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread T J
On Mon, Apr 26, 2010 at 10:03 AM, Charles R Harris wrote: > > > On Mon, Apr 26, 2010 at 10:55 AM, Charles R Harris > wrote: >> >> Hi All, >> >> We need to make a decision for ticket #1123 regarding what nansum should >> return when all values are nan. At some earlier point it was zero, but >> cur

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread David Warde-Farley
Nikolaus Rath wrote: > Robert Kern writes: > >>> Overloading '*' and '**' while convenient does have consequences. It >>> would be nice if we could have a few more infix operators in Python to >>> allow separation of element-by-element calculations and "dot-product" >>> calculations. >>>

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread josef . pktd
On Wed, Apr 28, 2010 at 1:30 PM, David Warde-Farley wrote: > > On 2010-04-28, at 12:05 PM, Travis Oliphant wrote: > >> a(b) is equivalent to dot(a,b) >> >> a(b)(c) would be equivalent to dot(dot(a,b),c) >> >> This seems rather reasonable. > > Indeed, and it leads to a rather pleasant way of permut

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread David Warde-Farley
On 2010-04-28, at 12:05 PM, Travis Oliphant wrote: > a(b) is equivalent to dot(a,b) > > a(b)(c) would be equivalent to dot(dot(a,b),c) > > This seems rather reasonable. Indeed, and it leads to a rather pleasant way of permuting syntax to change the order of operations, i.e. a(b(c)) vs. a(b)(c

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Nikolaus Rath
Robert Kern writes: >> Overloading '*' and '**' while convenient does have consequences.   It >> would be nice if we could have a few more infix operators in Python to >> allow separation of  element-by-element calculations and "dot-product" >> calculations. http://www.python.org/dev/peps/pep-022

Re: [Numpy-discussion] Recommended way to add Cython extension using numpy.distutils?

2010-04-28 Thread Kevin Jacobs
On Tue, Apr 27, 2010 at 8:09 PM, Matthew Brett wrote: > Hi, > > We (neuroimaging.scipy.org) are using numpy.distutils, and we have > .pyx files that we build with Cython. > > I wanted to add these in our current setup.py scripts, with something like: > > def configuration(parent_package='',top_pat

Re: [Numpy-discussion] Incomplete uninstall of 1.4.0 superpack

2010-04-28 Thread threexk threexk
David wrote: > On 04/27/2010 01:08 AM, threexk threexk wrote: > > David Cournapeau wrote: > > > On Mon, Apr 26, 2010 at 2:42 AM, threexk threexk > > wrote: > > > > Hello, > > > > > > > > I recently uninstalled the NumPy 1.4.0 superpack for Python 2.6 on > > Windows > > > > 7, and afterward a

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Charles R Harris
On Wed, Apr 28, 2010 at 10:05 AM, Travis Oliphant wrote: > > On Apr 26, 2010, at 7:19 PM, David Warde-Farley wrote: > > > Trying to debug code written by an undergrad working for a colleague > > of > > mine who ported code over from MATLAB, I am seeing an ugly melange of > > matrix objects and nda

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Charles R Harris
On Wed, Apr 28, 2010 at 10:08 AM, Dag Sverre Seljebotn < da...@student.matnat.uio.no> wrote: > David Warde-Farley wrote: > > Trying to debug code written by an undergrad working for a colleague of > > mine who ported code over from MATLAB, I am seeing an ugly melange of > > matrix objects and ndar

Re: [Numpy-discussion] floats as axis

2010-04-28 Thread Charles R Harris
On Wed, Apr 28, 2010 at 8:44 AM, Travis Oliphant wrote: > > On Apr 25, 2010, at 8:16 AM, josef.p...@gmail.com wrote: > > > (some) numpy functions take floats as valid axis argument. Is this a > > feature? > > > np.ones((2,3)).sum(1.2) > > array([ 3., 3.]) > np.ones((2,3)).sum(1.99) > >

Re: [Numpy-discussion] ndimage.label - howto force SWIG to use int32 - even on 64bit Linux ?

2010-04-28 Thread Charles R Harris
On Tue, Apr 27, 2010 at 2:27 AM, Sebastian Haase wrote: > Hi, > I wanted to write some C code to accept labels as they come from > ndimage.label. > For some reason ndimage.label produces its output as an int32 array - > even on my 64bit system . > > BTW, could this be considered a bug ? > > Likely

Re: [Numpy-discussion] Recommended way to add Cython extension using numpy.distutils?

2010-04-28 Thread Charles R Harris
On Tue, Apr 27, 2010 at 6:09 PM, Matthew Brett wrote: > Hi, > > We (neuroimaging.scipy.org) are using numpy.distutils, and we have > .pyx files that we build with Cython. > > I wanted to add these in our current setup.py scripts, with something like: > > def configuration(parent_package='',top_pat

Re: [Numpy-discussion] Speeding up loadtxt / savetxt

2010-04-28 Thread Chris Barker
Andreas Hilboll wrote: > Yes, I know. But the files I create must be readable by an application > developed in-house at our institude, and that only supports a) ASCII files > or b) some home-grown binary format, which I hate. > >> Also, an efficient reader for very simply formatted text is provide

[Numpy-discussion] Bug in MaskedArray min/max functions

2010-04-28 Thread Philip Cooper
if a masked array is created and has no masked values it can have a mask of just "False" scalar false that is. This causes an error when getting the max or min on axis=1 I don't have a fix but do offer a workaround. If you reset the mask to the "expanded"mask all works ok (but it's a bug that p

[Numpy-discussion] SciPy 2010: Talks Announced

2010-04-28 Thread Amenity Applewhite
Email not displaying correctly? View it in your browser. Hello, As summer approaches, plans for SciPy 2010 are coming into focus! Here are a few quick updates: General conference talks announced Thanks so much to everyone who submitted an abstract. We received a number of fantastic proposa

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread Keith Goodman
On Mon, Apr 26, 2010 at 9:55 AM, Charles R Harris wrote: > Hi All, > > We need to make a decision for ticket #1123 regarding what nansum should > return when all values are nan. At some earlier point it was zero, but > currently it is nan, in fact it is nan whatever the operation is. That is > con

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread Warren Weckesser
Travis Oliphant wrote: > > On Apr 26, 2010, at 12:03 PM, Charles R Harris wrote: > >> >> >> On Mon, Apr 26, 2010 at 10:55 AM, Charles R Harris >> mailto:charlesr.har...@gmail.com>> wrote: >> >> Hi All, >> >> We need to make a decision for ticket #1123 >>

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Robert Kern
On Wed, Apr 28, 2010 at 11:05, Travis Oliphant wrote: > > On Apr 26, 2010, at 7:19 PM, David Warde-Farley wrote: > >> Trying to debug code written by an undergrad working for a colleague >> of >> mine who ported code over from MATLAB, I am seeing an ugly melange of >> matrix objects and ndarrays t

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread Travis Oliphant
On Apr 26, 2010, at 12:03 PM, Charles R Harris wrote: On Mon, Apr 26, 2010 at 10:55 AM, Charles R Harris > wrote: Hi All, We need to make a decision for ticket #1123 regarding what nansum should return when all values are nan. At some earlier point it was zero, but currently it is nan,

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Dag Sverre Seljebotn
David Warde-Farley wrote: > Trying to debug code written by an undergrad working for a colleague of > mine who ported code over from MATLAB, I am seeing an ugly melange of > matrix objects and ndarrays that are interacting poorly with each other > and various functions in SciPy/other libraries.

Re: [Numpy-discussion] Speeding up loadtxt / savetxt

2010-04-28 Thread Andreas Hilboll
Hi Stéfan, > Do you specifically need to store text files? NumPy's binary storage > functions (numpy.load and save) are faster. Yes, I know. But the files I create must be readable by an application developed in-house at our institude, and that only supports a) ASCII files or b) some home-grown

Re: [Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread Travis Oliphant
On Apr 26, 2010, at 7:19 PM, David Warde-Farley wrote: > Trying to debug code written by an undergrad working for a colleague > of > mine who ported code over from MATLAB, I am seeing an ugly melange of > matrix objects and ndarrays that are interacting poorly with each > other > and various

Re: [Numpy-discussion] floats as axis

2010-04-28 Thread Travis Oliphant
On Apr 25, 2010, at 8:16 AM, josef.p...@gmail.com wrote: > (some) numpy functions take floats as valid axis argument. Is this a > feature? > np.ones((2,3)).sum(1.2) > array([ 3., 3.]) np.ones((2,3)).sum(1.99) > array([ 3., 3.]) > np.mean((1.5,0.5)) > 1.0 np.mean(1.5,0.5) >

Re: [Numpy-discussion] Incomplete uninstall of 1.4.0 superpack

2010-04-28 Thread David
On 04/27/2010 01:08 AM, threexk threexk wrote: > David Cournapeau wrote: > > On Mon, Apr 26, 2010 at 2:42 AM, threexk threexk > wrote: > > > Hello, > > > > > > I recently uninstalled the NumPy 1.4.0 superpack for Python 2.6 on > Windows > > > 7, and afterward a dialog popped up that said 1 fi

[Numpy-discussion] ndimage.label - howto force SWIG to use int32 - even on 64bit Linux ?

2010-04-28 Thread Sebastian Haase
(2nd try to get this post into the mailing list archive...) Hi, I wanted to write some C code to accept labels as they come from ndimage.label. For some reason ndimage.label produces its output as an int32 array - even on my 64bit system . BTW, could this be considered a bug ? Now, if I use the

Re: [Numpy-discussion] passing non-flat array to interpolator

2010-04-28 Thread josef . pktd
On Mon, Apr 26, 2010 at 12:04 PM, Thomas wrote: > > > I have some problem with interpolators in Scipy > does anyone knows if there is a way to pass a non-flat > array variables to Rbf, or other Scipy interpolator > eg. for my case of 17 x 1 problems of 500 data size > > x1.shape = (500,) > x2.shap

[Numpy-discussion] Recommended way to add Cython extension using numpy.distutils?

2010-04-28 Thread Matthew Brett
Hi, We (neuroimaging.scipy.org) are using numpy.distutils, and we have .pyx files that we build with Cython. I wanted to add these in our current setup.py scripts, with something like: def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration

[Numpy-discussion] [ANN] la 0.2, the labeled array

2010-04-28 Thread Keith Goodman
I am pleased to announce the second release of the la package, version 0.2. The main class of the la package is a labeled array, larry. A larry consists of a data array and a label list. The data array is stored as a NumPy array and the label list as a list of lists. larry has built-in methods su

Re: [Numpy-discussion] ma.std(ddof=1) bug?

2010-04-28 Thread Pierre GM
On Apr 23, 2010, at 12:45 PM, josef.p...@gmail.com wrote: > Is there a reason why ma.std(ddof=1) does not calculated the std if > there are 2 valid values? Bug! Good call... Should be fixed in SVN r8370. ___ NumPy-Discussion mailing list NumPy-Discussi

Re: [Numpy-discussion] Speeding up loadtxt / savetxt

2010-04-28 Thread Stéfan van der Walt
Hi Andreas On 23 April 2010 10:16, Andreas wrote: > I was wondering if there's a way to speedup loadtxt/savetxt for big > arrays? So far, I'm plainly using something like this:: Do you specifically need to store text files? NumPy's binary storage functions (numpy.load and save) are faster. Als

[Numpy-discussion] ndimage.label - howto force SWIG to use int32 - even on 64bit Linux ?

2010-04-28 Thread Sebastian Haase
Hi, I wanted to write some C code to accept labels as they come from ndimage.label. For some reason ndimage.label produces its output as an int32 array - even on my 64bit system . BTW, could this be considered a bug ? Now, if I use the typemaps of numpy.i I can choose between NPY_LONG and NPY_INT

[Numpy-discussion] proposing a "beware of [as]matrix()" warning

2010-04-28 Thread David Warde-Farley
Trying to debug code written by an undergrad working for a colleague of mine who ported code over from MATLAB, I am seeing an ugly melange of matrix objects and ndarrays that are interacting poorly with each other and various functions in SciPy/other libraries. In particular there was a custom

Re: [Numpy-discussion] Memory profiling NumPy code?

2010-04-28 Thread Joe Kington
I know you're looking for something with much more fine-grained control, (which I can't help much with) but I often find it useful to just plot the overall memory of the program over time. There may be an slicker way to do it, but here's the script I use, anyway... (saved as ~/bin/quick_profile, u

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread Charles R Harris
On Mon, Apr 26, 2010 at 10:55 AM, Charles R Harris < charlesr.har...@gmail.com> wrote: > Hi All, > > We need to make a decision for ticket > #1123regarding what > nansum should return when all values are nan. At some earlier > point it was

[Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread Charles R Harris
Hi All, We need to make a decision for ticket #1123regarding what nansum should return when all values are nan. At some earlier point it was zero, but currently it is nan, in fact it is nan whatever the operation is. That is consistent, simpl