6 questions
1
vote
1
answer
137
views
Efficiently find full row permutations in 2d array having repeated row pairs
Consider the array:
import numpy as np
import numpy_indexed as npi
from itertools import permutations
arr = np.array([[1, 2, 3, 4],
[3, 3, 3, 6],
[2, 0, 0, 2],
...
2
votes
1
answer
471
views
weighted numpy bincount for 2D IDs array and 1D weights
I am using numpy_indexed for applying a vectorized numpy bincount, as follows:
import numpy as np
import numpy_indexed as npi
rowidx, colidx = np.indices(index_tri.shape)
(cols, rows), B = npi.count((...
0
votes
1
answer
44
views
numpy - anyway to improve this further(PandasTook(1h26m), NumpyTakes(38m))
Initially had everything written pandas and for this exploratory exercise i had did a lot of groupby's and while running with the whole data it was ran for 1h 26m. Over the last weekend, i had changed ...
0
votes
1
answer
959
views
Masking a Numpy array and applying a calculation per mask without using a for loop
Let's say we have the following data array:
data_array = np.array([[1, 1, 1], [1, 1, 2], [2, 2, 2], [3, 3, 3], [4, 4, 4]], np.int16)
data_array
array([[1, 1, 1],
[1, 1, 2],
[2, 2, 2],
...
0
votes
1
answer
1k
views
Tensorflow Error when indexing a 4D array: ValueError: Shapes must be equal rank, but are 1 and 0
I'm modifying a simple CNN in Tensorflow and when I'm indexing a 4d array I get this error.
My reproducable example is:
from __future__ import print_function
import pdb
import numpy as np
import ...
3
votes
2
answers
2k
views
Efficient use of numpy_indexed output
>>> import numpy_indexed as npi
>>> import numpy as np
>>> a = np.array([[0,0,1,1,2,2], [4,4,8,8,10,10]]).T
>>> a
array([[ 0, 4],
[ 0, 4],
[ 1, 8],
...