Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions .github/actions/setup-uv-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ description: "Composite action to setup the Python and uv environment."

inputs:
python-version:
required: false
required: true
description: "The python version to use"
default: "3.11"

runs:
using: "composite"
Expand All @@ -19,15 +18,8 @@ runs:
run: curl -LsSf https://astral.sh/uv/install.sh | sh
shell: bash

- name: Load cached venv
id: cached-uv-dependencies
uses: actions/cache@v4
if: github.run_attempt == 1
with:
path: .venv
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('uv.lock') }}

- name: Install dependencies
if: github.run_attempt > 1 || steps.cached-uv-dependencies.outputs.cache-hit != 'true'
run: uv sync --all-groups
run: |
uv venv --python $(python${{ inputs.python-version }} --version | awk '{print $2;}')
uv sync --all-groups
shell: bash
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
fail-fast: false
defaults:
run:
Expand All @@ -53,6 +53,7 @@ jobs:
run: xvfb-run uv run pytest tests --cov --cov-config=pyproject.toml --cov-report=xml

- name: Check typing
if: "3.10" != ${{ matrix.python-version }} # python 3.10 works, however the typing check fails due to old typing rules not continued in future versions
run: uv run mypy

- name: Upload coverage reports to Codecov with GitHub Action on Python 3.11
Expand Down
5 changes: 3 additions & 2 deletions examples/notebooks/_internal_data_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"source": [
"import os\n",
"from pathlib import Path\n",
"from typing import Any\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import zarr\n",
Expand Down Expand Up @@ -497,7 +498,7 @@
"source": [
"# display image dataset \"fluor\" at time index 4 as an image\n",
"fluorescence = post_processing.image_metadata[0]\n",
"image_data: np.ndarray = post_processing.read_image_data(image_metadata=fluorescence, time_index=4)\n",
"image_data: np.ndarray[Any, np.dtype[np.float64]] = post_processing.read_image_data(image_metadata=fluorescence, time_index=4)\n",
"plt.imshow(image_data)\n",
"plt.title(\"post processing image data 'fluor' at time index 4\")\n",
"plt.show()"
Expand Down Expand Up @@ -605,4 +606,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
4 changes: 2 additions & 2 deletions examples/notebooks/_internal_n5_download_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"outputs": [],
"source": [
"\n",
"from typing import Any\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from tensorstore._tensorstore import TensorStore\n",
Expand Down Expand Up @@ -126,7 +126,7 @@
}
],
"source": [
"data: np.ndarray = dataset[:,:,0,0,:].read().result()\n",
"data: np.ndarray[Any, np.dtype[np.float64]] = dataset[:,:,0,0,:].read().result()\n",
"print(\"slice shape:\", data.shape)\n",
"\n",
"plt.imshow(data[:,:,0])\n",
Expand Down
391 changes: 361 additions & 30 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "pyvcell"
version = "0.2.0"
requires-python = ">=3.12,<4.0"
version = "0.2.3"
requires-python = ">=3.10,<4.0"
description = "This is the python wrapper for vcell modeling and simulation"
repository = "https://github.com/virtualcell/pyvcell"
documentation = "https://virtualcell.github.io/pyvcell/"
Expand All @@ -18,7 +18,7 @@ dependencies = [
"antimony (>=3.1.3)",
"h5py>=3.11.0,<4",
"imageio>=2.37.0,<3",
"libvcell (>=0.0.15.2)",
"libvcell (>=0.0.15.3)",
"lxml>=6.1.0,<7",
"matplotlib>=3.10.0,<4",
"numexpr>=2.10,<3",
Expand Down
22 changes: 15 additions & 7 deletions pyvcell/_internal/simdata/zarr_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,29 @@ def _get_domain_mask(dname: str) -> np.ndarray:

# add volumetric functions
for f in volume_functions:
func_data = f.evaluate(variable_bindings=bindings).reshape((num_z, num_y, num_x))
evaluated_data = f.evaluate(variable_bindings=bindings)
is_pre_sized: bool = evaluated_data.shape == (num_z, num_y, num_x)
if evaluated_data.shape == (): # scalar value
func_data = np.zeros((num_z, num_y, num_x), dtype=evaluated_data.dtype)
func_data.fill(evaluated_data.min()) # min of a scalar value is the value itself.
else:
func_data = evaluated_data if is_pre_sized else evaluated_data.reshape((num_z, num_y, num_x))
z1[t, c, :, :, :] = func_data
domain_name = f.name.split("::")[0]
function_name = f.name.split("::")[1]
name_parts = f.name.split("::")
if len(name_parts) > 2:
raise ValueError(f"Volume function name `{f.name}` is not in the expected format")
domain_half: str = f.name.split("::")[0] if len(name_parts) == 2 else ""
name_half: str = f.name.split("::")[-1]
if t == 0:
channel_metadata.append({
"index": c,
"label": function_name,
"domain_name": domain_name,
"label": name_half,
"domain_name": domain_half,
"min_values": [],
"max_values": [],
"mean_values": [],
})
domain_mask = _get_domain_mask(domain_name)
masked = func_data[domain_mask]
masked = func_data if len(domain_half) == 0 else func_data[_get_domain_mask(domain_half)]
channel_metadata[c]["min_values"].append(float(np.min(masked)))
channel_metadata[c]["max_values"].append(float(np.max(masked)))
channel_metadata[c]["mean_values"].append(float(np.mean(masked)))
Expand Down
Loading