Skip to content

BlockVector: improve numpy2 compatability (__getitem__(()) is identity)#3585

Merged
mrmundt merged 1 commit intoPyomo:mainfrom
jsiirola:block-vector-numpy2
Apr 29, 2025
Merged

BlockVector: improve numpy2 compatability (__getitem__(()) is identity)#3585
mrmundt merged 1 commit intoPyomo:mainfrom
jsiirola:block-vector-numpy2

Conversation

@jsiirola
Copy link
Copy Markdown
Member

Fixes # .

Summary/Motivation:

This resolves a problem with the implementation of PyNumero's BlockVector: numpy has the convention that __getitem__(tuple()) will return the original array. This adds support for that convention in BlockVector so that NumPy2 implementations of operators like isclose will not fail.

Changes proposed in this PR:

  • Adopt NumPy convention that passing an empty tuple to __getitem__ will return the original array.

Legal Acknowledgement

By contributing to this software project, I have read the contribution guide and agree to the following terms and conditions for my contribution:

  1. I agree my contributions are submitted under the BSD license.
  2. I represent I am authorized to make the contributions and grant the license. If my employer has rights to intellectual property that includes these contributions, I represent that I have received permission to make contributions and grant the required license on behalf of that employer.

@mrmundt mrmundt merged commit 55d55a6 into Pyomo:main Apr 29, 2025
5 of 28 checks passed
@jsiirola jsiirola deleted the block-vector-numpy2 branch April 29, 2025 21:58
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