diff --git a/poetry.lock b/poetry.lock index 999435e..537ed60 100644 --- a/poetry.lock +++ b/poetry.lock @@ -144,7 +144,7 @@ version = "3.0.0" description = "Annotate AST trees with source code positions" optional = false python-versions = ">=3.8" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "asttokens-3.0.0-py3-none-any.whl", hash = "sha256:e3078351a059199dd5138cb1c706e6430c05eff2ff136af5eb4790f9d28932e2"}, {file = "asttokens-3.0.0.tar.gz", hash = "sha256:0dcd8baa8d62b0c1d118b399b2ddba3c4aff271d0d7a9e0d4c1681c79035bbc7"}, @@ -518,7 +518,7 @@ files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] -markers = {main = "platform_system == \"Windows\" or sys_platform == \"win32\""} +markers = {main = "platform_system == \"Windows\""} [[package]] name = "comm" @@ -803,7 +803,7 @@ version = "5.1.1" description = "Decorators for Humans" optional = false python-versions = ">=3.5" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "decorator-5.1.1-py3-none-any.whl", hash = "sha256:b8c3f85900b9dc423225913c5aace94729fe1fa9763b38939a95226f02d37186"}, {file = "decorator-5.1.1.tar.gz", hash = "sha256:637996211036b6385ef91435e4fae22989472f9d571faba8927ba8253acbc330"}, @@ -865,7 +865,7 @@ version = "1.2.2" description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" -groups = ["main", "dev"] +groups = ["dev"] markers = "python_version < \"3.11\"" files = [ {file = "exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b"}, @@ -881,7 +881,7 @@ version = "2.2.0" description = "Get the currently executing AST node of a frame, and other information" optional = false python-versions = ">=3.8" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "executing-2.2.0-py2.py3-none-any.whl", hash = "sha256:11387150cad388d62750327a53d3339fad4888b39a6fe233c3afbb54ecffd3aa"}, {file = "executing-2.2.0.tar.gz", hash = "sha256:5d108c028108fe2551d1a7b2e8b713341e2cb4fc0aa7dcf966fa4327a5226755"}, @@ -1250,7 +1250,7 @@ version = "8.32.0" description = "IPython: Productive Interactive Computing" optional = false python-versions = ">=3.10" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "ipython-8.32.0-py3-none-any.whl", hash = "sha256:cae85b0c61eff1fc48b0a8002de5958b6528fa9c8defb1894da63f42613708aa"}, {file = "ipython-8.32.0.tar.gz", hash = "sha256:be2c91895b0b9ea7ba49d33b23e2040c352b33eb6a519cca7ce6e0c743444251"}, @@ -1304,7 +1304,7 @@ version = "0.19.2" description = "An autocompletion tool for Python that can be used for text editors." optional = false python-versions = ">=3.6" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "jedi-0.19.2-py2.py3-none-any.whl", hash = "sha256:a8ef22bde8490f57fe5c7681a3c83cb58874daf72b4784de3cce5b6ef6edb5b9"}, {file = "jedi-0.19.2.tar.gz", hash = "sha256:4770dc3de41bde3966b02eb84fbcf557fb33cce26ad23da12c742fb50ecb11f0"}, @@ -1907,7 +1907,7 @@ version = "0.1.7" description = "Inline Matplotlib backend for Jupyter" optional = false python-versions = ">=3.8" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "matplotlib_inline-0.1.7-py3-none-any.whl", hash = "sha256:df192d39a4ff8f21b1895d72e6a13f5fcc5099f00fa84384e0ea28c2cc0653ca"}, {file = "matplotlib_inline-0.1.7.tar.gz", hash = "sha256:8423b23ec666be3d16e16b60bdd8ac4e86e840ebd1dd11a30b9f117f2fa0ab90"}, @@ -2616,7 +2616,7 @@ version = "0.8.4" description = "A Python Parser" optional = false python-versions = ">=3.6" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "parso-0.8.4-py2.py3-none-any.whl", hash = "sha256:a418670a20291dacd2dddc80c377c5c3791378ee1e8d12bffc35420643d43f18"}, {file = "parso-0.8.4.tar.gz", hash = "sha256:eb3a7b58240fb99099a345571deecc0f9540ea5f4dd2fe14c2a99d6b281ab92d"}, @@ -2644,7 +2644,7 @@ version = "4.9.0" description = "Pexpect allows easy control of interactive console applications." optional = false python-versions = "*" -groups = ["main", "dev"] +groups = ["dev"] markers = "sys_platform != \"win32\" and sys_platform != \"emscripten\"" files = [ {file = "pexpect-4.9.0-py2.py3-none-any.whl", hash = "sha256:7236d1e080e4936be2dc3e326cec0af72acf9212a7e1d060210e70a47e253523"}, @@ -2838,7 +2838,7 @@ version = "3.0.50" description = "Library for building powerful interactive command lines in Python" optional = false python-versions = ">=3.8.0" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "prompt_toolkit-3.0.50-py3-none-any.whl", hash = "sha256:9b6427eb19e479d98acff65196a307c555eb567989e6d88ebbb1b509d9779198"}, {file = "prompt_toolkit-3.0.50.tar.gz", hash = "sha256:544748f3860a2623ca5cd6d2795e7a14f3d0e1c3c9728359013f79877fc89bab"}, @@ -2877,12 +2877,12 @@ version = "0.7.0" description = "Run a subprocess in a pseudo terminal" optional = false python-versions = "*" -groups = ["main", "dev"] +groups = ["dev"] +markers = "os_name != \"nt\" or sys_platform != \"win32\" and sys_platform != \"emscripten\"" files = [ {file = "ptyprocess-0.7.0-py2.py3-none-any.whl", hash = "sha256:4b41f3967fce3af57cc7e94b888626c18bf37a083e3651ca8feeb66d492fef35"}, {file = "ptyprocess-0.7.0.tar.gz", hash = "sha256:5c5d0a3b48ceee0b48485e0c26037c0acd7d29765ca3fbb5cb3831d347423220"}, ] -markers = {main = "sys_platform != \"win32\" and sys_platform != \"emscripten\"", dev = "sys_platform != \"win32\" and sys_platform != \"emscripten\" or os_name != \"nt\""} [[package]] name = "pure-eval" @@ -2890,7 +2890,7 @@ version = "0.2.3" description = "Safely evaluate AST nodes without side effects" optional = false python-versions = "*" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "pure_eval-0.2.3-py3-none-any.whl", hash = "sha256:1db8e35b67b3d218d818ae653e27f06c3aa420901fa7b081ca98cbedc874e0d0"}, {file = "pure_eval-0.2.3.tar.gz", hash = "sha256:5f4e983f40564c576c7c8635ae88db5956bb2229d7e9237d03b3c0b0190eaf42"}, @@ -3985,7 +3985,7 @@ version = "0.6.3" description = "Extract data from python stack frames and tracebacks for informative displays" optional = false python-versions = "*" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "stack_data-0.6.3-py3-none-any.whl", hash = "sha256:d5558e0c25a4cb0853cddad3d77da9891a08cb85dd9f9f91b9f8cd66e511e695"}, {file = "stack_data-0.6.3.tar.gz", hash = "sha256:836a778de4fec4dcd1dcd89ed8abff8a221f58308462e1c4aa2a3cf30148f0b9"}, @@ -4138,7 +4138,7 @@ version = "5.14.3" description = "Traitlets Python configuration system" optional = false python-versions = ">=3.8" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "traitlets-5.14.3-py3-none-any.whl", hash = "sha256:b74e89e397b1ed28cc831db7aea759ba6640cb3de13090ca145426688ff1ac4f"}, {file = "traitlets-5.14.3.tar.gz", hash = "sha256:9ed0579d3502c94b4b3732ac120375cda96f923114522847de4b3bb98b96b6b7"}, @@ -4350,7 +4350,7 @@ version = "0.2.13" description = "Measures the displayed width of unicode strings in a terminal" optional = false python-versions = "*" -groups = ["main", "dev"] +groups = ["dev"] files = [ {file = "wcwidth-0.2.13-py2.py3-none-any.whl", hash = "sha256:3da69048e4540d84af32131829ff948f1e022c1c6bdb8d6102117aac784f6859"}, {file = "wcwidth-0.2.13.tar.gz", hash = "sha256:72ea0c06399eb286d978fdedb6923a9eb47e1c486ce63e9b4e64fc18303972b5"}, @@ -4422,4 +4422,4 @@ jupyter = ["ipytree (>=0.2.2)", "ipywidgets (>=8.0.0)", "notebook"] [metadata] lock-version = "2.1" python-versions = ">=3.10,<4.0" -content-hash = "85cd739977f51e05bd43544fc600e79bd843de691c68a5b24cfbb2073d324cda" +content-hash = "9699633677b7ebde35a58f1472378e680a46a04c7016a9d213ef6235c8f54547" diff --git a/pyproject.toml b/pyproject.toml index 2e5cfa3..cd25180 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,6 @@ documentation = "https://virtualcell.github.io/pyvcell/" readme = "README.md" packages = [ {include = "pyvcell"}, - {include = "tests"}, ] [tool.poetry.dependencies] @@ -31,7 +30,6 @@ python-dateutil = "^2.9.0.post0" pyvista = "^0.44.2" python-libsbml = "^5.20.4" matplotlib = "^3.10.0" -ipython = "^8.32.0" [tool.poetry.group.dev.dependencies] pytest = "^7.2.0" diff --git a/pyvcell/data_model/plotter.py b/pyvcell/data_model/plotter.py index d8a34de..c2b2e2d 100644 --- a/pyvcell/data_model/plotter.py +++ b/pyvcell/data_model/plotter.py @@ -1,9 +1,8 @@ -from typing import Any, Union, no_type_check +from typing import Union, no_type_check import matplotlib.pyplot as plt import numpy as np import zarr -from IPython.display import HTML from matplotlib import animation from pyvcell.data_model.var_types import NDArray2D @@ -12,6 +11,10 @@ from pyvcell.simdata.postprocessing import PostProcessing, VariableInfo from pyvcell.utils import slice_dataset +plt.rcParams["animation.html"] = "jshtml" +plt.rcParams["figure.dpi"] = 150 +plt.ioff() + class Plotter: def __init__( @@ -143,17 +146,10 @@ def update(frame: int): # Create the animation fig.colorbar(sc, ax=ax, label="Intensity") # type: ignore[arg-type] - ani = animation.FuncAnimation(fig, update, num_timepoints, interval=interval, blit=False) - - return ani + return animation.FuncAnimation(fig, update, num_timepoints, interval=interval, blit=False) - @no_type_check - def render_animation(self, ani: animation.FuncAnimation) -> HTML: - return HTML(ani.to_jshtml()) - - def animate_channel_3d(self, channel_index: int) -> Any: - ani = self.get_3d_slice_animation(channel_index) - return self.render_animation(ani) + def animate_channel_3d(self, channel_index: int) -> animation.FuncAnimation: + return self.get_3d_slice_animation(channel_index) def get_image_animation(self, image_index: int, interval: int = 200) -> animation.FuncAnimation: """ @@ -184,14 +180,11 @@ def update(frame: int): return (img_plot,) # Create the animation - ani = animation.FuncAnimation(fig, update, frames=self.num_timepoints, interval=interval, blit=False) - - return ani + return animation.FuncAnimation(fig, update, frames=self.num_timepoints, interval=interval, blit=False) @no_type_check - def animate_image(self, image_index: int) -> HTML: - ani = self.get_image_animation(image_index) - return self.render_animation(ani) + def animate_image(self, image_index: int) -> animation.FuncAnimation: + return self.get_image_animation(image_index) def plot_averages(self) -> None: var_averages: set[VariableInfo] = {var for var in self.post_processing.variables if var.statistic_type == 0} diff --git a/tests/data_model/test_result.py b/tests/data_model/test_result.py index 160b259..28b1b93 100644 --- a/tests/data_model/test_result.py +++ b/tests/data_model/test_result.py @@ -1,12 +1,17 @@ # test result class +import os from pathlib import Path import numpy as np +import pytest from pyvcell.data_model.result import Result from pyvcell.data_model.var_types import NDArray2D +IN_GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true" + +@pytest.mark.skipif(IN_GITHUB_ACTIONS, reason="Test doesn't work in Github Actions.") def test_plot_slice_2D(solver_output_path: Path, solver_output_simid_jobid: tuple[int, int], zarr_path: Path) -> None: sim_id, job_id = solver_output_simid_jobid result = Result(solver_output_dir=solver_output_path, sim_id=sim_id, job_id=job_id, zarr_dir=zarr_path)