Skip to content

Commit

Permalink
Merge branch 'html' into refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
hainm committed Jun 20, 2024
2 parents d0b708e + a0cc4e6 commit e202afd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 6 additions & 4 deletions nglview/tests/test_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def test_show_pymatgen():
def test_show_qcelemental():
import qcelemental as qcel

mol = qcel.models.Molecule.from_data("He 0 0 0")
mol = qcel.models.Molecule.from_data("He 0 0 0")
view = nv.show_qcelemental(mol)
view

Expand Down Expand Up @@ -1025,15 +1025,17 @@ def test_write_html(mock_unset):
display(view)
fp = StringIO()

with patch.object(embed, 'embed_snippet') as mock_embed:
with patch.object(embed, 'embed_snippet') as mock_embed_snippet:
mock_embed_snippet.return_value = 'ok'
nv.write_html(fp, [view], frame_range=(0, 3))
mock_embed.assert_called_with([tm, cm, view])
mock_embed_snippet.assert_called_with([tm, cm, view])
mock_unset.assert_called_with()
assert len(view._ngl_coordinate_resource[0]) == 3
assert len(view._ngl_coordinate_resource[1]) == 3

# box
with patch.object(embed, 'embed_snippet') as mock_embed:
with patch.object(embed, 'embed_snippet') as mock_embed_snippet:
mock_embed_snippet.return_value = 'ok'
nv.write_html(fp, [HBox([view])], frame_range=(0, 3))
# FIXME: assertion?

Expand Down
5 changes: 1 addition & 4 deletions nglview/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from logging import getLogger

import ipywidgets as widgets
import ipywidgets.embed
from ipywidgets import embed
import numpy as np
from IPython.display import display
from ipywidgets import (Image, Box, DOMWidget, HBox, VBox, IntSlider, Output, Play, Widget,
Expand Down Expand Up @@ -84,9 +84,6 @@ def write_html(fp, views, frame_range=None):
>>> nglview.write_html('index.html', [view], frame_range=(0, 5)) # doctest: +SKIP
"""
views = isinstance(views, DOMWidget) and [views] or views
embed = ipywidgets.embed
color = None
theme = None

for _, v in _INIT_VIEWS.items():
views.insert(0, v)
Expand Down

0 comments on commit e202afd

Please sign in to comment.