Skip to content

Commit

Permalink
Merge 02f5241 into 061dc2f
Browse files Browse the repository at this point in the history
  • Loading branch information
MuellerSeb committed Apr 10, 2024
2 parents 061dc2f + 02f5241 commit ac9a695
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 83 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
run: |
python -m pylint src/pentapy/
- name: cython-lint check
run: |
cython-lint src/pentapy/
build_wheels:
name: wheels for ${{ matrix.cfg.os }} / ${{ matrix.cfg.arch }}
runs-on: ${{ matrix.cfg.os }}
Expand All @@ -50,9 +54,7 @@ jobs:
matrix:
cfg:
- { os: ubuntu-latest, arch: x86_64 }
- { os: ubuntu-latest, arch: i686 }
- { os: windows-latest, arch: AMD64 }
- { os: windows-latest, arch: x86 }
- { os: macos-latest, arch: x86_64 }
- { os: macos-latest, arch: arm64 }
- { os: macos-latest, arch: universal2 }
Expand All @@ -63,7 +65,7 @@ jobs:
fetch-depth: '0'

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.1
uses: pypa/cibuildwheel@v2.17.0
env:
CIBW_ARCHS: ${{ matrix.cfg.arch }}
with:
Expand Down
6 changes: 5 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.11"

sphinx:
configuration: docs/source/conf.py

formats: all

python:
version: 3.7
install:
- method: pip
path: .
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,22 @@
All notable changes to **pentapy** will be documented in this file.


## [1.3.0] - 2024-04

See [#21](https://github.com/GeoStat-Framework/pentapy/pull/21)

### Enhancements
- added support for python 3.12
- added support for numpy 2
- build extensions with numpy 2 and cython 3

### Changes
- dropped python 3.7 support
- dropped 32bit builds
- linted cython files
- increase maximal line length to 88 (black default)


## [1.2.0] - 2023-04

See [#19](https://github.com/GeoStat-Framework/pentapy/pull/19)
Expand All @@ -15,7 +31,7 @@ See [#19](https://github.com/GeoStat-Framework/pentapy/pull/19)

### Changes
- move to `src/` based package structure
- dropped python 3.7 support
- dropped python 3.6 support
- move meta-data to pyproject.toml
- simplified documentation

Expand Down Expand Up @@ -84,6 +100,7 @@ This is the first release of pentapy, a python toolbox for solving pentadiagonal
The solver is implemented in cython, which makes it really fast.


[1.3.0]: https://github.com/GeoStat-Framework/pentapy/compare/v1.2.0...v1.3.0
[1.2.0]: https://github.com/GeoStat-Framework/pentapy/compare/v1.1.2...v1.2.0
[1.1.2]: https://github.com/GeoStat-Framework/pentapy/compare/v1.1.1...v1.1.2
[1.1.1]: https://github.com/GeoStat-Framework/pentapy/compare/v1.1.0...v1.1.1
Expand Down
1 change: 1 addition & 0 deletions examples/01_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
and the product of the matrix (which is transformed to a full quadratic one)
and the solution of the system.
"""

import numpy as np

import pentapy as pp
Expand Down
1 change: 1 addition & 0 deletions examples/02_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Here we compare the outcome of the PTRANS-I and PTRANS-II algorithm for
a random input.
"""

import numpy as np

import pentapy as pp
Expand Down
1 change: 1 addition & 0 deletions examples/03_perform_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* perfplot
* matplotlib
"""

import numpy as np
import perfplot

Expand Down
1 change: 1 addition & 0 deletions examples/04_perform_full_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* perfplot
* matplotlib
"""

import numpy as np
import perfplot

Expand Down
1 change: 1 addition & 0 deletions examples/05_solve_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Here we demonstrate that the solver PTRANS-I can fail to solve a given system.
A warning is given in that case and the output will be a nan-array.
"""

import numpy as np

import pentapy as pp
Expand Down
47 changes: 27 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[build-system]
requires = [
"setuptools>=64",
"wheel",
"setuptools_scm>=7",
"oldest-supported-numpy",
"Cython>=0.29.32,<3.0",
"numpy>=2.0.0rc1,<2.3; python_version >= '3.9'",
"oldest-supported-numpy; python_version < '3.9'",
"Cython>=3.0.10,<3.1.0",
]
build-backend = "setuptools.build_meta"

[project]
requires-python = ">=3.7"
requires-python = ">=3.8"
name = "pentapy"
authors = [{name = "Sebastian Müller", email = "info@geostat-framework.org"}]
readme = "README.md"
Expand All @@ -26,15 +26,16 @@ classifiers = [
"Operating System :: Unix",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Scientific/Engineering",
"Topic :: Utilities",
]
dependencies = ["numpy>=1.14.5"]
dependencies = ["numpy>=1.20.0"]

[project.optional-dependencies]
scipy = ["scipy"]
Expand All @@ -49,15 +50,16 @@ doc = [
"matplotlib>=3",
"perfplot<0.9",
"numpydoc>=1.1",
"sphinx>=4",
"sphinx>=7",
"sphinx-gallery>=0.8",
"sphinx-rtd-theme>=1,<1.1",
"sphinx-rtd-theme>=2",
]
test = ["pytest-cov>=3"]
check = [
"black>=23,<24",
"isort[colors]<6",
"pylint<3",
"black>=24,<25",
"isort[colors]",
"pylint",
"cython-lint",
]

[project.urls]
Expand All @@ -80,11 +82,18 @@ fallback_version = "0.0.0.dev0"
[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 79

[tool.black]
line-length = 79
target-version = ["py37"]
target-version = [
"py38",
"py39",
"py310",
"py311",
"py312",
]

[tool.cython-lint]
max-line-length = 120

[tool.coverage]
[tool.coverage.run]
Expand Down Expand Up @@ -130,12 +139,10 @@ target-version = ["py37"]
[tool.cibuildwheel]
# Switch to using build
build-frontend = "build"
# Disable building PyPy wheels on all platforms, 32bit for py3.10/11 and musllinux builds, py3.6
skip = ["cp36-*", "pp*", "cp31*-win32", "cp31*-manylinux_i686", "*-musllinux_*"]
# Disable building PyPy wheels on all platforms, 32bit builds, py3.6, py3.7
skip = ["cp36-*", "cp37-*", "pp*", "*-win32", "*-manylinux_i686", "*-musllinux_*"]
# Run the package tests using `pytest`
test-extras = "test"
test-command = "pytest -v {package}/tests"
# Skip trying to test arm64 builds on Intel Macs
test-skip = "*-macosx_arm64 *-macosx_universal2:arm64"
# no wheels for linux-32bit anymore for numpy>=1.22
environment = "PIP_PREFER_BINARY=1"
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""pentapy: A toolbox for pentadiagonal matrizes."""

import os

import numpy as np
Expand Down
8 changes: 2 additions & 6 deletions src/pentapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@
create_banded
create_full
"""

from pentapy.core import solve
from pentapy.tools import (
create_banded,
create_full,
diag_indices,
shift_banded,
)
from pentapy.tools import create_banded, create_full, diag_indices, shift_banded

try:
from pentapy._version import __version__
Expand Down
20 changes: 9 additions & 11 deletions src/pentapy/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""The core module of pentapy."""

# pylint: disable=C0103, C0415, R0911, E0611
import warnings

Expand Down Expand Up @@ -101,10 +102,8 @@ def solve(mat, rhs, is_flat=False, index_row_wise=True, solver=1):
try:
from scipy.linalg import solve_banded
except ImportError as imp_err: # pragma: no cover
raise ValueError(
"pentapy.solve: "
"scipy.linalg.solve_banded could not be imported"
) from imp_err
msg = "pentapy.solve: scipy.linalg.solve_banded could not be imported"
raise ValueError(msg) from imp_err
if is_flat and index_row_wise:
mat_flat = np.array(mat)
_check_penta(mat_flat)
Expand All @@ -119,9 +118,8 @@ def solve(mat, rhs, is_flat=False, index_row_wise=True, solver=1):
from scipy import sparse as sps
from scipy.sparse.linalg import spsolve
except ImportError as imp_err:
raise ValueError(
"pentapy.solve: scipy.sparse could not be imported"
) from imp_err
msg = "pentapy.solve: scipy.sparse could not be imported"
raise ValueError(msg) from imp_err
if is_flat and index_row_wise:
mat_flat = np.array(mat)
_check_penta(mat_flat)
Expand All @@ -144,9 +142,8 @@ def solve(mat, rhs, is_flat=False, index_row_wise=True, solver=1):
from scipy import sparse as sps
from scipy.sparse.linalg import spsolve
except ImportError as imp_err:
raise ValueError(
"pentapy.solve: scipy.sparse could not be imported"
) from imp_err
msg = "pentapy.solve: scipy.sparse could not be imported"
raise ValueError(msg) from imp_err
if is_flat and index_row_wise:
mat_flat = np.array(mat)
_check_penta(mat_flat)
Expand All @@ -159,4 +156,5 @@ def solve(mat, rhs, is_flat=False, index_row_wise=True, solver=1):
M = sps.spdiags(mat_flat, [2, 1, 0, -1, -2], size, size, format="csc")
return spsolve(M, rhs, use_umfpack=True)
else: # pragma: no cover
raise ValueError("pentapy.solve: unknown solver (" + str(solver) + ")")
msg = f"pentapy.solve: unknown solver ({solver})"
raise ValueError(msg)
6 changes: 3 additions & 3 deletions src/pentapy/solver.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cython: language_level=3
cdef double[:] c_penta_solver1(double[:,:] mat_flat, double[:] rhs)
# cython: language_level=3
cdef double[:] c_penta_solver1(double[:, :] mat_flat, double[:] rhs)

cdef double[:] c_penta_solver2(double[:,:] mat_flat, double[:] rhs)
cdef double[:] c_penta_solver2(double[:, :] mat_flat, double[:] rhs)
11 changes: 5 additions & 6 deletions src/pentapy/solver.pyx
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
"""
This is a solver linear equation systems with a penta-diagonal matrix,
implemented in cython.
"""
import numpy as np

cimport cython
cimport numpy as np


def penta_solver1(double[:,:] mat_flat, double[:] rhs):
def penta_solver1(double[:, :] mat_flat, double[:] rhs):
return np.asarray(c_penta_solver1(mat_flat, rhs))


def penta_solver2(double[:,:] mat_flat, double[:] rhs):
def penta_solver2(double[:, :] mat_flat, double[:] rhs):
return np.asarray(c_penta_solver2(mat_flat, rhs))


cdef double[:] c_penta_solver1(double[:,:] mat_flat, double[:] rhs):
cdef double[:] c_penta_solver1(double[:, :] mat_flat, double[:] rhs):

cdef int mat_j = mat_flat.shape[1]

Expand Down Expand Up @@ -69,7 +68,7 @@ cdef double[:] c_penta_solver1(double[:,:] mat_flat, double[:] rhs):
return result


cdef double[:] c_penta_solver2(double[:,:] mat_flat, double[:] rhs):
cdef double[:] c_penta_solver2(double[:, :] mat_flat, double[:] rhs):

cdef int mat_j = mat_flat.shape[1]

Expand Down

0 comments on commit ac9a695

Please sign in to comment.