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

Allow to apply unitary qubit operators to qubits #263

Merged
merged 10 commits into from
Aug 26, 2018

Conversation

damiansteiger
Copy link
Contributor

No description provided.

Copy link
Contributor

@thomashaener thomashaener left a comment

Choose a reason for hiding this comment

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

Thanks a lot! 👍
I added a few comments

Example:

.. code-block:: python

Copy link
Contributor

Choose a reason for hiding this comment

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

This code is missing indentation I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

raise TypeError("Only one qubit or qureg allowed.")
# Check that operator is unitary
if not len(self.terms) == 1:
raise TypeError("Only unitary QubitOperators can be applied to "
Copy link
Contributor

Choose a reason for hiding this comment

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

Only QubitOperators consisting of a single Pauli string with a coefficient of unit length can be applied.
Otherwise, people might get confused if their operator actually is unitary but consists of multiple terms.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can it be unitary with multiple terms?

Copy link
Contributor

Choose a reason for hiding this comment

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

1/sqrt(2) * X + 1/sqrt(2) * Z = H

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great, thanks for the example

Return the inverse gate if QubitOperator is unitary.

Raises:
NotInvertible: inverse is not implemented if not unitary
Copy link
Contributor

Choose a reason for hiding this comment

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

if there are multiple terms or the coefficient is not 1 in absolute value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Raises:
NotInvertible: inverse is not implemented if not unitary
"""
if len(self.terms) == 1:
Copy link
Contributor

Choose a reason for hiding this comment

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

and abs(coefficient)...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

It won't raise an exception now, though...

Standard implementation of get_merged:

Raises:
NotMergeable: merging is not implemented
Copy link
Contributor

Choose a reason for hiding this comment

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

These docs are a bit strange ;-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, changed.

len(other.terms) == 1 and
len(self.terms) == 1):
return self * other

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need the comments below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm nope

Copy link
Contributor

@thomashaener thomashaener left a comment

Choose a reason for hiding this comment

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

💯

@damiansteiger damiansteiger merged commit 371ead6 into develop Aug 26, 2018
@damiansteiger damiansteiger deleted the feature/unitary-qubitoperator-as-gate branch August 26, 2018 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants