Skip to content

Commit d2da47e

Browse files
authored
Merge pull request #317 from GeoStat-Framework/cython_linting
Python 3.12 support, Cython linting
2 parents ab3c6c4 + 5638e15 commit d2da47e

File tree

7 files changed

+89
-67
lines changed

7 files changed

+89
-67
lines changed

.github/workflows/main.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,23 @@ jobs:
3232
- name: Install dependencies
3333
run: |
3434
python -m pip install --upgrade pip
35-
pip install black 'pylint<3' 'isort[colors]<6'
36-
pip install -v --editable .
35+
pip install -v --editable .[lint]
3736
3837
- name: black check
3938
run: |
4039
python -m black --check --diff --color .
4140
41+
- name: isort check
42+
run: |
43+
python -m isort --check --diff --color .
44+
4245
- name: pylint check
4346
run: |
4447
python -m pylint src/gstools/
4548
46-
- name: isort check
49+
- name: cython-lint check
4750
run: |
48-
python -m isort --check --diff --color .
51+
cython-lint src/gstools/
4952
5053
build_wheels:
5154
name: wheels for ${{ matrix.cfg.os }} / ${{ matrix.cfg.arch }}
@@ -68,7 +71,7 @@ jobs:
6871
fetch-depth: '0'
6972

7073
- name: Build wheels
71-
uses: pypa/cibuildwheel@v2.11.2
74+
uses: pypa/cibuildwheel@v2.16.2
7275
env:
7376
CIBW_ARCHS: ${{ matrix.cfg.arch }}
7477
with:
@@ -85,7 +88,7 @@ jobs:
8588
fail-fast: false
8689
matrix:
8790
os: [ubuntu-latest, windows-latest, macos-latest]
88-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
91+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
8992

9093
steps:
9194
- uses: actions/checkout@v2

.readthedocs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
version: 2
22

3+
build:
4+
os: ubuntu-22.04
5+
tools:
6+
python: "3.11"
7+
38
sphinx:
49
configuration: docs/source/conf.py
510

611
formats: all
712

813
python:
9-
version: 3.8
1014
install:
1115
- method: pip
1216
path: .

CHANGELOG.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
All notable changes to **GSTools** will be documented in this file.
44

