Skip to content

Removing cython dependency #168

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

Merged
merged 85 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
b9f9a4a
fix: adding json exports
lachlangrose Aug 21, 2023
9959756
fix: moving and renaming conversion functions
lachlangrose Dec 5, 2023
9beb25f
tests: adding tests for conversions
lachlangrose Dec 5, 2023
d82967a
fix: remove process_map2loop
lachlangrose Dec 12, 2023
0b7a2f4
fix: adding synthetic horizontal layers model
lachlangrose Dec 18, 2023
74f8a0f
fix: adding corners property to bounding box
lachlangrose Dec 18, 2023
d08375b
fix: substituting pli for p1
lachlangrose Dec 18, 2023
f807673
tests: test that horizontal layers are working
lachlangrose Dec 18, 2023
2596b30
fix: making structured tetra compatible with p1 interp
lachlangrose Dec 19, 2023
b78788d
fix: making p1 interpolator work
lachlangrose Dec 19, 2023
66aa851
fix: cast input to np array
lachlangrose Dec 19, 2023
33977b8
fix: adding type enums
lachlangrose Dec 19, 2023
7a92a8e
fix: adding sparse matrix neighbour calculator
lachlangrose Dec 19, 2023
a83e172
fix: adding some type hints
lachlangrose Dec 19, 2023
99f60d2
refactor: :heavy_minus_sign: removing model builder
lachlangrose Dec 19, 2023
0682765
fix: :sparkles: adding ability to calculate normalised value of a fea…
lachlangrose Dec 19, 2023
ba5aafc
fix: adding map for interpolator to support type
lachlangrose Jan 2, 2024
1f6de99
fix: enabling support builder with interpolator factory
lachlangrose Jan 2, 2024
c5b0270
fix: updating imports for maths functions
lachlangrose Jan 2, 2024
1bf0094
fix: adding support creator from bbox
lachlangrose Jan 2, 2024
583e167
fix: when reset clear the constraints dictionary
lachlangrose Jan 4, 2024
c973893
fix: reset when setting up interpolator
lachlangrose Jan 4, 2024
930cc3c
fix: removing old pli interpolator
lachlangrose Jan 4, 2024
f02ffd6
fix: fixing tetra indexing and masks
lachlangrose Jan 4, 2024
e4a2fac
fix: removing unused imports
lachlangrose Jan 4, 2024
c260d9f
fix: speeding up element getter
lachlangrose Jan 5, 2024
246db92
fix: adding onGeometryChange function for supports
lachlangrose Jan 5, 2024
13df0bf
fix: reset change number of constraints
lachlangrose Jan 5, 2024
37d2a34
fix: adding gradient orthogonal to p1interpolator
lachlangrose Jan 5, 2024
43d9825
fix: changing instrusion example to rescale points
lachlangrose Jan 5, 2024
75b2d6c
fix: setting model tolerance using new bounding box
lachlangrose Jan 8, 2024
193e0d4
fix: updating fold to use p1 interpolator
lachlangrose Jan 8, 2024
c084724
fix: renaming variables
lachlangrose Jan 8, 2024
7d4dc94
fix: adding name and vector args to min edge jumps
lachlangrose Jan 8, 2024
fccf1b7
fix: removing old imports
lachlangrose Jan 8, 2024
c8b5581
fix: fixing orthogonal constraints for p1
lachlangrose Jan 8, 2024
a7c30f0
fix: moving fault setup into fault builder frm model
lachlangrose Jan 8, 2024
9c1b4d1
fix: flake8 error
lachlangrose Jan 8, 2024
f86f50e
fix: add bb origin to surfaces
lachlangrose Jan 10, 2024
e575782
fix: fold constraints added in setup interpolator
lachlangrose Jan 10, 2024
d7e1272
fix: temp fix for issue with np types
lachlangrose Jan 10, 2024
cb1bd64
Replace reqs with correct theme
samjroberts Jan 12, 2024
86fd6bd
Adding PyPI custom link to navigation
samjroberts Jan 12, 2024
4c7064f
Replacing square icon with (nicer) round icon
samjroberts Jan 12, 2024
2579cd5
Adding navbar options and metadata
samjroberts Jan 12, 2024
dcb1d79
Fixing svg img
samjroberts Jan 12, 2024
706d1c5
Updating the contributors docs
samjroberts Jan 14, 2024
a9959df
removing accidental tab
samjroberts Jan 14, 2024
1dba5d2
Merge branch 'json' into dev-december-23
lachlangrose Jan 15, 2024
0aa7159
docs: fixing missing automodule
lachlangrose Jan 15, 2024
1658714
fix: adding length to bbox
lachlangrose Jan 15, 2024
f305211
fix: removing dof and name from interpolator json
lachlangrose Jan 15, 2024
24fb90a
docs: adding explicit imports for submodules
lachlangrose Jan 15, 2024
35d2195
docs: adding citations to documentation
lachlangrose Jan 15, 2024
611dae4
Merge branch 'dev-december-23' into fix/update-docs-navigation
lachlangrose Jan 15, 2024
8394c60
fix: removing reference to dtm creator and using get interpolator cor…
lachlangrose Jan 16, 2024
2e43a53
fix: face table resize when geometry reset
lachlangrose Jan 17, 2024
0737646
fix: elements property for base structured support
lachlangrose Jan 17, 2024
6af400a
fix: adding imports to api
lachlangrose Jan 17, 2024
0460c69
fix: changing from interpolator type string to enum
lachlangrose Jan 17, 2024
b2dc446
fix: removing cython
lachlangrose Jan 17, 2024
3db72dd
fix: only axial foliation is constrained by fold frame
lachlangrose Jan 18, 2024
f3f046a
Update release-please.yml
lachlangrose Jan 18, 2024
e480b68
Update release-please.yml
lachlangrose Jan 18, 2024
9425c9a
Update release-please.yml
lachlangrose Jan 18, 2024
512ad68
ci: updating to use pip wheel .
lachlangrose Jan 18, 2024
d2a534b
Update release-please.yml
lachlangrose Jan 18, 2024
389fac2
fix: disable progress bar for model update
lachlangrose Jan 18, 2024
1cc621b
Merge branch 'dev-december-23' of https://github.com/loop3d/LoopStruc…
lachlangrose Jan 18, 2024
93a01f0
Merge pull request #166 from sroberts88962/fix/update-docs-navigation
lachlangrose Jan 18, 2024
da08566
ci: remove numpy version for conda
lachlangrose Jan 18, 2024
5d3933b
fix: changing to interpolator factory
lachlangrose Jan 24, 2024
eda7c35
fix: identify points that fall on face of shared tetras. Automaticall…
lachlangrose Jan 24, 2024
640b704
fix: rename surface vtk property to vtk from pyvista
lachlangrose Jan 24, 2024
efec2ca
fix: add docstring and cast isinside to an array
lachlangrose Jan 24, 2024
160f6f8
docs: adding docs to surface datatype
lachlangrose Jan 24, 2024
d531287
fix: removing cython code
lachlangrose Jan 24, 2024
0d6aff2
fix: removing model api for time being
lachlangrose Jan 24, 2024
23add38
build: adding conda builds to git ignore
lachlangrose Jan 24, 2024
15ac42e
typo
lachlangrose Jan 24, 2024
da77dbd
ci: using conda convert to create osx
lachlangrose Jan 24, 2024
252dab4
ci: removing cython
lachlangrose Jan 24, 2024
ddd1d1d
ci: typo in yml
lachlangrose Jan 24, 2024
b1e5df8
ci: again
lachlangrose Jan 24, 2024
f9b1c23
ci: again
lachlangrose Jan 24, 2024
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
125 changes: 52 additions & 73 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ on:
name: release-please
jobs:
continuous-integration:
name: Continuous integration ${{ matrix.os }} python ${{ matrix.python-version }}
name: Continuous integration ${{ matrix.os }} python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"] #"macos-latest",
python-version: ["3.8","3.9","3.10"]
os: ${{ fromJSON(vars.BUILD_OS)}}
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS)}}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python }}
python-version: ${{ matrix.python }}
- name: Installing dependencies
shell: bash -l {0}
run: |
conda install -c conda-forge cython numpy scipy scikit-image scikit-learn pyamg flake8 pytest networkx osqp matplotlib -y
- name: Checking formatting of code
shell: bash -l {0}
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 LoopStructural --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 LoopStructural --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Building and install
# stop the build if there are Python syntax errors or undefined names
flake8 LoopStructural --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 LoopStructural --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Building and install
shell: bash -l {0}
run: |
python setup.py install build_ext --inplace
Expand Down Expand Up @@ -78,109 +78,88 @@ jobs:
with:
branch: gh-pages # The branch the action should deploy to.
folder: docs/build/html # The folder the action should deploy.

conda-deploy:
name: Uploading to Loop3d for python ${{ matrix.os }})
needs: ["documentation-test", "continuous-integration"]
runs-on: ${{ matrix.os }}
runs-on: ${{matrix.os}}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: ["3.10","3.9","3.8"]
os: ["ubuntu-latest"]
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS)}}
steps:
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}

- uses: actions/checkout@v2
- name: update submodules
# shell: bash -l {0}
# shell: bash -l {0}
run: |
git submodule update --init --recursive
- name: Add msbuild to PATH
if: matrix.os == 'windows-latest'
uses: microsoft/setup-msbuild@v1.0.2
- name: Conda build'
git submodule update --init --recursive
- name: Conda build
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
shell: bash -l {0}
run: |
conda install -c conda-forge conda-build scikit-build numpy cython anaconda-client -y
conda build -c anaconda -c conda-forge -c loop3d --output-folder conda conda --numpy 1.21
conda install anaconda-client -y
conda install -c conda-forge conda-build scikit-build numpy cython anaconda-client -y
conda build -c anaconda -c conda-forge -c loop3d --output-folder conda conda
conda convert -p all conda/linux-64/*.tar.bz2 -f -o conda
conda install anaconda-client -y
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: conda
path: conda


make_sdist:
needs: ["documentation-test", "continuous-integration"]
name: Make SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build SDist
run: |
pip install numpy cython
python setup.py sdist
- uses: actions/checkout@v3

- uses: actions/upload-artifact@v3
with:
name: dist
path: dist/*.tar.gz

build_wheels:
needs: ["documentation-test", "continuous-integration"]
name: Build wheels
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v2
- name: Build SDist
run: |
pip install numpy
python setup.py sdist
pip wheel -w wheelhouse .

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.0
env:
CIBW_ARCHS_MACOS: x86_64 universal2
CIBW_BUILD: "cp36-* cp37-* cp38-* cp39-* cp310*"
CIBW_BEFORE_BUILD: "pip install numpy cython" #make sure numpy is the same version as required by LS
- uses: actions/upload-artifact@v3
with:
name: dist
path: ./wheelhouse/*.whl

path: dist/*.tar.gz
- uses: actions/upload-artifact@v3
with:
name: dist
path: wheelhouse/*.whl

upload_to_pypi:
needs: ["release-please","build_wheels","make_sdist","conda-deploy"]
needs: ["release-please", "make_sdist", "conda-deploy"]
runs-on: ubuntu-latest
if: ${{ needs.release-please.outputs.release_created }}
steps:
- uses: actions/download-artifact@v3
with:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: actions/download-artifact@v3
with:
- uses: actions/download-artifact@v3
with:
name: conda
path: conda
- uses: pypa/gh-action-pypi-publish@v1.6.4
with:
skip_existing: true
verbose: true
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
- uses: conda-incubator/setup-miniconda@v2
- name: upload all files to conda-forge
shell: bash -l {0}
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
conda install -c anaconda anaconda-client -y
anaconda upload --label main conda/*/*.tar.bz2

