Skip to content

Commit 414ec77

Browse files
authored
Change to image handling for consistency (#51)
- Add an affine function that computes a `rasterio.Affine` object given a `scale_factor`. This assumes a simple scaling where the origin is (0,0) in the spatial coordinate system corresponding to the top-left pixel (0,0). More complex alignments would require explicit affine transforms. - Ensure `img_raster()` consistently returns a PIL.Image.Image. - Add `to_numpy()` method. - Changes to how caching works in remote images.
1 parent 9286eb7 commit 414ec77

File tree

6 files changed

+269
-113
lines changed

6 files changed

+269
-113
lines changed

.github/workflows/run-tests.yml

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,73 @@
1-
name: Run tests
1+
name: Test the library
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- master # for legacy repos
7+
- main
68
pull_request:
7-
branches: [main]
9+
branches:
10+
- master # for legacy repos
11+
- main
12+
workflow_dispatch: # Allow manually triggering the workflow
13+
schedule:
14+
# Run roughly every 15 days at 00:00 UTC
15+
# (useful to check if updates on dependencies break the package)
16+
- cron: "0 0 1,16 * *"
17+
18+
permissions:
19+
contents: read
20+
21+
concurrency:
22+
group: >-
23+
${{ github.workflow }}-${{ github.ref_type }}-
24+
${{ github.event.pull_request.number || github.sha }}
25+
cancel-in-progress: true
826

927
jobs:
10-
build:
11-
runs-on: ubuntu-latest
28+
test:
1229
strategy:
1330
matrix:
14-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15-
16-
name: Python ${{ matrix.python-version }}
31+
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
32+
platform:
33+
- ubuntu-latest
34+
# - macos-latest
35+
# - windows-latest
36+
runs-on: ${{ matrix.platform }}
37+
name: Python ${{ matrix.python }}, ${{ matrix.platform }}
1738
steps:
1839
- uses: actions/checkout@v4
1940

20-
- name: Setup Python
21-
uses: actions/setup-python@v5
41+
- uses: actions/setup-python@v5
42+
id: setup-python
2243
with:
23-
python-version: ${{ matrix.python-version }}
24-
cache: "pip"
44+
python-version: ${{ matrix.python }}
2545

2646
- name: Install dependencies
2747
run: |
2848
python -m pip install --upgrade pip
29-
pip install tox
49+
pip install tox coverage
3050
31-
- name: Test with tox
32-
run: |
51+
- name: Run tests
52+
run: >-
53+
pipx run --python '${{ steps.setup-python.outputs.python-path }}'
3354
tox
55+
-- -rFEx --durations 10 --color yes --cov --cov-branch --cov-report=xml # pytest args
56+
57+
- name: Check for codecov token availability
58+
id: codecov-check
59+
shell: bash
60+
run: |
61+
if [ ${{ secrets.CODECOV_TOKEN }} != '' ]; then
62+
echo "codecov=true" >> $GITHUB_OUTPUT;
63+
else
64+
echo "codecov=false" >> $GITHUB_OUTPUT;
65+
fi
66+
67+
- name: Upload coverage reports to Codecov with GitHub Action
68+
uses: codecov/codecov-action@v5
69+
if: ${{ steps.codecov-check.outputs.codecov == 'true' }}
70+
env:
71+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
72+
slug: ${{ github.repository }}
73+
flags: ${{ matrix.platform }} - py${{ matrix.python }}

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## Version 0.0.10
4+
5+
- Add an affine function that computes a `rasterio.Affine` object given a `scale_factor`. This assumes a simple scaling where the origin is (0,0) in the spatial coordinate system corresponding to the top-left pixel (0,0). More complex alignments would require explicit affine transforms.
6+
- Ensure img_raster() consistently returns a PIL.Image.Image.
7+
- Add to_numpy() method.
8+
- Changes to how caching works in remote images.
9+
10+
311
## Version 0.0.9
412
- Added `to_anndata()` in main `SpatialExperiment` class (PR #50)
513

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ install_requires =
5151
importlib-metadata; python_version<"3.8"
5252
biocframe>=0.6.3
5353
biocutils>=0.2
54-
summarizedexperiment>=0.5
5554
singlecellexperiment>=0.5.7
5655
pillow>=11.0
5756
requests
5857
scipy~=1.13
58+
rasterio
5959

6060

6161
[options.packages.find]

0 commit comments

Comments
 (0)