From 0a7e0082bad57ca8fb0d7516ad8c637d8999027b Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 15:21:15 +0200 Subject: [PATCH 01/11] minor installation fix --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ae87c82..38bea5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: with: version: "0.5.16" python-version: ${{ matrix.python-version }} - - name: Install the project - run: uv sync + - name: Install the project with `dev` + run: uv sync --extra dev - name: Run tests run: uv run pytest tests \ No newline at end of file From 94466e30ca920d21de66b0ffbfbb4dfc95fcfcd4 Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 15:25:54 +0200 Subject: [PATCH 02/11] minor local testing with workflow dispatch --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 38bea5f..7edfbda 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,6 +5,7 @@ on: branches: [main] pull_request: branches: [main] + workflow_dispatch: jobs: build: From fc6e4e2e2a55f0f2c0031d0e9df1ddd6c03d5a9d Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 15:30:06 +0200 Subject: [PATCH 03/11] adding a version flag for quick viewing --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 6523393..cb6be06 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # PtyLab.py: Unified Ptychography Toolbox ![Python 3.10+](https://img.shields.io/badge/python-3.10+-green.svg) +![Version](https://img.shields.io/badge/version-0.2.3-blue.svg) ![Tests](https://github.com/ShantanuKodgirwar/PtyLabX/actions/workflows/test.yml/badge.svg) PtyLab is an inverse modeling toolbox for Conventional (CP) and Fourier (FP) ptychography in a unified framework. For more information please check the [paper](https://opg.optica.org/oe/fulltext.cfm?uri=oe-31-9-13763&id=529026). From a25cb84f2d525e998471ffa74ec105b8527f1bae Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 15:35:46 +0200 Subject: [PATCH 04/11] fix: update test badge URL in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb6be06..68d7651 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # PtyLab.py: Unified Ptychography Toolbox ![Python 3.10+](https://img.shields.io/badge/python-3.10+-green.svg) ![Version](https://img.shields.io/badge/version-0.2.3-blue.svg) -![Tests](https://github.com/ShantanuKodgirwar/PtyLabX/actions/workflows/test.yml/badge.svg) +![Tests](https://github.com/PtyLab/PtyLab.py/actions/workflows/test.yml/badge.svg) PtyLab is an inverse modeling toolbox for Conventional (CP) and Fourier (FP) ptychography in a unified framework. For more information please check the [paper](https://opg.optica.org/oe/fulltext.cfm?uri=oe-31-9-13763&id=529026). From 90b8e46e1b66c44d5d63fd53dfbfd44b296c4168 Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 16:19:35 +0200 Subject: [PATCH 05/11] minor fix to suppress a warning --- PtyLab/utils/visualisation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PtyLab/utils/visualisation.py b/PtyLab/utils/visualisation.py index 022f4c7..4b954c9 100644 --- a/PtyLab/utils/visualisation.py +++ b/PtyLab/utils/visualisation.py @@ -120,7 +120,7 @@ def complexPlot(rgb, ax=None, pixelSize=1, axisUnit="pixel"): scalar_mappable = mpl.cm.ScalarMappable(norm=norm, cmap=mpl.cm.hsv) scalar_mappable.set_array([]) cbar = plt.colorbar(scalar_mappable, ax=ax, cax=cax, ticks=[-np.pi, 0, np.pi]) - cbar.ax.set_yticklabels(["$-\pi$", "0", "$\pi$"]) + cbar.ax.set_yticklabels([r"$-\pi$", "0", r"$\pi$"]) return im From 21f9b1a82104f04a2e994e665bf58ac8cddb7409 Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 16:20:53 +0200 Subject: [PATCH 06/11] feat: add CI-friendly fixture to generate minimal simu.hdf5 for tests --- tests/conftest.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..da238a2 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,38 @@ +import numpy as np +import h5py +import pytest +from pathlib import Path + + +@pytest.fixture(scope="session", autouse=True) +def generate_simu_hdf5(): + """Generate a minimal simu.hdf5 if it doesn't exist (CI-friendly). + + Tests that call easyInitialize("example:simulation_cpm") resolve to + example_data/simu.hdf5. This fixture ensures that file exists before + any test runs, so no real dataset needs to be committed to the repo. + If the file already exists (e.g. locally), it is left untouched. + """ + example_data_dir = Path(__file__).parent.parent / "example_data" + example_data_dir.mkdir(exist_ok=True) + hdf5_path = example_data_dir / "simu.hdf5" + + if hdf5_path.exists(): + yield hdf5_path + return + + rng = np.random.default_rng(42) + Nd, N_frames = 64, 20 + + ptychogram = rng.random((N_frames, Nd, Nd)).astype(np.float32) + encoder = rng.uniform(-1e-3, 1e-3, (N_frames, 2)) + + with h5py.File(hdf5_path, "w") as hf: + hf.create_dataset("ptychogram", data=ptychogram, dtype="f") + hf.create_dataset("encoder", data=encoder, dtype="f") + hf.create_dataset("dxd", data=np.array(75e-6)) + hf.create_dataset("zo", data=np.array(0.1)) + hf.create_dataset("wavelength", data=np.array(632e-9)) + hf.create_dataset("entrancePupilDiameter", data=np.array(170e-6)) + + yield hdf5_path From 3ef0e63519c043ca17a8d7934b08be2b9946fa37 Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 16:28:57 +0200 Subject: [PATCH 07/11] minor package level fix to suppress a warning --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 708ede8..13dadb2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "ptylab" -version = "0.2.3" +version = "0.2.4" description = "A cross-platform, open-source inverse modeling toolbox for conventional and Fourier ptychography" authors = [ { name = "Lars Loetgering", email = "lars.loetgering@fulbrightmail.org" }, From 4deafb75e2238787d94f91e0599e86ed8a2fc7fc Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 16:29:29 +0200 Subject: [PATCH 08/11] handle None case in getOrientation function --- PtyLab/io/readHdf5.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PtyLab/io/readHdf5.py b/PtyLab/io/readHdf5.py index 5facfbf..d097730 100644 --- a/PtyLab/io/readHdf5.py +++ b/PtyLab/io/readHdf5.py @@ -96,7 +96,7 @@ def getOrientation(filename): with h5py.File(str(filename), "r") as archive: if "orientation" in archive.keys(): orientation = np.array(archive["orientation"]).ravel()[0].astype(int) - return int(orientation) + return int(orientation) if orientation is not None else None def checkDataFields(filename, requiredFields): From b31bb2c71bdd4e58937b8bfb48b7ffd49888cce2 Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 16:34:41 +0200 Subject: [PATCH 09/11] using latest version of uv for CI --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7edfbda..c727bd7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,10 +18,10 @@ jobs: steps: - uses: actions/checkout@v4 - name: Install uv and set the python version - uses: astral-sh/setup-uv@v5 + uses: astral-sh/setup-uv@v8.0.0 with: - version: "0.5.16" python-version: ${{ matrix.python-version }} + cache-dependency-glob: "pyproject.toml" - name: Install the project with `dev` run: uv sync --extra dev - name: Run tests From d3088b63548c36711cfc53932ad2133fdb38b470 Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 16:37:28 +0200 Subject: [PATCH 10/11] CI also checks with 3.11 to 3.13 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c727bd7..2306c31 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.12", "3.13"] + python-version: ["3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v4 From b1042210001906de4be4d24de0c744f37a12302b Mon Sep 17 00:00:00 2001 From: Shantanu Kodgirwar Date: Wed, 8 Apr 2026 16:40:31 +0200 Subject: [PATCH 11/11] to suppress a js warning from CI --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2306c31..94c6463 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,7 +16,7 @@ jobs: python-version: ["3.11", "3.12", "3.13"] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6.0.2 - name: Install uv and set the python version uses: astral-sh/setup-uv@v8.0.0 with: