Re: [Numpy-discussion] Polar/spherical coordinates handling

2013-03-29 Thread Angus McMorland
On 29 March 2013 11:15, Todd wrote: > From what I can see, numpy doesn't have any functions for handling polar or > spherical coordinate to/from cartesian coordinate conversion. I think such > methods would be pretty useful. I am looking now and it doesn't look that > hard to create functions to

Re: [Numpy-discussion] Is there a way to reset an accumulate function?

2012-10-23 Thread Angus McMorland
On 23 October 2012 13:11, Cera, Tim wrote: > I have an array that is peppered throughout in random spots with 'nan'. I > would like to use 'cumsum', but I want it to reset the accumulation to 0 > whenever a 'nan' is encountered. Is there a way to do this? Aside from a > loop - which is what I a

Re: [Numpy-discussion] 2 greatest values, in a 3-d array, along one axis

2012-08-03 Thread Angus McMorland
On 3 August 2012 11:18, Jim Vickroy wrote: > Hello everyone, > > I'm trying to determine the 2 greatest values, in a 3-d array, along one > axis. > > Here is an approach: > > # -- > # procedure to determine greatest 2 values for 3rd dimension of

Re: [Numpy-discussion] numpy segfaults with ctypes

2011-08-22 Thread Angus McMorland
On 19 August 2011 16:11, Matthew Brett wrote: > Hi, > > On Fri, Aug 19, 2011 at 1:04 PM, Angus McMorland wrote: >> Hi all, >> >> I'm giving this email a new subject, in case that helps it catch the >> attention of someone who can fix my problem. I current

[Numpy-discussion] numpy segfaults with ctypes

2011-08-19 Thread Angus McMorland
Hi all, I'm giving this email a new subject, in case that helps it catch the attention of someone who can fix my problem. I currently cannot upgrade numpy from git to any date more recent than 10 July. Git commit feb8079070b8a659d7ee is the first that causes the problem (according to github, the c

[Numpy-discussion] numpy/ctypes segfault [was: PEP 3118 array size check]

2011-08-10 Thread Angus McMorland
On 10 August 2011 04:01, Pauli Virtanen wrote: > Mon, 08 Aug 2011 11:27:14 -0400, Angus McMorland wrote: >> I've just upgraded to the latest numpy from git along with upgrading >> Ubuntu to natty. Now some of my code, which relies on ctypes-wrapping of >> data structur

[Numpy-discussion] PEP 3118 array size check

2011-08-08 Thread Angus McMorland
Hi all, I've just upgraded to the latest numpy from git along with upgrading Ubuntu to natty. Now some of my code, which relies on ctypes-wrapping of data structures from a messaging system, fails with the error message: "RuntimeWarning: Item size computed from the PEP 3118 buffer format string d

Re: [Numpy-discussion] git source datetime build error

2011-06-07 Thread Angus McMorland
On 7 June 2011 17:57, Mark Wiebe wrote: > Hi Angus, > Thanks for reporting that, I've committed a fix so it builds in the > monolithic mode again. Thanks Mark. That fixed it for i686, but on x86_64 I get the following. Still looks datetime related. compile options: '-Ibuild/src.linux-x86_64-2.6/

[Numpy-discussion] git source datetime build error

2011-06-07 Thread Angus McMorland
Hi all, I'm experiencing a build failure from current numpy git, which seems to be datetime related. Here's the error message. creating build/temp.linux-i686-2.6/numpy/core/src/multiarray compile options: '-Inumpy/core/include -Ibuild/src.linux-i686-2.6/numpy/core/include/numpy -Inumpy/core/src/p

Re: [Numpy-discussion] *= operator not intuitive

2011-03-16 Thread Angus McMorland
On 16 March 2011 09:24, Paul Anton Letnes wrote: > Hi! > > This little snippet of code tricked me (in a more convoluted form). The *= > operator does not change the datatype of the left hand side array. Is this > intentional? It did fool me and throw my results quite a bit off. I always > assum

Re: [Numpy-discussion] Multiple Linear Regression

2011-03-16 Thread Angus McMorland
On 16 March 2011 02:53, dileep kunjaai wrote: > Dear sir, >  Can we do multiple linear regression(MLR)  in python is there any > inbuilt function for MLR Yes, you can use np.linalg.lstsq [1] for this. Here's a quick example: import numpy as np # model is y = b0.x0 + b1.x1 + b2.x2 b = np.arra

Re: [Numpy-discussion] Any easy way to do this?

2011-03-09 Thread Angus McMorland
On 9 March 2011 10:37, Neal Becker wrote: > Angus McMorland wrote: > >> On 9 March 2011 09:45, Neal Becker wrote: >>> given: w[i,j,k], y[l, k] >>> >>> find: >>> d[l,i,j] = norm(w[i,j] - y[l]) >>> >>> for each triple (l,i,j), w[i,j

Re: [Numpy-discussion] Any easy way to do this?

2011-03-09 Thread Angus McMorland
On 9 March 2011 09:45, Neal Becker wrote: > given: w[i,j,k], y[l, k] > > find: > d[l,i,j] = norm(w[i,j] - y[l]) > > for each triple (l,i,j), w[i,j]-y[l] is a vector, of which I want to find the > norm, and store into d[l,i,j] Is something like this what you want to do? w = np.random.randint(100,

[Numpy-discussion] permute and sum?

2011-02-28 Thread Angus McMorland
Hi all, I want to create a transpose of a vector, such that if the same index is given in the 'axes' list (as per np.transpose), then the sum of the original values sharing the same index is placed in the corresponding output index. For example: In: data = np.array([5, 7, 9, 6, 2]) In: order =

Re: [Numpy-discussion] Get the index of a comparison of two lists

2011-02-11 Thread Angus McMorland
On 11 February 2011 09:01, FRENK Andreas wrote: > Hi, > > I need to create a construct that returns the index of entries of the first > list, if values in the first and second list are equal. > > Take > > valA = [1,2,3,4,20,21,22,23,24] > valB = [1,2,3,4,  5,21,22,23] > The correct solution is: [0

Re: [Numpy-discussion] summing over more than one axis

2010-08-19 Thread Angus McMorland
On 19 August 2010 10:01, greg whittier wrote: > I frequently deal with 3D data and would like to sum (or find the > mean, etc.) over the last two axes.  I.e. sum a[i,j,k] over j and k. > I find using .sum() really convenient for 2d arrays but end up > reshaping 2d arrays to do this.  I know there

[Numpy-discussion] fancy indexing question

2010-08-17 Thread Angus McMorland
Hi all, I'm having a bit of a brain block about the following fancy indexing question, and am hoping someone can point me in the right direction. I have a 3-d array `a` that I want to reorder along its 0th dimension differently for each 1st dimension, with the indices given in a 2-d array `ord`. I

Re: [Numpy-discussion] Transpose Array How?

2010-06-23 Thread Angus McMorland
On 23 June 2010 16:13, Alan Bromborsky wrote: > Alan Bromborsky wrote: >> In the transpose function we have transpose(a,axis) where axis can be a >> list of integers.  But exactly what to the integers mean? If axis = >> [i1,i2] switching axis i1 with axis i2 is obvious, but what if axis = >> [i1,i

Re: [Numpy-discussion] indexing to sort with argsort(..., axis=1)

2010-04-13 Thread Angus McMorland
On 13 April 2010 04:01, Gökhan Sever wrote: > > > On Mon, Apr 12, 2010 at 9:41 PM, Angus McMorland wrote: > >> Hi all, >> >> I want to sort a 2d array along one dimension, with the indices returned >> by argsort, but the subsequent indexing syntax to ge

[Numpy-discussion] indexing to sort with argsort(..., axis=1)

2010-04-12 Thread Angus McMorland
Hi all, I want to sort a 2d array along one dimension, with the indices returned by argsort, but the subsequent indexing syntax to get the sorted array is not obvious. The following works, but I wonder if there is a simpler way: a = np.random.random(size=(5,3)) s = np.argsort(a, axis=1) sorted =

Re: [Numpy-discussion] Replacing NANs

2010-03-30 Thread Angus McMorland
On 30 March 2010 14:59, Vishal Rana wrote: > Hi, > In an array I want to replace all NANs with some number say 100, I found a > method nan_to_num but it only replaces with zero. > Any solution for this? ar[np.isnan(ar)] = my_num where ar is your array and my_num is the number you want to replace

Re: [Numpy-discussion] Syntax equivalent for np.array()

2010-02-10 Thread Angus McMorland
On 10 February 2010 11:02, Gökhan Sever wrote: > Hi, > > Simple question: > > I[4]: a = np.arange(10) > > I[5]: b = np.array(5) > > I[8]: a*b.cumsum() > O[8]: array([ 0,  5, 10, 15, 20, 25, 30, 35, 40, 45]) > > I[9]: np.array(a*b).cumsum() > O[9]: array([  0,   5,  15,  30,  50,  75, 105, 140, 180

[Numpy-discussion] Conversion of matlab import containing objects into 3d array

2010-02-05 Thread Angus McMorland
Hi all, I'm trying to import data from a matlab file using scipy.io.loadmat. One of the variables in the file imports as an array of shape (51,) of dtype object, with each element being an array of shape (23,100) of dtype float. How do I convert this array into a single array of dtype float with s

[Numpy-discussion] np.ma.apply_along_axis mask propagation

2010-01-27 Thread Angus McMorland
Hi all, I'm having an issue with np.ma.apply_along_axis not propagating a mask correctly. This code-snippet should hopefully show what's happening: import numpy as np xy = np.random.random(size=(5,2)) mask = np.tile(np.array([True] * 3 + [False] * 2)[:,None], (1,2)) xyma = np

Re: [Numpy-discussion] lstsq illegal instruction

2009-11-18 Thread Angus McMorland
2009/11/18 Robert Kern : > On Wed, Nov 18, 2009 at 15:15, Angus McMorland wrote: >> Hi all, >> >> Whenever I run numpy.linalg.lstsq with a xs parameter with both >> dimensions larger than 128, I get an "Illegal instruction" and python >> dies complet

[Numpy-discussion] lstsq illegal instruction

2009-11-18 Thread Angus McMorland
Hi all, Whenever I run numpy.linalg.lstsq with a xs parameter with both dimensions larger than 128, I get an "Illegal instruction" and python dies completely. It happens with both the Ubuntu jaunty standard numpy 1.2.1, and a recent svn 1.4.0.dev7727, but it doesn't seem to happen on any other mac

[Numpy-discussion] Pointer to array data for passing to swig-wrapped C++

2009-08-24 Thread Angus McMorland
Hi all, Our lab has an in-house messaging protocol, written in C++, for interfacing the different components of our experimental setups, and allowing programs written in several different languages to talk to each other. I'm currently trying to write a Python interface to this protocol, mainly so

Re: [Numpy-discussion] mean of two or more arrays while ignoring a specific value

2009-07-14 Thread Angus McMorland
2009/7/14 Greg Fiske : > Dear list, > > I’m learning to work with numpy arrays.  Can somebody explain how to get the > average of two separate arrays while ignoring a user defined value in one > array? > > For example: > a = numpy.array([1,5,4,99]) b = numpy.array([3,7,2,8]) > > Ignoring th

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

2008-12-08 Thread Angus McMorland
Hi James, 2008/12/8 James <[EMAIL PROTECTED]>: > > I have a very simple plot, and the lines join point to point, however i > would like to add a line of best fit now onto the chart, i am really new > to python etc, and didnt really understand those links! > > Can anyone help me :) It sounds like

Re: [Numpy-discussion] Masked array usage

2008-11-27 Thread Angus McMorland
2008/11/27 Robert Ferrell <[EMAIL PROTECTED]>: > I have a question about assigning to masked arrays. a is a len ==3 > masked array, with 2 unmasked elements. b is a len == 2 array. I > want to put the elements of b into the unmasked elements of a. How do > I do that? > > In [598]: a > Out[598]:

Re: [Numpy-discussion] import 16-bit tiff - byte-order problem?

2008-11-06 Thread Angus McMorland
2008/11/6 Robert Kern <[EMAIL PROTECTED]>: > On Thu, Nov 6, 2008 at 21:54, Angus McMorland <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> I'm trying to import a 16-bit tiff image into a numpy array. I have >> found, using google, suggestions to do th

[Numpy-discussion] import 16-bit tiff - byte-order problem?

2008-11-06 Thread Angus McMorland
Hi all, I'm trying to import a 16-bit tiff image into a numpy array. I have found, using google, suggestions to do the following: After starting with: i = Image.open('16bitGreyscaleImage.tif') Stéfan van der Walt suggested: a = np.array(i.getdata()).reshape(i.size) # a 1d numpy array and adap

Re: [Numpy-discussion] how to tell if a point is inside a polygon

2008-10-13 Thread Angus McMorland
2008/10/13 Mathew Yeates <[EMAIL PROTECTED]> > Is there a routine in scipy for telling whether a point is inside a > convex 4 sided polygon? Not specifically in scipy, as far as I know, but there are several supplementary packages that provide this functionality, including matplotlib: http://p

Re: [Numpy-discussion] Multiple Boolean Operations

2008-05-22 Thread Angus McMorland
2008/5/22 Andrea Gavana <[EMAIL PROTECTED]>: > Hi All, > >I am building some 3D grids for visualization starting from a much > bigger grid. I build these grids by satisfying certain conditions on > x, y, z coordinates of their cells: up to now I was using VTK to > perform this operation, but VT

Re: [Numpy-discussion] Debian Lenny switches to Python 2.5 default

2008-05-05 Thread Angus McMorland
2008/5/5 Keith Goodman <[EMAIL PROTECTED]>: > I'm the click of a botton away from changing the python default on my > Debian Lenny system from 2.4 to 2.5. Has anyone experienced any numpy > issues after the switch? All normal here so far, with most of a day's use. All numpy tests pass, and I ge

Re: [Numpy-discussion] Combining Sigmoid Curves

2008-05-02 Thread Angus McMorland
2008/5/2 Rich Shepard <[EMAIL PROTECTED]>: >When I last visited I was given excellent advice about Gaussian and other > bell-shaped curves. Upon further reflection I realized that the Gaussian > curves will not do; the curve does need to have y=0.0 at each end. > >I tried to apply a Beta

Re: [Numpy-discussion] Simple financial functions for NumPy

2008-04-04 Thread Angus McMorland
-1 for any functions added to numpy. As only an end-user, I realize I have little right to a say in these sorts of issues, but for whatever it may be worth, I strongly agree with Gael's viewpoint. We should be aiming towards modular systems for function distribution, and now that it seems that the

Re: [Numpy-discussion] display numpy array as image

2007-11-29 Thread Angus McMorland
On 30/11/2007, Zachary Pincus <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm curious if people have experience with / preferences for how to > display a numpy array onscreen as an image. I'm not sure if you're after anything specific, but a very convenient way to show 2-D arrays on screen is matp