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

quil.Instruction are recognized as any AbstractInstruction subclass by isinstance. #1748

Open
MarquessV opened this issue Feb 27, 2024 · 0 comments
Labels
bug 🐛 An issue that needs fixing.

Comments

@MarquessV
Copy link
Contributor

MarquessV commented Feb 27, 2024

AbstractInstruction has a metaclass that helps group quil Instruction types under the AbstractInstruction umbrella for compatibility. However, this metaclass is causing any Instruction to be recognized as any subclass of AbstractInstruction. This can be misleading, since it's possible the Instruction's inner type doesn't match the subclass it's being checked against:

from pyquil.quilbase import Pulse
from pyquil.quilatom import Frame, WaveformInvocation
from quil.instructions import Instruction

waveform = WaveformInvocation("MY_WAVEFORM")
frame = Frame([0], "MY_FRAME")
pulse = Pulse(frame, waveform)
pulse_instr = Instruction(pulse)
print(f"isinstance(pulse_instr, Frame): {isinstance(pulse_instr, Frame)}")

>>> isinstance(pulse_instr, Frame): True
@MarquessV MarquessV added the bug 🐛 An issue that needs fixing. label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue that needs fixing.
Projects
None yet
Development

No branches or pull requests

1 participant