Re: [Numpy-discussion] Find insertion point

2010-08-17 Thread Lane Brooks
On 08/17/2010 09:53 AM, Nikolaus Rath wrote: Hello, I want to find the first i such that x[i] y and x[i+1]= y. Is there a way to do this without using a Python loop? I can't use np.searchsorted(), because my x array crosses y several times. Best, -Nikolaus i =

[Numpy-discussion] Masked Array Usage Problems

2010-04-10 Thread Lane Brooks
I am trying out masked arrays for the first time and having some problems. I have a 2-D image as dtype=numpy.int16 I create a mask of all False to not mask out any pixels. I calculate the mean of the image original image and it comes out ~597. I calculate the mean of the masked array and it

Re: [Numpy-discussion] Masked Array Usage Problems

2010-04-10 Thread Lane Brooks
On Apr 10, 2010, at 5:17 AM, josef.p...@gmail.com wrote: On Sat, Apr 10, 2010 at 3:49 AM, Lane Brooks l...@brooks.nu wrote: I am trying out masked arrays for the first time and having some problems. I have a 2-D image as dtype=numpy.int16 I create a mask of all False to not mask out any

Re: [Numpy-discussion] Line of best fit!

2008-12-09 Thread Lane Brooks
James wrote: Hi, Thanks for all your help so far! Right i think it would be easier to just show you the chart i have so far; -- import numpy as np import matplotlib.pyplot as plt plt.plot([4,8,12,16,20,24], [0.008,0.016,0.021,0.038,0.062,0.116], 'bo')

Re: [Numpy-discussion] numpy CAPI questions

2008-10-20 Thread Lane Brooks
Travis E. Oliphant wrote: Lane Brooks wrote: I am using the numpy CAPI to write an extension module that returns a numpy Array from an imaging data source. I collect the image into a buffer that I allocate. I then create numpy Array using the PyArray_New(..) function and pass

[Numpy-discussion] numpy CAPI questions

2008-10-19 Thread Lane Brooks
questions: 1. Does NPY_OWNDATA mean that the object will deallocate the memory when the object is deleted? The manual seems to indicate that as such but it is not explicitly stated. 2. Is my reference counting correct? Do I need to call the PyArray_INCREF() on img? Thanks, Lane Brooks

Re: [Numpy-discussion] Getting an array's indices when a given condition is true

2008-10-18 Thread Lane Brooks
If you want the indexes, check out the np.where command, e.g. idx = np.where(dat = limit) If you want the values, use: val = dat[dat = limit] Lane Michael wrote: Hi list, been playing around with stride_tricks and find it terrifically productive; thankyou to everyone who has worked on

[Numpy-discussion] Images and numpy

2008-10-18 Thread Lane Brooks
What are the preferred ways to get images, like jpgs and pngs, from disk into a numpy array and from a numpy array to disk? I did some google searches and found a PEP thread where Travis was proposing an extended buffer protocol that would make for easier interoperability with libraries such

Re: [Numpy-discussion] Images and numpy

2008-10-18 Thread Lane Brooks
Robert Kern wrote: On Sat, Oct 18, 2008 at 23:07, Lane Brooks [EMAIL PROTECTED] wrote: What are the preferred ways to get images, like jpgs and pngs, from disk into a numpy array and from a numpy array to disk? I did some google searches and found a PEP thread where Travis was proposing

Re: [Numpy-discussion] Data types in Numerical Python

2008-10-12 Thread Lane Brooks
Linda Seltzer wrote: Here is an example that works for any working numpy installation: import numpy as npy npy.zeros((256, 256)) This suggestion from David did work so far, and removing the other import line enabled the program to run. However, the data types the program used as defaults

[Numpy-discussion] Dealing with types in extension modules

2008-09-10 Thread Lane Brooks
When writing an numpy extension module, what is the preferred way to deal with the all the possible types an ndarray can have? I have some data processing functions I need to implement and they need to be generic and work for all the possible numerical dtypes. I do not want to have to

Re: [Numpy-discussion] Dealing with types in extension modules

2008-09-10 Thread Lane Brooks
Travis E. Oliphant wrote: Lane Brooks wrote: When writing an numpy extension module, what is the preferred way to deal with the all the possible types an ndarray can have? I have some data processing functions I need to implement and they need to be generic and work for all the possible

Re: [Numpy-discussion] Dealing with types in extension modules

2008-09-10 Thread Lane Brooks
Travis E. Oliphant wrote: Lane Brooks wrote: Travis E. Oliphant wrote: Lane Brooks wrote: When writing an numpy extension module, what is the preferred way to deal with the all the possible types an ndarray can have? I have some data processing functions I need

[Numpy-discussion] CAPI segfault running python embedded

2008-06-20 Thread Lane Brooks
I have successfully written several extension modules that use the numpy CAPI to manipulate numpy arrays. I have to say numpy is great. I am now having a problem, however, when calling numpy capi functions when running python embedded in a third party, closed source, application. It

Re: [Numpy-discussion] CAPI segfault running python embedded

2008-06-20 Thread Lane Brooks
David Cournapeau wrote: Lane Brooks wrote: I have successfully written several extension modules that use the numpy CAPI to manipulate numpy arrays. I have to say numpy is great. I am now having a problem, however, when calling numpy capi functions when running python embedded