Skip to content

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jun 18, 2025

Summary

This commit fixes an issue in the .sympify() method when building the Sympy expression for a ParameterExpression that was constructed by calling ParameterExpression.subs() with a ParameterVectorElement type. The previous implementation of this method was passing the symbols for substitution by string which required sympy to "parse" the input. The square brackets for indexing the vector element in it's string representation was not valid for sympy to parse and this caused the error. To avoid this problem this commit adjusts the usage to pass a sypy expression object instead of a string. This is the intent of the function as string parsing has other issues in sympy and this was an oversight in the implementation that was doing this. By passing a sympy object to sympy it is able to handle the vector's name with square brackets.

Details and comments

Fixes #14640


This is an automatic backport of pull request #14641 done by [Mergify](https://mergify.com).

This commit fixes an issue in the .sympify() method when building the
Sympy expression for a `ParameterExpression` that was constructed by
calling `ParameterExpression.subs()` with a ParameterVectorElement type.
The previous implementation of this method was passing the symbols for
substitution by string which required sympy to "parse" the input. The
square brackets for indexing the vector element in it's string
representation was not valid for sympy to parse and this caused the
error. To avoid this problem this commit adjusts the usage to pass a
sypy expression object instead of a string. This is the intent of the
function as string parsing has other issues in sympy and this was an
oversight in the implementation that was doing this. By passing a sympy
object to sympy it is able to handle the vector's name with square
brackets.

Fixes #14640

(cherry picked from commit 69d7dbd)
@mergify mergify bot requested a review from a team as a code owner June 18, 2025 17:44
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the following people are relevant to this code:

  • @Qiskit/terra-core

@github-actions github-actions bot added priority: high Changelog: Bugfix Include in the "Fixed" section of the changelog labels Jun 18, 2025
@github-actions github-actions bot added this to the 2.1.0 milestone Jun 18, 2025
@jakelishman jakelishman enabled auto-merge June 18, 2025 17:51
@jakelishman jakelishman added this pull request to the merge queue Jun 18, 2025
@coveralls
Copy link

Pull Request Test Coverage Report for Build 15739866815

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • 7 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.005%) to 87.991%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.23%
crates/circuit/src/symbol_expr.rs 2 73.6%
crates/qasm2/src/lex.rs 4 92.23%
Totals Coverage Status
Change from base Build 15738709795: -0.005%
Covered Lines: 83056
Relevant Lines: 94392

💛 - Coveralls

Merged via the queue into stable/2.1 with commit ae0a334 Jun 18, 2025
29 checks passed
@jakelishman jakelishman deleted the mergify/bp/stable/2.1/pr-14641 branch June 18, 2025 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog priority: high
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants