Tagged Questions
3
votes
0answers
17 views
Access a Numpy Recarray via the C-API
If we have a Numpy recarray:
x = np.array([(1.,2.)], dtype=np.dtype([('a','<f8'),('b','<f8')]))
We can access its fields in Pythan as:
x['a'] or x['b']
But if this array is passed to a C program ...
2
votes
2answers
31 views
Fast peak-finding and centroiding in python
I am trying to develop a fast algorithm in python for finding peaks in an image and then finding the centroid of those peaks. I have written the following code using the scipy.ndimage.label and ...
7
votes
2answers
70 views
Chose the farthest k points from given n points
I have a set S of n points in dimension d for which I can calculate all pairwise distances if need be. I need to select k points in this set so that the sum of their pairwise distances is maximal. In ...
0
votes
2answers
19 views
pip dependency resolution fails when install both numpy and matplotlib
Starting from a clean python 2.7.3 installation, if I run
pip install -r requirements.txt
with the following requirements.txt:
Flask==0.10.1
Flask-Cache==0.12
Jinja2==2.7.1
MarkupSafe==0.18
...
1
vote
0answers
20 views
How do I define a numba class with ndarray arguments and/or output?
I tried this:
import numpy as np
import numba
@numba.jit
class foo(object):
@numba.void(numba.int32)
def __init__(self, somenum):
self.somenumarray = np.arange(somenum)
...
4
votes
3answers
54 views
Hot to generate equispaced interpolating values
I have a list of (x,y) values that are not uniformly spaced. Here is the archive used in this question.
I am able to interpolate between the values but what I get are not equispaced interpolating ...
3
votes
2answers
50 views
Iterate on an array with two implicit loops
Is it possible to iterate implicitly on an array with two indices?
Here is a very simple example of what I would like to do :
import numpy as np
x = np.arange(3)
y = np.zeros(3)
for i in range(3):
...
2
votes
1answer
25 views
Building one array out of several. Monte-Carlo method
Suppose we have several arrays (in my case, three: a1, a2, a3). We also have one more array of random uniformly distributed numbers, r. They are all of the same length. I need to build an array a ...
4
votes
4answers
52 views
numpy: how to select rows based on a bunch of criteria
How can I fetch the rows for which the second column equals to 4 or 6?
a = np.array(np.mat('1 2; 3 4; 5 6; 7 4'))
b = [4,6]
Apparently, this does not work:
c = a[a[:,1] in b]
0
votes
1answer
25 views
python 2.7 mac osx interactive plotting with matplotlib not working
From here I found this code:
import random
from matplotlib import pyplot as plt
import numpy as np
plt.ion() # interactive mode
ydata = [0] * 50
# make plot
ax1 = plt.axes()
line, = ...
1
vote
3answers
26 views
Making a numpy array with mixed types and writing it as csv
I am trying to create a numpy array to hold different types like this:
na_csv_output = np.zeros((len(ldt_timestamps),1),dtype=('i4,i4,i4,a10,a10,i4'))
The problem with this is that all 6 values are ...
3
votes
0answers
52 views
Problems using Python to solve coupled delay differential equations (DDEs)
I am trying to use pydelay library to solve a system of delay differential equations. I have followed instructions to setup my model. However, I ran into some errors and really appreciate any ...
0
votes
2answers
40 views
Load CSV to Pandas MultiIndex DataFrame
I have a 719mb CSV file that looks like:
from, to, dep, freq, arr, code, mode (header row)
RGBOXFD,RGBPADTON,127,0,27,99999,2
RGBOXFD,RGBPADTON,127,0,33,99999,2
RGBOXFD,RGBRDLEY,127,0,1425,99999,2
...
5
votes
2answers
52 views
Find minimum distance from point to complicated curve
I have a complicated curve defined as a set of points in a table like so (the full table is here):
# x y
1.0577 12.0914
1.0501 11.9946
1.0465 11.9338
...
If I plot this table with the ...
0
votes
2answers
47 views
Delete elements from numpy array by value [duplicate]
I have two numpy arrays that represent 2D coordinates. Each row represents (x, y) pairs:
a = np.array([[1, 1], [2, 1], [3, 1], [3, 2], [3, 3], [5, 5]])
b = np.array([[1, 1], [5, 5], [3, 2]])
I ...