Skip to content

Commit

Permalink
Merge pull request #227 from GeoStat-Framework/meshio5.1_fix
Browse files Browse the repository at this point in the history
Field: make Field.mesh compatible with meshio v5.1+
  • Loading branch information
MuellerSeb authored Jan 15, 2022
2 parents d8941c2 + 73c0de7 commit 60a601d
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
fetch-depth: '0'

- name: Build wheels
uses: pypa/cibuildwheel@v2.2.2
uses: pypa/cibuildwheel@v2.3.1
env:
CIBW_ARCHS: ${{ matrix.cfg.arch }}
with:
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to **GSTools** will be documented in this file.


## [1.3.5] - Pure Pink - ?

### Bugfixes
- `Field.mesh` was not compatible with [meshio](https://github.com/nschloe/meshio) v5.1+ [#227](https://github.com/GeoStat-Framework/GSTools/pull/227)


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

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


[Unreleased]: https://github.com/GeoStat-Framework/gstools/compare/v1.3.4...HEAD
[1.3.5]: 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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,10 +338,10 @@ in memory for immediate 3D plotting in Python.

- [NumPy >= 1.14.5](https://www.numpy.org)
- [SciPy >= 1.1.0](https://www.scipy.org/scipylib)
- [hankel >= 1.0.2](https://github.com/steven-murray/hankel)
- [hankel >= 1.0.0](https://github.com/steven-murray/hankel)
- [emcee >= 3.0.0](https://github.com/dfm/emcee)
- [pyevtk >= 1.1.1](https://github.com/pyscience-projects/pyevtk)
- [meshio>=4.0.3, <5.0](https://github.com/nschloe/meshio)
- [meshio >= 4.0.0](https://github.com/nschloe/meshio)

### Optional

Expand Down
4 changes: 2 additions & 2 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,10 @@ Requirements

- `Numpy >= 1.14.5 <http://www.numpy.org>`_
- `SciPy >= 1.1.0 <http://www.scipy.org>`_
- `hankel >= 1.0.2 <https://github.com/steven-murray/hankel>`_
- `hankel >= 1.0.0 <https://github.com/steven-murray/hankel>`_
- `emcee >= 3.0.0 <https://github.com/dfm/emcee>`_
- `pyevtk >= 1.1.1 <https://github.com/pyscience-projects/pyevtk>`_
- `meshio>=4.0.3, <5.0 <https://github.com/nschloe/meshio>`_
- `meshio >= 4.0.0 <https://github.com/nschloe/meshio>`_


Optional
Expand Down
9 changes: 3 additions & 6 deletions examples/03_variogram/01_find_best_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@
###############################################################################
# Create a ranking based on the score and determine the best models

ranking = [
(k, v)
for k, v in sorted(scores.items(), key=lambda item: item[1], reverse=True)
]
print("RANKING")
ranking = sorted(scores.items(), key=lambda item: item[1], reverse=True)
print("RANKING by Pseudo-r2 score")
for i, (model, score) in enumerate(ranking, 1):
print(i, model, score)
print(f"{i:>6}. {model:>15}: {score:.5}")

plt.show()
4 changes: 2 additions & 2 deletions examples/04_vector_field/01_3d_vector_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

###############################################################################
# create a uniform grid with PyVista
dim, spacing, origin = (40, 30, 10), (1, 1, 1), (-10, 0, 0)
mesh = pv.UniformGrid(dim, spacing, origin)
dims, spacing, origin = (40, 30, 10), (1, 1, 1), (-10, 0, 0)
mesh = pv.UniformGrid(dims=dims, spacing=spacing, origin=origin)

###############################################################################
# create an incompressible random 3d velocity field on the given mesh
Expand Down
6 changes: 5 additions & 1 deletion gstools/field/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
__all__ = ["fmt_mean_norm_trend", "to_vtk_helper", "generate_on_mesh"]


MESHIO_VERSION = list(map(int, meshio.__version__.split(".")[:2]))


def _fmt_func_val(f_cls, func_val): # pragma: no cover
if func_val is None:
return str(None)
Expand Down Expand Up @@ -190,7 +193,8 @@ def generate_on_mesh(
raise ValueError("Field.mesh: mesh dimension too low!")
pnts = np.empty((0, mesh_dim), dtype=np.double)
for cell in mesh.cells:
pnt = np.mean(mesh.points[cell[1]], axis=1)
cell_points = cell[1] if MESHIO_VERSION < [5, 1] else cell.data
pnt = np.mean(mesh.points[cell_points], axis=1)
offset.append(pnts.shape[0])
length.append(pnt.shape[0])
pnts = np.vstack((pnts, pnt))
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ test-command = "pytest -v {package}/tests"
test-skip = "*-macosx_arm64 *-macosx_universal2:arm64"

[[tool.cibuildwheel.overrides]]
# use manylinux2014 for py3.10
select = "cp310-*"
manylinux-x86_64-image = "manylinux2014"
select = "*manylinux_i686"
# no wheels for 32 bit anymore
before-test = "pip install 'numpy<1.22'"
12 changes: 6 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ project_urls =
[options]
packages = find:
install_requires =
emcee>=3.0.0,<4
hankel>=1.0.2,<2
meshio>=4.0.3,<6
numpy>=1.14.5,<2
pyevtk>=1.1.1,<2
scipy>=1.1.0,<2
emcee>=3.0.0
hankel>=1.0.0
meshio>=4.0.0
numpy>=1.14.5
pyevtk>=1.1.1
scipy>=1.1.0
python_requires = >=3.6
zip_safe = False

Expand Down

0 comments on commit 60a601d

Please sign in to comment.