Skip to content
This repository has been archived by the owner on Nov 13, 2023. It is now read-only.

Commit

Permalink
support for python 3.9 (#202)
Browse files Browse the repository at this point in the history
* support for python 3.9

Co-authored-by: Keith Roberts <krober@usp.edu>
  • Loading branch information
Keith Roberts and Keith Roberts authored Mar 9, 2021
1 parent 2a6d4ce commit cabf0ac
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 39 deletions.
26 changes: 23 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ jobs:
- run: pip install -U black flake8 --user
- run: black --check .
- run: flake8 .
build_3.9.0:
docker:
- image: circleci/python:3.9.0
steps:
- checkout
- run: python --version
- run: pip --version
- run: sudo apt install -y libopenmpi3 libopenmpi-dev openmpi-bin
- run: sudo apt-get update && sudo apt install -y cmake
- run: sudo apt-get install libboost-all-dev
- run: sudo apt-get install libmpfr-dev
- run: git clone https://github.com/CGAL/cgal.git && cd cgal/ && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && sudo make install
- run: sudo apt install -y libhdf5-dev
- run: sudo apt install -y python-pybind11
- run: pip install .[io] --user
- run:
pip install tox --user && tox -e py39
- run: bash <(curl -s https://codecov.io/bash)

build_3.8.1:
docker:
- image: circleci/python:3.8.1
Expand All @@ -23,7 +42,7 @@ jobs:
- run: git clone https://github.com/CGAL/cgal.git && cd cgal/ && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && sudo make install
- run: sudo apt install -y libhdf5-dev
- run: sudo apt install -y python-pybind11
- run: pip install . --user
- run: pip install .[io] --user
- run:
pip install tox --user && pip uninstall -y virtualenv && tox -e py38
- run: bash <(curl -s https://codecov.io/bash)
Expand All @@ -41,7 +60,7 @@ jobs:
- run: git clone https://github.com/CGAL/cgal.git && cd cgal/ && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && sudo make install
- run: sudo apt install -y libhdf5-dev
- run: sudo apt install -y python-pybind11
- run: pip install . --user
- run: pip install .[io] --user
- run:
pip install tox --user && tox -e py37
- run: bash <(curl -s https://codecov.io/bash)
Expand All @@ -59,7 +78,7 @@ jobs:
- run: git clone https://github.com/CGAL/cgal.git && cd cgal/ && git checkout 6f8f790 && mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release .. && sudo make install
- run: sudo apt install -y libhdf5-dev
- run: pip install pytest --user && git clone https://github.com/pybind/pybind11.git && cd pybind11 && mkdir build && cd build && cmake .. && sudo make install
- run: pip install . --user
- run: pip install .[io] --user
- run:
pip install tox --user && /home/circleci/.local/bin/tox -e py36
- run: bash <(curl -s https://codecov.io/bash)
Expand All @@ -72,3 +91,4 @@ workflows:
- build_3.6.5
- build_3.7.4
- build_3.8.1
- build_3.9.0
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ Table of contents
Installation
============

**Nov. 21, 2020 our software is not yet compatible with Python 3.9 because of the `segyio` package dependency which doesn't build yet with this version of Python. Until this is fixed, please use a Python version prior to 3.9 to run your scripts with this package.**


For installation, SeismicMesh needs [CGAL](https://www.cgal.org/) and
[pybind11](https://github.com/pybind/pybind11):

Expand All @@ -68,7 +65,7 @@ For installation, SeismicMesh needs [CGAL](https://www.cgal.org/) and
After that, SeismicMesh can be installed from the Python Package Index
([pypi](https://pypi.org/project/SeismicMesh/)), so with:

pip install -U SeismicMesh
pip install -U SeismicMesh[io]

For more detailed information about installation and requirements see:

Expand Down Expand Up @@ -827,6 +824,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rotations for all geometric primitives
- Stretching for all geometric primitives
- Visuzlization of signed distance functions
### Fixed
- Support for Python 3.9

## [3.4.0]-2021-02-14
### Added
Expand Down
14 changes: 10 additions & 4 deletions SeismicMesh/sizing/mesh_size_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import h5py
import matplotlib.pyplot as plt
import numpy as np
import segyio
from mpi4py import MPI
from scipy import ndimage
from scipy.interpolate import RegularGridInterpolator
Expand All @@ -26,6 +25,7 @@

from .cpp import limgrad


__all__ = [
"get_sizing_function_from_segy",
"write_velocity_model",
Expand All @@ -51,7 +51,7 @@ def get_sizing_function_from_segy(filename, bbox, comm=None, **kwargs):
* *hmax* (``float``) --
Maximum edge length in the domain (default==10,000 m)
* *wl* (``int``) --
Number of vertices per wavelength for a given 𝑓𝑚𝑎𝑥 (default==0 vertices)
Number of cells per wavelength for a given 𝑓𝑚𝑎𝑥 (default==0 cells)
* *freq* (``float``) --
𝑓𝑚𝑎𝑥 in hertz for which to estimate `wl` (default==2 Hertz)
* *grad* (``float``) --
Expand Down Expand Up @@ -406,7 +406,8 @@ def _gradient_sizing(vp, grad, stencil_size):
win_var = win_sqr_mean - win_mean ** 2

# normalize variance to [0,1]
win_var /= np.amax(win_var)
win_var = np.divide(win_var, np.amax(win_var))
# win_var /= np.amax(win_var)
win_var -= np.amin(win_var)
return grad / (win_var + 0.10)

Expand Down Expand Up @@ -587,11 +588,16 @@ def _read_bin(filename, nz, nx, ny, byte_order, axes_order, axes_order_sort, dty
else:
raise ValueError("Please specify byte_order as either: little or big.")
vp = vp.reshape(*axes, order=axes_order_sort)
return np.flipud(vp.transpose((*axes_order))), nz, nx, ny # z, x and then y

vp = np.flipud(vp.transpose((*axes_order,)))

return vp, nz, nx, ny # z, x and then y


def _read_segy(filename):
"""Read a velocity model from a SEG-y file"""
import segyio

with segyio.open(filename, ignore_geometry=True) as f:
nz, nx = len(f.samples), len(f.trace)
vp = np.zeros(shape=(nz, nx))
Expand Down
11 changes: 8 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = SeismicMesh
version = 3.4.0
version = 3.5.0
url = https://github.com/krober10nd/SeismicMesh
author = Keith Roberts
email = keithrbt0@gmail.com
Expand All @@ -24,7 +24,7 @@ classifiers =
Topic :: Scientific/Engineering :: Visualization
[options]
packages = find:
setup_requires = pybind11 >= 2.2
setup_requires = pybind11 >= 2.5
install_requires =
numpy
segyio
Expand All @@ -33,6 +33,11 @@ install_requires =
h5py
matplotlib
mpi4py
pybind11 >= 2.2
pybind11 >= 2.5
pyamg
python_requires = >=3.0

[options.extras_require]
benchmarking = meshplex; pygalmesh; pygmsh; meshio; termplotlib
io = segyio
all = segyio; meshplex; pygalmesh; pygmsh; meshio; termplotlib
24 changes: 0 additions & 24 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,6 @@
except ImportError:
print("Setuptools is required to build!")

if sys.version_info < (3, 0):
print("Python 3.0 or higher required, please upgrade.")
sys.exit(1)

if sys.version_info >= (3, 9, 0):
print(
"Python 3.9.0 or higher is not yet supported, please use an older Python version."
)
sys.exit(1)


benchmarking = [
"meshplex == 0.13.3",
"pygalmesh == 0.8.2",
"pygmsh == 7.0.0",
"termplotlib == 0.3.2",
"meshio == 4.2.2",
"termplotlib == 0.3.2",
]


class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Expand Down Expand Up @@ -104,8 +84,4 @@ def build_extension(self, ext):
CMakeExtension("SeismicMesh/geometry/cpp/fast_geometry"),
],
cmdclass=dict(build_ext=CMakeBuild),
extras_require={
"benchmarking": benchmarking,
},
python_requires=">=3.0",
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py36, py37, py38
envlist = py36, py37, py38, py39
isolated_build = True

[mpi]
Expand Down

0 comments on commit cabf0ac

Please sign in to comment.