Skip to content

Commit

Permalink
Merge pull request #29 from gregstarr/develop
Browse files Browse the repository at this point in the history
basic test + github action
  • Loading branch information
ZFTurbo authored Oct 17, 2024
2 parents 7321573 + 4ca2a60 commit 1d0565a
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "master", "develop" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry install --with dev
- name: Lint with flake8
run: |
poetry run flake8 ./volumentations --count --select=E9,F63,F7,F82 --show-source --statistics
- name: Test with pytest
run: |
poetry run pytest
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[tool.poetry]
name = "volumentations-3d"
version = "1.0.4"
description = "Library for 3D augmentations"
authors = [
"Roman Sol (ZFTurbo)",
"ashawkey",
"qubvel",
"muellerdo"
]
license = "MIT"
readme = "README.md"
packages = [{include = "volumentations"}]

[tool.poetry.dependencies]
python = ">=3.9, <3.12"
scikit-image = "^0.20.0"
opencv-python = "^4.7.0.72"
numpy = "^1.24.3"

[tool.poetry.group.dev.dependencies]
pytest = "^7.3.1"
flake8 = "^6.0.0"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
66 changes: 66 additions & 0 deletions test/test_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pytest
import numpy as np

from volumentations import *


augmentations = [
CenterCrop,
ColorJitter,
Contiguous,
# CropNonEmptyMaskIfExists,
Downscale,
ElasticTransform,
ElasticTransformPseudo2D,
Flip,
Float,
GaussianNoise,
GlassBlur,
GridDistortion,
GridDropout,
ImageCompression,
Normalize,
PadIfNeeded,
RandomBrightnessContrast,
RandomCrop,
RandomCropFromBorders,
RandomDropPlane,
RandomGamma,
RandomResizedCrop,
RandomRotate90,
RandomScale,
RandomScale2,
RemoveEmptyBorder,
Resize,
# ResizedCropNonEmptyMaskIfExists,
Rotate,
RotatePseudo2D,
Transpose,
]

arg_required = [
CenterCrop,
CropNonEmptyMaskIfExists,
PadIfNeeded,
RandomCrop,
RandomResizedCrop,
Resize,
ResizedCropNonEmptyMaskIfExists,
]


@pytest.fixture(scope="module")
def cube():
X, Y, Z = np.mgrid[-8:8:40j, -8:8:40j, -8:8:40j]
values = np.sin(X*Y*Z) / (X*Y*Z)
return values


@pytest.mark.parametrize("aug_class", augmentations)
def test_augmentations(aug_class, cube):
if aug_class in arg_required:
aug = aug_class(shape=(30, 30, 30))
else:
aug = aug_class()
new_cube = aug(True, "image", image=cube)["image"]
print(aug_class.__name__, new_cube.shape)
2 changes: 2 additions & 0 deletions volumentations/augmentations/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
from scipy.ndimage import gaussian_filter
from scipy.ndimage import map_coordinates
from warnings import warn
from itertools import product


MAX_VALUES_BY_DTYPE = {
np.dtype("uint8"): 255,
Expand Down

0 comments on commit 1d0565a

Please sign in to comment.