-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add quil-plotting module #412
base: main
Are you sure you want to change the base?
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a good start! I wonder how much can be simplified by leveraging quil-py's TemplateWaveforms and expression evaluation. I would also like to see documented examples, and clarification on what needs to be part of the public API here.
RED = "#ef476f" # Magneta | ||
BLUE = "#3d47d9" # Palatinate Blue | ||
GRAY = "#8a8b92" # Gray | ||
NAVY = "#0d0d36" # Cetacean Blue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these colors configurable? They should be for accessibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the Rigetti colors. They aren't easily configurable. Any suggestion how to make it so?
|
||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with using hatchling
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How are these checkpoints used in tests? Since this is a pure Python module, I think a brief CONTRIBUTING.md
explaining how to run and test this code would be valuable. I would also add a cargo-make Makefile with tasks to run the tests, at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mistake, will remove.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a README
"Operating System :: OS Independent", | ||
] | ||
dependencies = [ | ||
"numpy>=1.2.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the mistaken version of numpy, should be 1.21.0
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup
color_by: str = "Channel Type", | ||
runner_order: str = "Time (s)", | ||
exclude_readout: bool = True, | ||
normalize_by: Optional[str] = "Channel Type", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of plain strings, can we make "categoricals" and the like enums?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, however I'm not sure if using enums with a pandas dataframe is entirely conventional. I'm not actually sure what best practice would be here.
|
||
|
||
def deoxidize(num) -> complex: | ||
"""Remove Rust from a Number or PrefixExpression.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mentions the Number
variant, but doesn't handle it. Also, the evaluate
method is available on any Expression
, and raises an error if it cannot evaluate the expression to a complex number. So this could be simplified to a single line while keeping the same behavior. Since it is a single line, this function can likely be removed.
num.evaluate({}, {})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem to work on PrefixExpressions. Will revisit it though.
sample_rate = frame["SAMPLE-RATE"].inner().to_real() | ||
match name: | ||
case "flat": | ||
waveform_envelope = FlatWaveform(**parameters) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each of the template waveforms have an into_iq_values
method, any reason that isn't used here?
elif isinstance(program, Program): | ||
quil_program = program | ||
else: | ||
raise ValueError("Program must be a pyquil.Program or a quil.Program") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, should this package be aware of pyQuil's internal API? I think it would be better to remove this special case, and add a method to pyQuil's Program that can call into this package instead. That way, implementation details about pyQuil stay in pyQuil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, removing this is in the TODO.
calibrations = quil_program.calibrations | ||
expanded_quil_program, source_map = expand_with_source_mapping(quil_program, include_pragmas=False) | ||
blocks = expanded_quil_program.control_flow_graph().basic_blocks() | ||
assert len(blocks) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ruff
should raise a lint for this. In short, assert
is removed from optimized Python code, and it's generally better to explicitly raise an error. Reference
The intention is to use the TemplateWaveforms (I believe this is mentioned in the TODO list and it's actually necessary to avoid a circular dependency with pyquil). At the time of writing, I don't think this feature was released so that's why I made due with the pyquil ones. As for documentation, what do you have in mind? Should this integrate with the quil-rs documentation? |
No description provided.