Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread Ian Henriksen
On Mon, Oct 13, 2014 at 8:39 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Oct 13, 2014 at 12:54 PM, Sebastian Berg sebast...@sipsolutions.net wrote: On Mo, 2014-10-13 at 13:35 +0200, Daniele Nicolodi wrote: Hello, I have a C++ application that collects float, int or

Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread Stefan Seefeld
On Oct 14, 2014 4:40 AM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Oct 13, 2014 at 12:54 PM, Sebastian Berg sebast...@sipsolutions.net wrote: On Mo, 2014-10-13 at 13:35 +0200, Daniele Nicolodi wrote: Hello, I have a C++ application that collects float, int or complex

Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread Daniele Nicolodi
On 14/10/14 04:39, Charles R Harris wrote: On Mon, Oct 13, 2014 at 12:54 PM, Sebastian Berg sebast...@sipsolutions.net mailto:sebast...@sipsolutions.net wrote: On Mo, 2014-10-13 at 13:35 +0200, Daniele Nicolodi wrote: Hello, I have a C++ application that collects float,

[Numpy-discussion] numpy.mean slicing in a netCDF file

2014-10-14 Thread Fadzil Mnor
Hi all, I wrote a script and plot monthly mean zonal wind (from a netcdf file names uwnd.mon.mean.nc) and I'm not sure if I'm doing it correctly. What I have: *#this part calculates mean values for january only, from

Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread Nathaniel Smith
If the goal is to have something that works kind of like the new buffer protocol but with a wider variety of python versions, then you might find the old array interface useful: http://docs.scipy.org/doc/numpy/reference/arrays.interface.html I always get confused by the history here but I believe

Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread Daniele Nicolodi
On 14/10/14 13:39, Nathaniel Smith wrote: If the goal is to have something that works kind of like the new buffer protocol but with a wider variety of python versions, then you might find the old array interface useful: http://docs.scipy.org/doc/numpy/reference/arrays.interface.html I

Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread John Zwinck
On Tue, Oct 14, 2014 at 6:19 PM, Daniele Nicolodi dani...@grinta.net wrote: On Mo, 2014-10-13 at 13:35 +0200, Daniele Nicolodi wrote: I have a C++ application that collects float, int or complex data in a possibly quite large std::vector. The application has some SWIG

Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread Daniele Nicolodi
On 14/10/14 14:11, Daniele Nicolodi wrote: On 14/10/14 13:39, Nathaniel Smith wrote: If the goal is to have something that works kind of like the new buffer protocol but with a wider variety of python versions, then you might find the old array interface useful:

Re: [Numpy-discussion] Best way to expose std::vector to be used with numpy

2014-10-14 Thread Toby St Clere Smithe
John Zwinck jzwi...@gmail.com writes: Some time ago I needed to do something similar. I fused the NumPy C API and Boost.Python with a small bit of code which I then open-sourced as part of a slightly larger library. The most relevant part for you is here:

Re: [Numpy-discussion] Changed behavior of np.gradient

2014-10-14 Thread Charles R Harris
On Sat, Oct 4, 2014 at 3:16 PM, Stéfan van der Walt ste...@sun.ac.za wrote: On Oct 4, 2014 10:14 PM, Derek Homeier de...@astro.physik.uni-goettingen.de wrote: +1 for an order=2 or maxorder=2 flag If you parameterize that flag, users will want to change its value (above two). Perhaps

Re: [Numpy-discussion] Changed behavior of np.gradient

2014-10-14 Thread Nathaniel Smith
On 4 Oct 2014 22:17, Stéfan van der Walt ste...@sun.ac.za wrote: On Oct 4, 2014 10:14 PM, Derek Homeier de...@astro.physik.uni-goettingen.de wrote: +1 for an order=2 or maxorder=2 flag If you parameterize that flag, users will want to change its value (above two). Perhaps rather use a

Re: [Numpy-discussion] Changed behavior of np.gradient

2014-10-14 Thread Charles R Harris
On Tue, Oct 14, 2014 at 10:57 AM, Nathaniel Smith n...@pobox.com wrote: On 4 Oct 2014 22:17, Stéfan van der Walt ste...@sun.ac.za wrote: On Oct 4, 2014 10:14 PM, Derek Homeier de...@astro.physik.uni-goettingen.de wrote: +1 for an order=2 or maxorder=2 flag If you parameterize

Re: [Numpy-discussion] Changed behavior of np.gradient

2014-10-14 Thread Nathaniel Smith
On 14 Oct 2014 18:29, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Oct 14, 2014 at 10:57 AM, Nathaniel Smith n...@pobox.com wrote: On 4 Oct 2014 22:17, Stéfan van der Walt ste...@sun.ac.za wrote: On Oct 4, 2014 10:14 PM, Derek Homeier de...@astro.physik.uni-goettingen.de

Re: [Numpy-discussion] numpy.mean slicing in a netCDF file

2014-10-14 Thread Stephan Hoyer
Hi Fadzil, My strong recommendation is that you don't just use numpy/netCDF4 to process your data, but rather use one of a multitude of packages that have been developed specifically to facilitate working with labeled data from netCDF files: - Iris: http://scitools.org.uk/iris/ - CDAT:

Re: [Numpy-discussion] numpy.mean slicing in a netCDF file

2014-10-14 Thread Fadzil Mnor
Thank you Stephan, I've been trying to install IRIS on my laptop (OS X) for months. Errors everywhere. I'll look at that IRIS again, and other links. Cheers, Fadzil On Tue, Oct 14, 2014 at 7:09 PM, Stephan Hoyer sho...@gmail.com wrote: Hi Fadzil, My strong recommendation is that you don't

[Numpy-discussion] array indexing question

2014-10-14 Thread Neal Becker
I'm using np.nonzero to construct the tuple: (array([0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2]), array([1, 3, 5, 7, 2, 3, 6, 7, 4, 5, 6, 7])) Now what I want is the 2-D index array: [1,3,5,7, 2,3,6,7, 4,5,6,7] Any ideas? -- -- Those who don't understand recursion are doomed to repeat it

Re: [Numpy-discussion] array indexing question

2014-10-14 Thread Nathaniel Smith
For this to work at all you have to know a priori that there are the same number of non-zero entries in each row of your mask. Given that you know that, isn't it just a matter of calling reshape on the second array? On 14 Oct 2014 20:37, Neal Becker ndbeck...@gmail.com wrote: I'm using

Re: [Numpy-discussion] Changed behavior of np.gradient

2014-10-14 Thread Charles R Harris
On Tue, Oct 14, 2014 at 11:50 AM, Nathaniel Smith n...@pobox.com wrote: On 14 Oct 2014 18:29, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Oct 14, 2014 at 10:57 AM, Nathaniel Smith n...@pobox.com wrote: On 4 Oct 2014 22:17, Stéfan van der Walt ste...@sun.ac.za wrote: