Skip to content
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

CIBW: add support for py3.10 and Apple Silicon; use CIBWv2 #211

Merged
merged 45 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1b19ebb
CIBW: add support for py3.10; use CIBWv2
MuellerSeb Oct 11, 2021
89a483d
CI: fix old typo
MuellerSeb Oct 11, 2021
48457d7
pyproject: fix typo
MuellerSeb Oct 11, 2021
acb521a
CI: add py3.10 to sdist test
MuellerSeb Oct 20, 2021
f3b8ec3
add discussion paper
MuellerSeb Oct 20, 2021
17a9d2b
Merge pull request #214 from GeoStat-Framework/add_paper
MuellerSeb Oct 20, 2021
596ffd6
CIBW: skip 32bit builds for py3.10 like numpy
MuellerSeb Oct 21, 2021
c5aa154
CI: update python version strings
MuellerSeb Oct 21, 2021
da4d714
CI: fix old typo
MuellerSeb Oct 11, 2021
0cc899a
Remove Cython code & replace it with GSTools-Core
LSchueler Oct 27, 2021
68ea3b5
CI: use latest cibuildwheel version
MuellerSeb Nov 8, 2021
601459b
CI: manylinux2014 for cp310 (like scipy)
MuellerSeb Nov 8, 2021
04531fa
CI: skip musllinux
MuellerSeb Nov 8, 2021
490ad20
Fix names in unit tests
LSchueler Nov 9, 2021
41cb5d5
Restore Cython code and make Rust impl. optional
LSchueler Nov 9, 2021
e1bd45c
Remove unnecessary `dim` arg. in Cython code
LSchueler Nov 9, 2021
872570f
Satify coveralls
LSchueler Nov 9, 2021
1ff09ed
Update changelog
LSchueler Nov 9, 2021
60325f0
Update installation part of doc.
LSchueler Nov 9, 2021
164b687
Mention RAYON_NUM_THREADS in readme
LSchueler Nov 9, 2021
c0777e3
Use correct version of GSTools-Core
LSchueler Nov 9, 2021
774c730
Improve import situation
LSchueler Nov 10, 2021
0049a31
Clean up some linter flags
LSchueler Nov 10, 2021
ce978b8
Merge pull request #215 from GeoStat-Framework/rust-core
LSchueler Nov 11, 2021
83ea286
CI: use manylinux1 for cp3.6 wheels
MuellerSeb Nov 15, 2021
6be59f0
CI: auditwheel 4 is smart enough to build manylinux1 compatible wheel…
MuellerSeb Nov 16, 2021
8948f5f
CI: separate jobs per arch for wheels; add universal2 wheel for macos
MuellerSeb Nov 17, 2021
ce25b32
CI: also add arm64 wheels to be on the safe side
MuellerSeb Nov 17, 2021
5b97d67
CIBW: add support for py3.10; use CIBWv2
MuellerSeb Oct 11, 2021
672b006
pyproject: fix typo
MuellerSeb Oct 11, 2021
4563341
CI: add py3.10 to sdist test
MuellerSeb Oct 20, 2021
d5ca1f2
CIBW: skip 32bit builds for py3.10 like numpy
MuellerSeb Oct 21, 2021
44cd73c
CI: update python version strings
MuellerSeb Oct 21, 2021
57b5500
CI: use latest cibuildwheel version
MuellerSeb Nov 8, 2021
332ec74
CI: manylinux2014 for cp310 (like scipy)
MuellerSeb Nov 8, 2021
9633c58
CI: skip musllinux
MuellerSeb Nov 8, 2021
42d4f51
CI: use manylinux1 for cp3.6 wheels
MuellerSeb Nov 15, 2021
26debc5
CI: auditwheel 4 is smart enough to build manylinux1 compatible wheel…
MuellerSeb Nov 16, 2021
9944cca
CI: separate jobs per arch for wheels; add universal2 wheel for macos
MuellerSeb Nov 17, 2021
0f87dd4
CI: also add arm64 wheels to be on the safe side
MuellerSeb Nov 17, 2021
791203f
CI: skip testing arm64 on macos
MuellerSeb Nov 17, 2021
6bb10bc
Setup.cfg: add more classifiers
MuellerSeb Nov 17, 2021
3d6c787
CI: use build to build wheels
MuellerSeb Nov 17, 2021
c462c50
update Changelog
MuellerSeb Nov 17, 2021
c5e8ff1
Merge branch 'CIBW_update' of github.com:GeoStat-Framework/GSTools in…
MuellerSeb Nov 17, 2021
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
25 changes: 15 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions\setup-python@v2
uses: actions/setup-python@v2
with:
python-version: 3.8

Expand All @@ -46,24 +46,29 @@ jobs:
python -m isort --check --diff --color .

build_wheels:
name: wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
name: wheels for ${{ matrix.cfg.os }} / ${{ matrix.cfg.arch }}
runs-on: ${{ matrix.cfg.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
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 }

steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'

- name: Build wheels
uses: pypa/cibuildwheel@v1.11.1.post1
uses: pypa/cibuildwheel@v2.2.2
env:
CIBW_BUILD: cp36-* cp37-* cp38-* cp39-*
CIBW_TEST_EXTRAS: test
CIBW_TEST_COMMAND: pytest -v {project}/tests
CIBW_ARCHS: ${{ matrix.cfg.arch }}
with:
output-dir: dist

Expand All @@ -78,15 +83,15 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'

- name: Set up Python ${{ matrix.python-version }}
uses: actions\setup-python@v2
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

Expand Down
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
All notable changes to **GSTools** will be documented in this file.


## [1.3.4] - Pure Pink - 2021-11

### Enhancements
- add GStools-Core as optional dependency [#215](https://github.com/GeoStat-Framework/GSTools/pull/215)
- provide wheels for Python 3.10 [#211](https://github.com/GeoStat-Framework/GSTools/pull/211)
- provide macOS wheels for Apple Silicon [#211](https://github.com/GeoStat-Framework/GSTools/pull/211)

### Changes
- remove unnecessary `dim` argument in Cython code [#216](https://github.com/GeoStat-Framework/GSTools/issues/216)


## [1.3.3] - Pure Pink - 2021-08

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


[Unreleased]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.3...HEAD
[Unreleased]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.4...HEAD
[1.3.4]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.3...v1.3.4
[1.3.3]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.2...v1.3.3
[1.3.2]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.1...v1.3.2
[1.3.1]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.0...v1.3.1
Expand Down
10 changes: 10 additions & 0 deletions CITATION.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@Article{gmd-2021-301,
AUTHOR = {M\"uller, S. and Sch\"uler, L. and Zech, A. and He{\ss}e, F.},
TITLE = {GSTools v1.3: A toolbox for geostatistical modelling in Python},
JOURNAL = {Geoscientific Model Development Discussions},
VOLUME = {2021},
YEAR = {2021},
PAGES = {1--33},
URL = {https://gmd.copernicus.org/preprints/gmd-2021-301/},
DOI = {10.5194/gmd-2021-301}
}
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ To install the latest development version via pip, see the

## Citation

At the moment you can cite the Zenodo code publication of GSTools:
If you are using GSTools in your publication please cite our paper:

> Sebastian Müller & Lennart Schüler. GeoStat-Framework/GSTools. Zenodo. https://doi.org/10.5281/zenodo.1313628
> Müller, S., Schüler, L., Zech, A., and Heße, F.:
> GSTools v1.3: A toolbox for geostatistical modelling in Python,
> Geosci. Model Dev. Discuss. [preprint], https://doi.org/10.5194/gmd-2021-301, in review, 2021.

You can cite the Zenodo code publication of GSTools by:

If you want to cite a specific version, have a look at the Zenodo site.
> Sebastian Müller & Lennart Schüler. GeoStat-Framework/GSTools. Zenodo. https://doi.org/10.5281/zenodo.1313628

A publication for the GeoStat-Framework is in preperation.
If you want to cite a specific version, have a look at the [Zenodo site](https://doi.org/10.5281/zenodo.1313628).


## Documentation for GSTools
Expand Down Expand Up @@ -341,6 +345,7 @@ in memory for immediate 3D plotting in Python.

### Optional

- [GSTools-Core >= 0.2.0](https://github.com/GeoStat-Framework/GSTools-Core)
- [matplotlib](https://matplotlib.org)
- [pyvista](https://docs.pyvista.org/)

Expand Down
40 changes: 36 additions & 4 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ To get the latest development version you can install it directly from GitHub:

If something went wrong during installation, try the :code:`-I` `flag from pip <https://pip-python3.readthedocs.io/en/latest/reference/pip_install.html?highlight=i#cmdoption-i>`_.

**Speeding up GSTools by parallelization**

To enable the OpenMP support, you have to provide a C compiler and OpenMP.
Parallel support is controlled by an environment variable ``GSTOOLS_BUILD_PARALLEL``,
that can be ``0`` or ``1`` (interpreted as ``0`` if not present).
Expand All @@ -89,17 +91,46 @@ For the development version, you can do almost the same:
export GSTOOLS_BUILD_PARALLEL=1
pip install git+git://github.com/GeoStat-Framework/GSTools.git@main

**Using experimental GSTools-Core for even more speed**

You can install the optional dependency `GSTools-Core <https://github.com/GeoStat-Framework/GSTools-Core>`_,
which is a re-implementation of the main algorithms used in GSTools. The new
package uses the language Rust and it should be faster (in some cases by orders
of magnitude), safer, and it will potentially completely replace the current
standard implementation in Cython. Once the package GSTools-Core is available
on your machine, it will be used by default. In case you want to switch back to
the Cython implementation, you can set :code:`gstools.config.USE_RUST=False` in
your code. This also works at runtime. You can install the optional dependency
e.g. by

.. code-block:: none

pip install gstools[rust]

or by manually installing the package

.. code-block:: none

pip install gstools-core

GSTools-Core will automatically use all your cores in parallel, without having
to use OpenMP or a local C compiler.
In case you want to restrict the number of threads used, you can set the
environment variable ``RAYON_NUM_THREADS`` to the desired amount.


Citation
========

At the moment you can cite the Zenodo code publication of GSTools:
If you are using GSTools in your publication please cite our paper:

| *Sebastian Müller & Lennart Schüler. GeoStat-Framework/GSTools. Zenodo. https://doi.org/10.5281/zenodo.1313628*
| *Müller, S., Schüler, L., Zech, A., and Heße, F.: GSTools v1.3: A toolbox for geostatistical modelling in Python, Geosci. Model Dev. Discuss. [preprint], https://doi.org/10.5194/gmd-2021-301, in review, 2021.*

You can cite the Zenodo code publication of GSTools by:

If you want to cite a specific version, have a look at the Zenodo site.
| *Sebastian Müller & Lennart Schüler. GeoStat-Framework/GSTools. Zenodo. https://doi.org/10.5281/zenodo.1313628*

A publication for the GeoStat-Framework is in preperation.
If you want to cite a specific version, have a look at the `Zenodo site <https://doi.org/10.5281/zenodo.1313628)>`__.


Tutorials and Examples
Expand Down Expand Up @@ -385,6 +416,7 @@ Requirements
Optional
--------

- `GSTools-Core >= 0.2.0 <https://github.com/GeoStat-Framework/GSTools-Core>`_
- `matplotlib <https://matplotlib.org>`_
- `pyvista <https://docs.pyvista.org>`_

Expand Down
1 change: 1 addition & 0 deletions gstools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"""
# Hooray!
from gstools import (
config,
covmodel,
field,
krige,
Expand Down
14 changes: 14 additions & 0 deletions gstools/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
"""
GStools subpackage providing global variables.

.. currentmodule:: gstools.config

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

USE_RUST = True
except ImportError:
USE_RUST = False
10 changes: 8 additions & 2 deletions gstools/field/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,22 @@
RandMeth
IncomprRandMeth
"""
# pylint: disable=C0103, W0222
# pylint: disable=C0103, W0222, C0412
import warnings
from copy import deepcopy as dcp

import numpy as np

from gstools import config
from gstools.covmodel.base import CovModel
from gstools.field.summator import summate, summate_incompr
from gstools.random.rng import RNG

if config.USE_RUST: # pragma: no cover
# pylint: disable=E0401
from gstools_core import summate, summate_incompr
else:
from gstools.field.summator import summate, summate_incompr

__all__ = ["RandMeth", "IncomprRandMeth"]


Expand Down
16 changes: 11 additions & 5 deletions gstools/krige/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,29 @@
.. autosummary::
Krige
"""
# pylint: disable=C0103, W0221, E1102, R0201
# pylint: disable=C0103, W0221, E1102, R0201, C0412
import collections

import numpy as np
import scipy.linalg as spl
from scipy.spatial.distance import cdist

from gstools import config
from gstools.field.base import Field
from gstools.krige.krigesum import (
calc_field_krige,
calc_field_krige_and_variance,
)
from gstools.krige.tools import get_drift_functions, set_condition
from gstools.tools.geometric import rotated_main_axes
from gstools.tools.misc import eval_func
from gstools.variogram import vario_estimate

if config.USE_RUST: # pragma: no cover
# pylint: disable=E0401
from gstools_core import calc_field_krige, calc_field_krige_and_variance
else:
from gstools.krige.krigesum import (
calc_field_krige,
calc_field_krige_and_variance,
)

__all__ = ["Krige"]


Expand Down
4 changes: 2 additions & 2 deletions gstools/variogram/estimator.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ cdef _normalization_func_vec choose_estimator_normalization_vec(str estimator_ty


def directional(
const int dim,
const double[:,:] f,
const double[:] bin_edges,
const double[:,:] pos,
Expand All @@ -203,6 +202,7 @@ def directional(
choose_estimator_normalization_vec(estimator_type)
)

cdef int dim = pos.shape[0]
cdef int d_max = direction.shape[0]
cdef int i_max = bin_edges.shape[0] - 1
cdef int j_max = pos.shape[1] - 1
Expand Down Expand Up @@ -237,13 +237,13 @@ def directional(
return np.asarray(variogram), np.asarray(counts)

def unstructured(
const int dim,
const double[:,:] f,
const double[:] bin_edges,
const double[:,:] pos,
str estimator_type='m',
str distance_type='e',
):
cdef int dim = pos.shape[0]
cdef _dist_func distance

if distance_type == 'e':
Expand Down
31 changes: 21 additions & 10 deletions gstools/variogram/variogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
vario_estimate
vario_estimate_axis
"""
# pylint: disable=C0412
import numpy as np

from gstools import config
from gstools.normalizer.tools import remove_trend_norm_mean
from gstools.tools.geometric import (
ang2dir,
Expand All @@ -20,12 +22,20 @@
generate_grid,
)
from gstools.variogram.binning import standard_bins
from gstools.variogram.estimator import (
directional,
ma_structured,
structured,
unstructured,
)

if config.USE_RUST: # pragma: no cover
# pylint: disable=E0401
from gstools_core import variogram_directional as directional
from gstools_core import variogram_ma_structured as ma_structured
from gstools_core import variogram_structured as structured
from gstools_core import variogram_unstructured as unstructured
else:
from gstools.variogram.estimator import (
directional,
ma_structured,
structured,
unstructured,
)

__all__ = [
"vario_estimate",
Expand Down Expand Up @@ -59,7 +69,8 @@ def _separate_dirs_test(direction, angles_tol):
for j in range(i + 1, direction.shape[0]):
s_prod = np.minimum(np.abs(np.dot(direction[i], direction[j])), 1)
separate_dirs &= np.arccos(s_prod) >= 2 * angles_tol
return separate_dirs
# gstools-core doesn't like the type `numpy.bool_`
return bool(separate_dirs)


def vario_estimate(
Expand Down Expand Up @@ -341,7 +352,6 @@ def vario_estimate(
# "h"aversine or "e"uclidean distance type
distance_type = "h" if latlon else "e"
estimates, counts = unstructured(
dim,
field,
bin_edges,
pos,
Expand All @@ -350,7 +360,6 @@ def vario_estimate(
)
else:
estimates, counts = directional(
dim,
field,
bin_edges,
pos,
Expand Down Expand Up @@ -441,7 +450,9 @@ def vario_estimate_axis(
field = np.ma.array(field, ndmin=1, dtype=np.double)
if missing:
field.mask = np.logical_or(field.mask, missing_mask)
mask = np.asarray(np.ma.getmaskarray(field), dtype=np.int32)
mask = np.ma.getmaskarray(field)
if not config.USE_RUST:
mask = np.asarray(mask, dtype=np.int32)
else:
field = np.array(field, ndmin=1, dtype=np.double, copy=False)
missing_mask = None # free space
Expand Down
Loading