Skip to content

Commit d33d50e

Browse files
committed
Removed py3dmol as a dependency
1 parent 7fe767d commit d33d50e

File tree

4 files changed

+2
-62
lines changed

4 files changed

+2
-62
lines changed

poetry.lock

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ ray = "2.10"
2323
sphinx-design = "^0.5.0"
2424
myst-nb = "^0.17.2"
2525
sphinx-copybutton = "^0.5.2"
26-
py3dmol = "^2.0.4"
2726
scipy = "1.9.3"
2827
urllib3 = "1.26.6"
2928

symmer/utils.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import scipy as sp
44
from typing import List, Tuple, Union
55
from functools import reduce
6-
import py3Dmol
76
from scipy.sparse import csr_matrix
87
from scipy.sparse import kron as sparse_kron
98
from symmer.operators.utils import _rref_binary
@@ -225,39 +224,6 @@ def gram_schmidt_from_quantum_state(state:Union[np.array, list, QuantumState]) -
225224

226225
return M
227226

228-
229-
def Draw_molecule(
230-
xyz_string: str, width: int = 400, height: int = 400, style: str = "sphere"
231-
) -> py3Dmol.view:
232-
"""Draw molecule from xyz string.
233-
234-
Note if molecule has unrealistic bonds, then style should be sphere. Otherwise stick style can be used
235-
which shows bonds.
236-
237-
TODO: more styles at http://3dmol.csb.pitt.edu/doc/$3Dmol.GLViewer.html
238-
239-
Args:
240-
xyz_string (str): xyz string of molecule
241-
width (int): width of image
242-
height (int): Height of image
243-
style (str): py3Dmol style ('sphere' or 'stick')
244-
245-
Returns:
246-
view (py3dmol.view object). Run view.show() method to print molecule.
247-
"""
248-
view = py3Dmol.view(width=width, height=height)
249-
view.addModel(xyz_string, "xyz")
250-
if style == "sphere":
251-
view.setStyle({'sphere': {"radius": 0.2}})
252-
elif style == "stick":
253-
view.setStyle({'stick': {}})
254-
else:
255-
raise ValueError(f"unknown py3dmol style: {style}")
256-
257-
view.zoomTo()
258-
return view
259-
260-
261227
def get_sparse_matrix_large_pauliwordop(P_op: PauliwordOp) -> csr_matrix:
262228
"""
263229
In order to build the sparse matrix (e.g. above 18 qubits), this function goes through each pauli term

tests/test_symmer_utils.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from symmer.operators import PauliwordOp, QuantumState
2-
from symmer.utils import (exact_gs_energy, random_anitcomm_2n_1_PauliwordOp,Draw_molecule,
2+
from symmer.utils import (exact_gs_energy, random_anitcomm_2n_1_PauliwordOp,
33
tensor_list, gram_schmidt_from_quantum_state, product_list,
44
get_sparse_matrix_large_pauliwordop, matrix_allclose)
55
import numpy as np
66
from openfermion import QubitOperator
7-
import py3Dmol
87

98
H2_sto3g = {'qubit_encoding': 'jordan_wigner',
109
'unit': 'angstrom',
@@ -446,16 +445,6 @@ def test_gram_schmidt_from_quantum_state_numpy_array():
446445
assert np.allclose(U_gram[:, 0], psi_norm), 'first column of U_gram not correct'
447446
assert np.allclose(U_gram @ U_gram.conj().T, np.eye(2 ** nq)), 'U_gram not unitary'
448447

449-
450-
def test_Draw_molecule():
451-
452-
xyz = H2_sto3g['geometry']
453-
viewer_sphere = Draw_molecule(xyz, width=400, height=400, style='sphere')
454-
assert isinstance(viewer_sphere, py3Dmol.view)
455-
456-
viewer_stick = Draw_molecule(xyz, width=400, height=400, style='stick')
457-
assert isinstance(viewer_stick, py3Dmol.view)
458-
459448
def test_get_sparse_matrix_large_pauliwordop():
460449
for nq in range(2,6):
461450
n_terms = 10*nq

0 commit comments

Comments
 (0)