Multidimensional array into table

I have a bunch of arrays: let CNSNRT = ["CNS", "NRT", 3637, 2113] as [Any] let ADKANC = ["ADK", "ANC", 1192, 2200] as [Any] let LAXMCE = ["LAX", "MCE", 259 , 2370] as [Any] let ANCMCG = ["ANC", "MCG", 219, 2440] as [Any] let ATLGLH = ["ATL", "GLH", ...
more »

2017-08-13 18:08 (1) Answers

Python 3 - 2D array sort by multiple columns

I have a 2D array, with 6 columns, in python which has numeric data and I want to be able to sort by multiple columns. I have tried this: def sort_data(): dataset.sort(key=lambda x: (x[2], x[5], x[1])) but my results appear like this: 0 0000...
more »

2017-08-10 11:08 (1) Answers

Allocate 6xNxN array

I have a variable N. I need a 6xNxN array. Something like this: int arr[6][N][N]; But, obviously, that doesn't work. I'm not sure how I'd go about allocating this so that I can access, e.g. arr[5][4][4] if N is 5, and arr[5][23][23] if N is 24. ...
more »

2017-08-09 05:08 (3) Answers

transpose on 4-d array in numpy

I have a 4d array (python) with a batch of 10000 images with 5 channels in each image. Each image is 25*25 i.e. the 4d array shape is 10000*5*25*25. I need to transpose the images. The naive way is with nested loops: for i in range(np.s...
more »

2017-08-07 14:08 (1) Answers

Multidimensional array in numpy

I have an array of shape (5,2) which each row consist of an array of shape (4,3,2) and a float number. After I slice that array[:,0], I get an array of shape (5,) which each element has shape of (4,3,2), instead of an array of shape (5,4,3,2) (even ...
more »

2017-08-05 20:08 (3) Answers

Access n-th dimension in python

I want a easy to read access to some parts of a multidimensional numpy array. For any array accessing the first dimension is easy (b[index]). Accessing the sixth dimension on the other hand is "hard" (especially to read). b[:,:,:,:,:,index] #the ne...
more »

2017-08-02 15:08 (4) Answers

Lua passing multi dimensional array

Hi I am a fairly new Lua programmer and I am trying to pass parameters to a multidimensional array, but I keep getting a nil value error. I have a multidimensional array: local transform = { forward = { distance = 1, swing = robot.swing,...
more »

2017-08-02 00:08 (1) Answers

Multi Dimensional Numpy Array Sorting

I have (5,5) np.array like below. >>> a array([[23, 15, 11, 0, 17], [ 1, 2, 20, 4, 6], [16, 22, 8, 10, 18], [ 7, 12, 13, 14, 5], [ 3, 9, 21, 19, 24]]) I want to multi dimensional sort the np.array to loo...
more »

2017-07-13 17:07 (1) Answers

Adding Numpy arrays like Counters

Since collections.Counter is so slow, I am pursuing a faster method of summing mapped values in Python 2.7. It seems like a simple concept and I'm kind of disappointed in the built-in Counter method. Basically, I need to be able to take arrays like...
more »

2017-07-10 22:07 (5) Answers

delete item from multidimensional ndarray

I have a <class 'numpy.ndarray'> of this shape: (148, 1, 2) With some coordinates: [[[273 290]] [[271 292]] [[268 292]] [[267 293]] [[266 293]] [[265 294]] [[261 294]] [[261 295]] [[260 296]] [[258 296]] [[256 298]] [[254...
more »

2017-07-07 10:07 (0) Answers

Efficiently sample vectors from numpy ndarray

I have a multidimensional numpy array X of shape: (B, dim, H, W) I would like to randomly sample k dim-dimensional vectors out of X. I can get the sample indices from a msk of shape (B, 1, H, W): sIdx = random.sample((msk.flat>=0).nonzero()[0], k...
more »

2017-07-04 09:07 (1) Answers

Compare arrays multidimensionally

I would like to compare arrays multidimensionally. Well, this is what I am trying to: I got an array with elements like: $excludedParents = array( [0] => 'a', [1] => 'span#testid', [2] => 'em', [3] => 'div.testclass') Now I am using ...
more »

2017-06-29 13:06 (0) Answers

Efficiently define an implicit Numpy array

A and B are Numpy arrays of common shape [n1,n2,n3]. The values of B are all integers in [0,n3). I want A to "invert" B in the sense that each value of A satisfies A[i,j,B[i,j,k]]=k for all i,j,k in the appropriate ranges. It's how obvious to do this...
more »

2017-06-29 03:06 (1) Answers

Return searchlight vectors for a given numpy array

Consider a 3D numpy array D of dimension, say, (30 x 40 x 50). For each voxel D[x,y,z] I want to store a vector that contains neighboring voxels within a certain radius (including the D[x,y,z] itself). (As an example here is a picture of such a sphe...
more »

2017-06-28 23:06 (2) Answers

Calling a 2D array function?

I first apologize if some of you find my problem stupid and easy to solve, but I am a very beginner in "c". My task is to create an inverse of a 3x3 matrix using different functions. What I am trying to do now is to tell the user to input values f...
more »

2017-06-23 08:06 (4) Answers

Sort multidimensional array by key of set of array

I'm looking for a solution to sort by key a multi dimensional array, the point is that I can sort a set of array with multidimensional that has no custom key ID and the array is in set, but this array contains custom key and I need to sort by date: ...
more »

2017-06-20 16:06 (1) Answers