Skip to content

Replace list+ndarray concatenation with numpy operations in tutorials#91

Open
Copilot wants to merge 2 commits intomainfrom
copilot/update-ndarray-in-tutorials
Open

Replace list+ndarray concatenation with numpy operations in tutorials#91
Copilot wants to merge 2 commits intomainfrom
copilot/update-ndarray-in-tutorials

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 18, 2026

The pattern [-1] + revenue_locations mixes Python list concatenation with numpy arrays, creating type inconsistency and obscuring intent.

Changes

  • Replaced [-1] + array_name with np.insert(array_name, 0, -1) in both tutorials
  • Updated 4 instances in hillstrom.rst
  • Updated 4 instances in oregon.rst

Example

# Before
locations=[-1] + revenue_locations  # Returns list

# After  
locations=np.insert(revenue_locations, 0, -1)  # Returns ndarray

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.

…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
Copilot AI requested a review from TomeHirata February 18, 2026 16:43
@TomeHirata TomeHirata marked this pull request as ready for review March 31, 2026 12:46
Copilot AI review requested due to automatic review settings March 31, 2026 12:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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> with np.insert(<array>, 0, -1) in the Hillstrom tutorial.
  • Replaced [-1] + <numpy_array> with np.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.

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.

3 participants