Skip to content

Fully support Python version 3.8 again #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
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
16 changes: 6 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,17 @@ jobs:
pip install -v --editable '.[lint,test]'
pip install "coveralls>=3.0.0"

- name: black check
- name: ruff linter
run: |
python -m black --check --diff --color .
python -m ruff check src/gstools/

- name: black preview
- name: ruff import check
run: |
python -m black --preview --diff --color .
python -m ruff check --select I --diff src/gstools/

- name: isort check
- name: ruff format check
run: |
python -m isort --check --diff --color .

- name: pylint check
run: |
python -m pylint src/gstools/
python -m ruff format --diff src/gstools/

- name: coveralls check
run: |
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [Unreleased] - ?

### Changes

- replace pylint, black, and isort with ruff [#391](https://github.com/GeoStat-Framework/GSTools/pull/391)

## [1.7.0] - Morphic Mint - 2025-04

### Enhancements
Expand Down
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ with your idea or suggestion and we'd love to discuss about it.

- Fork the repo on [GitHub](https://github.com/GeoStat-Framework/GSTools)
- Add yourself to AUTHORS.md (if you want to).
- We use [black](https://github.com/psf/black) and [isort](https://github.com/PyCQA/isort) to format our code.
Please use the scripts `black .` and `isort .` after you have written your code.
- We use [Ruff](https://github.com/psf/black) to check and format the code.
Please use the scripts `ruff check src/gstools`,
`ruff check --select I --fix src/gstools/`, and
`ruff format --diff src/gstools/` after you have written your code.
- Add some tests if possible.
- Add an example showing your new feature in one of the examples sub-folders if possible.
Follow this [Sphinx-Gallary guide](https://sphinx-gallery.github.io/stable/syntax.html#embed-rst-in-your-example-python-files).
Expand Down
9 changes: 3 additions & 6 deletions examples/01_random_field/05_mesh_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,18 @@

- `points="points"` will generate a field on the mesh points
- `points="centroids"` will generate a field on the cell centroids

In this example, we will generate a simple mesh with the aid of
`meshzoo <https://github.com/nschloe/meshzoo>`_.
"""

import matplotlib.pyplot as plt
import matplotlib.tri as tri
import meshio
import meshzoo
import numpy as np

import gstools as gs

# generate a triangulated hexagon with meshzoo
points, cells = meshzoo.ngon(6, 4)
# read a triangulated hexagon
points = np.load("hexagon_points.npy")
cells = np.load("hexagon_cells.npy")
mesh = meshio.Mesh(points, {"triangle": cells})

###############################################################################
Expand Down
Binary file added examples/01_random_field/hexagon_cells.npy
Binary file not shown.
Binary file added examples/01_random_field/hexagon_points.npy
Binary file not shown.
54 changes: 4 additions & 50 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ dependencies = [
doc = [
"myst_parser",
"matplotlib>=3.7",
"meshzoo>=0.7",
"numpydoc>=1.1",
"pykrige>=1.5,<2",
"pyvista>=0.40",
Expand All @@ -71,13 +70,9 @@ plotting = [
"matplotlib>=3.7",
"pyvista>=0.40",
]
rust = ["gstools_core>=1.0.0"]
rust = ["gstools_core>=1.1.0"]
test = ["pytest-cov>=3"]
lint = [
"black>=24",
"pylint",
"isort[colors]",
]
lint = ["ruff"]

[project.urls]
Changelog = "https://github.com/GeoStat-Framework/GSTools/blob/main/CHANGELOG.md"
Expand Down Expand Up @@ -107,21 +102,9 @@ include = [
[tool.hatch.build.targets.wheel]
packages = ["src/gstools"]

[tool.isort]
profile = "black"
multi_line_output = 3
line_length = 79

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

[tool.coverage]
[tool.coverage.run]
Expand All @@ -140,32 +123,3 @@ target-version = [
"def __repr__",
"def __str__",
]

[tool.pylint]
[tool.pylint.main]
extension-pkg-whitelist = [
"numpy",
"scipy",
"gstools_core",
]
ignore = "_version.py"
load-plugins = [
"pylint.extensions.no_self_use",
]

[tool.pylint.message_control]
disable = [
"R0801",
]

[tool.pylint.reports]
output-format = "colorized"

[tool.pylint.design]
max-args = 20
max-locals = 50
max-branches = 30
max-statements = 85
max-attributes = 30
max-public-methods = 80
max-positional-arguments=20
1 change: 1 addition & 0 deletions src/gstools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@
"Krige",
"SRF",
"CondSRF",
"PGS",
"rotated_main_axes",
"generate_grid",
"generate_st_grid",
Expand Down
3 changes: 1 addition & 2 deletions src/gstools/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

NUM_THREADS = None

# pylint: disable=W0611
try: # pragma: no cover
import gstools_core
import gstools_core # noqa: F401

_GSTOOLS_CORE_AVAIL = True
USE_GSTOOLS_CORE = True
Expand Down
1 change: 0 additions & 1 deletion src/gstools/covmodel/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
SumModel
"""

# pylint: disable=C0103, R0201, E1101, C0302, W0613, W0231
import copy

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion src/gstools/covmodel/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
fit_variogram
"""

# pylint: disable=C0103, W0632
import numpy as np
from scipy.optimize import curve_fit

Expand Down
1 change: 0 additions & 1 deletion src/gstools/covmodel/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
JBessel
"""

# pylint: disable=C0103, C0302, E1101, R0201
import warnings

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion src/gstools/covmodel/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
plot_spectral_rad_pdf
"""

# pylint: disable=C0103, C0415, E1130
import numpy as np

from gstools.tools.geometric import generate_grid
Expand Down
1 change: 0 additions & 1 deletion src/gstools/covmodel/sum_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
sum_model_repr
"""

# pylint: disable=W0212
import numpy as np

from gstools.tools import RADIAN_SCALE
Expand Down
1 change: 0 additions & 1 deletion src/gstools/covmodel/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
model_repr
"""

# pylint: disable=C0103, W0212
import warnings

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion src/gstools/covmodel/tpl_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
TPLSimple
"""

# pylint: disable=C0103, E1101
import warnings

import numpy as np
Expand Down
1 change: 0 additions & 1 deletion src/gstools/field/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Field
"""

# pylint: disable=C0103, C0415
from collections.abc import Iterable
from copy import copy
from functools import partial
Expand Down
2 changes: 0 additions & 2 deletions src/gstools/field/cond_srf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
CondSRF
"""

# pylint: disable=C0103, W0231, W0221, W0222, E1102

import numpy as np

from gstools.field.base import Field
Expand Down
29 changes: 8 additions & 21 deletions src/gstools/field/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
Fourier
"""

# pylint: disable=C0103, W0222, C0412, W0231
import warnings
from abc import ABC, abstractmethod
from copy import deepcopy as dcp
Expand All @@ -29,8 +28,7 @@
from gstools.random.rng import RNG
from gstools.tools.geometric import generate_grid

if config._GSTOOLS_CORE_AVAIL: # pylint: disable=W0212; # pragma: no cover
# pylint: disable=E0401
if config._GSTOOLS_CORE_AVAIL: # pragma: no cover
from gstools_core import summate as summate_gsc
from gstools_core import summate_fourier as summate_fourier_gsc
from gstools_core import summate_incompr as summate_incompr_gsc
Expand All @@ -43,11 +41,8 @@

def _summate(cov_samples, z_1, z_2, pos, num_threads=None):
"""A wrapper function for calling the randomization algorithms."""
if (
config.USE_GSTOOLS_CORE
and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212
):
summate_fct = summate_gsc # pylint: disable=E0606
if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
summate_fct = summate_gsc
else:
summate_fct = summate_c
return summate_fct(cov_samples, z_1, z_2, pos, num_threads)
Expand All @@ -62,23 +57,17 @@ def _summate_incompr(
):
"""A wrapper function for calling the incompr. randomization algorithms."""

if (
config.USE_GSTOOLS_CORE
and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212
):
summate_incompr_fct = summate_incompr_gsc # pylint: disable=E0606
if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
summate_incompr_fct = summate_incompr_gsc
else:
summate_incompr_fct = summate_incompr_c
return summate_incompr_fct(cov_samples, z_1, z_2, pos, num_threads)


def _summate_fourier(spectrum_factor, modes, z_1, z_2, pos, num_threads=None):
"""A wrapper function for calling the Fourier algorithms."""
if (
config.USE_GSTOOLS_CORE
and config._GSTOOLS_CORE_AVAIL # pylint: disable=W0212
):
summate_fourier_fct = summate_fourier_gsc # pylint: disable=E0606
if config.USE_GSTOOLS_CORE and config._GSTOOLS_CORE_AVAIL:
summate_fourier_fct = summate_fourier_gsc
else:
summate_fourier_fct = summate_fourier_c
return summate_fourier_fct(
Expand Down Expand Up @@ -830,9 +819,7 @@ def reset_seed(self, seed=np.nan):
self._model.spectrum(k_norm) * np.prod(self._delta_k)
)

def _fill_to_dim(
self, values, dim, dtype=float, default_value=None
): # pylint: disable=R6301
def _fill_to_dim(self, values, dim, dtype=float, default_value=None):
"""Fill an array with last element up to len(dim)."""
r = np.atleast_1d(values)
if values is None:
Expand Down
3 changes: 1 addition & 2 deletions src/gstools/field/pgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
PGS
"""

# pylint: disable=C0103
import numpy as np

# very clunky way of supporting both np 1.x and 2.x exceptions
Expand Down Expand Up @@ -129,7 +128,7 @@ def calc_lithotype_axes(self, lithotypes_shape):
# unstructured grid
centroid = self._fields.mean(axis=1)
for d in range(self._dim):
l = np.floor(self._fields[d].min()) - 1
l = np.floor(self._fields[d].min()) - 1 # noqa: E741
h = np.ceil(self._fields[d].max()) + 1
m = (h + l) / 2.0
dist = max(np.abs(h - m), np.abs(l - m))
Expand Down
1 change: 0 additions & 1 deletion src/gstools/field/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
plot_vec_field
"""

# pylint: disable=C0103, W0613, E1101, E0606
import numpy as np
from scipy import interpolate as inter
from scipy.spatial import ConvexHull
Expand Down
2 changes: 0 additions & 2 deletions src/gstools/field/srf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
SRF
"""

# pylint: disable=C0103, W0221, E1102

import numpy as np

from gstools.field.base import Field
Expand Down
1 change: 0 additions & 1 deletion src/gstools/field/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
generate_on_mesh
"""

# pylint: disable=W0212, C0415
import meshio
import numpy as np

Expand Down
7 changes: 3 additions & 4 deletions src/gstools/field/upscaling.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
var_no_scaling
"""

# pylint: disable=W0613
import warnings

import numpy as np
Expand Down Expand Up @@ -75,9 +74,9 @@ def var_coarse_graining(model, point_volumes=0.0):
)
# interpret volume as a hypercube and calculate the edge length
edge = point_volumes ** (1.0 / model.dim)
var_factor = (
model.len_scale**2 / (model.len_scale**2 + edge**2 / 4)
) ** (model.dim / 2.0)
var_factor = (model.len_scale**2 / (model.len_scale**2 + edge**2 / 4)) ** (
model.dim / 2.0
)

return model.sill * var_factor

Expand Down
Loading