Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
78 changes: 56 additions & 22 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,70 @@ name: Testing

on:
push:
branches:
- '*'
branches: ['*']
pull_request:
branches:
- '*'
branches: ['*']

jobs:
setup-build:
name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }}, ${{ matrix.test-file }})
name: Ex1 (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.10"]
test-file: ["tests/test_dcip.py", "tests/test_em.py", "tests/test_gpr.py tests/test_seismic.py", "tests/test_inversion.py", "tests/test_gravity.py tests/test_mag.py"]
test-file: [
"tests/test_dcip.py",
"tests/test_em.py",
"tests/test_gpr.py tests/test_seismic.py",
"tests/test_inversion.py",
"tests/test_gravity.py tests/test_mag.py"
]

steps:
- uses: actions/checkout@v2
- uses: mamba-org/setup-micromamba@v1
with:
environment-file: environment-dev.yml
init-shell: >-
bash
powershell
create-args: >-
python=${{ matrix.python-version }}
cache-environment: true
post-cleanup: 'all'
- name: Run Tests
shell: micromamba-shell {0}
run: |
pip install -e . --no-deps
pytest ${{ matrix.test-file }} -v
- uses: actions/checkout@v4

# Use Miniforge3 (not "latest" to avoid 404s) + mamba, strict conda-forge
- name: Setup Conda (Miniforge3 + mamba)
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
miniforge-version: "24.11.0-0" # pin to avoid 'latest' asset 404s
python-version: ${{ matrix.python-version }}
activate-environment: geosci-labs-dev
environment-file: environment-dev.yml
use-mamba: true
auto-update-conda: false
auto-activate-base: false
channels: conda-forge
channel-priority: strict
condarc: |
channels:
- conda-forge
channel_priority: strict

- name: Show environment info
run: |
conda info
conda list

- name: Install geosci-labs
run: |
pip install -e .

- name: Install test dependencies (pytest + testipynb)
run: |
n=0
until [ $n -ge 3 ]; do
mamba install -y pytest && pip install -U testipynb && break
n=$((n+1))
echo "Retry $n/3 after transient fetch error..."
sleep 10
done

- name: Run tests
run: pytest -v ${{ matrix.test_file }}
2 changes: 1 addition & 1 deletion environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies:
- pip
- pymatsolver
- requests
- SimPEG==0.23.0
- simpeg
- pytest
- flake8
- black
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ dependencies:
- pymatsolver
- python=3.10
- requests
- SimPEG
- simpeg
- pip:
- git+https://github.com/geoscixyz/geosci-labs
5 changes: 3 additions & 2 deletions geoscilabs/dcip/DCLayers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from matplotlib import rcParams

from discretize import TensorMesh
from discretize.utils import closest_points_index

from simpeg import maps, utils
from simpeg.utils.solver_utils import get_default_solver
Expand Down Expand Up @@ -161,8 +162,8 @@ def solve_2D_potentials(rho1, rho2, h, A, B):
sigma[mesh.gridCC[:, 1] >= -h] = 1.0 / rho1 # since the model is 2D

q = np.zeros(mesh.nC)
a = utils.closestPoints(mesh, A[:2])
b = utils.closestPoints(mesh, B[:2])
a = closest_points_index(mesh, A[:2])
b = closest_points_index(mesh, B[:2])

q[a] = 1.0 / mesh.cell_volumes[a]
q[b] = -1.0 / mesh.cell_volumes[b]
Expand Down
Loading