Re: [Numpy-discussion] after building from source, how to register numpy with synaptic?
On Fri, Apr 24, 2009 at 10:11:07PM -0400, Chris Colbert wrote: Like the subject says, is there a way to register numpy with synaptic after building numpy from source? Don't play with the system's packaging system unless you really know what you are doing. Just install the numpy you are building outside of /usr/lib/... (you should never be installing home-build stuff in there). For instance install it in /usr/local: sudo python setup.py install --prefix /usr/local Now it will override the system's numpy. So you can install matplotlib, which will drag along the system's numpy, but you won't see it. On a side note, I tend to install home-built packages that overide system packages only in my home. I have a $HOME/usr directory, with a small directory hierarchy (usr/lib, usr/bin, ...), it is added in my PATH and PYTHONPATH, and I install there. Gaël ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] after building from source, how to register numpy with synaptic?
On Apr 25, 2009, at 5:36 AM, Gael Varoquaux wrote: On Fri, Apr 24, 2009 at 10:11:07PM -0400, Chris Colbert wrote: Like the subject says, is there a way to register numpy with synaptic after building numpy from source? Don't play with the system's packaging system unless you really know what you are doing. Just install the numpy you are building outside of /usr/lib/... (you should never be installing home-build stuff in there). One link: http://www.doughellmann.com/projects/virtualenvwrapper/ I became a fan of virtualenvs, which lets you install different packages (not always compatible) without messing up the system's Python. Quite useful for tests and/or having multiple numpy versions in parallel. For instance install it in /usr/local: sudo python setup.py install --prefix /usr/local Now it will override the system's numpy. So you can install matplotlib, which will drag along the system's numpy, but you won't see it. On a side note, I tend to install home-built packages that overide system packages only in my home. I have a $HOME/usr directory, with a small directory hierarchy (usr/lib, usr/bin, ...), it is added in my PATH and PYTHONPATH, and I install there. Gaël ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Distance Formula on an Array
Hi, I have an array sized n*3. Each three-component is a 3D position. Given another 3D position, how is the distance between it and every three-component in the array found with NumPy? So, for example, if the array is: [[0,0,0],[0,1,0],[0,0,3]] And the position is: [0,4,0] I need this array out: [4,3,5] (Just a simple Pythagorean Distance Formula) Ideas? Thanks, Ian ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Distance Formula on an Array
On Sat, Apr 25, 2009 at 12:50 PM, Ian Mallett geometr...@gmail.com wrote: Hi, I have an array sized n*3. Each three-component is a 3D position. Given another 3D position, how is the distance between it and every three-component in the array found with NumPy? So, for example, if the array is: [[0,0,0],[0,1,0],[0,0,3]] And the position is: [0,4,0] I need this array out: [4,3,5] (Just a simple Pythagorean Distance Formula) In [3]: vec = array([[0,0,0],[0,1,0],[0,0,3]]) In [4]: pos = array([0,4,0]) In [5]: sqrt(((vec - pos)**2).sum(1)) Out[5]: array([ 4., 3., 5.]) Chuck ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Distance Formula on an Array
On Sat, Apr 25, 2009 at 3:57 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Sat, Apr 25, 2009 at 12:50 PM, Ian Mallett geometr...@gmail.com wrote: Hi, I have an array sized n*3. Each three-component is a 3D position. Given another 3D position, how is the distance between it and every three-component in the array found with NumPy? So, for example, if the array is: [[0,0,0],[0,1,0],[0,0,3]] And the position is: [0,4,0] I need this array out: [4,3,5] (Just a simple Pythagorean Distance Formula) In [3]: vec = array([[0,0,0],[0,1,0],[0,0,3]]) In [4]: pos = array([0,4,0]) In [5]: sqrt(((vec - pos)**2).sum(1)) Out[5]: array([ 4., 3., 5.]) if scipy is permitted: a = np.array([[0,0,0],[0,1,0],[0,0,3]]) scipy.spatial.distance_matrix(a, [[0,4,0]]) array([[ 4.], [ 3.], [ 5.]]) scipy.spatial.minkowski_distance(a, [0,4,0]) array([ 4., 3., 5.]) Josef ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Distance Formula on an Array
On Sat, Apr 25, 2009 at 12:57 PM, Charles R Harris charlesr.har...@gmail.com wrote: In [3]: vec = array([[0,0,0],[0,1,0],[0,0,3]]) In [4]: pos = array([0,4,0]) In [5]: sqrt(((vec - pos)**2).sum(1)) Out[5]: array([ 4., 3., 5.]) Chuck On Sat, Apr 25, 2009 at 1:00 PM, josef.p...@gmail.com wrote: if scipy is permitted: a = np.array([[0,0,0],[0,1,0],[0,0,3]]) scipy.spatial.distance_matrix(a, [[0,4,0]]) array([[ 4.], [ 3.], [ 5.]]) scipy.spatial.minkowski_distance(a, [0,4,0]) array([ 4., 3., 5.]) Josef Thanks you two. I'm going to guess SciPy might be faster (?), but unfortunately it's not going to be available. Thanks, though. Problem solved. Thanks again, Ian ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Distance Formula on an Array
Oops, one more thing. In reference to: vec = array([[0,0,0],[0,1,0],[0,0,3]]) pos = array([0,4,0]) sqrt(((vec - pos)**2).sum(1)) - array([ 4., 3., 5.]) Can I make vec an array of class instances? I tried: class c: def __init__(self): self.position = [0,0,0] vec = array([c(),c(),c()]) pos = array([0,4,0]) sqrt(((vec.position - pos)**2).sum(1)) Which doesn't work. I'm not familiar with class objects in arrays--how should they be referenced? Thanks again, Ian ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Distance Formula on an Array
On Sat, Apr 25, 2009 at 4:38 PM, Ian Mallett geometr...@gmail.com wrote: Oops, one more thing. In reference to: vec = array([[0,0,0],[0,1,0],[0,0,3]]) pos = array([0,4,0]) sqrt(((vec - pos)**2).sum(1)) - array([ 4., 3., 5.]) Can I make vec an array of class instances? I tried: class c: def __init__(self): self.position = [0,0,0] vec = array([c(),c(),c()]) pos = array([0,4,0]) sqrt(((vec.position - pos)**2).sum(1)) Which doesn't work. I'm not familiar with class objects in arrays--how should they be referenced? I never work with object arrays. I think they will kill your performance if you need fast calculation for many positions. list comprehension works: print [sqrt(((v.position - pos)**2).sum()) for v in vec] I didn't find any other way either. Josef ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion