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

Flag "is_executed" is defined but not implemented #462

Closed
mlazzarin opened this issue Sep 10, 2021 · 2 comments · Fixed by #463
Closed

Flag "is_executed" is defined but not implemented #462

mlazzarin opened this issue Sep 10, 2021 · 2 comments · Fixed by #463
Assignees
Labels
bug Something isn't working

Comments

@mlazzarin
Copy link
Contributor

The "is_executed" flag in the AbstractCircuit class is defined here

# Flag to keep track if the circuit was executed
# We do not allow adding gates in an executed circuit
self.is_executed = False

but it seems like it is not accessed nor modified anywhere in the source code of Qibo.
Indeed, it always returns False. The "add" method ignores it and simply checks for "_final_state"
if self._final_state is not None:
raise_error(RuntimeError, "Cannot add gates to a circuit after it is "
"executed.")

This is a minor bug but it may cause issues if such flag is used by unaware users.
Should we implement it properly (or simply remove it)?

@mlazzarin mlazzarin added the bug Something isn't working label Sep 10, 2021
@scarrazza
Copy link
Member

@mlazzarin thanks for pointing this out. I think we forgot to remove this attribute after some cleanup, nowadays we check this features in

if self._final_state is not None:
raise_error(RuntimeError, "Cannot add gates to a circuit after it is "
"executed.")

@stavros11 do you agree, right?

@stavros11
Copy link
Member

@mlazzarin thank you for checking the code. Indeed you may find some attributes around the code that are not used anymore because we forgot to remove them during a cleanup or refactoring. This particular attribute seems redundant to me as any if self.is_executed could be replaced by if self._final_state is not None since, if I am not mistaken, the final state attribute is assigned after a circuit execution.

I don't think such attributes would cause problems in every day usage but may confuse people that look at the code and should be removed. @mlazzarin you can remove this if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants