In the optimisation methods ex 2 there is a hint as below
ππππ_πππ‘πβ_π=π βπ’πππππ_π[:,π:π]
Numpy array slicing method is ;-
Array_sub = array[start : stop : step , start : stop : step , etc ] where the comma delineates between separate slices of the object array.
Why does the hint suggest we get data from the second slice rather than the first?
I do notice that if I remove the first colon and comma then the routine fails,
Regards
Ian
Got it. You are combining indexing and slicing, which requires the βempty sliceβ at the start.
Ian
The point is that there are two dimensions, right? We want the full width of the βrowsβ dimension, but only a subset of the column dimension. Thatβs because the columns are the samples and we want a subset of them. So itβs not an βempty sliceβ: itβs the full range of the index. The way you say that is β:β, in other words a range with no start and no end: so in python that means take everything. The range is from the earliest possible start to the latest possible end.
Thanks Paul
That explains a lot.
Ian