5+
## [1.5.1] - Nifty Neon - 2023-11
6+
7+
### Enhancements
8+
9+
see [#317](https://github.com/GeoStat-Framework/GSTools/pull/317)
10+
11+
- added wheels for Python 3.12
12+
- dropped support for Python 3.7 (EOL)
13+
- linted Cython files with cython-lint
14+
- use Cython 3 to build extensions
15+
16+
517
## [1.5.0] - Nifty Neon - 2023-06
618

719
### Enhancements
@@ -404,7 +416,8 @@ See: [#197](https://github.com/GeoStat-Framework/GSTools/issues/197)
404416
First release of GSTools.
405417

406418

407-
[Unreleased]: https://github.com/GeoStat-Framework/gstools/compare/v1.5.0...HEAD
419+
[Unreleased]: https://github.com/GeoStat-Framework/gstools/compare/v1.5.1...HEAD
420+
[1.5.1]: https://github.com/GeoStat-Framework/gstools/compare/v1.5.0...v1.5.1
408421
[1.5.0]: https://github.com/GeoStat-Framework/gstools/compare/v1.4.1...v1.5.0
409422
[1.4.1]: https://github.com/GeoStat-Framework/gstools/compare/v1.4.0...v1.4.1
410423
[1.4.0]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.5...v1.4.0

pyproject.toml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ requires = [
33
"setuptools>=64",
44
"setuptools_scm>=7",
55
"oldest-supported-numpy",
6-
"Cython>=0.29.32,<3.0",
6+
"Cython>=3.0",
77
"extension-helpers>=1",
88
]
99
build-backend = "setuptools.build_meta"
1010

1111
[project]
12-
requires-python = ">=3.7"
12+
requires-python = ">=3.8"
1313
name = "gstools"
1414
description = "GSTools: A geostatistical toolbox."
1515
authors = [
@@ -32,11 +32,11 @@ classifiers = [
3232
"Programming Language :: Python",
3333
"Programming Language :: Python :: 3",
3434
"Programming Language :: Python :: 3 :: Only",
35-
"Programming Language :: Python :: 3.7",
3635
"Programming Language :: Python :: 3.8",
3736
"Programming Language :: Python :: 3.9",
3837
"Programming Language :: Python :: 3.10",
3938
"Programming Language :: Python :: 3.11",
39+
"Programming Language :: Python :: 3.12",
4040
"Topic :: Scientific/Engineering",
4141
"Topic :: Scientific/Engineering :: GIS",
4242
"Topic :: Scientific/Engineering :: Hydrology",
@@ -72,6 +72,12 @@ plotting = [
7272
]
7373
rust = ["gstools_core>=0.2.0,<1"]
7474
test = ["pytest-cov>=3"]
75+
lint = [
76+
"black",
77+
"pylint",
78+
"isort[colors]",
79+
"cython-lint",
80+
]
7581

7682
[project.urls]
7783
Changelog = "https://github.com/GeoStat-Framework/GSTools/blob/main/CHANGELOG.md"
@@ -98,11 +104,11 @@ line_length = 79
98104
[tool.black]
99105
line-length = 79
100106
target-version = [
101-
"py37",
102107
"py38",
103108
"py39",
104109
"py310",
105110
"py311",
111+
"py312",
106112
]
107113

108114
[tool.coverage]
@@ -154,8 +160,8 @@ target-version = [
154160
[tool.cibuildwheel]
155161
# Switch to using build
156162
build-frontend = "build"
157-
# Disable building PyPy wheels on all platforms, 32bit for py3.10/11 and musllinux builds, py3.6
158-
skip = ["cp36-*", "pp*", "cp31*-win32", "cp31*-manylinux_i686", "*-musllinux_*"]
163+
# Disable building PyPy wheels on all platforms, 32bit for py3.10/11/12, musllinux builds, py3.6/7
164+
skip = ["cp36-*", "cp37-*", "pp*", "cp31*-win32", "cp31*-manylinux_i686", "*-musllinux_*"]
159165
# Run the package tests using `pytest`
160166
test-extras = "test"
161167
test-command = "pytest -v {package}/tests"

src/gstools/field/summator.pyx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
1+
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
22
"""
33
This is the randomization method summator, implemented in cython.
44
"""
55

66
import numpy as np
7-
8-
cimport cython
9-
107
from cython.parallel import prange
118

129
cimport numpy as np
@@ -18,7 +15,7 @@ def summate(
1815
const double[:] z_1,
1916
const double[:] z_2,
2017
const double[:, :] pos
21-
):
18+
):
2219
cdef int i, j, d
2320
cdef double phase
2421
cdef int dim = pos.shape[0]
@@ -53,7 +50,7 @@ def summate_incompr(
5350
const double[:] z_1,
5451
const double[:] z_2,
5552
const double[:, :] pos
56-
):
53+
):
5754
cdef int i, j, d
5855
cdef double phase
5956
cdef double k_2
@@ -76,6 +73,7 @@ def summate_incompr(
7673
phase += cov_samples[d, j] * pos[d, i]
7774
for d in range(dim):
7875
proj[d] = e1[d] - cov_samples[d, j] * cov_samples[0, j] / k_2
79-
summed_modes[d, i] += proj[d] * (z_1[j] * cos(phase) + z_2[j] * sin(phase))
80-
76+
summed_modes[d, i] += (
77+
proj[d] * (z_1[j] * cos(phase) + z_2[j] * sin(phase))
78+
)
8179
return np.asarray(summed_modes)

src/gstools/krige/krigesum.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
1+
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
22
"""
33
This is a summator for the kriging routines
44
"""
55

66
import numpy as np
7-
8-
cimport cython
97
from cython.parallel import prange
8+
109
cimport numpy as np
1110

1211

0 commit comments

Comments
 (0)