From: Sebastian H. <ha...@ms...> - 2006-09-15 01:20:58
|
Hi, what I'm asking is if numpy has an equivalent to numarray's info() function: >>> na.arange(10).info() class: <class 'numarray.numarraycore.NumArray'> shape: (10,) strides: (4,) byteoffset: 0 bytestride: 4 itemsize: 4 aligned: 1 contiguous: 1 buffer: <memory at 0x085b7ec8 with size:0x00000028 held by object 0x4306e5e0 aliasing object 0x00000000> data pointer: 0x085b7ec8 (DEBUG ONLY) byteorder: 'little' byteswap: 0 type: Int32 This was always helpful to me when debugging C binding code. Especially I'm asking if there is any way to get the memory address of an array - for debugging purposes only - of course ;-) Thanks, Sebastian Haase |
From: Francesc A. <fa...@ca...> - 2006-09-15 06:10:38
|
El dj 14 de 09 del 2006 a les 18:20 -0700, en/na Sebastian Haase va escriure: > Especially I'm asking if there is any way to get the memory address of an= =20 > array - for debugging purposes only - of course ;-) For this, you can print the data buffer: In [1]:import numpy In [2]:a=3Dnumpy.array([1]) In [3]:a.data Out[3]:<read-write buffer for 0x82a9970, ptr 0x821f630, size 4 at 0xb6dd3300> although I'm not sure which number is the memory address I'd say it's the last one. Cheers, --=20 >0,0< Francesc Altet http://www.carabos.com/ V V C=C3=A1rabos Coop. V. Enjoy Data "-" |
From: Albert S. <fu...@gm...> - 2006-09-15 09:51:37
|
> -----Original Message----- > From: num...@li... [mailto:numpy- > dis...@li...] On Behalf Of Sebastian Haase > Sent: 15 September 2006 03:21 > To: numpy-discussion > Subject: [Numpy-discussion] how to get info about internals of an > arrayobject ? > > Hi, > what I'm asking is if numpy has an equivalent to numarray's info() > function: > <snip> > This was always helpful to me when debugging C binding code. > > Especially I'm asking if there is any way to get the memory address of an > array - for debugging purposes only - of course ;-) numpy.array([]).__array_interface__['data'][0] Cheers, Albert |
From: Travis O. <oli...@ie...> - 2006-09-15 16:44:00
|
Albert Strasheim wrote: >> -----Original Message----- >> From: num...@li... [mailto:numpy- >> dis...@li...] On Behalf Of Sebastian Haase >> Sent: 15 September 2006 03:21 >> To: numpy-discussion >> Subject: [Numpy-discussion] how to get info about internals of an >> arrayobject ? >> >> Hi, >> what I'm asking is if numpy has an equivalent to numarray's info() >> function: >> > > >> <snip> >> > > >> This was always helpful to me when debugging C binding code. >> >> Especially I'm asking if there is any way to get the memory address of an >> array - for debugging purposes only - of course ;-) >> > > numpy.array([]).__array_interface__['data'][0] > Or numpy.ctypes._as_parameter_ (should work even if you don't have ctypes installed) -Travis |
From: Travis O. <oli...@ie...> - 2006-09-15 16:59:52
|
Sebastian Haase wrote: > Hi, > what I'm asking is if numpy has an equivalent to numarray's info() function: > >>>> na.arange(10).info() >>>> numpy.numarray.info(numpy.arange(10)) (get recent SVN as there were some bugs just fixed. -Travis |
From: Sebastian H. <ha...@ms...> - 2006-09-15 19:20:37
|
On Friday 15 September 2006 10:00, Travis Oliphant wrote: > Sebastian Haase wrote: > > Hi, > > > > what I'm asking is if numpy has an equivalent to numarray's info() function: > >>>> na.arange(10).info() > > numpy.numarray.info(numpy.arange(10)) > > (get recent SVN as there were some bugs just fixed. > > -Travis Thanks, should this maybe also be added somewhere in the numpy module itself !? I guess the question is, what the original intent was for numarray to put it in (only for debugging ?) -- then we could decide if this would also make sense for numpy. I have never used numpy.info(obj) - I don't know what is does (compared to __doc__) but maybe it could be extended like if isinstance( obj , N.ndarray): print N.numarray.info( obj ) right now it prints nothings (and returns None) Thanks, Sebastian Haase |
From: Travis O. <oli...@ee...> - 2006-09-15 19:49:59
|
Sebastian Haase wrote: >On Friday 15 September 2006 10:00, Travis Oliphant wrote: > > >>Sebastian Haase wrote: >> >> >>>Hi, >>> >>>what I'm asking is if numpy has an equivalent to numarray's info() >>> >>> >function: > > >>>>>>na.arange(10).info() >>>>>> >>>>>> >>numpy.numarray.info(numpy.arange(10)) >> >>(get recent SVN as there were some bugs just fixed. >> >>-Travis >> >> > >Thanks, > >should this maybe also be added somewhere in the numpy module itself !? >I guess the question is, what the original intent was for numarray to put it >in (only for debugging ?) -- then we could decide if this would also make >sense for numpy. > >I have never used numpy.info(obj) - I don't know what is does (compared to >__doc__) > It prints the doc string of an object searching for it better than help seems to do and without a "pager". Compare numpy.info(numpy.sin) versus help(numpy.sin) I don't know what the info method was for other than debugging. What about having the __doc__ attribute of an ndarray return the info? -Travis |
From: Sebastian H. <ha...@ms...> - 2006-09-15 20:49:44
|
On Friday 15 September 2006 12:49, Travis Oliphant wrote: > Sebastian Haase wrote: > >On Friday 15 September 2006 10:00, Travis Oliphant wrote: > >>Sebastian Haase wrote: > >>>Hi, > >>> > >>>what I'm asking is if numpy has an equivalent to numarray's info() > > > >function: > >>>>>>na.arange(10).info() > >> > >>numpy.numarray.info(numpy.arange(10)) > >> > >>(get recent SVN as there were some bugs just fixed. > >> > >>-Travis > > > >Thanks, > > > >should this maybe also be added somewhere in the numpy module itself !? > >I guess the question is, what the original intent was for numarray to put > > it in (only for debugging ?) -- then we could decide if this would also > > make sense for numpy. > > > >I have never used numpy.info(obj) - I don't know what is does (compared to > >__doc__) > > It prints the doc string of an object searching for it better than help > seems to do and without a "pager". > > Compare numpy.info(numpy.sin) versus help(numpy.sin) In PyShell I would miss the output of numpy.info(numpy.sin) since it goes to the (C) stdout and not to the (sometimes redirected ) python sys.stdout. So it seems it prints N.sin.__doc__ The output from help(...) goes to the (python) sys.stdout (or stderr !?) and is quite long (and mostly just generec info about ufuncs ...) > > I don't know what the info method was for other than debugging. > > What about having the __doc__ attribute of an ndarray return the info? > Maybe, but honestly I would *not* expect any kind of "live inspection" to be done by __doc__ I would expect more like "ndarray is an efficient way to handle large data sets in python - it is the bases for Numerical Python, see www.scipy.org " Maybe info() should just be an array attribute - just like it was it numarray. -Sebastian |