title: Matrix indexing in Numpy
body: <p>I was growing confused during the development of a small Python script involving matrix operations, so I fired up a shell to play around with a toy example and develop a better understanding of matrix indexing in Numpy.</p>
  
  <p>This is what I did:</p>
  
  <pre><code>&gt;&gt;&gt; import numpy as np
  &gt;&gt;&gt; A = np.matrix([1,2,3])
  &gt;&gt;&gt; A
  matrix([[1, 2, 3]])
  &gt;&gt;&gt; A[0]
  matrix([[1, 2, 3]])
  &gt;&gt;&gt; A[0][0]
  matrix([[1, 2, 3]])
  &gt;&gt;&gt; A[0][0][0]
  matrix([[1, 2, 3]])
  &gt;&gt;&gt; A[0][0][0][0]
  matrix([[1, 2, 3]])
  </code></pre>
  
  <p>As you can imagine, this has <em>not</em> helped me develop a better understanding of matrix indexing in Numpy. This behavior would make sense for something that I would describe as "An array of itself", but I doubt anyone in their right mind would choose that as a model for matrices in a scientific library.</p>
  
  <p>What is, then, the logic to the output I obtained? Why would the first element of a matrix object be itself?</p>
  
  <p>PS: I know how to obtain the first entry of the matrix. What I am interested in is the logic behind this design decision.</p>
  
  <p>EDIT: I'm not asking how to access a matrix element, or why a matrix row behaves like a matrix. I'm asking for a definition of the behavior of a matrix when indexed with a single number. It's an action typical of arrays, but the resulting behavior is nothing like the one you would expect from an array. I would like to know how this is implemented and what's the logic behind the design decision.</p>