Skip to content
Merged
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
57 changes: 57 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python application

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install Poetry
uses: snok/install-poetry@v1.4.1
with:
version: 2.1.1
virtualenvs-create: true
- name: Configure poetry
run: |
poetry config virtualenvs.in-project true

- name: Poetry Cache
uses: actions/cache@v4
id: poetry-cache
with:
path: .venv
key: venv-${{ hashFiles('**/poetry.lock', '**/pyproject.toml') }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
poetry install --no-root
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 --exclude=.venv/ . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 --exclude=.venv/ . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
poetry install --no-root
poetry run python -m pip list
poetry run python -m pytest
2 changes: 1 addition & 1 deletion gen_inroom_rtss.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import Dict, List

import numpy as np
from pydicom import Dataset, Sequence, read_file, uid, write_file
from pydicom import Dataset, Sequence, dcmread as read_file, uid, dcmwrite as write_file

# Copied and modified from ImageLoading.py from OnkoDICOM, which was LGPL 2.1 at the time

Expand Down
171 changes: 170 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@ license = "Apache-2.0"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"pydicom >=3.0.1",
"numpy >= 2.2.3"
"pydicom ~=3.0.1",
"numpy ~= 2.2.3"
]
package-mode = false

[build-system]
requires = ["poetry-core>=2.0"]
build-backend = "poetry.core.masonry.api"

[tool.pytest]
testpaths = ["rtregistrationcalc/tests"]
python_files = "test_*.py"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.5"
pytest-cov = "^6.0.0"
4 changes: 2 additions & 2 deletions test_gen_inroom_rtss.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_valid_orientation_and_position(self):

# Handles empty or incomplete orientation and position lists gracefully
def test_empty_or_incomplete_lists(self):
with pytest.raises(IndexError):
with pytest.raises((IndexError, ValueError)):
img_stack_displacement([], [])
with pytest.raises(IndexError):
with pytest.raises((IndexError, ValueError)):
img_stack_displacement(["1.0", "0.0"], ["0.0"])