Skip to content

Commit

Permalink
Remove discussion of addresses from API and docs and replace with "CI…
Browse files Browse the repository at this point in the history
… strings" (#54)

* Remove discussion of addresses

* Add release note

* Fix docs

* Update warning

* Don't specify base-10 integers
  • Loading branch information
caleb-johnson authored Sep 23, 2024
1 parent fd663c2 commit 0819a31
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 82 deletions.
6 changes: 3 additions & 3 deletions docs/how_tos/choose_subspace_dimension.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"source": [
"from qiskit_addon_sqd.configuration_recovery import recover_configurations\n",
"from qiskit_addon_sqd.fermion import (\n",
" bitstring_matrix_to_sorted_addresses,\n",
" bitstring_matrix_to_ci_strs,\n",
" flip_orbital_occupancies,\n",
" solve_fermion,\n",
")\n",
Expand Down Expand Up @@ -176,8 +176,8 @@
" int_occs = np.zeros((n_batches, 2 * num_orbitals))\n",
" cs = []\n",
" for j in range(n_batches):\n",
" addresses = bitstring_matrix_to_sorted_addresses(batches[j], open_shell=open_shell)\n",
" int_d[j] = len(addresses[0]) * len(addresses[1])\n",
" ci_strs = bitstring_matrix_to_ci_strs(batches[j], open_shell=open_shell)\n",
" int_d[j] = len(ci_strs[0]) * len(ci_strs[1])\n",
" energy_sci, coeffs_sci, avg_occs, spin = solve_fermion(\n",
" batches[j],\n",
" hcore,\n",
Expand Down
6 changes: 3 additions & 3 deletions docs/how_tos/integrate_dice_solver.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"from qiskit_addon_sqd.configuration_recovery import recover_configurations\n",
"from qiskit_addon_sqd.counts import counts_to_arrays, generate_counts_uniform\n",
"from qiskit_addon_sqd.fermion import (\n",
" bitstring_matrix_to_sorted_addresses,\n",
" bitstring_matrix_to_ci_strs,\n",
" flip_orbital_occupancies,\n",
")\n",
"from qiskit_addon_sqd.subsampling import postselect_and_subsample\n",
Expand Down Expand Up @@ -100,9 +100,9 @@
" int_e = np.zeros(n_batches)\n",
" int_occs = np.zeros((n_batches, 2 * num_orbitals))\n",
" for j in range(n_batches):\n",
" addresses = bitstring_matrix_to_sorted_addresses(batches[j], open_shell=open_shell)\n",
" ci_strs = bitstring_matrix_to_ci_strs(batches[j], open_shell=open_shell)\n",
" energy_sci, wf_mags, avg_occs = solve_dice(\n",
" addresses,\n",
" ci_strs,\n",
" active_space_path,\n",
" os.path.abspath(\".\"),\n",
" spin_sq=spin_sq,\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"This package provides two tools to perform this projection:\n",
"\n",
"- ``qiskit_addon_sqd.qubit.matrix_elements_from_pauli()``: is a lower-level function\n",
"that returns the non-zero matrix elements of a Pauli string and the corresponding addresses\n",
"that returns the non-zero matrix elements of a Pauli string and the corresponding indices\n",
"of the non-zero elements.\n",
"\n",
"- ``qiskit_addon_sqd.qubit.project_operator_to_subspace()``: is a higher-level function that \n",
Expand Down Expand Up @@ -92,7 +92,7 @@
"id": "5707b93c",
"metadata": {},
"source": [
"### First method: nonzero matrix elements and addresses."
"### First method: nonzero matrix elements and indices."
]
},
{
Expand Down Expand Up @@ -142,11 +142,9 @@
"operator_from_matrix_elements = coo_matrix((d, d), dtype=\"complex128\")\n",
"\n",
"for pauli in hamiltonian.paulis:\n",
" matrix_elements, row_addresses, col_addresses = matrix_elements_from_pauli(\n",
" bitstring_matrix, pauli\n",
" )\n",
" matrix_elements, row_indices, col_indices = matrix_elements_from_pauli(bitstring_matrix, pauli)\n",
" operator_from_matrix_elements += coo_matrix(\n",
" (matrix_elements, (row_addresses, col_addresses)), (d, d)\n",
" (matrix_elements, (row_indices, col_indices)), (d, d)\n",
" )"
]
},
Expand Down
38 changes: 18 additions & 20 deletions docs/how_tos/select_open_closed_shell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,10 @@
}
],
"source": [
"from qiskit_addon_sqd.fermion import bitstring_matrix_to_sorted_addresses\n",
"from qiskit_addon_sqd.fermion import bitstring_matrix_to_ci_strs\n",
"\n",
"addresses = bitstring_matrix_to_sorted_addresses(batches[0], open_shell=open_shell)\n",
"print(addresses)"
"ci_strs = bitstring_matrix_to_ci_strs(batches[0], open_shell=open_shell)\n",
"print(ci_strs)"
]
},
{
Expand Down Expand Up @@ -277,15 +277,14 @@
}
],
"source": [
"addresses_up = addresses[0]\n",
"addresses_dn = addresses[1]\n",
"ci_strs_up, ci_strs_dn = ci_strs\n",
"\n",
"print(\"Basis elements of the subspace:\")\n",
"\n",
"for address_up in addresses_up:\n",
" for address_dn in addresses_dn:\n",
"for ci_str_up in ci_strs_up:\n",
" for ci_str_dn in ci_strs_dn:\n",
" format_name = \"{0:0\" + str(num_orbitals) + \"b}\"\n",
" print(\"|\" + format_name.format(address_up) + format_name.format(address_dn) + \">\")"
" print(\"|\" + format_name.format(ci_str_up) + format_name.format(ci_str_dn) + \">\")"
]
},
{
Expand Down Expand Up @@ -436,13 +435,13 @@
"name": "stdout",
"output_type": "stream",
"text": [
"(array([1, 4], dtype=int64), array([2, 8], dtype=int64))\n"
"(array([2, 8], dtype=int64), array([1, 4], dtype=int64))\n"
]
}
],
"source": [
"addresses = bitstring_matrix_to_sorted_addresses(batches[0], open_shell=open_shell)\n",
"print(addresses)"
"ci_strs = bitstring_matrix_to_ci_strs(batches[0], open_shell=open_shell)\n",
"print(ci_strs)"
]
},
{
Expand Down Expand Up @@ -484,23 +483,22 @@
"output_type": "stream",
"text": [
"Basis elements of the subspace:\n",
"|00010010>\n",
"|00011000>\n",
"|01000010>\n",
"|01001000>\n"
"|00100001>\n",
"|00100100>\n",
"|10000001>\n",
"|10000100>\n"
]
}
],
"source": [
"addresses_up = addresses[0]\n",
"addresses_dn = addresses[1]\n",
"ci_strs_up, ci_strs_dn = ci_strs\n",
"\n",
"print(\"Basis elements of the subspace:\")\n",
"\n",
"for address_up in addresses_up:\n",
" for address_dn in addresses_dn:\n",
"for ci_str_up in ci_strs_up:\n",
" for ci_str_dn in ci_strs_dn:\n",
" format_name = \"{0:0\" + str(num_orbitals) + \"b}\"\n",
" print(\"|\" + format_name.format(address_up) + format_name.format(address_dn) + \">\")"
" print(\"|\" + format_name.format(ci_str_up) + format_name.format(ci_str_dn) + \">\")"
]
},
{
Expand Down
28 changes: 13 additions & 15 deletions docs/how_tos/use_oo_to_optimize_hamiltonian_basis.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 0819a31

Please sign in to comment.