Skip to content

Commit

Permalink
Merge pull request #317 from GeoStat-Framework/cython_linting
Browse files Browse the repository at this point in the history
Python 3.12 support, Cython linting
  • Loading branch information
MuellerSeb authored Nov 3, 2023
2 parents ab3c6c4 + 5638e15 commit d2da47e
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 67 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,23 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install black 'pylint<3' 'isort[colors]<6'
pip install -v --editable .
pip install -v --editable .[lint]
- name: black check
run: |
python -m black --check --diff --color .
- name: isort check
run: |
python -m isort --check --diff --color .
- name: pylint check
run: |
python -m pylint src/gstools/
- name: isort check
- name: cython-lint check
run: |
python -m isort --check --diff --color .
cython-lint src/gstools/
build_wheels:
name: wheels for ${{ matrix.cfg.os }} / ${{ matrix.cfg.arch }}
Expand All @@ -68,7 +71,7 @@ jobs:
fetch-depth: '0'

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.2
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_ARCHS: ${{ matrix.cfg.arch }}
with:
Expand All @@ -85,7 +88,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v2
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.8
install:
- method: pip
path: .
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

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

## [1.5.1] - Nifty Neon - 2023-11

### Enhancements

see [#317](https://github.com/GeoStat-Framework/GSTools/pull/317)

- added wheels for Python 3.12
- dropped support for Python 3.7 (EOL)
- linted Cython files with cython-lint
- use Cython 3 to build extensions


## [1.5.0] - Nifty Neon - 2023-06

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


[Unreleased]: https://github.com/GeoStat-Framework/gstools/compare/v1.5.0...HEAD
[Unreleased]: https://github.com/GeoStat-Framework/gstools/compare/v1.5.1...HEAD
[1.5.1]: https://github.com/GeoStat-Framework/gstools/compare/v1.5.0...v1.5.1
[1.5.0]: https://github.com/GeoStat-Framework/gstools/compare/v1.4.1...v1.5.0
[1.4.1]: https://github.com/GeoStat-Framework/gstools/compare/v1.4.0...v1.4.1
[1.4.0]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.5...v1.4.0
Expand Down
18 changes: 12 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ requires = [
"setuptools>=64",
"setuptools_scm>=7",
"oldest-supported-numpy",
"Cython>=0.29.32,<3.0",
"Cython>=3.0",
"extension-helpers>=1",
]
build-backend = "setuptools.build_meta"

[project]
requires-python = ">=3.7"
requires-python = ">=3.8"
name = "gstools"
description = "GSTools: A geostatistical toolbox."
authors = [
Expand All @@ -32,11 +32,11 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"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",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Scientific/Engineering :: Hydrology",
Expand Down Expand Up @@ -72,6 +72,12 @@ plotting = [
]
rust = ["gstools_core>=0.2.0,<1"]
test = ["pytest-cov>=3"]
lint = [
"black",
"pylint",
"isort[colors]",
"cython-lint",
]

[project.urls]
Changelog = "https://github.com/GeoStat-Framework/GSTools/blob/main/CHANGELOG.md"
Expand All @@ -98,11 +104,11 @@ line_length = 79
[tool.black]
line-length = 79
target-version = [
"py37",
"py38",
"py39",
"py310",
"py311",
"py312",
]

[tool.coverage]
Expand Down Expand Up @@ -154,8 +160,8 @@ target-version = [
[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 for py3.10/11/12, musllinux builds, py3.6/7
skip = ["cp36-*", "cp37-*", "pp*", "cp31*-win32", "cp31*-manylinux_i686", "*-musllinux_*"]
# Run the package tests using `pytest`
test-extras = "test"
test-command = "pytest -v {package}/tests"
Expand Down
14 changes: 6 additions & 8 deletions src/gstools/field/summator.pyx
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
"""
This is the randomization method summator, implemented in cython.
"""

import numpy as np

cimport cython

from cython.parallel import prange

cimport numpy as np
Expand All @@ -18,7 +15,7 @@ def summate(
const double[:] z_1,
const double[:] z_2,
const double[:, :] pos
):
):
cdef int i, j, d
cdef double phase
cdef int dim = pos.shape[0]
Expand Down Expand Up @@ -53,7 +50,7 @@ def summate_incompr(
const double[:] z_1,
const double[:] z_2,
const double[:, :] pos
):
):
cdef int i, j, d
cdef double phase
cdef double k_2
Expand All @@ -76,6 +73,7 @@ def summate_incompr(
phase += cov_samples[d, j] * pos[d, i]
for d in range(dim):
proj[d] = e1[d] - cov_samples[d, j] * cov_samples[0, j] / k_2
summed_modes[d, i] += proj[d] * (z_1[j] * cos(phase) + z_2[j] * sin(phase))

summed_modes[d, i] += (
proj[d] * (z_1[j] * cos(phase) + z_2[j] * sin(phase))
)
return np.asarray(summed_modes)
5 changes: 2 additions & 3 deletions src/gstools/krige/krigesum.pyx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
# cython: language_level=3, boundscheck=False, wraparound=False, cdivision=True
"""
This is a summator for the kriging routines
"""

import numpy as np

cimport cython
from cython.parallel import prange

cimport numpy as np


Expand Down
Loading

0 comments on commit d2da47e

Please sign in to comment.