Skip to content

Implement ControlledGate #430

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

Merged
merged 4 commits into from
May 29, 2018
Merged

Implement ControlledGate #430

merged 4 commits into from
May 29, 2018

Conversation

Strilanc
Copy link
Contributor

@Strilanc Strilanc commented May 28, 2018

  • Add extensions parameter to PotentialImplementation to allow recursive casting
  • Fix ParameterizableGate not being exported

Fixes #389
Fixes #431

- Add extensions parameter to PotentialImplementation to allow recursive casting
- Fix ParameterizableGate not being exported
@Strilanc Strilanc requested a review from kevinsung May 28, 2018 04:00
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label May 28, 2018
@Strilanc
Copy link
Contributor Author

Strilanc commented May 28, 2018

The build failure on travis is some kind of mypy bug. Opened #431 to investigate.

gate_features.ParameterizableGate,
gate_features.ReversibleGate,
gate_features.TextDiagrammableGate,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these particular subclasses in this list?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think I see ... these are the ones that you implemented methods for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

if desired_type in POTENTIALLY_EXPOSED_SUB_TYPES:
cast_sub_gate = ext.try_cast(self.sub_gate, desired_type)
if cast_sub_gate is None:
return None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not raise a TypeError, as you do in _cast_sub_gate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is a try_cast method, not a cast method.

This method is inherited from PotentialImplementation and so must satisfy that contract as opposed to one that may be more convenient to this specific class.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I guess this is just following the docstring of try_cast_to.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I see.

Copy link
Collaborator

@kevinsung kevinsung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Naturally, supporting potential implementation of CompositeGate is tricky but this gives a path forward for someone who wants to do that.

@kevinsung kevinsung merged commit 35fe511 into master May 29, 2018
@Strilanc Strilanc deleted the controlled_gate branch July 18, 2018 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants