Skip to content

Commit b002f3d

Browse files
Merge pull request #86 from ShantanuKodgirwar/fix-CI
Fix CI
2 parents 915f59f + b104221 commit b002f3d

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

.github/workflows/test.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,24 @@ on:
55
branches: [main]
66
pull_request:
77
branches: [main]
8+
workflow_dispatch:
89

910
jobs:
1011
build:
1112

1213
runs-on: ubuntu-latest
1314
strategy:
1415
matrix:
15-
python-version: ["3.12", "3.13"]
16+
python-version: ["3.11", "3.12", "3.13"]
1617

1718
steps:
18-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v6.0.2
1920
- name: Install uv and set the python version
20-
uses: astral-sh/setup-uv@v5
21+
uses: astral-sh/setup-uv@v8.0.0
2122
with:
22-
version: "0.5.16"
2323
python-version: ${{ matrix.python-version }}
24-
- name: Install the project
25-
run: uv sync
24+
cache-dependency-glob: "pyproject.toml"
25+
- name: Install the project with `dev`
26+
run: uv sync --extra dev
2627
- name: Run tests
2728
run: uv run pytest tests

PtyLab/io/readHdf5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def getOrientation(filename):
9696
with h5py.File(str(filename), "r") as archive:
9797
if "orientation" in archive.keys():
9898
orientation = np.array(archive["orientation"]).ravel()[0].astype(int)
99-
return int(orientation)
99+
return int(orientation) if orientation is not None else None
100100

101101

102102
def checkDataFields(filename, requiredFields):

PtyLab/utils/visualisation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def complexPlot(rgb, ax=None, pixelSize=1, axisUnit="pixel"):
120120
scalar_mappable = mpl.cm.ScalarMappable(norm=norm, cmap=mpl.cm.hsv)
121121
scalar_mappable.set_array([])
122122
cbar = plt.colorbar(scalar_mappable, ax=ax, cax=cax, ticks=[-np.pi, 0, np.pi])
123-
cbar.ax.set_yticklabels(["$-\pi$", "0", "$\pi$"])
123+
cbar.ax.set_yticklabels([r"$-\pi$", "0", r"$\pi$"])
124124
return im
125125

126126

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# PtyLab.py: Unified Ptychography Toolbox
22
![Python 3.10+](https://img.shields.io/badge/python-3.10+-green.svg)
3-
![Tests](https://github.com/ShantanuKodgirwar/PtyLabX/actions/workflows/test.yml/badge.svg)
3+
![Version](https://img.shields.io/badge/version-0.2.3-blue.svg)
4+
![Tests](https://github.com/PtyLab/PtyLab.py/actions/workflows/test.yml/badge.svg)
45

56
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).
67

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "ptylab"
3-
version = "0.2.3"
3+
version = "0.2.4"
44
description = "A cross-platform, open-source inverse modeling toolbox for conventional and Fourier ptychography"
55
authors = [
66
{ name = "Lars Loetgering", email = "lars.loetgering@fulbrightmail.org" },

tests/conftest.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import numpy as np
2+
import h5py
3+
import pytest
4+
from pathlib import Path
5+
6+
7+
@pytest.fixture(scope="session", autouse=True)
8+
def generate_simu_hdf5():
9+
"""Generate a minimal simu.hdf5 if it doesn't exist (CI-friendly).
10+
11+
Tests that call easyInitialize("example:simulation_cpm") resolve to
12+
example_data/simu.hdf5. This fixture ensures that file exists before
13+
any test runs, so no real dataset needs to be committed to the repo.
14+
If the file already exists (e.g. locally), it is left untouched.
15+
"""
16+
example_data_dir = Path(__file__).parent.parent / "example_data"
17+
example_data_dir.mkdir(exist_ok=True)
18+
hdf5_path = example_data_dir / "simu.hdf5"
19+
20+
if hdf5_path.exists():
21+
yield hdf5_path
22+
return
23+
24+
rng = np.random.default_rng(42)
25+
Nd, N_frames = 64, 20
26+
27+
ptychogram = rng.random((N_frames, Nd, Nd)).astype(np.float32)
28+
encoder = rng.uniform(-1e-3, 1e-3, (N_frames, 2))
29+
30+
with h5py.File(hdf5_path, "w") as hf:
31+
hf.create_dataset("ptychogram", data=ptychogram, dtype="f")
32+
hf.create_dataset("encoder", data=encoder, dtype="f")
33+
hf.create_dataset("dxd", data=np.array(75e-6))
34+
hf.create_dataset("zo", data=np.array(0.1))
35+
hf.create_dataset("wavelength", data=np.array(632e-9))
36+
hf.create_dataset("entrancePupilDiameter", data=np.array(170e-6))
37+
38+
yield hdf5_path

0 commit comments

Comments
 (0)