Re: [Numpy-discussion] [ANN] NumPy 1.0b4 now available

2006-08-28 Thread Bruce Who
Hi, Travis

I can pack my scripts into an executable with py2exe, but errors occur
once it runs:

No scipy-style subpackage 'random' found in D:\test\dist\numpy.
Ignoring: No module named info
import core -> failed: No module named _internal
import lib -> failed: 'module' object has no attribute '_ARRAY_API'
import linalg -> failed: 'module' object has no attribute '_ARRAY_API'
import dft -> failed: 'module' object has no attribute '_ARRAY_API'
Traceback (most recent call last):
  File "main.py", line 9, in ?
  File "numpy\__init__.pyc", line 49, in ?

  File "numpy\add_newdocs.pyc", line 2, in ?
gkDc
  File "numpy\lib\__init__.pyc", line 5, in ?

  File "numpy\lib\type_check.pyc", line 8, in ?

  File "numpy\core\__init__.pyc", line 6, in ?

  File "numpy\core\umath.pyc", line 12, in ?

  File "numpy\core\umath.pyc", line 10, in __load

AttributeError: 'module' object has no attribute '_ARRAY_API'


This is the main.py file:
#===
# filename:main.py
import wx
import numpy

class myFrame(wx.Frame):
def __init__(self, *args, **kwds):
wx.Frame.__init__(self, *args, **kwds)
##-- your widgets
##-- put stuff into sizer
self.sizer_ = wx.BoxSizer(wx.VERTICAL)
## self.sizer_.Add(your_ctrl, proportion = 1, flag = wx.EXPAND)

## apply sizer
self.SetSizer(self.sizer_)
self.SetAutoLayout(True)

def main():## {{{
app = wx.PySimpleApp(0)
frame = myFrame(None, -1, title = '')
frame.Show(True)
app.SetTopWindow(frame)
app.MainLoop()
##   }}}

if __name__ == "__main__":main()
#===
# filename:setup.py
import glob
import sys

from distutils.core import setup
import py2exe

includes = ["encodings",
"encodings.*",
   ]

excludes = ["javax.comm"]

options = {
"py2exe":
{
#"compressed": 1,
#"optimize": 0,
#"bundle_files":2,
"skip_archive":1,
"includes": includes,
'excludes': excludes
}
  }

setup(
version = "0.1",
description = "",
name = "test",
options = options,
windows = [
{
"script":"main.py",
}
],
#zipfile = None,
)


and I run this command to compile the scripts:
python setup.py py2exe

and all packages I use are:
python2.4.3
numpy-0.98
py2exe-0.6.5
wxpython-2.6.3.2

I unistalled Numeric before I compiled scripts.

If you google "numpy py2exe", you can find others guys stumbled by the
same issue with ease:

http://aspn.activestate.com/ASPN/Mail/Message/py2exe-users/3249182
http://www.nabble.com/matplotlib,-numpy-and-py2exe-t1901429.html

I just hope this can be fixed in the next table release of numpy.

On 8/29/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> bruce.who.hk wrote:
> > Hi, Travis
> >
> > I just wonder if NumPy 1.0b4 can get along with py2exe? Just a few weeks 
> > ago I made a application in Python. At first I used Numpy, it works OK, but 
> > I cannot pack it into a workable executable with py2exe and the XXX.log 
> > saied that numpy cannot find some module. I found some hints in py2exe 
> > wiki, but it still doesn't work. At Last I tried Numeric instead and it got 
> > OK. I just hope that you donnot stop the maintenance of Numeric before you 
> > are sure that Numpy can work with py2exe.
> >
> We've already stopped maintenance of Numeric nearly 1 year ago.If
> NumPy doesn't work with py2exe then we need help figuring out why.  The
> beta-release period is the perfect time to fix that.  I've never used
> py2exe myself, but I seem to recall that some have been able to make it
> work.
>
> The problem may just be listing the right set of modules to carry along
> because you may not be able to get that with just the Python-side
> imports.  Post any errors you receive to
> numpy-discussion@lists.sourceforge.net
>
> Thanks,
>
>
> -Travis
>
>


Bruce Who

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


Re: [Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-28 Thread Robin Dunn
Travis Oliphant wrote:
> Christopher Barker wrote:
>> HI all,
>>
>> File 
>> "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", 
>> line 2814, in SetDataBuffer
>> return _core_.Image_SetDataBuffer(*args, **kwargs)
>> TypeError: non-character array cannot be interpreted as character buffer
>>
>> If I try to pass in a numpy array, while it works great with a 
>> numarray array.
> 
> This error sounds like wx is using the *wrong* buffer protocol.  Don't 
> use bf_getcharbuffer as it is of uncertain utility.  It is slated for 
> removal from Python 3000.  It was meant to be used as a way to determine 
> buffers that were supposed to contain characters (not arbitrary data).
> 
> Just use bf_getreadbuffer and bf_getwritebuffer  from tp_as_buffer.

I'm using PyArg_Parse($input, "t#", ...) to get the buffer pointer and 
size.  Is there another format specifier to use for the buffer pointer 
using the other slots or do I need to drop down to a lower level API to 
get it?  I didn't realize there was a distinction between buffer and 
character buffer.  Another read of the PyArg_Parse docs with that new 
fact makes things a little more clear.

Looking at the code I guess "s#" will do it, I guess I thought it would 
try to coerce the object to a PyString like some other APIs do, which I 
was trying to avoid, but it doesn't appear to do that, (only encoding a 
unicode object if that is passed.)I think I'll take a shot at using 
tp_as_buffer directly to avoid any confusion in the future and avoid the 
arg parse overhead...  Any other suggestions?

BTW Chris, try using buffer(RGB) and buffer(Alpha) in your sample, I 
expect that will work with the current code.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!


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


[Numpy-discussion] A minor annoyance with MA

2006-08-28 Thread PGM
Folks, 
I keep running into the following problem since some recent update (I'm 
currently running 1.0b3, but the problem occurred roughly around 0.9.8):

>>> import numpy.core.ma as MA
>>> x=MA.array([[1],[2]],mask=False)
>>> x.sum(None)
/usr/lib64/python2.4/site-packages/numpy/core/ma.py in reduce(self, target, 
axis, dtype)
393 m.shape = (1,)
394 if m is nomask:
--> 395 return masked_array (self.f.reduce (t, axis))
396 else:
397 t = masked_array (t, m)

TypeError: an integer is required
#

Note that x.sum(0) and x.sum(1)  work fine. I know some consensus seems to be 
lacking with MA, but still, I can't see why axis=None is not recognized.

Corollary: with masked array, the default axis for sum is 0, when it's None 
for regular arrays. Is there a reason for this inconsistency ?

Thanks a lot

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


Re: [Numpy-discussion] tensor dot ?

2006-08-28 Thread Bill Baxter
On 8/29/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> Example:
>
> If a.shape is (3,4,5)
> and b.shape is (4,3,2)
>
> Then
>
> tensordot(a, b, axes=([1,0],[0,1]))
>
> returns a (5,2) array which is equivalent to the code:
>
> c = zeros((5,2))
> for i in range(5):
> for j in range(2):
> for k in range(3):
> for l in range(4):
> c[i,j] += a[k,l,i]*b[l,k,j]

That's pretty cool.
>From there it shouldn't be too hard to make a wrapper that would allow
you to write c_ji = a_kli * b_lkj  (w/sum over k and l) like:

   tensordot_ez(a,'kli', b,'lkj', out='ji')

or maybe with numexpr-like syntax:

   tensor_expr('_ji = a_kli * b_lkj')  [pulling a and b out of the
globals()/locals()]

Might be neat to be able to build a callable function for repeated reuse:

   tprod = tensor_func('_ji = [0]_kli * [1]_lkj')   # [0] and [1]
become parameters 0 and 1
   c = tprod(a, b)

or to pass the output through a (potentially reused) array argument:

   tprod1 = tensor_func('[0]_ji = [1]_kli * [2]_lkj')
   tprod1(c, a, b)

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


Re: [Numpy-discussion] tensor dot ?

2006-08-28 Thread Travis Oliphant
Simon Burton wrote:
 numpy.dot.__doc__
 
> matrixproduct(a,b)
> Returns the dot product of a and b for arrays of floating point types.
> Like the generic numpy equivalent the product sum is over
> the last dimension of a and the second-to-last dimension of b.
> NB: The first argument is not conjugated.
>
> Does numpy support summing over arbitrary dimensions,
> as in tensor calculus ?
>
> I could cook up something that uses transpose and dot, but it's
> reasonably tricky i think :)
>   

I've just added tensordot to NumPy (adapted and enhanced from 
numarray).   It allows you to sum over an arbitrary number of axes.   It 
uses a 2-d dot-product internally as that is optimized if you have a 
fast blas installed.

Example:

If a.shape is (3,4,5)
and b.shape is (4,3,2)

Then

tensordot(a, b, axes=([1,0],[0,1]))

returns a (5,2) array which is equivalent to the code:

c = zeros((5,2))
for i in range(5):
for j in range(2):
for k in range(3):
for l in range(4):
c[i,j] += a[k,l,i]*b[l,k,j]


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


Re: [Numpy-discussion] std(axis=1) memory footprint issues + moving avg / stddev

2006-08-28 Thread Torgil Svensson
> The C-code is basically a directy "translation" of the original Python
> code.
...
> If I had to do it over again, I would place the std implementation there where
> it could be appropriately optimized.

Isn't C-code a good place for optimizations?

//Torgil


On 8/27/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> Torgil Svensson wrote:
> > Hi
> >
> > ndarray.std(axis=1) seems to have memory issues on large 2D-arrays. I
> > first thought I had a performance issue but discovered that std() used
> > lots of memory and therefore caused lots of swapping.
> >
> There are certainly lots of intermediate arrays created as the
> calculation proceeds.  The calculation is not particularly "smart."  It
> just does the basic averaging and multiplication needed.
>
> > I want to get an array where element i is the stadard deviation of row
> > i in the 2D array. Using valgrind on the std() function...
> >
> > $ valgrind --tool=massif python -c "from numpy import *;
> > a=reshape(arange(10*100),(10,100)).std(axis=1)"
> >
> > ... showed me a peak of 200Mb memory while iterating line by line...
> >
> >
> The C-code is basically a directy "translation" of the original Python
> code.  There are lots of temporaries created (apparently 5 at one point
> :-).  I did this before I had the _internal.py code in place where I
> place Python functions that need to be accessed from C.  If I had to do
> it over again, I would place the std implementation there where it could
> be appropriately optimized.
>
>
>
> -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=lnk&kid=120709&bid=263057&dat=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=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] 1.0b4 problem continuted from 1.0b3

