matrix-indexing

Python: Index an array using the colon operator in an arbitrary dimension

Python: Index an array using the colon operator in an arbitrary dimension Question: I have a numpy nd array. A simplified version of my task is to take a vector from along each axis. To illustrate: import numpy x = numpy.array(range(24)).reshape((2,3,4)) x0 = x[0,0,:] x1 = x[0,:,0] x2 = x[:,0,0] However I do not necessarily …

Total answers: 3

What does [:, :] mean on NumPy arrays

What does [:, :] mean on NumPy arrays Question: Sorry for the stupid question. I’m programming in PHP but found some nice code in Python and want to "recreate" it in PHP. But I’m quite frustrated about the line: self.h = -0.1 self.activity = numpy.zeros((512, 512)) + self.h self.activity[:, :] = self.h I don’t understand …

Total answers: 3