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
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: deploy

on:
push:
branches: [master]
branches: [develop]
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
workflow_dispatch:
Expand All @@ -16,15 +16,15 @@ jobs:
with:
fetch-depth: 0

- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/setup-python@v6
with:
python-version: "3.9"
python-version: "3.12"

- name: Build
run: |
python -m pip install --upgrade pip
pip install setuptools setuptools_scm wheel
python setup.py sdist bdist_wheel
run: uv build

- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
25 changes: 9 additions & 16 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,36 @@ name: testing

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

jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v6

- name: Install uv
uses: astral-sh/setup-uv@v5

- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

# https://github.com/actions/cache/blob/main/examples.md#python---pip
- uses: actions/cache@v5
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pip-${{ hashFiles('**/setup.py') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-pip-

- name: Install
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
run: uv sync --extra dev

- name: Test with pytest
run: |
python -m pytest -v --cov=hsnf --cov-config=setup.cfg --cov-report=xml tests/
uv run pytest -v --cov=hsnf --cov-report=xml tests/

- name: Upload coverage to Codecov
if: matrix.python-version == '3.9'
if: matrix.python-version == '3.12'
uses: codecov/codecov-action@v5
with:
file: ./coverage.xml
Expand Down
52 changes: 25 additions & 27 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: check-json
- id: debug-statements
- id: end-of-file-fixer
# formatter
- repo: https://github.com/psf/black
rev: 23.9.1
- id: check-toml
- id: check-merge-conflict
- id: detect-private-key
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.8
hooks:
- id: black
# linter
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
- id: ruff-format
types_or: [python, pyi, jupyter]
- id: ruff
args: [ "--fix", "--show-fixes"]
types_or: [python, pyi]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.19.1
hooks:
- id: flake8
- id: mypy
exclude: ^docs/
# type annotation
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.1
rev: v1.19.1
hooks:
- id: mypy
exclude: ^docs/
# isort
- repo: https://github.com/pycqa/isort
rev: 5.12.0
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.2
hooks:
- id: uv-lock
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.1
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
- id: isort
name: isort (cython)
types: [cython]
- id: isort
name: isort (pyi)
types: [pyi]
# Upgrade syntax
- repo: https://github.com/asottile/pyupgrade
rev: v3.10.1
- id: check-github-workflows
- repo: https://github.com/tox-dev/pyproject-fmt
rev: v2.20.0
hooks:
- id: pyupgrade
- id: pyproject-fmt
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
version: 2

build:
os: "ubuntu-20.04"
os: "ubuntu-24.04"
tools:
python: "3.10"
python: "3.12"

python:
install:
Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ or in local:
```shell
git clone git@github.com:lan496/hsnf.git
cd hsnf
pip install -e .[dev,docs]
uv sync --all-extras
```

## References
Expand Down
4 changes: 1 addition & 3 deletions hsnf/Z_module.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright (c) 2019 Kohei Shinohara
# Distributed under the terms of the MIT License.
from __future__ import annotations

import warnings

import numpy as np
Expand All @@ -25,7 +23,7 @@ class ZmoduleHomomorphism:

def __init__(self, A, basis_from, basis_to):
if A.dtype not in [np.int32, np.int64]:
warnings.warn("Decomposed matrix should be integer.")
warnings.warn("Decomposed matrix should be integer.", stacklevel=2)

self._A = A
self._basis_from = basis_from
Expand Down
10 changes: 4 additions & 6 deletions hsnf/integer_system.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

import numpy as np
from scipy.linalg import solve_triangular

Expand Down Expand Up @@ -215,12 +213,12 @@ def _solve_modular_integer_linear_system_special(D: NDArrayInt, Lb: NDArrayInt,
"""
factors = eratosthenes(q)
specials = []
for p, l in factors.items():
sol = _solve_modular_integer_linear_system_special_prime_power(D, Lb, p**l, rank)
for p, exp in factors.items():
sol = _solve_modular_integer_linear_system_special_prime_power(D, Lb, p**exp, rank)
if sol is None:
return None
assert np.allclose(np.mod(D @ sol - Lb, p**l), 0)
specials.append((sol, p**l))
assert np.allclose(np.mod(D @ sol - Lb, p**exp), 0)
specials.append((sol, p**exp))

y_special, _ = crt_on_list(specials)

Expand Down
3 changes: 1 addition & 2 deletions hsnf/utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from __future__ import annotations
from typing import TypeAlias

import numpy as np
import numpy.typing as npt
from typing_extensions import TypeAlias # for Python<3.10

NDArrayInt: TypeAlias = npt.NDArray[np.int_]

Expand Down
89 changes: 65 additions & 24 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,34 +1,75 @@
[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
build-backend = "setuptools.build_meta"
requires = [ "setuptools>=45", "setuptools-scm[toml]>=6.2", "wheel" ]

# Enable version inference
[tool.setuptools_scm]
[project]
name = "hsnf"
description = "Computing Hermite normal form and Smith normal form."
readme = "README.md"
license = "MIT"
authors = [
{ name = "Kohei Shinohara" },
]
requires-python = ">=3.10"
classifiers = [
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"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",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering :: Mathematics",
]
dynamic = [ "version" ]
dependencies = [
"numpy>=1.20.1",
"scipy",
"setuptools",
"setuptools-scm",
"wheel",
]
optional-dependencies.dev = [
"mypy",
"pre-commit",
"pytest",
"pytest-cov",
"ruff",
]
optional-dependencies.docs = [
"myst-parser",
"sphinx",
"sphinx-autobuild",
"sphinx-book-theme",
"sphinxcontrib-bibtex",
]
urls.Documentation = "https://hsnf.readthedocs.io/en/latest/"
urls.Homepage = "https://github.com/lan496/hsnf"
urls.Repository = "https://github.com/lan496/hsnf"

[tool.setuptools]
package-data.hsnf = [ "py.typed" ]
packages.find.exclude = [ "tests" ]

[tool.pytest.ini_options]
testpaths = ["tests"]
[tool.setuptools_scm]

[tool.black]
[tool.ruff]
line-length = 99
target-version = ['py38', 'py39', 'py310']
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| docs
)/
'''
exclude = [ "docs" ]
lint.select = [ "B", "C", "E", "F", "I", "UP", "W" ]
lint.ignore = [ "E203", "E231", "E501" ]

[tool.mypy]
exclude = [
'docs',
"docs",
]

[tool.pytest]
ini_options.testpaths = [ "tests" ]

[tool.coverage]
run.omit = [ "tests/" ]
7 changes: 0 additions & 7 deletions setup.cfg

This file was deleted.

Loading
Loading