Re: [Numpy-discussion] numpy.fromiter in numpypy

2015-01-01 Thread Matti Picus
In general, you will find more help on pypy-related questions in a pypy-related communication channel like pypy-...@python.org or visiting us on IRC at #pypy. This is a known issue with the numpy-status page, since you are not the first to notice I will try to fix it soon

[Numpy-discussion] numpy developers

2015-01-01 Thread Charles R Harris
Hi All, I've invited Alex Griffing onto the team to be a numpy developer. He has been contributing fixes and reviews for a while and it is time to give him more opportunity to contribute. I think he will do well. Chuck ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Yuxiang Wang
1) @Strula Sorry about my stupid mistake! That piece of code totally gave away how green I am in coding C :) And yes, that piece of code works like a charm now! I am able to run my model. Thanks a million! 2) @Strula and also thanks for your insight on the limitation of the method. Currently I am

Re: [Numpy-discussion] Access dtype kind from cython

2015-01-01 Thread Nathaniel Smith
On Thu, Jan 1, 2015 at 7:38 PM, Valentin Haenel wrote: [...] > So, I actually discovered an additional ugly workaround. Basically it > turns out, that my dtype instance does have a 'kind' attribute, but it > is a Python str object. Hence I needed to do: > > ord(dtype_.kind[0]) Your Cython dtype

[Numpy-discussion] The future of ndarray.diagonal()

2015-01-01 Thread Alexander Belopolsky
A discussion [1] is currently underway at GitHub which will benefit from a larger forum. In version 1.9, the diagonal() method was changed to return a read-only (non-contiguous) view into the original array instead of a plain copy. Also, it has been announced [2] that in 1.10 the view will become

Re: [Numpy-discussion] npymath on Windows

2015-01-01 Thread Sturla Molden
On 28/12/14 17:17, David Cournapeau wrote: > This is not really supported. You should avoid mixing compilers when > building C extensions using numpy C API. Either all mingw, or all MSVC. That is not really good enough. Even if we build binary wheels with MinGW (see link) the binary npymath libr

Re: [Numpy-discussion] npymath on Windows

2015-01-01 Thread Sturla Molden
On 28/12/14 01:59, Matthew Brett wrote: > As far as I can see, 'acosf' is defined in the msvc runtime library. > I guess that '_acosf' is defined in some mingw runtime library? AFAIK it is a GCC built-in function. When the GCC compiler or linker sees it the binary code will be inlined. https://

[Numpy-discussion] numpy.fromiter in numpypy

2015-01-01 Thread Albert-Jan Roskam
Hi, I would like to use the numpy implementation for Pypy. In particular, I would like to use numpy.fromiter, which is available according to this overview: http://buildbot.pypy.org/numpy-status/latest.html. However, contrary to what this website says, this function is not yet available. Conclu

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Sturla Molden
On 01/01/15 19:56, Nathaniel Smith wrote: > However, I suspect that this question can't really be answered in a > useful way without more information about why exactly the C code wants > a **double (instead of a *double) and what it expects to do with it. > E.g., is it going to throw away the pas

Re: [Numpy-discussion] Access dtype kind from cython

2015-01-01 Thread Valentin Haenel
Hi, * Nathaniel Smith [2014-12-31]: > On Tue, Dec 30, 2014 at 11:03 PM, Valentin Haenel wrote: > > * Eric Moore [2014-12-30]: > >> On Monday, December 29, 2014, Valentin Haenel wrote: > >> > >> > Hi, > >> > > >> > how do I access the kind of the data from cython, i.e. the single > >> > charact

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Sturla Molden
On 01/01/15 20:25, Yuxiang Wang wrote: > #include > > __declspec(dllexport) void foobar(const int m, const int n, const > double **x, double **y) > { > size_t i, j; > y = (** double)malloc(sizeof(double *) * m); > for(i=0; i y[i] = (*double)calloc(sizeof(double), n); >

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Yuxiang Wang
Great thanks to both Strula and also Nathaniel! @Strula, thanks for your help! And I do think your solution makes total sense. However, the code doesn't work well on my computer. // dummy.c #include __declspec(dllexport) void foobar(const int m, const int n, const double **x, d

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Nathaniel Smith
On Thu, Jan 1, 2015 at 6:00 PM, Yuxiang Wang wrote: > Dear all, > > I am currently using a piece of C code, where one of the input > argument of a function is **double. As you discovered, Numpy's ctypes utilities are helpful for getting a *double out of an ndarray, but they don't really have anyt

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Sturla Molden
On 01/01/15 19:00, Yuxiang Wang wrote: > Could anyone please give any thoughts to help? Say you want to call "void foobar(int m, int n, double **x)" from dummy.so or dummpy.dll with ctypes. Here is a fully worked out example (no tested, but is will work unless I made a typo): import numpy as np

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Sturla Molden
On 01/01/15 19:30, Sturla Molden wrote: > You can pretend double** is an array of dtype np.intp. This is because > on all modern systems, double** has the size of void*, and np.intp is an > integer with the size of void* (np.intp maps to Py_intptr_t). Well, it also requires that the user space is

Re: [Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Sturla Molden
You can pretend double** is an array of dtype np.intp. This is because on all modern systems, double** has the size of void*, and np.intp is an integer with the size of void* (np.intp maps to Py_intptr_t). Now you just need to fill in the adresses. If you have a 2d ndarray in C order, or at lea

[Numpy-discussion] Pass 2d ndarray into C **double using ctypes

2015-01-01 Thread Yuxiang Wang
Dear all, I am currently using a piece of C code, where one of the input argument of a function is **double. So, in numpy, I tried np.ctypeslib.ndpointer(ctypes.c_double), but obviously this wouldn't work because this is only *double, not **double. Then I tried np.ctypeslib.ndpointer(np.ctypesli