From f7f880a51f3fe0576681153ed37f97bb4b477dbe Mon Sep 17 00:00:00 2001 From: Nikola Sibalic Date: Mon, 1 Jan 2024 19:15:55 +0100 Subject: [PATCH] support rendering on headless backends by not using enable_depth_peeling --- ifigures/__init__.py | 2 +- ifigures/amoplots.py | 6 ++++-- ifigures/timelines.py | 3 +-- pyproject.toml | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ifigures/__init__.py b/ifigures/__init__.py index b206f9d..ecefd26 100644 --- a/ifigures/__init__.py +++ b/ifigures/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.2.4" +__version__ = "0.2.5" from .interact import InteractiveFigure from .widgets import RadioWidget, RangeWidget, RangeWidgetViridis, DropDownWidget diff --git a/ifigures/amoplots.py b/ifigures/amoplots.py index ce6540a..deb807d 100644 --- a/ifigures/amoplots.py +++ b/ifigures/amoplots.py @@ -6,6 +6,7 @@ import pyvista as pv from io import BytesIO from PIL import Image +from os import environ class EnergyLevels: @@ -708,7 +709,7 @@ def plot(self, axis=None, debug=False, ], labelOffset=None ): - """Plots Bloch sphere on the given axis. + r"""Plots Bloch sphere on the given axis. Args: axis (_type_, optional): _description_. Defaults to None. @@ -720,7 +721,8 @@ def plot(self, axis=None, debug=False, label (list, optional): _description_. Defaults to [r"$|e\rangle$", r"$|g\rangle$", r"$\frac{|e\rangle+|g\rangle}{\sqrt{2}}$", r"$\frac{|e\rangle+i|g\rangle}{\sqrt{2}}$" ]. labelOffset (_type_, optional): _description_. Defaults to None. """ - self.p.enable_depth_peeling(10) + if environ.get("PYVISTA_OFF_SCREEN") != "true": + self.p.enable_depth_peeling(10) self.p.camera_position = cameraPosition # [(13.0, 0.0, 1.0), # (0.0, 0.0, 0.0), diff --git a/ifigures/timelines.py b/ifigures/timelines.py index 34c848e..e2b6680 100644 --- a/ifigures/timelines.py +++ b/ifigures/timelines.py @@ -509,8 +509,7 @@ def saveStaticFigure(self, folderName:str): with open(latexFile, 'w') as f: f.write(eventsLaTeX) - print("Add generated folder and this line to use timeline in LaTeX:\n\input{%s}" - % latexFile) + print(f"Add generated folder and this line to use timeline in LaTeX:\n\input{latexFile}") return diff --git a/pyproject.toml b/pyproject.toml index 3485206..e4c5c68 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "interactive-publishing" -version = "0.2.4" +version = "0.2.5" description = "Templates and tools for creating interactive figures and interactive text for publishing in EPUB3/HTML5." authors = ["Nikola Sibalic "] license = "BSD-3-Clause license"