Skip to content

Commit

Permalink
Clarify Array Slicing Syntax from 'array[start:stop[:step]]' to 'arra…
Browse files Browse the repository at this point in the history
…y[start:stop:step]' (#465)

* Clarified Array Slicing Syntax

* Update numpy-basics.ipynb

Thank you for the feedback. I appreciate the concern about the notation implying that the second colon and the step parameter are mandatory. 

I propose we adopt 'array[start:stop:step]' as the primary notation in examples but include a clear note in the text explaining that the step parameter is optional: "The step parameter is optional and can be omitted, in which case the slice uses a default step of 1."

* Resolved issue with wrong use of parenthesis ` `
  • Loading branch information
kazakhpunk committed May 20, 2024
1 parent 07bcc55 commit 2101e01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/numpy/numpy-basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@
"source": [
"### Slices\n",
"\n",
"Slicing syntax is written as `array[start:stop[:step]]`, where **all numbers are optional**.\n",
"Slicing syntax is written as `array[start:stop:step]`. Note that **all numbers are optional**. Importantly, the **step** parameter is optional and can be omitted, in which case the slice uses a default step of 1.\n",
"- defaults: \n",
" - start = 0\n",
" - stop = len(dim)\n",
Expand Down

0 comments on commit 2101e01

Please sign in to comment.