[Numpy-discussion] numpy and cython in pure python mode

2009-09-21 Thread Sebastian Haase
Hi, I'm not subscribed to the cython list - hoping enough people would care to justify my post here: I know that cython's numpy is still getting better and better over time, but is it already today possible to have numpy support when using Cython in "pure python" mode? I like the idea of being abl

Re: [Numpy-discussion] [IPython-dev] Testing matplotlib on IPython trunk

2009-09-21 Thread Gökhan Sever
Thanks Fernando for the quick response. Today this is the 3rd time I am hitting an unsupported feature in the Python lands. 1-) No attribute docstrings 2-) Look this question: http://stackoverflow.com/questions/1458203/reading-a-float-from-string and 3rd is this. However I think I influenced t

Re: [Numpy-discussion] Multi-dimensional indexing

2009-09-21 Thread Daran L. Rife
I forgot to mention that the second array, which I wish to conditionally select elements from using tmax_idx, has the same dimensions as the "speed" array, That is, (ntimes, nlon, nlat) = U.shape And tmax_idx has dimensions of (nlon, nlat). Daran -- > My apology for the simplemindedness of

Re: [Numpy-discussion] something wrong with docs?

2009-09-21 Thread Fernando Perez
On Mon, Sep 21, 2009 at 11:32 AM, Pauli Virtanen wrote: > The `sphinx.ext.doctest` extension is not enabled, so the testcode:: > etc. directives are not available. I'm not sure if it should be enabled > -- it would be cleaner to just replace the testcode:: stuff with the > ordinary example markup.

Re: [Numpy-discussion] Numpy large array bug

2009-09-21 Thread Citi, Luca
Here it is... http://projects.scipy.org/numpy/ticket/1229 ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread David Cournapeau
On Tue, Sep 22, 2009 at 12:57 AM, Neal Becker wrote: > David Cournapeau wrote: > >> On Mon, Sep 21, 2009 at 9:00 PM, Neal Becker wrote: >>> >>> numpy arrays of fpi should support all numeric operations.  Also mixed >>> fpi/integer operations. >>> >>> I'm not sure how to go about implementing this

Re: [Numpy-discussion] Numpy large array bug

2009-09-21 Thread Charles R Harris
Hi, Luca, On Mon, Sep 21, 2009 at 4:52 PM, Citi, Luca wrote: > I think the original bug is due to > line 535 of numpy/core/src/multiarray/ctors.c (svn) > that should be: >intp numcopies, nbytes; > instead of: >int numcopies, nbytes; > > To resume: > in line 535 of numpy/core/src/multiarr

Re: [Numpy-discussion] Numpy large array bug

2009-09-21 Thread Citi, Luca
I think the original bug is due to line 535 of numpy/core/src/multiarray/ctors.c (svn) that should be: intp numcopies, nbytes; instead of: int numcopies, nbytes; To resume: in line 535 of numpy/core/src/multiarray/ctors.c and in line 209 of numpy/core/src/multiarray/item_selection.c int sh

Re: [Numpy-discussion] masked arrays as array indices (is a bad idea)

2009-09-21 Thread Pierre GM
On Sep 21, 2009, at 4:23 PM, Ernest Adrogué wrote: > > This explains why x[x == 3] = 4 works "as expected", whereas > x[x == 0] = 4 ruins everything. Basically, any condition that matches > 0 will match every masked item as well. There's room for improvement here indeed. I need to check first w

[Numpy-discussion] Numpy large array bug

2009-09-21 Thread Kashyap Ashwin
Also, what about PyArray_PutMask() That function also has a line like "int i, chunk, ni, max_item, nv, tmp;" Should that be changed as well? (Your patch does not fix my original issue.) BTW, in numpy 1.3, that is present in numpy/core/src/multiarraymodule.c. Can someone please give me a te

Re: [Numpy-discussion] Indexing transposes the array?

2009-09-21 Thread David Warde-Farley
On 21-Sep-09, at 3:36 PM, Jonathan Taylor wrote: > Why does indexing seem to transpose this array? > > In [14]: x = arange(8).reshape((2,2,2)) > > In [15]: x[0,:,:] > Out[15]: > array([[0, 1], > [2, 3]]) > > In [16]: x[0,:,[0,1]] > Out[16]: > array([[0, 2], > [1, 3]]) The last example

Re: [Numpy-discussion] masked arrays as array indices (is a bad idea)

