All Questions
14 questions
2
votes
1
answer
268
views
Replace nested for loops when assigning intial conditions in a 4-dimensional array
I create a 4-dimensional (x, y, z, t) array of zero values. I then set the initial values at t = Tmax. To do this, I use a nested for loop. I attempted to improve ...
4
votes
1
answer
109
views
Dataframe transformation to numpy ndarray takes ages to complete
I would like to transform my dataframe into an array of fixed-sized chunks from each unique segment. Specifically, I would like to transform the ...
1
vote
1
answer
2k
views
Count the number of neighbors
I have a numpy array called contour of \$N\$ coordinates (x,y) of dimension (N, 2).
For each ...
-1
votes
1
answer
57
views
Trying to get every 6th set of 4 bytes from a python array [closed]
I have an array of bytes 6144 bytes long. I want to extract a set of 4 bytes every 6th set of 4 bytes . So every 24 bytes I want to extract 4 of those bytes and join them in a new array. So
...
9
votes
3
answers
1k
views
Creating an affinity-matrix between protein and RNA sequences
I wrote an algorithm that analyzes protein-RNA interactions and I found that the following function is the bottleneck that causes performance issues:
...
2
votes
0
answers
152
views
Python list operation - merge adjacent cubes into minimum number of shapes
I am hoping to find a way to make the process a lot faster. The lists are made of rows of 6 numbers, i.e. [[float] * 6, ...]. The intent is to pass a list of cube ...
3
votes
1
answer
569
views
List of word to list of index in a vocabulary [closed]
I have a dataset composed of ~700k samples. Each sample is composed of n_features features. Each feature is a word. Each feature has his own vocabulary. The size of the vocabularies range from 18 to ...
4
votes
1
answer
599
views
Getting angle between all points in array
I have got some code that calculates the angle between all of the points in an array. It works, but it is quite slow. This is because it has complexity O(n^2). It has to loop through the array and ...
0
votes
2
answers
173
views
Faster generation of list with multiple sublists [closed]
I'm trying to improve the performance of some rather large code. One of the bottlenecks is the line below. It doesn't look like much but it is processed millions of times.
Is there any way to improve ...
7
votes
1
answer
662
views
Optimized computation of pairwise correlations in Python
Given a set of discrete locations (e.g. "sites") that are pairwise related in some categorical ways (e.g. general proximity) and contains local level data (e.g. population size), I wish to efficiently ...
7
votes
1
answer
245
views
Combining two clock tick vectors with NumPy
I have two long (7683200 length) 1D arrays corresponding to two clock cycles, that I wish to combine into single 1D array. The clock_ticks_fine cycles between 0-255,...
5
votes
1
answer
1k
views
NumPy array filter optimisation
I've got a filter that I'd like to work out how to optimize. The most basic implementation, using loops is like the following:
...
10
votes
2
answers
214
views
Improve performance of math function applied to arrays
This block of code is already somewhat optimized thanks to some answers given over at Stack Overflow. In the last question I made (Improve performance of function without parallelization) the code was ...
18
votes
2
answers
97k
views
Fastest way to iterate over Numpy array
I wrote a function to calculate the gamma coefficient of a clustering. The bottleneck is the comparison of values from dist_withing to ...