-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it easier to access dumps and matrices from Python (#2042)
This adds some convenience accessors for getting dumps, messages, and matrices as separate entries from an invocation of `qsharp.run` and `qsharp.eval`. Previously, the only way to get a state dump from a run was the awkward: ```python state = qsharp.StateDump(qsharp.run("DumpMachine()", shots=1, save_events=True)[0]["events"][0].state_dump()) ``` This change preserves the existings "events" entry in the saved output, which has everything intermingled in the order from each shot, but also introduces dumps, messages, and matrices that will keep just the ordered output of that type. This makes the above pattern slightly better (and more discoverable): ```python state = qsharp.run("DumpMachine()", shots=1, save_events=True)[0]["dumps"][0] ``` This adds similar functionality to `qsharp.eval` which now supports `save_events=True` to capture output, so for single shot execution you can use: ```python state = qsharp.eval("DumpMachine()", save_events=True)["dumps"][0] ```
- Loading branch information
Showing
4 changed files
with
180 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters