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

Unwanted error logged when loading a circuit from json #1519

Open
stavros11 opened this issue Nov 8, 2024 · 1 comment
Open

Unwanted error logged when loading a circuit from json #1519

stavros11 opened this issue Nov 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@stavros11
Copy link
Member

The following script

import json
from qibo import Circuit, gates

c = Circuit(2)
c.add(gates.CZ(0, 1))

with open("test.json", "w") as file:
    json.dump(c.raw, file)

with open("test.json", "r") as file:
    cd = json.load(file)
    cl = Circuit(2)
    cl = c.from_dict(cd)

produces this output

[Qibo 0.2.14|ERROR|2024-11-08 14:05:50]: Cannot use `controlled_by` method on gate <qibo.gates.gates.CZ object at 0x7f13cd1a1a60> because it is already controlled by (0,).

It does not fail, and the loaded circuit cl is usable, so I would not consider it very urgent, however it is weird that the error is printed.
This is most likely due to some try-except in the loader.

@stavros11 stavros11 added the bug Something isn't working label Nov 8, 2024
@alecandido
Copy link
Member

Yes, the solution should be similar to the one in #1505: if you know that it's going to be used in a try ... except, you should avoid usage of raise_error() in favor of a plain raise.

raise_error() will first log, then raise. So, if it already logged, it is impossible to take it back, even if the error gets subsequently caught.

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

No branches or pull requests

2 participants