[Numpy-discussion] A random.normal function with stdev as array

John Byrnes byrnes at bu.edu
Thu Apr 6 09:15:25 CDT 2006


On Thu, Apr 06, 2006 at 03:36:59AM -0600, Travis Oliphant wrote:
> John Byrnes wrote:
> >Hi Eric,
> >
> >In the past , I've done things like
> >
> >######
> >normdist = lambda x: numpy.random.normal(0,x)
> >vecnormal = numpy.vectorize(normdist)
> >
> >stdev = numpy.array([1.1,1.2,1.0,2.2])
> >result = vecnormal(stdev)
> >
> >######
> >
> >This works fine for up to 10k elements for stdev for some reason.
> >Any larger then that and i get a Bus error on my PPC mac and a segfault on
> >my x86 linux box.
> >
> >  
> 
> This needs to be tracked down.  It looks like some-kind of error is not 
> being caught correctly.  You should not get a segfault.  Could you 
> provide a stack-trace when the problem occurs? 
> 
> One issue is that vectorize is using object arrays under the covers 
> which is consuming roughly 2x the memory than you may think.    An 
> object array is created and the function is called for every element.  
> This object array is then converted to a number type after the fact.  
> 
> The segfault should be tracked down in any case.
> 
> -Travis
> 
> 
>

Hi Travis,

Here is a backtrace from gdb on my mac.

John


#0  0x00470b88 in log1pl ()
#1  0x00000000 in ?? ()
Cannot access memory at address 0x0
Cannot access memory at address 0x0
#2  0x004708ec in log1pl ()
#3  0x1000c348 in PyObject_Call (func=0x4, arg=0x4, kw=0x15fb) at /Users/bob/src/Python-2.4.1/Objects/abstract.c:1751
#4  0x1007ce34 in ext_do_call (func=0x1, pp_stack=0xbfffed90, flags=211904, na=8656012, nk=1194304) at /Users/bob/src/Python-2.4.1/Python/ceval.c:3824
#5  0x1007a230 in PyEval_EvalFrame (f=0x848410) at /Users/bob/src/Python-2.4.1/Python/ceval.c:2203
#6  0x1007b284 in PyEval_EvalCodeEx (co=0x2, globals=0x4, locals=0x1, args=0x3, argcount=1049072, kws=0x841150, kwcount=1, defs=0x8411fc, defcount=0, closure=0x0) at /Users/bob/src/Python-2.4.1/Python/ceval.c:2730
#7  0x10026274 in function_call (func=0x880bb0, arg=0x1001f0, kw=0x848410) at /Users/bob/src/Python-2.4.1/Objects/funcobject.c:548
#8  0x1000c348 in PyObject_Call (func=0x4, arg=0x4, kw=0x15fb) at /Users/bob/src/Python-2.4.1/Objects/abstract.c:1751
#9  0x10015a88 in instancemethod_call (func=0x52eef0, arg=0x54a170, kw=0x0) at /Users/bob/src/Python-2.4.1/Objects/classobject.c:2431
#10 0x1000c348 in PyObject_Call (func=0x4, arg=0x4, kw=0x15fb) at /Users/bob/src/Python-2.4.1/Objects/abstract.c:1751
#11 0x10059358 in slot_tp_call (self=0x53e4f0, args=0x5b310, kwds=0x0) at /Users/bob/src/Python-2.4.1/Objects/typeobject.c:4526
#12 0x1000c348 in PyObject_Call (func=0x4, arg=0x4, kw=0x15fb) at /Users/bob/src/Python-2.4.1/Objects/abstract.c:1751
#13 0x1007c9e4 in do_call (func=0x53e4f0, pp_stack=0x53e4f0, na=0, nk=8655844) at /Users/bob/src/Python-2.4.1/Python/ceval.c:3755
#14 0x1007c6dc in call_function (pp_stack=0x0, oparg=4) at /Users/bob/src/Python-2.4.1/Python/ceval.c:3570
#15 0x1007a140 in PyEval_EvalFrame (f=0x10e200) at /Users/bob/src/Python-2.4.1/Python/ceval.c:2163
#16 0x1007c83c in fast_function (func=0x4, pp_stack=0x10e360, n=268927488, na=268755664, nk=1) at /Users/bob/src/Python-2.4.1/Python/ceval.c:3629
#17 0x1007c6c4 in call_function (pp_stack=0xbffff5bc, oparg=4) at /Users/bob/src/Python-2.4.1/Python/ceval.c:3568
#18 0x1007a140 in PyEval_EvalFrame (f=0x10e030) at /Users/bob/src/Python-2.4.1/Python/ceval.c:2163
#19 0x1007b284 in PyEval_EvalCodeEx (co=0x0, globals=0x4, locals=0x1, args=0x10078200, argcount=1049072, kws=0x841150, kwcount=1, defs=0x8411fc, defcount=0, closure=0x0) at /Users/bob/src/Python-2.4.1/Python/ceval.c:2730
#20 0x1007e678 in PyEval_EvalCode (co=0x4, globals=0x4, locals=0x15fb) at /Users/bob/src/Python-2.4.1/Python/ceval.c:484
#21 0x100b2ee0 in run_node (n=0x10078200, filename=0x4 <Address 0x4 out of bounds>, globals=0x0, locals=0x10e180, flags=0x2) at /Users/bob/src/Python-2.4.1/Python/pythonrun.c:1265
#22 0x100b23b0 in PyRun_InteractiveOneFlags (fp=0x54a1a5, filename=0x56ca0 "", flags=0x10e030) at /Users/bob/src/Python-2.4.1/Python/pythonrun.c:762
#23 0x100b2190 in PyRun_InteractiveLoopFlags (fp=0x56b94, filename=0xd440 "", flags=0x100f21b8) at /Users/bob/src/Python-2.4.1/Python/pythonrun.c:695
#24 0x100b3bb0 in PyRun_AnyFileExFlags (fp=0xa0001554, filename=0x100f36ac "<stdin>", closeit=0, flags=0xbffff934) at /Users/bob/src/Python-2.4.1/Python/pythonrun.c:658
#25 0x100bf640 in Py_Main (argc=269413412, argv=0x20000000) at /Users/bob/src/Python-2.4.1/Modules/main.c:484
#26 0x000018d0 in start ()
#27 0x8fe1a278 in __dyld__dyld_start ()





More information about the Numpy-discussion mailing list