Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pip install -e .[all]

3. After you've finished with your changes, please run linter, tests and check that coverage didn't go down too much:
```bash
black tiler tests
ruff check . && ruff format .
coverage run -m pytest
coverage report
```
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
31 changes: 20 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
name: CI

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

jobs:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: 3.9
- uses: pre-commit/action@v3.0.1
python-version: "3.13"
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

test:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
# 3.9 will reach EoL in October 2025
# https://devguide.python.org/#status-of-python-branches
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13" ]
# https://devguide.python.org/versions/
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14" ]
numpy: [ "" ]
include:
# oldest supported numpy (the floor declared in pyproject.toml)
- python-version: "3.9"
numpy: "==1.20.3"
# newest numpy 1.x
- python-version: "3.12"
numpy: "<2"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
- run: |
python -m pip install --upgrade pip
pip install .[test]
pip install -e .[test]
if [ -n "${{ matrix.numpy }}" ]; then pip install "numpy${{ matrix.numpy }}"; fi
pip install coveralls
- run: coverage run -m pytest -v
- run: coverage report
- if: github.event_name != 'pull_request'
run: coveralls
env:
Expand Down
21 changes: 18 additions & 3 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,43 @@ on:
types: [published]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.14" ]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: ${{ matrix.python-version }}
- run: |
pip install .[test]
pytest -v

deploy:
name: Upload release to PyPI
needs: test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/tiler
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- uses: actions/setup-python@v5
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.x"

- run: python -m pip install --user build

- run: python -m build

- uses: pypa/gh-action-pypi-publish@release/v1
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
verbose: true
skip-existing: true
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.12
rev: v0.16.1
hooks:
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-ast
- id: check-docstring-first
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Alternatively, you can clone the repository and install it manually:
```bash
git clone git@github.com:the-lay/tiler.git
cd tiler
pip install
pip install .
```

If you are planning to contribute, please take a look at the [contribution instructions](.github/CONTRIBUTING.md).
Expand Down
6 changes: 4 additions & 2 deletions misc/docs.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
cd "$(dirname "$file_name")"/.. || exit
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/.."

# build docs
pdoc -o docs -d google src/tiler

# add downsized teaser image to the docs directory
magick convert -resize 50% misc/teaser/tiler_teaser.png docs/tiler_teaser.png
magick misc/teaser/tiler_teaser.png -resize 50% docs/tiler_teaser.png

# replace unnecessary index
rm docs/index.html
Expand Down
14 changes: 10 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,25 @@ authors = [
{name = "the-lay", email = "ilja.gubin@gmail.com"}
]
dependencies = [
"numpy",
"numpy>=1.20",
"tqdm",
]
requires-python = ">=3.9"
readme = "README.md"
license = {text = "MIT"}
license = "MIT"
license-files = ["LICENSE"]
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Topic :: Software Development :: Libraries :: Python Modules",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]

[project.urls]
Expand All @@ -41,7 +47,7 @@ all = [
]

[build-system]
requires = ["setuptools>=64", "setuptools-scm>=8"]
requires = ["setuptools>=77", "setuptools-scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
Expand Down
6 changes: 6 additions & 0 deletions src/tiler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import importlib.metadata
import sys

from tiler.merger import Merger
from tiler.tiler import Tiler

__all__ = ["Tiler", "Merger"]

try:
__version__ = importlib.metadata.version("tiler")
except importlib.metadata.PackageNotFoundError: # pragma: no cover
__version__ = "0+unknown"

# Import README file as a module general docstring, only when generating documentation
# We also modify it to make it prettier
if "pdoc" in sys.modules: # pragma: no cover
Expand Down
2 changes: 1 addition & 1 deletion src/tiler/tiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def recalculate(
# Channel dimension can be None which means we need to check for init too
if not hasattr(self, "channel_dimension") or channel_dimension is not None:
self.channel_dimension = channel_dimension
if self.channel_dimension:
if self.channel_dimension is not None:
if (self.channel_dimension >= self._n_dim) or (self.channel_dimension < -self._n_dim):
raise ValueError(
f"Specified channel dimension is out of bounds "
Expand Down
10 changes: 10 additions & 0 deletions tests/test_tiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@

import numpy as np

import tiler
from tiler import Tiler


class TestTilingCommon(unittest.TestCase):
def test_version(self):
self.assertIsInstance(tiler.__version__, str)
self.assertTrue(tiler.__version__)

def test_channel_dimension_zero_bounds_check(self):
# channel_dimension=0 must go through the same bounds validation as any other value
with self.assertRaises(ValueError):
Tiler(data_shape=(), tile_shape=(), channel_dimension=0)

def test_init(self):
with self.assertRaises(ValueError):
Tiler(data_shape=(-10, -30), tile_shape=(10, 10))
Expand Down
Loading