-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify Array Slicing Syntax from 'array[start:stop[:step]]' to 'array[start:stop:step]' #465
Clarify Array Slicing Syntax from 'array[start:stop[:step]]' to 'array[start:stop:step]' #465
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
👋 Thanks for opening this PR! The Cookbook will be automatically built with GitHub Actions. To see the status of your deployment, click below. |
The challenge with this update is now it implies that the second colon is mandatory, which isn't true. That's why In fairness, neither the numpy docs nor the Python docs denote slicing as we have previously done here, so maybe this is a good cleanup to match those sources. |
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."
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." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this clarification!
core/numpy/numpy-basics.ipynb
Outdated
@@ -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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a little syntax error here preventing the text from rendering properly.
It should be array[start:stop:step]
(closed with the back quote) instead of `array[start:stop:step]'
Thank you for this feedback! I've changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that fix @kazakhpunk, this looks good now!
The link check failure is unrelated to this PR.
Merging this now. Thanks for the contribution @kazakhpunk! |
This pull request updates the array slicing syntax documentation. The original syntax notation 'array[start:stop[:step]]' could be misinterpreted as suggesting the step parameter is nested within the stop parameter. This update simplifies the notation to 'array[start:stop:step]', clearly delineating each parameter, enhancing readability and reducing potential confusion for users.