2009-09-21 Thread Ernest Adrogué
21/09/09 @ 14:43 (-0400), thus spake Pierre GM: > > > On Sep 21, 2009, at 12:17 PM, Ryan May wrote: > > > 2009/9/21 Ernest Adrogué > > Hello there, > > > > Given a masked array such as this one: > > > > In [19]: x = np.ma.masked_equal([-1, -1, 0, -1, 2], -1) > > > > In [20]: x > > Out[20]: > >

Re: [Numpy-discussion] Numpy question: Best hardware for Numpy?

2009-09-21 Thread David Warde-Farley
On 21-Sep-09, at 10:53 AM, David Cournapeau wrote: > Concerning the hardware, I have just bought a core i7 (the cheapest > model is ~ 200$ now, with 4 cores and 8 Mb of shared cache), and the > thing flies for floating point computation. My last computer was a > pentium 4 so I don't have a lot of

[Numpy-discussion] Indexing transposes the array?

2009-09-21 Thread Jonathan Taylor
Why does indexing seem to transpose this array? In [14]: x = arange(8).reshape((2,2,2)) In [15]: x[0,:,:] Out[15]: array([[0, 1], [2, 3]]) In [16]: x[0,:,[0,1]] Out[16]: array([[0, 2], [1, 3]]) Thanks, Jonathan. ___ NumPy-Discussion mailin

Re: [Numpy-discussion] Numpy large array bug

2009-09-21 Thread Citi, Luca
I can confirm this bug for the last svn. Also: >>> a.put([2*1024*1024*1024 + 100,], 8) IndexError: index out of range for array in this case, I think the error is that in numpy/core/src/multiarray/item_selection.c in PyArray_PutTo line 209 should be: intp i, chunk, ni, max_item, nv, tmp; inst

Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread Gökhan Sever
Ahh my blindness and apologies :) The nice feeling of reinventing the wheel... Probably I forgot to reshape the image data in the first place before applying into ndimage.label(). However, this was a nice example to understand recursion, and get to know some basics of computer vision and few lib

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread David Warde-Farley
On 21-Sep-09, at 2:55 PM, Xavier Gnata wrote: > Should I read that to learn you cython and numpy interact? > Or is there another best documentation (with examples...)? You should have a look at the Bresenham algorithm thread you posted. I went to the trouble of converting some Python code for B

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread Christopher Barker
Xavier Gnata wrote: > David Cournapeau wrote: >> That's only a data point, but I almost always use cython in those cases, I'm a second data point, but I think there are many more. Judging from the SciPy conference, Cython is the preferred method for new projects. > Should I read that to learn y

Re: [Numpy-discussion] Numpy large array bug

2009-09-21 Thread Kashyap Ashwin
Yes, it happens for the trunk as well. > > import numpy as np > > > > a=np.zeros((2*1024*1024*1024 + 1), dtype="uint8") > > > > a[:]=1 > > # returns immediately > > > > a.mean() > > > > 0.0 > > print a > > > > [0 0 0 ..., 0 0 0] > > The bug only happens when the nElements > 2G (2^31). So for

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread Xavier Gnata
David Cournapeau wrote: > Xavier Gnata wrote: > >> Hi, >> >> I have a large 2D numpy array as input and a 1D array as output. >> In between, I would like to use C code. >> C is requirement because it has to be fast and because the algorithm >> cannot be written in a numpy oriented way :( (no wa

Re: [Numpy-discussion] masked arrays as array indices (is a bad idea)

2009-09-21 Thread Pierre GM
On Sep 21, 2009, at 12:17 PM, Ryan May wrote: > 2009/9/21 Ernest Adrogué > Hello there, > > Given a masked array such as this one: > > In [19]: x = np.ma.masked_equal([-1, -1, 0, -1, 2], -1) > > In [20]: x > Out[20]: > masked_array(data = [-- -- 0 -- 2], > mask = [ True True False

Re: [Numpy-discussion] Numpy large array bug

2009-09-21 Thread Charles R Harris
On Mon, Sep 21, 2009 at 12:30 PM, Francesc Alted wrote: > A Monday 21 September 2009 19:45:27 Kashyap Ashwin escrigué: > > Hello, > > > > I have downloaded numpy 1.3rc2 sources and compiled it on Ubuntu Hardy > > Linux x86_64. numpy.test() seems to run ok as well. > > > > > > > > Here is the bug I

Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread David Warde-Farley
I think Zachary is right, ndimage does what you want: In [48]: image = array( [[0,0,0,1,1,0,0], [0,0,0,1,1,1,0], [0,0,0,1,0,0,0], [0,0,0,0,0,0,0], [0,1,0,0,0,0,0], [0,1,1,0,0,0,0], [0,0,0,0,1,1,0], [0,0,0,0,1,1,1]]) In [57]: import scipy.ndimage as ndimage In [58]: labels, num_found = ndimage.la

Re: [Numpy-discussion] something wrong with docs?

2009-09-21 Thread Pauli Virtanen
ma, 2009-09-21 kello 13:15 -0400, Skipper Seabold kirjoitti: > On Mon, Sep 21, 2009 at 7:27 AM, Neal Becker wrote: > > I'm trying to read about subclassing. When I view > > > > http://docs.scipy.org/doc/numpy/user/basics.subclassing.html?highlight=subclass#module- > > numpy.doc.subclassing > > >

Re: [Numpy-discussion] Numpy large array bug

2009-09-21 Thread Francesc Alted
A Monday 21 September 2009 19:45:27 Kashyap Ashwin escrigué: > Hello, > > I have downloaded numpy 1.3rc2 sources and compiled it on Ubuntu Hardy > Linux x86_64. numpy.test() seems to run ok as well. > > > > Here is the bug I can reproduce > > > > import numpy as np > > a=np.zeros((2*1024*1024*1024

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread Robert Kern
On Mon, Sep 21, 2009 at 12:39, Neal Becker wrote: > 1. Where would I find this new datetime dtype? It's in the SVN trunk. > 2. Don't know exactly what 'parameterized' dtypes are.  Does this mean that > the dtype for 8.1 format fixed-pt is different from the dtype for 6.2 > format, for example?

Re: [Numpy-discussion] Simple pattern recognition

2009-09-21 Thread René Dudfield
On Mon, Sep 21, 2009 at 6:45 PM, Gökhan Sever wrote: > I asked this question at > http://stackoverflow.com/questions/1449139/simple-object-recognition and get > lots of nice feedback, and finally I have managed to implement what I > wanted. > > What I was looking for is named "connected component

[Numpy-discussion] Numpy large array bug

2009-09-21 Thread Kashyap Ashwin
Hello, I have downloaded numpy 1.3rc2 sources and compiled it on Ubuntu Hardy Linux x86_64. numpy.test() seems to run ok as well. Here is the bug I can reproduce import numpy as np a=np.zeros((2*1024*1024*1024 + 1), dtype="uint8") a[:]=1 # returns immediately a.mean() 0.0 p

[Numpy-discussion] Building problem on CentOS 5.3

2009-09-21 Thread Patrik Jonsson
Hi all, I've installed python 2.5 on my centos 5.3 x86_64 machine (system standard is 2.4), and now I want to install numpy for it. However, the build fails. The final message is: "EnvironmentError: math library missing; rerun setup.py after setting the MATHLIB env variable" However, from lookin

Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread Gökhan Sever
ndimage.label works differently than what I have done here. Later using find_objects you can get slices for row or column basis. Not possible to construct a dynamical structure to find objects that are in the in both axis. Could you look at the stackoverflow article once again and comment back?

Re: [Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread Pauli Virtanen
ma, 2009-09-21 kello 13:35 -0400, Elaine Angelino kirjoitti: > ok a couple more questions: > 1) how does sphinxext relate to numpydoc? > sphinxext in scipy source tree -- > http://svn.scipy.org/svn/numpy/trunk/doc/sphinxext/ > numpydoc on PyPI -- http://pypi.python.org/pypi?% > 3Aaction=search&term

Re: [Numpy-discussion] [SciPy-User] Simple pattern recognition

2009-09-21 Thread Zachary Pincus
I believe that pretty generic connected-component finding is already available with scipy.ndimage.label, as David suggested at the beginning of the thread... This function takes a binary array (e.g. zeros where the background is, non-zero where foreground is) and outputs an array where each

Re: [Numpy-discussion] Simple pattern recognition

2009-09-21 Thread Gökhan Sever
I asked this question at http://stackoverflow.com/questions/1449139/simple-object-recognition and get lots of nice feedback, and finally I have managed to implement what I wanted. What I was looking for is named "connected component labelling or analysis" for my "connected component extraction" I

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread Neal Becker
Robert Kern wrote: > On Mon, Sep 21, 2009 at 12:02, Neal Becker wrote: >> Robert Kern wrote: >> >>> On Mon, Sep 21, 2009 at 10:57, Neal Becker wrote: David Cournapeau wrote: > On Mon, Sep 21, 2009 at 9:00 PM, Neal Becker > wrote: >> >> numpy arrays of fpi should suppor

Re: [Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread Elaine Angelino
ok a couple more questions: 1) how does sphinxext relate to numpydoc? sphinxext in scipy source tree -- http://svn.scipy.org/svn/numpy/trunk/doc/sphinxext/ numpydoc on PyPI -- http://pypi.python.org/pypi?%3Aaction=search&term=numpydoc&submit=search 2) what about postprocess.py, should i be usin

Re: [Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread David Warde-Farley
On 21-Sep-09, at 1:20 PM, Elaine Angelino wrote: > thanks robert! > > yes i saw this (http://svn.scipy.org/svn/numpy/trunk/doc/sphinxext/) > but is there a good description of how to use this? i'm looking for > a "standard recipe" that could be followed by myself and others. > e.g. what fu

Re: [Numpy-discussion] np.take versus fancy indexing

2009-09-21 Thread Eric Firing
Wes McKinney wrote: > Any clue why I'm seeing this behavior? np.take's documentation says it > does the "same thing" as fancy indexing, but from this example I'm not > so sure: The code used to implement np.take is not the same as that used in fancy indexing. np.take's mission is simpler, so it

Re: [Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread Robert Kern
On Mon, Sep 21, 2009 at 12:20, Elaine Angelino wrote: > thanks robert! > > yes i saw this (http://svn.scipy.org/svn/numpy/trunk/doc/sphinxext/) but is > there a good description of how to use this?  i'm looking for a "standard > recipe" that could be followed by myself and others.  e.g. what funct

Re: [Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread Elaine Angelino
thanks robert! yes i saw this (http://svn.scipy.org/svn/numpy/trunk/doc/sphinxext/) but is there a good description of how to use this? i'm looking for a "standard recipe" that could be followed by myself and others. e.g. what functions to call and in what order... i would like to emulate what n

Re: [Numpy-discussion] something wrong with docs?

2009-09-21 Thread Skipper Seabold
On Mon, Sep 21, 2009 at 7:27 AM, Neal Becker wrote: > I'm trying to read about subclassing.  When I view > > http://docs.scipy.org/doc/numpy/user/basics.subclassing.html?highlight=subclass#module- > numpy.doc.subclassing > > It seems the examples show the _outputs_ of tests, but I don't see the >

Re: [Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread josef . pktd
On Mon, Sep 21, 2009 at 1:08 PM, Robert Kern wrote: > On Mon, Sep 21, 2009 at 12:03, Elaine Angelino > wrote: >> Hi there -- >> >> I have been working on a small Python package whose central data object >> comes from Numpy (the record array object). >> >> I would like to produce documentation tha

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread Robert Kern
On Mon, Sep 21, 2009 at 12:02, Neal Becker wrote: > Robert Kern wrote: > >> On Mon, Sep 21, 2009 at 10:57, Neal Becker wrote: >>> David Cournapeau wrote: >>> On Mon, Sep 21, 2009 at 9:00 PM, Neal Becker wrote: > > numpy arrays of fpi should support all numeric operations.  Also

Re: [Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread Robert Kern
On Mon, Sep 21, 2009 at 12:03, Elaine Angelino wrote: > Hi there -- > > I have been working on a small Python package whose central data object > comes from Numpy (the record array object). > > I would like to produce documentation that looks like Numpy's, and am > planning to follow Numpy's docst

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread Neal Becker
Robert Kern wrote: > On Mon, Sep 21, 2009 at 10:57, Neal Becker wrote: >> David Cournapeau wrote: >> >>> On Mon, Sep 21, 2009 at 9:00 PM, Neal Becker >>> wrote: numpy arrays of fpi should support all numeric operations. Also mixed fpi/integer operations. I'm not sure ho

[Numpy-discussion] numpy docstring sphinx pre-processors

2009-09-21 Thread Elaine Angelino
Hi there -- I have been working on a small Python package whose central data object comes from Numpy (the record array object). I would like to produce documentation that looks like Numpy's, and am planning to follow Numpy's docstring standard. Numpy uses Sphinx to generate documentation (e.g. f

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread Robert Kern
On Mon, Sep 21, 2009 at 10:57, Neal Becker wrote: > David Cournapeau wrote: > >> On Mon, Sep 21, 2009 at 9:00 PM, Neal Becker wrote: >>> >>> numpy arrays of fpi should support all numeric operations.  Also mixed >>> fpi/integer operations. >>> >>> I'm not sure how to go about implementing this.  

Re: [Numpy-discussion] masked arrays as array indices

2009-09-21 Thread Ryan May
2009/9/21 Ernest Adrogué > Hello there, > > Given a masked array such as this one: > > In [19]: x = np.ma.masked_equal([-1, -1, 0, -1, 2], -1) > > In [20]: x > Out[20]: > masked_array(data = [-- -- 0 -- 2], > mask = [ True True False True False], > fill_value = 99) > > Whe

[Numpy-discussion] masked arrays as array indices

2009-09-21 Thread Ernest Adrogué
Hello there, Given a masked array such as this one: In [19]: x = np.ma.masked_equal([-1, -1, 0, -1, 2], -1) In [20]: x Out[20]: masked_array(data = [-- -- 0 -- 2], mask = [ True True False True False], fill_value = 99) When you make an assignemnt in the vein of x[x ==

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread Neal Becker
David Cournapeau wrote: > On Mon, Sep 21, 2009 at 9:00 PM, Neal Becker wrote: >> >> numpy arrays of fpi should support all numeric operations. Also mixed >> fpi/integer operations. >> >> I'm not sure how to go about implementing this. At first, I was thinking >> to just subclass numpy array. B

Re: [Numpy-discussion] Numpy question: Best hardware for Numpy?

2009-09-21 Thread Chris Colbert
Just because I have a ruler handy :) On my laptop with qx9300, I invert that 5000, 5000 double (float64) matrix in 14.67s. Granted my cpu cores were all at about 75 degrees during that process.. Cheers! Chris On Mon, Sep 21, 2009 at 4:53 PM, David Cournapeau wrote: > On Mon, Sep 21, 2009

Re: [Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread David Cournapeau
On Mon, Sep 21, 2009 at 9:00 PM, Neal Becker wrote: > > numpy arrays of fpi should support all numeric operations.  Also mixed > fpi/integer operations. > > I'm not sure how to go about implementing this.  At first, I was thinking to > just subclass numpy array.  But, I don't think this provides f

Re: [Numpy-discussion] Numpy question: Best hardware for Numpy?

2009-09-21 Thread David Cournapeau
On Mon, Sep 21, 2009 at 8:59 PM, Romain Brette wrote: > David Warde-Farley a écrit : >> On 20-Sep-09, at 2:17 PM, Romain Brette wrote: >> >>> Would anyone have thoughts about what the best hardware would be for >>> Numpy? In >>> particular, I am wondering about Intel Core i7 vs Xeon. Also, I feel

Re: [Numpy-discussion] Numpy question: Best hardware for Numpy?

2009-09-21 Thread René Dudfield
hi, Definitely memory speed is probably the biggest thing to consider. Also using 64bit if you need to do lots of calculations, and cache things. ACML is another alternative... but I've never tried linking it with numpy http://developer.amd.com/cpu/Libraries/acml/Pages/default.aspx AMD Phenom II

Re: [Numpy-discussion] Numpy question: Best hardware for Numpy?

2009-09-21 Thread Francesc Alted
A Monday 21 September 2009 13:59:39 Romain Brette escrigué: > David Warde-Farley a écrit : > > On 20-Sep-09, at 2:17 PM, Romain Brette wrote: > >> Would anyone have thoughts about what the best hardware would be for > >> Numpy? In > >> particular, I am wondering about Intel Core i7 vs Xeon. Also, I

[Numpy-discussion] fixed-point arithmetic

2009-09-21 Thread Neal Becker
One thing I'm really missing is something like matlab's fixed-pt toolbox. I'd love to see this added to numpy. A fixed point integer (fpi) type is based on an integer, but keeps track of where the 'binary point' is. When created, the fpi has a specified number of fractional bits and integer b

Re: [Numpy-discussion] Numpy question: Best hardware for Numpy?

2009-09-21 Thread Romain Brette
David Warde-Farley a écrit : > On 20-Sep-09, at 2:17 PM, Romain Brette wrote: > >> Would anyone have thoughts about what the best hardware would be for >> Numpy? In >> particular, I am wondering about Intel Core i7 vs Xeon. Also, I feel >> that the >> limiting factor might be memory speed and cach

Re: [Numpy-discussion] is ndarray.base the closest b ase or the ultimate base?

2009-09-21 Thread Hans Meine
Hi! On Monday 21 September 2009 12:31:27 Citi, Luca wrote: > I think you do not need to do the chain up walk on view creation. > If the assumption is that base is the ultimate base, on view creation > you can do something like (pseudo-code): > view.base = parent if parent.owndata else parent.base

[Numpy-discussion] something wrong with docs?

2009-09-21 Thread Neal Becker
I'm trying to read about subclassing. When I view http://docs.scipy.org/doc/numpy/user/basics.subclassing.html?highlight=subclass#module- numpy.doc.subclassing It seems the examples show the _outputs_ of tests, but I don't see the actual example code. e.g., the first example renders like this

Re: [Numpy-discussion] Best way to insert C code in numpy code

2009-09-21 Thread David Cournapeau
Xavier Gnata wrote: > Hi, > > I have a large 2D numpy array as input and a 1D array as output. > In between, I would like to use C code. > C is requirement because it has to be fast and because the algorithm > cannot be written in a numpy oriented way :( (no way...really). > > Which tool should I

Re: [Numpy-discussion] is ndarray.base the closest base or the ultimate base?

2009-09-21 Thread Citi, Luca
I think you do not need to do the chain up walk on view creation. If the assumption is that base is the ultimate base, on view creation you can do something like (pseudo-code): view.base = parent if parent.owndata else parent.base ___ NumPy-Discussion ma

Re: [Numpy-discussion] is ndarray.base the closest base or the ultimate base?

2009-09-21 Thread Pauli Virtanen
Mon, 21 Sep 2009 10:51:52 +0100, Citi, Luca wrote: > Thanks for your quick answer. > > Is there a reason for that? > Am I wrong or it only makes life harder, such as: > > while (PyArray_Check(base) && !PyArray_CHKFLAGS(base, NPY_OWNDATA)) { >base = PyArray_BASE(base); > } > > plus the possib

Re: [Numpy-discussion] is ndarray.base the closest base or the ultimate base?

2009-09-21 Thread Citi, Luca
Thanks for your quick answer. Is there a reason for that? Am I wrong or it only makes life harder, such as: while (PyArray_Check(base) && !PyArray_CHKFLAGS(base, NPY_OWNDATA)) { base = PyArray_BASE(base); } plus the possible error you underlined, plus the fact that this keeps a chain of zo

Re: [Numpy-discussion] string arrays - accessing data from C++

2009-09-21 Thread Jaroslav Hajek
On Fri, Sep 18, 2009 at 10:26 PM, Christopher Barker wrote: > Jaroslav Hajek wrote: string lengths determined >>> c-style null termination >>> >> >> Hmm, this didn't seem to work for me. But maybe I was doing something >> else wrong. Thanks. > > well, I notice that for a length-n string, if t

Re: [Numpy-discussion] is ndarray.base the closest base or the ultimate base?

2009-09-21 Thread Pauli Virtanen
Mon, 21 Sep 2009 09:35:47 +0100, Citi, Luca wrote: > I cannot quite understand whether ndarray.base is the closest base, the > one from which the view was made or the ultimate base, the one actually > containing the data. > I think the documentation and the actual behaviour mismatch. The closest b

[Numpy-discussion] is ndarray.base the closest base or the ultimate base?

2009-09-21 Thread Citi, Luca
Hello, I cannot quite understand whether ndarray.base is the closest base, the one from which the view was made or the ultimate base, the one actually containing the data. I think the documentation and the actual behaviour mismatch. In [1]: import numpy as np In [2]: x = np.arange(12) In [3]: y =

Re: [Numpy-discussion] PyArray_AsCArray (cfunction, in Array API) in Numpy User Guide

2009-09-21 Thread Takafumi Arakaki
Hi, I wrote sample code and it works fine. This is my code, in case anyone else want to know how to use it: #include #include "structmember.h" #include static PyObject * print_a1(PyObject *dummy, PyObject *args) { npy_intp dims[3]; /* PyArray_AsCArray is for ndim <= 3 */ int typenum; int