2006-08-28 Thread Torgil Svensson
This is really a matplotlib problem.

>From matplotlib users mailing-list archives:

> From: Charlie Moad <[EMAIL PROTECTED]>
> Snapshot build for use with numpy-1.0b3
> 2006-08-23 06:11
>
> Here is a snapshot of svn this morning for those wanting to work with
 the numpy beta.  Both builds are for python2.4 and windows.
>
> exe: http://tinyurl.com/gf299
> egg: http://tinyurl.com/fbjmg
>
> -Charlie

That exe-file worked for me.

//Torgil



On 8/28/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > On 8/25/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> >
> >> [EMAIL PROTECTED] wrote:
> >>
> >>> Message: 4
> >>> Date: Thu, 24 Aug 2006 14:17:44 -0600
> >>> From: Travis Oliphant <[EMAIL PROTECTED]>
> >>> Subject: Re: [Numpy-discussion] (no subject)
> >>> To: Discussion of Numerical Python
> >>> 
> >>> Message-ID: <[EMAIL PROTECTED]>
> >>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> >>>
> >>> [EMAIL PROTECTED] wrote:
> >>>
> >>>
> >>>
> >>> You have a module built against an older version of NumPy.  What modules
> >>> are being loaded?  Perhaps it is matplotlib or SciPy
> >>>
> >>>
> >> You need to re-build matplotlib.  They should be producing a binary that
> >> is compatible with 1.0b2 (I'm being careful to make sure future releases
> >> are binary compatible with 1.0b2).
> >>
> >> Also, make sure that you remove the build directory under numpy if you
> >> have previously built a version of numpy prior to 1.0b2.
> >>
>
> You have to download the SVN version of matplotlib.  The released
> version does not support 1.0b2 and above yet.
>
> -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=lnk&kid=120709&bid=263057&dat=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=lnk&kid=120709&bid=263057&dat=121642
___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-28 Thread Robert Kern
Christopher Barker wrote:

> While I'm a great advocate of the new array protocol, it seems 
> supporting the buffer protocol also would be a good idea. I've enclosed 
> some simple test code. It works with numarray, but not numpy 1.0b4

Instead of

   I.SetDataBuffer(some_array)

you can use

   I.SetDataBuffer(buffer(some_array))

and it seems to work on OS X with Python 2.4, numpy 1.0b2 and wxMac 2.6.3.3 .

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


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


Re: [Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-28 Thread Travis Oliphant
Christopher Barker wrote:
> HI all,
>
> File 
> "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", 
> line 2814, in SetDataBuffer
> return _core_.Image_SetDataBuffer(*args, **kwargs)
> TypeError: non-character array cannot be interpreted as character buffer
>
> If I try to pass in a numpy array, while it works great with a 
> numarray array.

This error sounds like wx is using the *wrong* buffer protocol.  Don't 
use bf_getcharbuffer as it is of uncertain utility.  It is slated for 
removal from Python 3000.  It was meant to be used as a way to determine 
buffers that were supposed to contain characters (not arbitrary data).

Just use bf_getreadbuffer and bf_getwritebuffer  from tp_as_buffer.

More support for the buffer protocol all the way around is a good idea. 
  NumPy has always supported it very well (just make sure to use it 
correctly).   FYI, I'm going to write a PEP to get the array protocol 
placed as an add-on to the buffer protocol for Python 2.6

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


[Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-28 Thread Christopher Barker

HI all,

Robin Dunn has been working on adding better support for dumping data 
directly to wxPython from the num* packages. I've been talking to him 
about the new array interface, and he might well support it 
(particularly if one of us contributes code), but in the meantime, he's 
got a number of things working with python buffers. For instance:


wx.Image.SetDataBuffer(dataBuffer)

That sets the data for a wxImage to the buffer handed in. This isn't as 
nice as the array protocol, as it has no way of checking anything other 
than if the length of the buffer is correct, but it is a good way to 
maximize performance for this sort of thing.


he's now working on adding methods for creating wx.Bitmaps directly from 
buffers. In the process if testing some of this, I discovered that 
numarray (which Robin is testing with) works fine, but numpy does not. I 
get:


File "/usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py", 
line 2814, in SetDataBuffer

return _core_.Image_SetDataBuffer(*args, **kwargs)
TypeError: non-character array cannot be interpreted as character buffer

If I try to pass in a numpy array, while it works great with a numarray 
array.


While I'm a great advocate of the new array protocol, it seems 
supporting the buffer protocol also would be a good idea. I've enclosed 
some simple test code. It works with numarray, but not numpy 1.0b4


Tested with Python 2.4.3, wxPython 2.6.3.0, Linux fedora core4

-Chris





--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115   (206) 526-6317   main reception

[EMAIL PROTECTED]
#!/usr/bin/env python

import wx

dim=100
R=0; G=1; B=2; A=3

import numpy as N
arr = N.empty((dim, dim, 4), N.uint8)
#import numarray as N
#arr = N.array(shape=(dim, dim, 4), typecode='u1')

arr[:,:,R] = 125
arr[:,:,G] = 0
arr[:,:,B] = 255
alpha = N.arange(dim) * 255 / dim
arr[:,:,A] = alpha


class F(wx.Frame):
def __init__(self, *args, **kwargs):
wx.Frame.__init__(self, *args, **kwargs)

self.Bind(wx.EVT_PAINT, self.OnPaint)

def OnPaint(self, event):
dc = wx.PaintDC(self)
print "Drawing the bitmap"
dc.DrawBitmap(bmp, 20, 20, True)

A = wx.App()

RGB = arr[:,:,0:3].copy()
Alpha = arr[:,:,3].copy()
I = wx.EmptyImage(dim, dim)
I.SetDataBuffer(RGB)
I.SetAlphaBuffer(Alpha)

bmp = wx.BitmapFromImage(I)

f = F(None)
f.Show()
A.MainLoop()
-
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=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] request for new array method: arr.abs()

2006-08-28 Thread Christopher Barker
Travis Oliphant wrote:
> I think I prefer to just add the float, bool, object, unicode, str names 
> to the "non-imported" numpy
> name-space.

which mean you get it with:

import numpy as N
N.float

but not with

from numpy import *

?

If that's what you mean, then I'm all for it!

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

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


Re: [Numpy-discussion] 1.0b4 problem continuted from 1.0b3

2006-08-28 Thread Travis Oliphant
[EMAIL PROTECTED] wrote:
> On 8/25/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
>   
>> [EMAIL PROTECTED] wrote:
>> 
>>> Message: 4
>>> Date: Thu, 24 Aug 2006 14:17:44 -0600
>>> From: Travis Oliphant <[EMAIL PROTECTED]>
>>> Subject: Re: [Numpy-discussion] (no subject)
>>> To: Discussion of Numerical Python
>>> 
>>> Message-ID: <[EMAIL PROTECTED]>
>>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>>
>>> [EMAIL PROTECTED] wrote:
>>>
>>>
>>>
>>> You have a module built against an older version of NumPy.  What modules
>>> are being loaded?  Perhaps it is matplotlib or SciPy
>>>
>>>   
>> You need to re-build matplotlib.  They should be producing a binary that
>> is compatible with 1.0b2 (I'm being careful to make sure future releases
>> are binary compatible with 1.0b2).
>>
>> Also, make sure that you remove the build directory under numpy if you
>> have previously built a version of numpy prior to 1.0b2.
>> 

You have to download the SVN version of matplotlib.  The released 
version does not support 1.0b2 and above yet.

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


[Numpy-discussion] 1.0b4 problem continuted from 1.0b3

2006-08-28 Thread kortmann
On 8/25/06, Travis Oliphant <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] wrote:
> > Message: 4
> > Date: Thu, 24 Aug 2006 14:17:44 -0600
> > From: Travis Oliphant <[EMAIL PROTECTED]>
> > Subject: Re: [Numpy-discussion] (no subject)
> > To: Discussion of Numerical Python
> > 
> > Message-ID: <[EMAIL PROTECTED]>
> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed
> >
> > [EMAIL PROTECTED] wrote:
> >
> >
> >
> > You have a module built against an older version of NumPy.  What modules
> > are being loaded?  Perhaps it is matplotlib or SciPy
> >
>
> You need to re-build matplotlib.  They should be producing a binary that
> is compatible with 1.0b2 (I'm being careful to make sure future releases
> are binary compatible with 1.0b2).
>
> Also, make sure that you remove the build directory under numpy if you
> have previously built a version of numpy prior to 1.0b2.
>
> -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=lnk&kid=120709&bid=263057&dat=121642
> ___
> Numpy-discussion mailing list
> Numpy-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>

Travis I have recompiled everything.  I removed sci py numpy and matplotlib.

I installed the numpy 1.0b4 win32exe, and then installed scipi 0.5 and
then the latest matplotlib 0.87.4

I recieved this error at first, which is a matplot lib error,

C:\Lameness>c:\python23\python templatewindow.py
Traceback (most recent call last):
  File "templatewindow.py", line 7, in ?
import wxmpl
  File "c:\python23\lib\site-packages\wxmpl.py", line 25, in ?
import matplotlib.numerix as Numeric
  File "C:\PYTHON23\Lib\site-packages\matplotlib\numerix\__init__.py",
line 74,
in ?
Matrix = matrix
NameError: name 'matrix' is not defined
,
and then switched matplotlib to use numeric, and i recieve this error once
again

Overwriting info= from scipy.misc.helpmod
(was  from numpy.lib.utils)
Overwriting who= from scipy.misc.common (was
 from numpy.lib.utils)
Overwriting source= from scipy.misc.helpmod
(was
 from numpy.lib.utils)
RuntimeError: module compiled against version 100 of C-API but this
version
of numpy is 102
Fatal Python error: numpy.core.multiarray failed to import... exiting.


abnormal program termination


i googled the error and also found this thread but have not found a solution

http://www.mail-archive.com/numpy-discussion@lists.sourceforge.net/msg01700.html

any help?
thanks
-Kenny


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


