Skip to content

Commit

Permalink
(chore): a modern python package
Browse files Browse the repository at this point in the history
  • Loading branch information
ilan-gold committed Nov 20, 2024
1 parent 0c32cc6 commit 848d714
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 24 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Python Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.10, 3.11, 3.12]
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install UV
uses: astral-sh/setup-uv@v3
with:
version: "0.5.0"
enable-cache: true
cache-dependency-glob: |
pyproject.toml
- name: Install python deps
run: |
uv pip install --system -e ".[test]"
- name: Python Tests
run: pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ wheels/
*.egg-info/
.installed.cfg
*.egg
/generate_tiff_offsets/_version.py

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
40 changes: 40 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[build-system]
build-backend = "hatchling.build"
requires = ["hatchling", "hatch-vcs"]

[project]
name = "generate-tiff-offsets"
description = "A package to generate TIFF offsets"
authors = [
{ name = "Ilan Gold", email = "[email protected]" }
]
readme = "README.md"
requires-python = ">=3.10"
classifiers = [
"Environment :: Console",
"Framework :: Jupyter",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Natural Language :: English",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Visualization",
]
license = { text = "MIT" }
dependencies = ["tifffile>=2023.9.26"]
dynamic = ["version"]
[project.optional-dependencies]
test = ["pytest"]

[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "generate_tiff_offsets/_version.py"
[tool.hatch.build.targets.wheel]
packages = ["src/anndata", "src/testing"]
10 changes: 0 additions & 10 deletions requirements_dev.txt

This file was deleted.

21 changes: 7 additions & 14 deletions tests/test_generate_tiff_offsets.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
#!/usr/bin/env python

"""Tests for `generate_tiff_offsets` package."""


import unittest
import json

from generate_tiff_offsets.generate_tiff_offsets import generate_tiff_offsets


class TestGenerate_tiff_offsets(unittest.TestCase):
"""Tests for `generate_tiff_offsets` package."""

def test_offsets(self):
generate_tiff_offsets('./tests/test-input/multi-channel.ome.tif')
with open('./tests/test-output-expected/multi-channel.offsets.json', 'r') as f:
expected = json.loads(f.read())
with open('./tests/test-input/multi-channel.offsets.json', 'r') as f:
actual = json.loads(f.read())
assert(actual == expected)
def test_offsets():
generate_tiff_offsets('./tests/test-input/multi-channel.ome.tif')
with open('./tests/test-output-expected/multi-channel.offsets.json', 'r') as f:
expected = json.loads(f.read())
with open('./tests/test-input/multi-channel.offsets.json', 'r') as f:
actual = json.loads(f.read())
assert(actual == expected)

0 comments on commit 848d714

Please sign in to comment.