QuantumKatas icon indicating copy to clipboard operation
QuantumKatas copied to clipboard

[PhaseEstimation] Enable task 1.3 in Jupyter notebook

Open tcNickolas opened this issue 3 years ago • 0 comments

Currently task 1.3 (Validate inputs to QPE) is covered by two types of tests - Q# test TestAssertIsEigenstate_True that checks that the solution doesn't throw exceptions on inputs that are a valid unitary-eigenstate pair, and C# tests that check that the solution does throw exception on inputs that are not a valid unitary-eigenstate pair. The first part of the test can be invoked via %kata magic, as usual, but the C# part cannot (see https://github.com/microsoft/QuantumKatas/issues/166).

We can enable this task in the Jupyter Notebook frontend for this kata as follows:

  1. Add the code cell %kata TestAssertIsEigenstate_True magic and the operation skeleton, like we do for the regular tasks.
  2. Add another code cell after it that would define a new operation that calls AssertIsEigenstate with several commented out unitary-eigenstate pairs that should each throw exception.
  3. Add third code cell with %simulate magic calling the operation from the second cell*, and user instructions to uncomment a line, run second and third cells, check that an exception is thrown, comment the line and uncomment the next one, and try again.

This is not the best user experience we can offer, but fixing #166 is not trivial, and a temporary solution is better than none.

tcNickolas avatar May 19 '22 19:05 tcNickolas