Florida Man
Florida Man

Reputation: 2147

Different in List size

could someone explain me the difference in the List size? Once it is (x,1) and the other (x,). I think I get an idexError due to that.

Thanks enter image description here

print(Annotation_Matrix)
   [array([[1],
   ..., 
   [7],
   [7],
   [7]], dtype=uint8)]

print(idx)
[array([ True,  True,  True, ..., False, False, False], dtype=bool)]

p.s. the left one is created with

matlabfile.get(...)

the right one with

in1d(...) 

Upvotes: 1

Views: 80

Answers (1)

Mario González
Mario González

Reputation: 68

An array A of size (x,1) is a matrix of x rows and 1 columns (2 dimensions), which differs from A.T of size (1,x). They have the same elements but in different 'orientation'. An array B of size (x,) is a vector of x coordinates (1 dimension), without any orientation (it's not a row nor a column). It's just a list of elements.

In the first case, one can access an element with A[i,:] which is the same of A[i,0] (because it has only one column). In the later, the call B[i,:] causes an error because the array B has only one dimension. The correct call is B[i].

I hope this helps you to solve the problem.

Upvotes: 1

Related Questions