[Numpy-discussion] weave using numeric or numpy?

2006-08-28 Thread Carlos Pita
Hi all!I'm rewriting some swig-based extensions that implement intensive inner loops dealing with numeric/numpy arrays. The intention is to build these extensions by means of weave inline, ext_module, ext_function, etc. I'm not sure about how to point weave to my numpy instalation. By default it tries to include "Numeric/arrayobject.h" and fails if you hack things to get that resolved to numpy arrayobject.h (for example, it complaints that PyArray_SBYTE is undefined). Anyway, even if I managed myself to force weave to compile against numpy/arrayobject.h, I'd still not be sure about the "runtime" that will be chosen. I'm very confused at this point, no library flags are provided at compile/link time, so how is the runtime selected between numpy, Numeric (or even numarray)?Thank you in advance.Best regards,Carlos 
		 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
Probalo ya! -
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=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] Numeric/numpy incompatibility

2006-08-28 Thread Travis Oliphant
Andrew Straw wrote:
> The following code indicates there is a problem adding a numpy scalar
> type to a Numeric array. Is this expected behavior or is there a bug
> somewhere?
>   
There was a bug in the __array_struct__ attribute of array flags wherein 
the NOTSWAPPED flag was not being set as it should be.

This is fixed in SVN.

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


Re: [Numpy-discussion] numpy1.04b4: undefined symbol: PyUnicodeUCS2_FromUnicode. error No _WIN32

2006-08-28 Thread rex
Travis Oliphant <[EMAIL PROTECTED]> [2006-08-28 12:42]:
> rex wrote:
> > ImportError: /usr/lib/python2.4/site-packages/numpy/core/multiarray.so: 
> > undefined symbol: PyUnicodeUCS2_FromUnicode
> >
> >
> >   
> 
> This error usually means that NumPy was built and linked against a 
> Python build where unicode strings were 2-bytes per character but you 
> are trying to import it on a Python build where unicode strings are 
> 4-bytes per character.   Perhaps you have changed your build of Python 
> and did not remove the build directory of NumPy.
> 
> Try
> 
> rm -fr build
> 
> in the numpy directory (where you run setup.py) and build again.

Ah! THANK YOU! 

Python 2.4.2 (#1, May  2 2006, 08:13:46)
[GCC 4.1.0 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.test()
  Found 5 tests for numpy.distutils.misc_util
  Found 3 tests for numpy.lib.getlimits
  Found 31 tests for numpy.core.numerictypes
  Found 32 tests for numpy.linalg
  Found 13 tests for numpy.core.umath
  Found 4 tests for numpy.core.scalarmath
  Found 8 tests for numpy.lib.arraysetops
  Found 42 tests for numpy.lib.type_check
  Found 155 tests for numpy.core.multiarray
  Found 3 tests for numpy.fft.helper
  Found 36 tests for numpy.core.ma
  Found 10 tests for numpy.lib.twodim_base
  Found 10 tests for numpy.core.defmatrix
  Found 1 tests for numpy.lib.ufunclike
  Found 4 tests for numpy.ctypeslib
  Found 39 tests for numpy.lib.function_base
  Found 1 tests for numpy.lib.polynomial
  Found 8 tests for numpy.core.records
  Found 26 tests for numpy.core.numeric
  Found 4 tests for numpy.lib.index_tricks
  Found 46 tests for numpy.lib.shape_base
  Found 0 tests for __main__

--
Ran 481 tests in 1.956s

OK

Now on to doing it again with MKL...
>From the numpy directory:
rm -fr build
cp site_mkl.cfg site.cfg

where site_mkl.cfg is:
---
[DEFAULT]
library_dirs=/opt/intel/mkl/8.1/lib/32
include_dirs=/opt/intel/mkl/8.1/include

[blas_opt]
libraries=libmkl.so,libmkl_p3.so,libmkl_vml_p3.so,libmkl_ia32.a,libguide.so,libmkl_def.so
#libraries=whatever_the_mkl_blas_lib_is,mkl_ia32,mkl,guide

[lapack_opt]
libraries=libmkl_lapack32.so,libmkl_lapack.a,
#libraries=mkl_lapack,mkl_lapack32,mkl_ia32,mkl,guide
--
python setup.py install >& inst.log

Looks OK, so in another window:

python
Python 2.4.2 (#1, May  2 2006, 08:13:46)
[GCC 4.1.0 (SUSE Linux)] on linux2
>>> import numpy
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/numpy/__init__.py", line 39, in ?
import linalg
  File "/usr/lib/python2.4/site-packages/numpy/linalg/__init__.py", line 4, in ?
from linalg import *
  File "/usr/lib/python2.4/site-packages/numpy/linalg/linalg.py", line 25, in ?
from numpy.linalg import lapack_lite
ImportError: libmkl_lapack32.so: cannot open shared object file: No such file 
or directory
>>>

Oops!

^d

export INCLUDE=/opt/intel/mkl/8.1/include:$INCLUDE
export LD_LIBRARY_PATH=/opt/intel/mkl/8.1/lib/32:$LD_LIBRARY_PATH
python
Python 2.4.2 (#1, May  2 2006, 08:13:46)
[GCC 4.1.0 (SUSE Linux)] on linux2
>>> import numpy
>>> numpy.test()
  Found 5 tests for numpy.distutils.misc_util
  Found 3 tests for numpy.lib.getlimits
  Found 31 tests for numpy.core.numerictypes
  Found 32 tests for numpy.linalg
  Found 13 tests for numpy.core.umath
  Found 4 tests for numpy.core.scalarmath
  Found 8 tests for numpy.lib.arraysetops
  Found 42 tests for numpy.lib.type_check
  Found 155 tests for numpy.core.multiarray
  Found 3 tests for numpy.fft.helper
  Found 36 tests for numpy.core.ma
  Found 10 tests for numpy.lib.twodim_base
  Found 10 tests for numpy.core.defmatrix
  Found 1 tests for numpy.lib.ufunclike
  Found 4 tests for numpy.ctypeslib
  Found 39 tests for numpy.lib.function_base
  Found 1 tests for numpy.lib.polynomial
  Found 8 tests for numpy.core.records
  Found 26 tests for numpy.core.numeric
  Found 4 tests for numpy.lib.index_tricks
  Found 46 tests for numpy.lib.shape_base
  Found 0 tests for __main__

--
Ran 481 tests in 2.152s

OK

Now off to build SciPy.

Thanks again!

-rex

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


[Numpy-discussion] Numeric/numpy incompatibility

2006-08-28 Thread Andrew Straw
The following code indicates there is a problem adding a numpy scalar
type to a Numeric array. Is this expected behavior or is there a bug
somewhere?

This bit me in the context of updating some of my code to numpy, while
part of it still uses Numeric.

import Numeric
import numpy

print 'Numeric.__version__',Numeric.__version__
print 'numpy.__version__',numpy.__version__

a = Numeric.zeros( (10,2), Numeric.Float )
b = numpy.float64(23.39)
a[0,1] = a[0,1] + b
assert a[0,1]==b


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


Re: [Numpy-discussion] request for new array method: arr.abs()

2006-08-28 Thread Travis Oliphant
Christopher Barker wrote:
> Travis Oliphant wrote:
>
>   
>> Instead, I like better the idea of adding abs, round, max, and min to 
>> the "non-import-*" namespace of numpy.
>> 
>
> Another I'd like is the built-in data types. I always use:
>
> import numpy as N
>
> so then I do:
>
> a = zeros(shape, float)
> or
> a = zeros(shape, N.float_)
>
> but for non-built-in types, I can't do the former.
>
> The underscore is minor but why not just have:
>
> float = float
>
> in numpy.py?
>
> (and of course, the others)
>   

I think I prefer to just add the float, bool, object, unicode, str names 
to the "non-imported" numpy
name-space.

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


Re: [Numpy-discussion] numpy1.04b4: undefined symbol: PyUnicodeUCS2_FromUnicode. error No _WIN32

2006-08-28 Thread Travis Oliphant
rex wrote:
> Numpy builds, but fails to run with the error message:
>
>   
>> python
>> 
> Python 2.4.2 (#1, Apr 24 2006, 18:13:30)
> [GCC 4.1.0 (SUSE 10.1 Linux)] on linux2
>   
 import numpy
 
> Traceback (most recent call last):
>   File "", line 1, in ?
>   File "/usr/lib/python2.4/site-packages/numpy/__init__.py", line 35, in ?
> import core
>   File "/usr/lib/python2.4/site-packages/numpy/core/__init__.py", line 5, in ?
> import multiarray
> ImportError: /usr/lib/python2.4/site-packages/numpy/core/multiarray.so: 
> undefined symbol: PyUnicodeUCS2_FromUnicode
>
>
>   

This error usually means that NumPy was built and linked against a 
Python build where unicode strings were 2-bytes per character but you 
are trying to import it on a Python build where unicode strings are 
4-bytes per character.   Perhaps you have changed your build of Python 
and did not remove the build directory of NumPy.

Try

rm -fr build

in the numpy directory (where you run setup.py) and build again.


You can tell how many bytes-per-unicode character your system is built 
with by looking at the output of sys.maxunicode



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


Re: [Numpy-discussion] request for new array method: arr.abs()

2006-08-28 Thread Christopher Barker
Travis Oliphant wrote:

> Instead, I like better the idea of adding abs, round, max, and min to 
> the "non-import-*" namespace of numpy.

Another I'd like is the built-in data types. I always use:

import numpy as N

so then I do:

a = zeros(shape, float)
or
a = zeros(shape, N.float_)

but for non-built-in types, I can't do the former.

The underscore is minor but why not just have:

float = float

in numpy.py?

(and of course, the others)

-Chris




-- 
Christopher Barker, Ph.D.
Oceanographer

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


[Numpy-discussion] numpy1.04b4: undefined symbol: PyUnicodeUCS2_FromUnicode. error No _WIN32

2006-08-28 Thread rex
Numpy builds, but fails to run with the error message:

> python
Python 2.4.2 (#1, Apr 24 2006, 18:13:30)
[GCC 4.1.0 (SUSE 10.1 Linux)] on linux2
>>> import numpy
Traceback (most recent call last):
  File "", line 1, in ?
  File "/usr/lib/python2.4/site-packages/numpy/__init__.py", line 35, in ?
import core
  File "/usr/lib/python2.4/site-packages/numpy/core/__init__.py", line 5, in ?
import multiarray
ImportError: /usr/lib/python2.4/site-packages/numpy/core/multiarray.so: 
undefined symbol: PyUnicodeUCS2_FromUnicode


Build was without BLAS or LAPACK. Results were the same when Intel MKL
was used.

python setup.py install >& inst.log
Running from numpy source directory.
non-existing path in 'numpy/distutils': 'site.cfg'
F2PY Version 2_3078
blas_opt_info:
blas_mkl_info:
  libraries mkl,vml,guide not found in /usr/local/lib
  libraries mkl,vml,guide not found in /usr/lib
  NOT AVAILABLE

[...]

running install
running build
running config_fc
running build_src
building py_modules sources
building extension "numpy.core.multiarray" sources
  adding 'build/src.linux-i686-2.4/numpy/core/config.h' to sources.
executing numpy/core/code_generators/generate_array_api.py
  adding 'build/src.linux-i686-2.4/numpy/core/__multiarray_api.h' to sources.
  adding 'build/src.linux-i686-2.4/numpy/core/src' to include_dirs.
numpy.core - nothing done with h_files= 
['build/src.linux-i686-2.4/numpy/core/src/scalartypes
.inc', 'build/src.linux-i686-2.4/numpy/core/src/arraytypes.inc', 
'build/src.linux-i686-2.4/nu
mpy/core/config.h', 'build/src.linux-i686-2.4/numpy/core/__multiarray_api.h']
building extension "numpy.core.umath" sources
  adding 'build/src.linux-i686-2.4/numpy/core/config.h' to sources.
executing numpy/core/code_generators/generate_ufunc_api.py
  adding 'build/src.linux-i686-2.4/numpy/core/__ufunc_api.h' to sources.
  adding 'build/src.linux-i686-2.4/numpy/core/src' to include_dirs.
numpy.core - nothing done with h_files= 
['build/src.linux-i686-2.4/numpy/core/src/scalartypes
.inc', 'build/src.linux-i686-2.4/numpy/core/src/arraytypes.inc', 
'build/src.linux-i686-2.4/nu
mpy/core/config.h', 'build/src.linux-i686-2.4/numpy/core/__ufunc_api.h']
building extension "numpy.core._sort" sources
  adding 'build/src.linux-i686-2.4/numpy/core/config.h' to sources.
executing numpy/core/code_generators/generate_array_api.py
  adding 'build/src.linux-i686-2.4/numpy/core/__multiarray_api.h' to sources.
numpy.core - nothing done with h_files= 
['build/src.linux-i686-2.4/numpy/core/config.h', 'bui
ld/src.linux-i686-2.4/numpy/core/__multiarray_api.h']
building extension "numpy.core.scalarmath" sources
  adding 'build/src.linux-i686-2.4/numpy/core/config.h' to sources.
executing numpy/core/code_generators/generate_array_api.py
  adding 'build/src.linux-i686-2.4/numpy/core/__multiarray_api.h' to sources.
executing numpy/core/code_generators/generate_ufunc_api.py
  adding 'build/src.linux-i686-2.4/numpy/core/__ufunc_api.h' to sources.
numpy.core - nothing done with h_files= 
['build/src.linux-i686-2.4/numpy/core/config.h', 'bui
ld/src.linux-i686-2.4/numpy/core/__multiarray_api.h', 
'build/src.linux-i686-2.4/numpy/core/__
ufunc_api.h']
building extension "numpy.core._dotblas" sources
building extension "numpy.lib._compiled_base" sources
building extension "numpy.numarray._capi" sources
building extension "numpy.fft.fftpack_lite" sources
building extension "numpy.linalg.lapack_lite" sources
### Warning:  Using unoptimized lapack ###
  adding 'numpy/linalg/lapack_litemodule.c' to sources.
  adding 'numpy/linalg/zlapack_lite.c' to sources.
  adding 'numpy/linalg/dlapack_lite.c' to sources.
  adding 'numpy/linalg/blas_lite.c' to sources.
  adding 'numpy/linalg/dlamch.c' to sources.
  adding 'numpy/linalg/f2c_lite.c' to sources.
building extension "numpy.random.mtrand" sources
Could not locate executable f95
customize GnuFCompiler
customize GnuFCompiler
customize GnuFCompiler using config

***
C compiler: gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall 
-Wstrict-prototypes -fPIC

compile options: '-Inumpy/core/src -Inumpy/core/include 
-I/usr/include/python2.4 -c'
gcc: _configtest.c
_configtest.c:7:2: error: #error No _WIN32
_configtest.c:7:2: error: #error No _WIN32
failure.
removing: _configtest.c _configtest.o
***

building data_files sources

[...]

changing mode of /usr/bin/f2py to 755
running install_data
copying build/src.linux-i686-2.4/numpy/core/__multiarray_api.h -> 
/usr/lib/python2.4/site-pac
kages/numpy/core/include/numpy
copying build/src.linux-i686-2.4/numpy/core/multiarray_api.txt -> 
/usr/lib/python2.4/site-pac
kages/numpy/core/include/numpy
copying build/src.linux-i686-2.4/numpy/core/__ufunc_api.h -> 
/usr/lib/python2.4/site-packages
/numpy/core/include/numpy
copying build/src.linux-i686-2.4/numpy/core/ufunc_api.txt -> 
/usr/lib/python2

Re: [Numpy-discussion] C Api newbie question

2006-08-28 Thread Matt Knox


>>Matt Knox wrote:>>> Hi there. I'm in the unfortunate situation of trying to track down a >> memory error in someone elses code, and to make matters worse I don't >> really know jack squat about C programming. The problem seems to arise >> when several numpy arrays are created from C arrays in the C api and >> returned to python, and then trying to print out or cast to a string >> the resulting array. I think the problem may be happening due to the >> following chunk of code:>> {>>  PyObject* temp = PyArray_SimpleNewFromData(1, &numobjs, typeNum, >> dbValues);>>  PyObject* temp2 = PyArray_FromArray((PyArrayObject*)temp, >> ((PyArrayObject*)temp)->descr, DEFAULT_FLAGS | ENSURECOPY);>>  Py_DECREF(temp);>>  PyDict_SetItemString(returnVal, "data", temp2);>>  Py_DECREF(temp2);>> }>>  >> Lets assume that all my other inputs up this point are fine and that >> numobjs, typeNum, and dbValues are fine. Is their anything obviously >> wrong with the above chunk of code? or does it appear ok? Ultimately >> the dictionary "returnVal" is returned by the function this code came >> from, and everything else is discarded. Any help is very greatly >> appreciated. Thanks in advance,
> You didn't indicate what kind of trouble you are having.>> First of all, this is kind of odd style.  Why is a new array created > from a data-pointer and then copied using PyArray_FromArray (the > ENSURECOPY flag will give you a copy)?  Using>> temp2 = PyArray_Copy(temp)>> seems simpler.   This will also avoid the reference-count problem that > is currently happening in the PyArray_FromArray call on the descr > structure.    Any array-creation function that takes a descr structure > "steals" a reference to it, so you need to increment the reference count > if you are passing an unowned reference to a ->descr structure.>> -Travis
 
Sorry. Yeah, the problem was the interpreter crashing on exit, which afteryour response definitely seems like it was a reference count issue. Ichanged the PyArray_FromArray call to be PyArray_Copy and it seems to workfine. Thank you very much!
 
Love the numpy stuff (when I can stay in the python world and not mess withthe C stuff :) ). Keep up the great work!
 
- MattBe one of the first to try  Windows Live Mail.
-
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=lnk&kid=120709&bid=263057&dat=121642___
Numpy-discussion mailing list
Numpy-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion


Re: [Numpy-discussion] memory corruption bug

2006-08-28 Thread Bill Baxter
Nope, that's the way python works in general for any type other than
basic scalar types.
>>> a = [1,2,3,4]
>>> b = a
>>> b[1] = 99
>>> print a
[1, 99, 3, 4]
>>> print b
[1, 99, 3, 4]

Also the issue never comes up for types like tuples or strings because
they aren't mutable.

--bb

On 8/28/06, Sven Schreiber <[EMAIL PROTECTED]> wrote:
> Charles R Harris schrieb:
> > +1. I too suspect that what you have here is a reference/copy problem.
> > The only thing that is local to the class is the reference (pointer),
> > the data is global.
> >
> > Chuck
>
> Ok, so you guys were right, turns out that my problem was caused by the
> fact that a local assignment like x = y is also by reference only, which
> I wasn't really aware of. (Of course, it's explained in Travis' book...)
> So that behavior is different from standard python assignments, isn't it?
>
> Sorry for the noise.
>
> -Sven
>

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


Re: [Numpy-discussion] memory corruption bug

2006-08-28 Thread Sven Schreiber
Charles R Harris schrieb:
> +1. I too suspect that what you have here is a reference/copy problem.
> The only thing that is local to the class is the reference (pointer),
> the data is global.
> 
> Chuck

Ok, so you guys were right, turns out that my problem was caused by the
fact that a local assignment like x = y is also by reference only, which
I wasn't really aware of. (Of course, it's explained in Travis' book...)
So that behavior is different from standard python assignments, isn't it?

Sorry for the noise.

-Sven

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


Re: [Numpy-discussion] Optimizing mean(axis=0) on a 3D array

2006-08-28 Thread Martin Spacek
Martin Spacek wrote:

> 
> Actually, your original version is just as fast as the take() version. 
> Both are about 9X faster than numpy.mean() on my system. I prefer the 
> take() version because you only have to pass a single argument to 
> mean_accum()

I forgot to mention that all my indices are, for now, sorted. I just 
tried shuffling them (as you did), but I still get the same 9x 
improvement in speed, so I don't know why you only get a 4x improvement 
on your system.

Martin

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


Re: [Numpy-discussion] Optimizing mean(axis=0) on a 3D array

2006-08-28 Thread Martin Spacek
Tim Hochberg wrote:

> I'm actually surprised that the take version is faster than my original 
> version since it makes a big  ol' copy. I guess this is an indication 
> that indexing is more expensive than I realize. That's why nothing beats 
> measuring!

Actually, your original version is just as fast as the take() version. 
Both are about 9X faster than numpy.mean() on my system. I prefer the 
take() version because you only have to pass a single argument to 
mean_accum()

Martin

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