- uses: pypa/gh-action-pypi-publish@v1.6.4
with:
skip_existing: true
verbose: true
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
- uses: conda-incubator/setup-miniconda@v2
- name: upload all files to conda-forge
shell: bash -l {0}
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
conda install -c anaconda anaconda-client -y
anaconda upload --label main conda/*/*.tar.bz2
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,7 @@ examples/*.png
dev/scalar_field
dev/unconf
docs/source/sg_execution_times.rst
conda/index.html
conda/channeldata.json
conda/noarch
conda/win-64
4 changes: 2 additions & 2 deletions LoopStructural/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
LoopStructural API
=======================
LoopStructural
==============

"""

Expand Down
2 changes: 2 additions & 0 deletions LoopStructural/api/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ._interpolate import LoopInterpolator
from ._surface import LoopIsosurfacer
3 changes: 2 additions & 1 deletion LoopStructural/api/_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from LoopStructural.interpolators import (
GeologicalInterpolator,
InterpolatorFactory,
InterpolatorType,
)
from LoopStructural.utils import BoundingBox
from LoopStructural.utils import getLogger
Expand All @@ -18,7 +19,7 @@ def __init__(
self,
bounding_box: BoundingBox,
dimensions: int = 3,
type: str = "FDI",
type=InterpolatorType.FINITE_DIFFERENCE,
nelements: int = 1000,
):
"""Scikitlearn like interface for LoopStructural interpolators
Expand Down
73 changes: 66 additions & 7 deletions LoopStructural/api/_surface.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Optional, Union
from typing import Optional, Union, Callable
import numpy as np
import numpy.typing as npt
from LoopStructural.utils import getLogger

logger = getLogger(__name__)
Expand All @@ -13,23 +14,81 @@
from LoopStructural.utils import BoundingBox
from LoopStructural.datatypes import Surface

surface_list = dict[str, tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]]
surface_list = dict[
str, tuple[npt.ArrayLike, npt.ArrayLike, npt.ArrayLike, npt.ArrayLike]
]


class LoopIsosurfacer:
def __init__(self, bounding_box: BoundingBox, interpolator: GeologicalInterpolator):
def __init__(
self,
bounding_box: BoundingBox,
interpolator: Optional[GeologicalInterpolator] = None,
callable: Optional[Callable[[npt.ArrayLike], npt.ArrayLike]] = None,
):
"""Extract isosurfaces from a geological interpolator or a callable function.


Parameters
----------
bounding_box : BoundingBox
_description_
interpolator : Optional[GeologicalInterpolator], optional
interpolator object, by default None
callable : Optional[Callable[[npt.ArrayLike], npt.ArrayLike]], optional
callable object, by default None

Raises
------
ValueError
_description_
ValueError
_description_
ValueError
_description_
"""
self.bounding_box = bounding_box
self.interpolator = interpolator
self.callable = callable
if interpolator is None and callable is None:
raise ValueError("Must specify either interpolator or callable")
if interpolator is not None and self.callable is not None:
raise ValueError("Must specify either interpolator or callable")

if interpolator is not None:
self.callable = interpolator.evaluate_value
if self.callable is None:
raise ValueError("Must specify either interpolator or callable")

def fit(self, values: Union[list, int, float]) -> surface_list:
"""Extract isosurfaces from the interpolator

Parameters
----------
values : Union[list, int, float]
Either a list of values to extract isosurfaces for, or a single value
to extract a single isosurface for, or an integer to extract that many
isosurfaces evenly spaced between the minimum and maximum values of the
interpolator.

Returns
-------
surface_list
a dictionary containing the extracted isosurfaces
"""
if not callable(self.callable):
raise ValueError("No interpolator of callable function set")
surfaces = {}
all_values = self.interpolator.evaluate_value(self.bounding_box.regular_grid())
all_values = self.callable(self.bounding_box.regular_grid())
if isinstance(values, list):
isovalues = values
elif isinstance(values, float):
isovalues = [values]
elif isinstance(values, int):
isovalues = np.linspace(np.min(all_values), np.max(all_values), values)
isovalues = np.linspace(
np.min(all_values) + np.finfo(float).eps,
np.max(all_values) + np.finfo(float).eps,
values,
)
for isovalue in isovalues:
verts, faces, normals, values = marching_cubes(
all_values.reshape(self.bounding_box.nsteps, order="C"),
Expand All @@ -38,7 +97,7 @@ def fit(self, values: Union[list, int, float]) -> surface_list:
)
values = np.zeros(verts.shape[0]) + isovalue
surfaces[f"surface_{isovalue}"] = Surface(
vertices=verts,
vertices=verts + self.bounding_box.origin,
triangles=faces,
normals=normals,
name=f"surface_{isovalue}",
Expand Down
6 changes: 0 additions & 6 deletions LoopStructural/api/model.py

This file was deleted.

1 change: 1 addition & 0 deletions LoopStructural/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
from ._base import load_tabular_intrusion
from ._base import load_geological_map_data
from ._base import load_fault_trace
from ._base import load_horizontal
37 changes: 37 additions & 0 deletions LoopStructural/datasets/_base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
from os.path import dirname, join
from pathlib import Path
from typing import Tuple
import numpy as np
import pandas as pd


def load_horizontal() -> Tuple[pd.DataFrame, np.ndarray]:
"""Synthetic model for horizontal layers

Returns
-------
Tuple[pd.DataFrame, np.ndarray]
dataframe with feature_name 'strati', bounding box array
"""
bb = np.array([[0, 0, 0], [10, 10, 10]])
xy = np.mgrid[0:10, 0:10].reshape(2, -1).T
data = pd.DataFrame(
np.vstack(
[
np.hstack(
[
xy,
np.zeros(xy.shape[0])[:, None] + 2,
np.zeros(xy.shape[0])[:, None] + 2,
]
),
np.hstack(
[
xy,
np.zeros(xy.shape[0])[:, None] + 3,
np.zeros(xy.shape[0])[:, None] + 3,
]
),
]
),
columns=["X", "Y", "Z", "val"],
)

data["feature_name"] = "strati"
return data, bb


def load_claudius():
"""Model dataset sampled from 3D seismic data

Expand Down
Loading