From f9fba19d8f67ae949238ac813d6222ecb4f2f5d8 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Wed, 15 Nov 2023 13:38:42 +0000 Subject: [PATCH 1/5] modernise plt.add vedo call see https://github.com/marcomusy/vedo/commit/6e81bbea067bd35f429e82bdbc3b832a12569581 --- brainrender/render.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brainrender/render.py b/brainrender/render.py index b2dcc0d1..09818852 100644 --- a/brainrender/render.py +++ b/brainrender/render.py @@ -302,7 +302,7 @@ def export(self, savepath): # Create new plotter and save to file plt = Plotter() - plt.add(self.clean_renderables, render=False) + plt.add(self.clean_renderables).render() plt = plt.show(interactive=False) plt.camera[-2] = -1 From 9ec052d2645b572f0734bc3f2fbe6bdde234fb08 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Wed, 15 Nov 2023 14:00:37 +0000 Subject: [PATCH 2/5] ensure k3d is the backend for html export, but that this change in backend is scoped k3d seems like a good choice for html as k3d provides standalone HTML/JS rendering capabilities: https://github.com/K3D-tools/K3D-jupyter it is one of the options for a jupyter notebook too. see https://vedo.embl.es/docs/vedo.html --- brainrender/render.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brainrender/render.py b/brainrender/render.py index 09818852..fa59ffc9 100644 --- a/brainrender/render.py +++ b/brainrender/render.py @@ -289,6 +289,7 @@ def export(self, savepath): """ logger.debug(f"Exporting scene to {savepath}") _backend = self.backend + _default_backend = vsettings.default_backend if not self.is_rendered: self.render(interactive=False) @@ -314,7 +315,7 @@ def export(self, savepath): ) # Reset settings - vsettings.notebookBackend = None + vsettings.default_backend = _default_backend self.backend = _backend return str(path) From e3dee52a105cbdb72c1ba0df7a56aedc320714a0 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Wed, 15 Nov 2023 14:13:17 +0000 Subject: [PATCH 3/5] remove camera operation I don't see why our export function should affect the camera. I removed it here because camera is an empty list in the test. --- brainrender/render.py | 1 - 1 file changed, 1 deletion(-) diff --git a/brainrender/render.py b/brainrender/render.py index fa59ffc9..a7d91408 100644 --- a/brainrender/render.py +++ b/brainrender/render.py @@ -305,7 +305,6 @@ def export(self, savepath): plt = Plotter() plt.add(self.clean_renderables).render() plt = plt.show(interactive=False) - plt.camera[-2] = -1 with open(path, "w") as fp: fp.write(plt.get_snapshot()) From 4ba30fcc0bf411c72f14198ff36a463c3a9c6a80 Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Wed, 15 Nov 2023 14:22:26 +0000 Subject: [PATCH 4/5] modularise export test --- tests/test_export_html.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/test_export_html.py b/tests/test_export_html.py index 4ac5cc4e..25f34d02 100644 --- a/tests/test_export_html.py +++ b/tests/test_export_html.py @@ -5,15 +5,19 @@ from brainrender import Scene -@pytest.mark.local -def test_export_for_web(): +@pytest.fixture +def scene(): + """Provide a scene with a brain region""" s = Scene(title="BR") - th = s.add_brain_region("TH") - s.add_label(th, "TH") + return s + - path = s.export("test.html") +@pytest.mark.local +def test_export_for_web(scene): + """Check that exporting to html creates the expected file""" + path = scene.export("test.html") assert path == "test.html" path = Path(path) @@ -21,5 +25,9 @@ def test_export_for_web(): path.unlink() + +@pytest.mark.local +def test_export_for_web_raises(scene): + """Check that exporting with invalid file extention raises ValueError""" with pytest.raises(ValueError): - path = s.export("test.py") + scene.export("test.py") From fe20094121713012817122b41353c18b476ce82b Mon Sep 17 00:00:00 2001 From: alessandrofelder Date: Wed, 15 Nov 2023 14:23:10 +0000 Subject: [PATCH 5/5] make export test non-local --- tests/test_export_html.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/test_export_html.py b/tests/test_export_html.py index 25f34d02..70ca54b5 100644 --- a/tests/test_export_html.py +++ b/tests/test_export_html.py @@ -14,7 +14,6 @@ def scene(): return s -@pytest.mark.local def test_export_for_web(scene): """Check that exporting to html creates the expected file""" path = scene.export("test.html") @@ -26,7 +25,6 @@ def test_export_for_web(scene): path.unlink() -@pytest.mark.local def test_export_for_web_raises(scene): """Check that exporting with invalid file extention raises ValueError""" with pytest.raises(ValueError):