Tagged Questions
12
votes
2answers
6k views
Inverse Distance Weighted (IDW) Interpolation with Python
The Question:
What is the best way to calculate inverse distance weighted (IDW) interpolation in Python, for point locations?
Some Background:
Currently I'm using RPy2 to interface with R and it's ...
56
votes
3answers
10k views
How do you use the ellipsis slicing syntax in Python?
This came up in Hidden features of Python, but I can't see good documentation or examples that explain how the feature works.
8
votes
4answers
2k views
Using strides for an efficient moving average filter
I recently learned about strides in the answer to this post, and was wondering how I could use them to compute a moving average filter more efficiently than what I proposed in this post (using ...
10
votes
4answers
2k views
Efficient Numpy 2D array construction from 1D array
I have an array like this:
A = array([1,2,3,4,5,6,7,8,9,10])
And I am trying to get an array like this:
B = array([[1,2,3],
[2,3,4],
[3,4,5],
[4,5,6]])
Where each ...
5
votes
3answers
4k views
Using numpy to build an array of all combinations of two arrays
I'm trying to run over the parameters space of a 6 parameter function to study it's numerical behavior before trying to do anything complex with it so I'm searching for a efficient way to do this.
My ...
18
votes
9answers
12k views
Python Numpy Very Large Matrices
Numpy is an extremely useful library, and from using it I've found that it's capable of handling matrices which are quite large (10000x10000) easily, but begins to struggle with anything much larger ...
10
votes
5answers
4k views
Simple wrapping of C code with cython
I have a number of C functions, and I would like to call them from python. cython seems to be the way to go, but I can't really find an example of how exactly this is done. My C function looks like ...
17
votes
1answer
2k views
Numpy: Should I use newaxis or None?
In numpy one can use the 'newaxis' object in the slicing syntax to create an axis of length one, e.g.:
import numpy as np
print np.zeros((3,5))[:,np.newaxis,:].shape
# shape will be (3,1,5)
The ...
7
votes
3answers
1k views
Equivalent of Numpy.argsort() in basic python?
hi is there a build'in function of python that does on python.array what argsort() does on a numpy.array?
4
votes
5answers
229 views
How to save big (not huge) dictonaries in Python?
My dictionary will consist of several thousand keys which each key having a 1000x1000 numpy array as value. I don't need the file to be human readable. Small size and fast loading times are more ...
8
votes
2answers
1k views
Use numpy array in shared memory for multiprocessing
I would like to use a numpy array in shared memory for use with the multiprocessing module. The difficulty is using it like a numpy array, and not just as a ctypes array.
from multiprocessing import ...
8
votes
3answers
2k views
How do I pass large numpy arrays between python subprocesses without saving to disk?
Is there a good way to pass a large chunk of data between two python subprocesses without using the disk? Here's a cartoon example of what I'm hoping to accomplish:
import sys, subprocess, numpy
...
8
votes
2answers
2k views
Reordering matrix elements to reflect column and row clustering in naiive python
I'm looking for a way to perform clustering separately on matrix rows and than on its columns, reorder the data in the matrix to reflect the clustering and putting it all together. The clustering ...
12
votes
5answers
3k views
the best shortest path algorithm
what is the difference between the "Floyd-Warshall algorithm" and "Dijkstra's Algorithm", and which is the best for finding the shortest path in a graph?
I need to calculate the shortest path between ...
5
votes
5answers
849 views
itertools product speed up
I use itertools.product to generate all possible variations of 4 elements of length 13. The 4 and 13 can be arbitrary, but as it is, I get 4^13 results, which is a lot. I need the result as a Numpy ...