Skip to content

Commit 662d1cb

Browse files
committed
Merge branch 'main' into face_props_mass_matrices
2 parents 6e02972 + d08dd68 commit 662d1cb

23 files changed

+566
-147
lines changed

.ci/azure/run_tests.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,19 @@ test_args=""
1010

1111
source activate discretize-test
1212

13-
if ${do_doc}
14-
then
15-
if ${is_azure}
16-
then
13+
if [[ "$is_azure" == "true" ]]; then
14+
if [[ "$do_doc" == "true" ]]; then
1715
.ci/setup_headless_display.sh
1816
fi
1917
fi
20-
if ${do_cov}
21-
then
18+
if [[ "do_cov" == "true" ]]; then
2219
echo "Testing with coverage"
2320
test_args="--cov --cov-config=pyproject.toml $test_args"
2421
fi
2522

2623
pytest -vv $test_args
2724

28-
if ${do_cov}
29-
then
25+
if [[ "do_cov" == "true" ]]; then
3026
coverage xml
3127
fi
3228

.ci/azure/setup_env.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,31 @@ set -ex #echo on and exit if any line fails
44
# TF_BUILD is set to True on azure pipelines.
55
is_azure=$(echo "${TF_BUILD:-false}" | tr '[:upper:]' '[:lower:]')
66
do_doc=$(echo "${DOC_BUILD:-false}" | tr '[:upper:]' '[:lower:]')
7+
is_free_threaded=$(echo "${PYTHON_FREETHREADING:-false}" | tr '[:upper:]' '[:lower:]')
8+
is_rc=$(echo "${PYTHON_RELEASE_CANDIDATE:-false}" | tr '[:upper:]' '[:lower:]')
9+
is_bare=$(echo "${ENVIRON_BARE:-false}" | tr '[:upper:]' '[:lower:]')
710

8-
if ${is_azure}
9-
then
10-
if ${do_doc}
11-
then
11+
if [[ "$is_azure" == "true" ]]; then
12+
if [[ "$do_doc" == "true" ]]; then
1213
.ci/setup_headless_display.sh
1314
fi
1415
fi
1516

16-
cp .ci/environment_test.yml environment_test_with_pyversion.yml
17-
echo " - python="$PYTHON_VERSION >> environment_test_with_pyversion.yml
17+
if [[ "$is_free_threaded" == "true" || "$is_bare" == "true" ]]; then
18+
cp .ci/environment_test_bare.yml environment_test_with_pyversion.yml
19+
echo " - python-freethreading="$PYTHON_VERSION >> environment_test_with_pyversion.yml
20+
else
21+
cp .ci/environment_test.yml environment_test_with_pyversion.yml
22+
echo " - python="$PYTHON_VERSION >> environment_test_with_pyversion.yml
23+
fi
1824

25+
if [[ "$is_rc" == "true" ]]; then
26+
sed -i '/^channels:/a\ - conda-forge/label/python_rc' environment_test_with_pyversion.yml
27+
fi
1928
conda env create --file environment_test_with_pyversion.yml
2029
rm environment_test_with_pyversion.yml
2130

22-
if ${is_azure}
23-
then
31+
if [[ "$is_azure" == "true" ]]; then
2432
source activate discretize-test
2533
pip install pytest-azurepipelines
2634
else

.ci/azure/test.yml

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@ jobs:
22
- job:
33
strategy:
44
matrix:
5-
linux-Python310:
6-
image: ubuntu-latest
7-
python.version: '3.10'
8-
coverage: True
95
linux-Python311:
106
image: ubuntu-latest
117
python.version: '3.11'
8+
coverage: True
129
linux-Python312:
1310
image: ubuntu-latest
1411
python.version: '3.12'
1512
linux-Python313:
1613
image: ubuntu-latest
1714
python.version: '3.13'
18-
osx-Python310:
19-
image: macOS-latest
20-
python.version: '3.10'
15+
linux-Python313t:
16+
image: ubuntu-latest
17+
python.version: '3.13'
18+
environ.bare: True
19+
python.freethreading: True
20+
coverage: True
21+
linux-Python314:
22+
image: ubuntu-latest
23+
environ.bare: True
24+
python.version: '3.14'
25+
linux-Python314t:
26+
image: ubuntu-latest
27+
python.version: '3.14'
28+
environ.bare: True
29+
python.freethreading: True
2130
osx-Python311:
2231
image: macOS-latest
2332
python.version: '3.11'
@@ -27,9 +36,19 @@ jobs:
2736
osx-Python313:
2837
image: macOS-latest
2938
python.version: '3.13'
30-
win-Python310:
31-
image: windows-latest
32-
python.version: '3.10'
39+
osx-Python313t:
40+
image: macOS-latest
41+
python.version: '3.13'
42+
python.freethreading: True
43+
osx-Python314:
44+
image: macOS-latest
45+
python.version: '3.14'
46+
environ.bare: True
47+
osx-Python314t:
48+
image: macOS-latest
49+
python.version: '3.14'
50+
environ.bare: True
51+
python.freethreading: True
3352
win-Python311:
3453
image: windows-latest
3554
python.version: '3.11'
@@ -39,6 +58,20 @@ jobs:
3958
win-Python313:
4059
image: windows-latest
4160
python.version: '3.13'
61+
win-Python313t:
62+
image: windows-latest
63+
python.version: '3.13'
64+
environ.bare: True
65+
python.freethreading: True
66+
win-Python314:
67+
image: windows-latest
68+
environ.bare: True
69+
python.version: '3.14'
70+
win-Python314t:
71+
image: windows-latest
72+
python.version: '3.14'
73+
environ.bare: True
74+
python.freethreading: True
4275
displayName: "${{ variables.image }} ${{ variables.python.version }}"
4376
pool:
4477
vmImage: $(image)

.ci/environment_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ dependencies:
3131
- meson-python>=0.14.0
3232
- meson
3333
- ninja
34-
- cython>=0.29.35
34+
- cython>=3.1.0
3535
- setuptools_scm

.ci/environment_test_bare.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: discretize-test
2+
channels:
3+
- conda-forge
4+
dependencies:
5+
- numpy>=1.22.4
6+
- scipy>=1.12
7+
8+
# testing
9+
- sympy
10+
- pytest
11+
- pytest-cov
12+
13+
# Building
14+
- pip
15+
- meson-python>=0.14.0
16+
- meson
17+
- ninja
18+
- cython>=3.1.0
19+
- setuptools_scm

.github/workflows/build_distributions.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
# macos-13 is an intel runner, macos-14 is apple silicon
12-
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
11+
# macos-15-intel is an Intel runner, macos-14 is Apple silicon
12+
os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, windows-11-arm, macos-15-intel, macos-14]
1313

1414
steps:
15-
- uses: actions/checkout@v4
16-
with:
17-
fetch-depth: 0
15+
- uses: actions/checkout@v5
1816

1917
- name: Build wheels
20-
uses: pypa/cibuildwheel@v2.21.3
18+
uses: pypa/cibuildwheel@v3.2.0
2119

2220
- uses: actions/upload-artifact@v4
2321
with:

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ Code:
114114
https://github.com/simpeg/discretize
115115

116116
Tests:
117-
https://travis-ci.org/simpeg/discretize
117+
https://dev.azure.com/simpeg/discretize/_build
118118

119119
Bugs & Issues:
120120
https://github.com/simpeg/discretize/issues

discretize/_extensions/interputils_cython.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# cython: embedsignature=True, language_level=3
22
# cython: linetrace=True
3+
# cython: freethreading_compatible = True
34
import numpy as np
45
import cython
56
cimport numpy as np

discretize/_extensions/simplex_helpers.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# distutils: language=c++
22
# cython: embedsignature=True, language_level=3
33
# cython: linetrace=True
4+
# cython: freethreading_compatible = True
45

56
from libcpp.pair cimport pair
67
from libcpp.unordered_map cimport unordered_map

discretize/_extensions/tree.cpp

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,44 @@ void Cell::refine_func(node_map_t& nodes, function test_func, double *xs, double
418418
}
419419
}
420420

421+
void Cell::refine_image(node_map_t& nodes, double* image, int_t *shape_cells, double *xs, double*ys, double *zs, bool diag_balance){
422+
// early exit if my level is higher than or equal to target
423+
if (level == max_level){
424+
return;
425+
}
426+
int_t start_ix = points[0]->location_ind[0]/2;
427+
int_t start_iy = points[0]->location_ind[1]/2;
428+
int_t start_iz = n_dim == 2 ? 0 : points[0]->location_ind[2]/2;
429+
int_t end_ix = points[3]->location_ind[0]/2;
430+
int_t end_iy = points[3]->location_ind[1]/2;
431+
int_t end_iz = n_dim == 2? 1 : points[7]->location_ind[2]/2;
432+
int_t nx = shape_cells[0];
433+
int_t ny = shape_cells[1];
434+
int_t nz = shape_cells[2];
435+
436+
int_t i_image = (nx * ny) * start_iz + nx * start_iy + start_ix;
437+
double val_start = image[i_image];
438+
bool all_unique = true;
439+
440+
// if any of the image data contained in the cell are different, subdivide myself
441+
for(int_t iz=start_iz; iz<end_iz && all_unique; ++iz)
442+
for(int_t iy=start_iy; iy<end_iy && all_unique; ++iy)
443+
for(int_t ix=start_ix; ix<end_ix && all_unique; ++ix){
444+
i_image = (nx * ny) * iz + nx * iy + ix;
445+
all_unique = image[i_image] == val_start;
446+
}
447+
448+
if(!all_unique){
449+
if(is_leaf()){
450+
divide(nodes, xs, ys, zs, true, diag_balance);
451+
}
452+
// recurse into children
453+
for(int_t i = 0; i < (1<<n_dim); ++i){
454+
children[i]->refine_image(nodes, image, shape_cells, xs, ys, zs, diag_balance);
455+
}
456+
}
457+
}
458+
421459
void Cell::divide(node_map_t& nodes, double* xs, double* ys, double* zs, bool balance, bool diag_balance){
422460
// Gaurd against dividing a cell that is already at the max level
423461
if (level == max_level){
@@ -896,6 +934,18 @@ void Tree::refine_function(function test_func, bool diagonal_balance){
896934
roots[iz][iy][ix]->refine_func(nodes, test_func, xs, ys, zs, diagonal_balance);
897935
};
898936

937+
void Tree::refine_image(double *image, bool diagonal_balance){
938+
int_t shape_cells[3];
939+
shape_cells[0] = nx/2;
940+
shape_cells[1] = ny/2;
941+
shape_cells[2] = nz/2;
942+
for(int_t iz=0; iz<nz_roots; ++iz)
943+
for(int_t iy=0; iy<ny_roots; ++iy)
944+
for(int_t ix=0; ix<nx_roots; ++ix)
945+
roots[iz][iy][ix]->refine_image(nodes, image, shape_cells, xs, ys, zs, diagonal_balance);
946+
}
947+
948+
899949
void Tree::finalize_lists(){
900950
for(int_t iz=0; iz<nz_roots; ++iz)
901951
for(int_t iy=0; iy<ny_roots; ++iy)

0 commit comments

Comments
 (0)