0

I'm trying to understand this line of Python.

 dP = -(dt / tau_stdp) * P[:, it] + A_plus * pre_spike_train_ex[:, it + 1] 

but I can't find what the ' : ' does in these NumPy arrays

Seti Net
  • 693
  • 1
  • 7
  • 24
  • 1
    It's for slicing a range of elements, similar to slicing a list or string. – Barmar Jun 07 '23 at 19:43
  • Slicing NumPy arrays is the same as slicing in lists. I would recommend checking this out: https://stackoverflow.com/questions/509211/how-slicing-in-python-works In essence, in your code, `P[:, it]` means you are looking at the elements from all the rows and only the `it`th column of `P`. – ndhulipala Jun 07 '23 at 19:54
  • Inside `[]` a `:` is a python `slice`. The fuller usage is `start:stop:step`, which you should have learned in Python basics. Here it 'selects' all of one dimension of a 2d array. I suggest spending some time on numpy fundamentals, especially indexing, https://numpy.org/doc/stable/user/basics.indexing.html – hpaulj Jun 07 '23 at 20:11
  • Does this answer your question? [A colon before a number in numpy array](https://stackoverflow.com/questions/44337881/a-colon-before-a-number-in-numpy-array) – jared Jun 07 '23 at 23:44

0 Answers0