diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1ccb9fc9..79993388 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,10 +37,6 @@ jobs: run: | python -m ruff check src/gstools/ - - name: ruff import check - run: | - python -m ruff check --select I --diff src/gstools/ - - name: ruff format check run: | python -m ruff format --diff src/gstools/ @@ -58,7 +54,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14] + os: + [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-14] # https://github.com/scipy/oldest-supported-numpy/blob/main/setup.cfg ver: - { py: "3.8", np: "==1.20.0", sp: "==1.5.4" } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dbe9e88e..60359004 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,68 +30,9 @@ 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 [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 + Please use the scripts `ruff check 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). - Push to your fork and submit a pull request. - -### PyLint Settings - -Your code will be checked by [Pylint](https://github.com/PyCQA/pylint/) -with `pylint gstools` in the CI. -We made some generous default settings in `pyproject.toml` for the linter: - -- max-args = 20 -- max-locals = 50 -- max-branches = 30 -- max-statements = 80 -- max-attributes = 25 -- max-public-methods = 75 - -Since some classes in GSTools are quite huge and some function signatures are -somewhat longish. - -By default [R0801](https://vald-phoenix.github.io/pylint-errors/plerr/errors/similarities/R0801) -(duplicate-code) is disabled, since it produces a lot of false positive errors -for docstrings and `__init__.py` settings. - -We also disabled some pylint checks for some files by setting -comments like these at the beginning: -```python -# pylint: disable=C0103 -``` - -Here is a list of the occurring disabled errors: -- [C0103](https://vald-phoenix.github.io/pylint-errors/plerr/errors/basic/C0103) - (invalid-name) - `ax`, `r` etc. are marked as no valid names -- [C0302](https://vald-phoenix.github.io/pylint-errors/plerr/errors/format/C0302) - (too-many-lines) - namely the `CovModel` definition has more than 1000 lines -- [C0415](https://vald-phoenix.github.io/pylint-errors/plerr/errors/imports/C0415) - (import-outside-toplevel) - needed sometimes for deferred imports of optional - dependencies like `matplotlib` -- [R0201](https://vald-phoenix.github.io/pylint-errors/plerr/errors/classes/R0201) - (no-self-use) - methods with no `self` calls in some base-classes -- [W0212](https://vald-phoenix.github.io/pylint-errors/plerr/errors/classes/W0212) - (protected-access) - we didn't want to draw attention to `CovModel._prec` -- [W0221](https://vald-phoenix.github.io/pylint-errors/plerr/errors/classes/W0221) - (arguments-differ) - the `__call__` methods of `SRF` and `Krige` differ from `Field` -- [W0222](https://vald-phoenix.github.io/pylint-errors/plerr/errors/classes/W0222) - (signature-differ) - the `__call__` methods of `SRF` and `Krige` differ from `Field` -- [W0231](https://vald-phoenix.github.io/pylint-errors/plerr/errors/classes/W0231) - (super-init-not-called) - some child classes have their specialized `__init__` -- [W0613](https://vald-phoenix.github.io/pylint-errors/plerr/errors/variables/W0613) - (unused-argument) - needed sometimes to match required call signatures -- [W0632](https://vald-phoenix.github.io/pylint-errors/plerr/errors/variables/W0632) - (unbalanced-tuple-unpacking) - false positive for some call returns -- [E1101](https://vald-phoenix.github.io/pylint-errors/plerr/errors/typecheck/E1101) - (no-member) - some times false positive -- [E1102](https://vald-phoenix.github.io/pylint-errors/plerr/errors/typecheck/E1102) - (not-callable) - this is a false-positive result form some called properties -- [E1130](https://vald-phoenix.github.io/pylint-errors/plerr/errors/typecheck/E1130) - (invalid-unary-operand-type) - false positive at some points - -Although we disabled these errors at some points, we encourage you to prevent -disabling errors when it is possible. diff --git a/examples/11_plurigaussian/02_spatial_relations.py b/examples/11_plurigaussian/02_spatial_relations.py index 36516fc2..0380c89c 100644 --- a/examples/11_plurigaussian/02_spatial_relations.py +++ b/examples/11_plurigaussian/02_spatial_relations.py @@ -69,18 +69,12 @@ for i in range(4): lithotypes[ M[0] // 2 + S1[0] : M[0] // 2 + S1[0] + rect[0], - M[1] // 2 - + S1[1] - + rect[1] - + 3 - + 2 * i : M[1] // 2 + M[1] // 2 + S1[1] + rect[1] + 3 + 2 * i : M[1] // 2 + S1[1] + rect[1] + 4 + 2 * i, - ] = ( - 4 + i - ) + ] = 4 + i ############################################################################### # With the two SRFs and the L-field ready, we can create the PGS. diff --git a/examples/11_plurigaussian/04_3d_pgs.py b/examples/11_plurigaussian/04_3d_pgs.py index d5aaef84..9457fea0 100644 --- a/examples/11_plurigaussian/04_3d_pgs.py +++ b/examples/11_plurigaussian/04_3d_pgs.py @@ -7,7 +7,6 @@ """ # sphinx_gallery_thumbnail_path = 'pics/3d_pgs.png' -import matplotlib.pyplot as plt import numpy as np import gstools as gs diff --git a/pyproject.toml b/pyproject.toml index 08ec4966..885bcd77 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,7 @@ [build-system] -requires = [ - "hatchling>=1.8.0", - "hatch-vcs", -] +requires = ["hatchling>=1.8.0", "hatch-vcs"] build-backend = "hatchling.build" [project] @@ -12,7 +9,7 @@ requires-python = ">=3.8" name = "gstools" description = "GSTools: A geostatistical toolbox." authors = [ - {name = "Sebastian Müller, Lennart Schüler", email = "info@geostat-framework.org"}, + { name = "Sebastian Müller, Lennart Schüler", email = "info@geostat-framework.org" }, ] readme = "README.md" license = "LGPL-3.0" @@ -67,10 +64,7 @@ doc = [ "sphinx-rtd-theme>=3", "sphinxcontrib-youtube>=1.1", ] -plotting = [ - "matplotlib>=3.7", - "pyvista>=0.40", -] +plotting = ["matplotlib>=3.7", "pyvista>=0.40"] rust = ["gstools_core>=1.0.0"] test = ["pytest-cov>=3"] lint = ["ruff"] @@ -95,10 +89,7 @@ version-file = "src/gstools/_version.py" template = "__version__ = '{version}'" [tool.hatch.build.targets.sdist] -include = [ - "/src", - "/tests", -] +include = ["/src", "/tests"] [tool.hatch.build.targets.wheel] packages = ["src/gstools"] @@ -107,20 +98,22 @@ packages = ["src/gstools"] line-length = 79 target-version = "py38" +[tool.ruff.lint] +select = [ + "F", + "I", +] + [tool.coverage] - [tool.coverage.run] - source = ["gstools"] - omit = [ - "*docs*", - "*examples*", - "*tests*", - "*/src/gstools/covmodel/plot.py", - "*/src/gstools/field/plot.py", - ] +[tool.coverage.run] +source = ["gstools"] +omit = [ + "*docs*", + "*examples*", + "*tests*", + "*/src/gstools/covmodel/plot.py", + "*/src/gstools/field/plot.py", +] - [tool.coverage.report] - exclude_lines = [ - "pragma: no cover", - "def __repr__", - "def __str__", - ] +[tool.coverage.report] +exclude_lines = ["pragma: no cover", "def __repr__", "def __str__"] diff --git a/tests/test_rng.py b/tests/test_rng.py index 8fe16728..26cadb85 100644 --- a/tests/test_rng.py +++ b/tests/test_rng.py @@ -5,9 +5,8 @@ import unittest import numpy as np -from scipy.stats import kurtosis, normaltest, skew -from gstools import Gaussian, TPLStable +from gstools import Gaussian from gstools.random.rng import RNG @@ -100,7 +99,8 @@ def test_sample_dist(self): # TODO test with different models - # TODO rework this + # TODO rework this, needs + # from scipy.stats import kurtosis, normaltest, skew # def test_gau(self): # for d in range(len(self.rngs)): # Z, k = self.rngs[d]('gau', self.len_scale, self.many_modes) diff --git a/tests/test_srf.py b/tests/test_srf.py index eb9468ca..8226a046 100644 --- a/tests/test_srf.py +++ b/tests/test_srf.py @@ -9,7 +9,6 @@ import numpy as np import gstools as gs -from gstools import transform as tf HAS_PYVISTA = False try: