Tagged Questions
0
votes
1answer
12 views
numpy ravel versus flat in slice assignment
According to the documentation, ndarray.flat is an iterator over the array while ndarray.ravel returns a flattened array (when possible). So my question is, when should we use one or the other?
Which ...
1
vote
3answers
30 views
Find ordered vector in numpy array
I need to find a vector in a numpy.array.
For example, I have a np.array named e and I want to find the vector [1, 2] in e (meaning that I would like to have the index of the vector inside the ...
2
votes
1answer
31 views
Iterating through dictionary and numpy array simultaneously
Is there a slick way of iterating through a dictionary of objects, calling a member function of each object and assigning the value to a numpy array. I have the following member function code:
# ...
2
votes
0answers
18 views
numpy ndarray subclass ufunc that return scalar type
For numpy.ndarray subclass, ufunc outputs have the same type. This is good in general but I would like for ufunc with scalar output to return scalar type (such as numpy.float64).
Example:
import ...
1
vote
2answers
26 views
Sum ndarray values
Is there an easier way to get the sum of all values (assuming they are all numbers) in an ndarray :
import numpy as np
m = np.array([[1,2],[3,4]])
result = 0
(dim0,dim1) = m.shape
for i in ...
0
votes
1answer
25 views
Numpy Pandas install fails with Sandbox violation on /dev/null
I'm attempting to install numpy and pandas to a Jenkins server through requirements.txt. However it's failing on the below 2 lines in the file.
numpy>=1.6.1
pandas==0.12.0
The output being:
...
2
votes
1answer
32 views
Finding the intersection of a curve from polyfit
This seems simple but I can't quite figure it out. I have a curve calculated from x,y data. Then I have a line. I want to find the x, y values for where the two intersect.
Here is what I've got so ...
2
votes
1answer
37 views
Why calculations of eigenvectors of a 2 by 2 matrix with numpy crashes my Python session?
I try to do the following:
import numpy as np
from numpy import linalg as la
w, v = la.eig(np.array([[1, -1], [1, 1]]))
As a result I have a crash of the python session with the following message:
...
1
vote
2answers
43 views
Initializing 2D array to hold a list in each location
Can I create a numpy array that stores a list (initially empty) in each location?
According to the documentation, numpy arrays store homogeneous types, so I would imagine that this is possible. But I ...
2
votes
6answers
81 views
Get x,y,value 1D arrays from 2D numpy array (linear indexing)
Say I have a 2D array like the one below:
array([3, 6, 7
1,-1, 3])
I would like to get in 3 separate arrays the x, y and value of the array . In other words:
x = [0, 1, 0, 1, 0, 1]
y ...
7
votes
1answer
39 views
fitting data with numpy
Let me start by telling that what I get may not be what I expect and perhaps you can help me here. I have the following data:
>>> x
array([ 3.08, 3.1 , 3.12, 3.14, 3.16, 3.18, 3.2 , ...
3
votes
1answer
152 views
Numpy/Scipy Sparse vs dense multiplication
There appears to be some discrepancies between the scipy sparse matrix types and the normal numpy matrix type
import scipy.sparse as sp
A = sp.dia_matrix(tri(3,4))
vec = array([1,2,3,4])
print A * ...
10
votes
5answers
613 views
What's an efficient way to find if a point lies in the convex hull of a point cloud?
I have a point cloud of coordinates in numpy. For a high number of points, I want to find out if the points lie in the convex hull of the point cloud.
I tried pyhull but I cant figure out how to ...
4
votes
1answer
2k views
How to use python numpy.savetxt to write strings and float number to an ASCII file?
I have a set of lists that contain both strings and float numbers, such as:
import numpy as num
NAMES = num.array(['NAME_1', 'NAME_2', 'NAME_3'])
FLOATS = num.array([ 0.5 , 0.2 , 0.3 ])
...
2
votes
2answers
293 views
python numpy.convolve to solve convolution integral with limits from 0 to t instead -t to t
I have a convolution integral of the type:
To solve this integral numerically, I would like to use numpy.convolve(). Now, as you can see in the online help, the convolution is formally done from ...