Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParameterExpression.__eq__ to accept comparing a bound expression to a fixed value #5423

Closed
kdk opened this issue Nov 23, 2020 · 4 comments · Fixed by #5444
Closed

ParameterExpression.__eq__ to accept comparing a bound expression to a fixed value #5423

kdk opened this issue Nov 23, 2020 · 4 comments · Fixed by #5444
Labels
good first issue Good for newcomers help wanted community contributions welcome. For filters like http://github-help-wanted.com/
Milestone

Comments

@kdk
Copy link
Member

kdk commented Nov 23, 2020

It would be good to update ParameterExpression.__eq__ to accept comparing a bound expression to a fixed value, but this can be a separate issue.

Originally posted by @kdk in #5192 (comment)

@kdk kdk added the good first issue Good for newcomers label Nov 23, 2020
@kdk kdk added the help wanted community contributions welcome. For filters like http://github-help-wanted.com/ label Nov 23, 2020
@Drinion
Copy link

Drinion commented Nov 29, 2020

Hi! I'm new to the community and would like to give it a shot. May I?

mergify bot added a commit that referenced this issue Dec 3, 2020
* ParameterExpression.__eq__ takes bound expr == val

This is a code update in response to issue #5423
The current implementation of __eq__ method of
ParameterExpression class only allows comparison
between two parameter expressions.

With this update it is possible to compare a
bounded parameter expression with a fixed value.

If the argument passed to __eq__ is a number:
(1) Check that self has no unbound parameters i.e.
    self.parameters == 0
(2) Check that the value of the sympy expression
    is equal to the argument

Added a test in test/python/circuit/test_parameters.py
to check that the comparison with a fixed value works

* Updated return type in __eq__ docstring

The return type is now specifically mentioned to be a bool

* Replace else block in __eq_ and add release note

As per the suggestion in the PR #5444 thread,
the else statement in the __eq__ method is now
replaced with just a return statement, since it
is simpler and equivalent

A release note about the PR is also now added.

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@1ucian0
Copy link
Member

1ucian0 commented Dec 10, 2020

Is this issue closed by #5444 ?

@1ucian0 1ucian0 closed this as completed Dec 10, 2020
@1ucian0 1ucian0 reopened this Dec 10, 2020
@1ucian0
Copy link
Member

1ucian0 commented Dec 10, 2020

ping @kdk ? Otherwise, @Drinion can take it.

@kdk
Copy link
Member Author

kdk commented Dec 10, 2020

This is added in #5444 .

@kdk kdk closed this as completed Dec 10, 2020
@kdk kdk linked a pull request Dec 10, 2020 that will close this issue
@kdk kdk added this to the 0.17 milestone Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted community contributions welcome. For filters like http://github-help-wanted.com/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants