Skip to content

Numpy >2.0 bug for indexing in utils multiply()#53

Draft
dalyw wants to merge 3 commits into
mainfrom
debug/pyo_indexing
Draft

Numpy >2.0 bug for indexing in utils multiply()#53
dalyw wants to merge 3 commits into
mainfrom
debug/pyo_indexing

Conversation

@dalyw
Copy link
Copy Markdown
Contributor

@dalyw dalyw commented Jun 4, 2026

#54 - one solution, Alex had some ideas too on pyomo usability

For numpy ≥ 2.0, the numpy charge_array was indexed by the Pyomo time-set member instead of its position. Worked when model.t = range(T), but raised IndexError for model.t = any other ordered set (e.g. float seconds).

Debugged using Claude: Added helper at(expr, t). Numpy operands are indexed by their ordinal position, Pyomo operands by their member.

Added a non-range test case to test_multiply_pyo.

Pull request recommendations:

  • Name your pull request your-development-type/short-description. Ex: feature/gui
  • Link to any relevant issue in the PR description. Ex: Resolves [ENH: Support optimization of flexibility metrics #12]
  • Provide context of changes.
  • Provide relevant tests for your feature or bug fix.
  • Provide or update documentation for any feature added by your pull request.

Thanks for contributing!

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 94.37%. Comparing base (d044d34) to head (b642fcf).

Files with missing lines Patch % Lines
eeco/utils.py 83.33% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (94.11%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #53      +/-   ##
==========================================
- Coverage   94.38%   94.37%   -0.01%     
==========================================
  Files          10       10              
  Lines        1603     1601       -2     
==========================================
- Hits         1513     1511       -2     
  Misses         90       90              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dalyw dalyw marked this pull request as draft June 5, 2026 15:23
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.

2 participants