Skip to content
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

Merged
merged 3 commits into from
May 20, 2024

Conversation

kazakhpunk
Copy link
Contributor

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.

@kazakhpunk kazakhpunk requested a review from a team as a code owner April 26, 2024 13:53
@kazakhpunk kazakhpunk requested review from mgrover1 and jukent and removed request for a team April 26, 2024 13:53
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Copy link

github-actions bot commented Apr 26, 2024

👋 Thanks for opening this PR! The Cookbook will be automatically built with GitHub Actions. To see the status of your deployment, click below.
🔍 Git commit SHA: 66ece31
✅ Deployment Preview URL: https://ProjectPythia.github.io/pythia-foundations/_preview/465

@dopplershift
Copy link
Contributor

The challenge with this update is now it implies that the second colon is mandatory, which isn't true. That's why :step was in its own brackets before.

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."
@kazakhpunk
Copy link
Contributor Author

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."

jukent
jukent previously approved these changes May 1, 2024
Copy link
Contributor

@jukent jukent left a 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!

@@ -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",
Copy link
Member

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]'

@kazakhpunk
Copy link
Contributor Author

Thank you for this feedback!

I've changed array[start:stop:step]' to array[start:stop:step]`

Copy link
Member

@brian-rose brian-rose left a 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.

@brian-rose
Copy link
Member

Merging this now. Thanks for the contribution @kazakhpunk!

@brian-rose brian-rose merged commit 2101e01 into ProjectPythia:main May 20, 2024
2 of 3 checks passed
github-actions bot pushed a commit that referenced this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants