Replace list+ndarray concatenation with numpy operations in tutorials#91
Open
Replace list+ndarray concatenation with numpy operations in tutorials#91
Conversation
…utorials Co-authored-by: TomeHirata <33407409+TomeHirata@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update ndarray operation in tutorial examples
Replace list+ndarray concatenation with numpy operations in tutorials
Feb 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the documentation tutorials to avoid mixing Python list concatenation with NumPy arrays when prepending -1 to location arrays, keeping types consistent with the library’s locations: np.ndarray API expectations.
Changes:
- Replaced
[-1] + <numpy_array>withnp.insert(<array>, 0, -1)in the Hillstrom tutorial. - Replaced
[-1] + <numpy_array>withnp.insert(<array>, 0, -1)in the Oregon tutorial.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| docs/source/tutorials/hillstrom.rst | Uses np.insert(..., 0, -1) for predict_pte(..., locations=...) to keep locations as an ndarray. |
| docs/source/tutorials/oregon.rst | Uses np.insert(..., 0, -1) for predict_lpte(..., locations=...) in both costs and visits sections to keep locations as an ndarray. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pattern
[-1] + revenue_locationsmixes Python list concatenation with numpy arrays, creating type inconsistency and obscuring intent.Changes
[-1] + array_namewithnp.insert(array_name, 0, -1)in both tutorialshillstrom.rstoregon.rstExample
Both produce functionally equivalent results, but the numpy operation maintains type consistency and clearly expresses the intent to prepend -1 to the array.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.