{"action":"created","comment":{"url":"https://api.github.com/repos/quantumlib/Cirq/pulls/comments/242745898","pull_request_review_id":186332350,"id":242745898,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDI0Mjc0NTg5OA==","diff_hunk":"@@ -447,9 +448,134 @@ def _simulator_iterator(\n         \"\"\"\n         raise NotImplementedError()\n \n+    def compute_displays(\n+            self,\n+            program: Union[circuits.Circuit, schedules.Schedule],\n+            param_resolver: study.ParamResolver = study.ParamResolver({}),\n+            qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT,\n+            initial_state: Union[int, np.ndarray] = 0,\n+    ) -> study.ComputeDisplaysResult:\n+        \"\"\"Computes displays in the supplied Circuit.\n+\n+        Args:\n+            program: The circuit or schedule to simulate.\n+            param_resolver: Parameters to run with the program.\n+            qubit_order: Determines the canonical ordering of the qubits used\n+                to define the order of amplitudes in the wave function.\n+            initial_state: If an int, the state is set to the computational\n+                basis state corresponding to this state. Otherwise  if this\n+                is a np.ndarray it is the full initial state. In this case it\n+                must be the correct size, be normalized (an L2 norm of 1), and\n+                be safely castable to an appropriate dtype for the simulator.\n+\n+        Returns:\n+            ComputeDisplaysResult for the simulation.\n+        \"\"\"\n+        return self.compute_displays_sweep(\n+            program, [param_resolver], qubit_order, initial_state)[0]\n+\n+    def compute_displays_sweep(\n+            self,\n+            program: Union[circuits.Circuit, schedules.Schedule],\n+            params: Optional[study.Sweepable] = None,\n+            qubit_order: ops.QubitOrderOrList = ops.QubitOrder.DEFAULT,\n+            initial_state: Union[int, np.ndarray] = 0,\n+    ) -> List[study.ComputeDisplaysResult]:\n+        \"\"\"Computes displays in the supplied Circuit.\n+\n+        In contrast to `compute_displays`, this allows for sweeping\n+        over different parameter values.\n+\n+        Args:\n+            program: The circuit or schedule to simulate.\n+            params: Parameters to run with the program.\n+            qubit_order: Determines the canonical ordering of the qubits used to\n+                define the order of amplitudes in the wave function.\n+            initial_state: If an int, the state is set to the computational\n+                basis state corresponding to this state.\n+                Otherwise if this is a np.ndarray it is the full initial state.\n+                In this case it must be the correct size, be normalized (an L2\n+                norm of 1), and  be safely castable to an appropriate\n+                dtype for the simulator.\n+\n+        Returns:\n+            List of ComputeDisplaysResults for this run, one for each\n+            possible parameter resolver.\n+        \"\"\"\n+        circuit = (program if isinstance(program, circuits.Circuit)\n+                   else program.to_circuit())\n+        param_resolvers = study.to_resolvers(params or study.ParamResolver({}))\n+        qubit_order = ops.QubitOrder.as_qubit_order(qubit_order)\n+        qubits = qubit_order.order_for(circuit.all_qubits())\n+\n+        compute_displays_results = []  # type: List[study.ComputeDisplaysResult]\n+        for param_resolver in param_resolvers:\n+            display_values = {}  # type: ignore\n+\n+            # Compute the displays in the first Moment\n+            moment = circuit[0]\n+            state = wave_function.to_valid_state_vector(\n+                initial_state, num_qubits=len(qubits))\n+            qubit_map = {q: i for i, q in enumerate(qubits)}\n+            _enter_moment_display_values_into_dictionary(\n+                display_values, moment, state, qubit_order, qubit_map)\n+\n+            # Compute the displays in the rest of the Moments\n+            all_step_results = self.simulate_moment_steps(circuit,\n+                                                          param_resolver,\n+                                                          qubit_order,\n+                                                          initial_state)\n+            for step_result, moment in zip(all_step_results, circuit[1:]):\n+                _enter_moment_display_values_into_dictionary(\n+                    display_values,\n+                    moment,\n+                    step_result.state(),\n+                    qubit_order,\n+                    step_result.qubit_map)\n+\n+            compute_displays_results.append(study.ComputeDisplaysResult(\n+                params=param_resolver,\n+                display_values=display_values))\n+\n+        return compute_displays_results\n+\n+\n+def _enter_moment_display_values_into_dictionary(\n+        display_values: Dict,\n+        moment: ops.Moment,\n+        state: np.ndarray,\n+        qubit_order: ops.QubitOrder,\n+        qubit_map: Dict[ops.QubitId, int]):\n+    displays = (op for op in moment\n+                if isinstance(op, (ops.SamplesDisplay,","path":"cirq/sim/simulator.py","position":null,"original_position":145,"commit_id":"ac5bf1b065b861cd41ecb7f7cab4244a68983eb1","original_commit_id":"cba3d55c6510397815ce977264d25920b2760b7f","user":{"login":"kevinsung","id":4296166,"node_id":"MDQ6VXNlcjQyOTYxNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/4296166?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinsung","html_url":"https://github.com/kevinsung","followers_url":"https://api.github.com/users/kevinsung/followers","following_url":"https://api.github.com/users/kevinsung/following{/other_user}","gists_url":"https://api.github.com/users/kevinsung/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinsung/subscriptions","organizations_url":"https://api.github.com/users/kevinsung/orgs","repos_url":"https://api.github.com/users/kevinsung/repos","events_url":"https://api.github.com/users/kevinsung/events{/privacy}","received_events_url":"https://api.github.com/users/kevinsung/received_events","type":"User","site_admin":false},"body":"Done.","created_at":"2018-12-18T23:37:06Z","updated_at":"2018-12-18T23:37:06Z","html_url":"https://github.com/quantumlib/Cirq/pull/1252#discussion_r242745898","pull_request_url":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/quantumlib/Cirq/pulls/comments/242745898"},"html":{"href":"https://github.com/quantumlib/Cirq/pull/1252#discussion_r242745898"},"pull_request":{"href":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252"}},"in_reply_to_id":242744371},"pull_request":{"url":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252","id":238849598,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM4ODQ5NTk4","html_url":"https://github.com/quantumlib/Cirq/pull/1252","diff_url":"https://github.com/quantumlib/Cirq/pull/1252.diff","patch_url":"https://github.com/quantumlib/Cirq/pull/1252.patch","issue_url":"https://api.github.com/repos/quantumlib/Cirq/issues/1252","number":1252,"state":"open","locked":false,"title":"Add method for computing Display values to SimulatesIntermediateWaveFunction","user":{"login":"kevinsung","id":4296166,"node_id":"MDQ6VXNlcjQyOTYxNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/4296166?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinsung","html_url":"https://github.com/kevinsung","followers_url":"https://api.github.com/users/kevinsung/followers","following_url":"https://api.github.com/users/kevinsung/following{/other_user}","gists_url":"https://api.github.com/users/kevinsung/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinsung/subscriptions","organizations_url":"https://api.github.com/users/kevinsung/orgs","repos_url":"https://api.github.com/users/kevinsung/repos","events_url":"https://api.github.com/users/kevinsung/events{/privacy}","received_events_url":"https://api.github.com/users/kevinsung/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-12-14T21:36:52Z","updated_at":"2018-12-18T23:37:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8227d8db2f3e86391b166a55e047f15401f8a3b0","assignee":null,"assignees":[],"requested_reviewers":[{"login":"dabacon","id":87974,"node_id":"MDQ6VXNlcjg3OTc0","avatar_url":"https://avatars0.githubusercontent.com/u/87974?v=4","gravatar_id":"","url":"https://api.github.com/users/dabacon","html_url":"https://github.com/dabacon","followers_url":"https://api.github.com/users/dabacon/followers","following_url":"https://api.github.com/users/dabacon/following{/other_user}","gists_url":"https://api.github.com/users/dabacon/gists{/gist_id}","starred_url":"https://api.github.com/users/dabacon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabacon/subscriptions","organizations_url":"https://api.github.com/users/dabacon/orgs","repos_url":"https://api.github.com/users/dabacon/repos","events_url":"https://api.github.com/users/dabacon/events{/privacy}","received_events_url":"https://api.github.com/users/dabacon/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":922112536,"node_id":"MDU6TGFiZWw5MjIxMTI1MzY=","url":"https://api.github.com/repos/quantumlib/Cirq/labels/cla:%20yes","name":"cla: yes","color":"FFFFFF","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252/commits","review_comments_url":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252/comments","review_comment_url":"https://api.github.com/repos/quantumlib/Cirq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/quantumlib/Cirq/issues/1252/comments","statuses_url":"https://api.github.com/repos/quantumlib/Cirq/statuses/ac5bf1b065b861cd41ecb7f7cab4244a68983eb1","head":{"label":"kevinsung:simulate_displays","ref":"simulate_displays","sha":"ac5bf1b065b861cd41ecb7f7cab4244a68983eb1","user":{"login":"kevinsung","id":4296166,"node_id":"MDQ6VXNlcjQyOTYxNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/4296166?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinsung","html_url":"https://github.com/kevinsung","followers_url":"https://api.github.com/users/kevinsung/followers","following_url":"https://api.github.com/users/kevinsung/following{/other_user}","gists_url":"https://api.github.com/users/kevinsung/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinsung/subscriptions","organizations_url":"https://api.github.com/users/kevinsung/orgs","repos_url":"https://api.github.com/users/kevinsung/repos","events_url":"https://api.github.com/users/kevinsung/events{/privacy}","received_events_url":"https://api.github.com/users/kevinsung/received_events","type":"User","site_admin":false},"repo":{"id":143246355,"node_id":"MDEwOlJlcG9zaXRvcnkxNDMyNDYzNTU=","name":"Cirq","full_name":"kevinsung/Cirq","private":false,"owner":{"login":"kevinsung","id":4296166,"node_id":"MDQ6VXNlcjQyOTYxNjY=","avatar_url":"https://avatars1.githubusercontent.com/u/4296166?v=4","gravatar_id":"","url":"https://api.github.com/users/kevinsung","html_url":"https://github.com/kevinsung","followers_url":"https://api.github.com/users/kevinsung/followers","following_url":"https://api.github.com/users/kevinsung/following{/other_user}","gists_url":"https://api.github.com/users/kevinsung/gists{/gist_id}","starred_url":"https://api.github.com/users/kevinsung/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevinsung/subscriptions","organizations_url":"https://api.github.com/users/kevinsung/orgs","repos_url":"https://api.github.com/users/kevinsung/repos","events_url":"https://api.github.com/users/kevinsung/events{/privacy}","received_events_url":"https://api.github.com/users/kevinsung/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kevinsung/Cirq","description":"A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.","fork":true,"url":"https://api.github.com/repos/kevinsung/Cirq","forks_url":"https://api.github.com/repos/kevinsung/Cirq/forks","keys_url":"https://api.github.com/repos/kevinsung/Cirq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kevinsung/Cirq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kevinsung/Cirq/teams","hooks_url":"https://api.github.com/repos/kevinsung/Cirq/hooks","issue_events_url":"https://api.github.com/repos/kevinsung/Cirq/issues/events{/number}","events_url":"https://api.github.com/repos/kevinsung/Cirq/events","assignees_url":"https://api.github.com/repos/kevinsung/Cirq/assignees{/user}","branches_url":"https://api.github.com/repos/kevinsung/Cirq/branches{/branch}","tags_url":"https://api.github.com/repos/kevinsung/Cirq/tags","blobs_url":"https://api.github.com/repos/kevinsung/Cirq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kevinsung/Cirq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kevinsung/Cirq/git/refs{/sha}","trees_url":"https://api.github.com/repos/kevinsung/Cirq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kevinsung/Cirq/statuses/{sha}","languages_url":"https://api.github.com/repos/kevinsung/Cirq/languages","stargazers_url":"https://api.github.com/repos/kevinsung/Cirq/stargazers","contributors_url":"https://api.github.com/repos/kevinsung/Cirq/contributors","subscribers_url":"https://api.github.com/repos/kevinsung/Cirq/subscribers","subscription_url":"https://api.github.com/repos/kevinsung/Cirq/subscription","commits_url":"https://api.github.com/repos/kevinsung/Cirq/commits{/sha}","git_commits_url":"https://api.github.com/repos/kevinsung/Cirq/git/commits{/sha}","comments_url":"https://api.github.com/repos/kevinsung/Cirq/comments{/number}","issue_comment_url":"https://api.github.com/repos/kevinsung/Cirq/issues/comments{/number}","contents_url":"https://api.github.com/repos/kevinsung/Cirq/contents/{+path}","compare_url":"https://api.github.com/repos/kevinsung/Cirq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kevinsung/Cirq/merges","archive_url":"https://api.github.com/repos/kevinsung/Cirq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kevinsung/Cirq/downloads","issues_url":"https://api.github.com/repos/kevinsung/Cirq/issues{/number}","pulls_url":"https://api.github.com/repos/kevinsung/Cirq/pulls{/number}","milestones_url":"https://api.github.com/repos/kevinsung/Cirq/milestones{/number}","notifications_url":"https://api.github.com/repos/kevinsung/Cirq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kevinsung/Cirq/labels{/name}","releases_url":"https://api.github.com/repos/kevinsung/Cirq/releases{/id}","deployments_url":"https://api.github.com/repos/kevinsung/Cirq/deployments","created_at":"2018-08-02T05:25:07Z","updated_at":"2018-12-14T19:37:17Z","pushed_at":"2018-12-18T23:37:01Z","git_url":"git://github.com/kevinsung/Cirq.git","ssh_url":"git@github.com:kevinsung/Cirq.git","clone_url":"https://github.com/kevinsung/Cirq.git","svn_url":"https://github.com/kevinsung/Cirq","homepage":"","size":3075,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"quantumlib:master","ref":"master","sha":"79feab6cdca48756b4903e9c4c718d74054aaea7","user":{"login":"quantumlib","id":31279789,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxMjc5Nzg5","avatar_url":"https://avatars1.githubusercontent.com/u/31279789?v=4","gravatar_id":"","url":"https://api.github.com/users/quantumlib","html_url":"https://github.com/quantumlib","followers_url":"https://api.github.com/users/quantumlib/followers","following_url":"https://api.github.com/users/quantumlib/following{/other_user}","gists_url":"https://api.github.com/users/quantumlib/gists{/gist_id}","starred_url":"https://api.github.com/users/quantumlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantumlib/subscriptions","organizations_url":"https://api.github.com/users/quantumlib/orgs","repos_url":"https://api.github.com/users/quantumlib/repos","events_url":"https://api.github.com/users/quantumlib/events{/privacy}","received_events_url":"https://api.github.com/users/quantumlib/received_events","type":"Organization","site_admin":false},"repo":{"id":114306758,"node_id":"MDEwOlJlcG9zaXRvcnkxMTQzMDY3NTg=","name":"Cirq","full_name":"quantumlib/Cirq","private":false,"owner":{"login":"quantumlib","id":31279789,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxMjc5Nzg5","avatar_url":"https://avatars1.githubusercontent.com/u/31279789?v=4","gravatar_id":"","url":"https://api.github.com/users/quantumlib","html_url":"https://github.com/quantumlib","followers_url":"https://api.github.com/users/quantumlib/followers","following_url":"https://api.github.com/users/quantumlib/following{/other_user}","gists_url":"https://api.github.com/users/quantumlib/gists{/gist_id}","starred_url":"https://api.github.com/users/quantumlib/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/quantumlib/subscriptions","organizations_url":"https://api.github.com/users/quantumlib/orgs","repos_url":"https://api.github.com/users/quantumlib/repos","events_url":"https://api.github.com/users/quantumlib/events{/privacy}","received_events_url":"https://api.github.com/users/quantumlib/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/quantumlib/Cirq","description":"A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.","fork":false,"url":"https://api.github.com/repos/quantumlib/Cirq","forks_url":"https://api.github.com/repos/quantumlib/Cirq/forks","keys_url":"https://api.github.com/repos/quantumlib/Cirq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/quantumlib/Cirq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/quantumlib/Cirq/teams","hooks_url":"https://api.github.com/repos/quantumlib/Cirq/hooks","issue_events_url":"https://api.github.com/repos/quantumlib/Cirq/issues/events{/number}","events_url":"https://api.github.com/repos/quantumlib/Cirq/events","assignees_url":"https://api.github.com/repos/quantumlib/Cirq/assignees{/user}","branches_url":"https://api.github.com/repos/quantumlib/Cirq/branches{/branch}","tags_url":"https://api.github.com/repos/quantumlib/Cirq/tags","blobs_url":"https://api.github.com/repos/quantumlib/Cirq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/quantumlib/Cirq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/quantumlib/Cirq/git/refs{/sha}","trees_url":"https://api.github.com/repos/quantumlib/Cirq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/quantumlib/Cirq/statuses/{sha}","languages_url":"https://api.github.com/repos/quantumlib/Cirq/languages","stargazers_url":"https://api.github.com/repos/quantumlib/Cirq/stargazers","contributors_url":"https://api.github.com/repos/quantumlib/Cirq/contributors","subscribers_url":"https://api.github.com/repos/quantumlib/Cirq/subscribers","subscription_url":"https://api.github.com/repos/quantumlib/Cirq/subscription","commits_url":"https://api.github.com/repos/quantumlib/Cirq/commits{/sha}","git_commits_url":"https://api.github.com/repos/quantumlib/Cirq/git/commits{/sha}","comments_url":"https://api.github.com/repos/quantumlib/Cirq/comments{/number}","issue_comment_url":"https://api.github.com/repos/quantumlib/Cirq/issues/comments{/number}","contents_url":"https://api.github.com/repos/quantumlib/Cirq/contents/{+path}","compare_url":"https://api.github.com/repos/quantumlib/Cirq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/quantumlib/Cirq/merges","archive_url":"https://api.github.com/repos/quantumlib/Cirq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/quantumlib/Cirq/downloads","issues_url":"https://api.github.com/repos/quantumlib/Cirq/issues{/number}","pulls_url":"https://api.github.com/repos/quantumlib/Cirq/pulls{/number}","milestones_url":"https://api.github.com/repos/quantumlib/Cirq/milestones{/number}","notifications_url":"https://api.github.com/repos/quantumlib/Cirq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/quantumlib/Cirq/labels{/name}","releases_url":"https://api.github.com/repos/quantumlib/Cirq/releases{/id}","deployments_url":"https://api.github.com/repos/quantumlib/Cirq/deployments","created_at":"2017-12-14T23:41:49Z","updated_at":"2018-12-18T23:26:32Z","pushed_at":"2018-12-18T23:37:03Z","git_url":"git://github.com/quantumlib/Cirq.git","ssh_url":"git@github.com:quantumlib/Cirq.git","clone_url":"https://github.com/quantumlib/Cirq.git","svn_url":"https://github.com/quantumlib/Cirq","homepage":"","size":3104,"stargazers_count":1266,"watchers_count":1266,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":183,"mirror_url":null,"archived":false,"open_issues_count":206,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":183,"open_issues":206,"watchers":1266,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252"},"html":{"href":"https://github.com/quantumlib/Cirq/pull/1252"},"issue":{"href":"https://api.github.com/repos/quantumlib/Cirq/issues/1252"},"comments":{"href":"https://api.github.com/repos/quantumlib/Cirq/issues/1252/comments"},"review_comments":{"href":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252/comments"},"review_comment":{"href":"https://api.github.com/repos/quantumlib/Cirq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/quantumlib/Cirq/pulls/1252/commits"},"statuses":{"href":"https://api.github.com/repos/quantumlib/Cirq/statuses/ac5bf1b065b861cd41ecb7f7cab4244a68983eb1"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"kevinsung"}}