Skip to content

Commit 3589370

Browse files
committed
Merge branch 'main' into 1.0.0_alpha
2 parents ab960ed + 636e3ff commit 3589370

13 files changed

Lines changed: 164 additions & 30 deletions

File tree

.ci/azure/deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ jobs:
4949
5050
- bash: |
5151
# Update latest symlink
52-
cd discretize-docs
53-
rm -f en/latest
54-
ln -s "en/$BRANCH_NAME" en/latest
52+
cd discretize-docs/en
53+
rm -f latest
54+
ln -s "$BRANCH_NAME" latest
5555
displayName: Point Latest to tag
5656
condition: eq(variables.IS_TAG, true)
5757

.github/workflows/build_distributions.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ jobs:
1818

1919
- name: Build wheels
2020
uses: pypa/cibuildwheel@v2.21.3
21-
# env:
22-
# CIBW_SOME_OPTION: value
23-
# ...
24-
# with:
25-
# package-dir: .
26-
# output-dir: wheelhouse
27-
# config-file: "{package}/pyproject.toml"
2821

2922
- uses: actions/upload-artifact@v4
3023
with:
@@ -63,5 +56,8 @@ jobs:
6356
merge-multiple: true
6457

6558
- uses: pypa/gh-action-pypi-publish@release/v1
66-
# with:
67-
# To test: repository-url: https://test.pypi.org/legacy/
59+
with:
60+
user: __token__
61+
password: ${{ secrets.PYPI_API_TOKEN }}
62+
skip-existing: true
63+
packages-dir: ./dist/

README.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,25 @@ Currently, discretize supports:
6161

6262
Installing
6363
^^^^^^^^^^
64-
**discretize** is on conda-forge
64+
**discretize** is on conda-forge, and is the recommended installation method.
6565

6666
.. code:: shell
6767
6868
conda install -c conda-forge discretize
6969
70-
**discretize** is on pypi
70+
Prebuilt wheels of **discretize** are on pypi for most platforms
7171

7272
.. code:: shell
7373
7474
pip install discretize
7575
76-
To install from source
76+
To install from source, note this requires a `c++` compiler supporting the `c++17` standard.
7777

7878
.. code:: shell
7979
8080
git clone https://github.com/simpeg/discretize.git
81-
python setup.py install
81+
cd discretize
82+
pip install .
8283
8384
Citing discretize
8485
^^^^^^^^^^^^^^^^^

discretize/base/base_tensor_mesh.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,7 @@ def _get_interpolation_matrix(
715715
raise ValueError("Points outside of mesh")
716716
else:
717717
indZeros = np.logical_not(self.is_inside(loc))
718+
loc = loc.copy()
718719
loc[indZeros, :] = np.array([v.mean() for v in self.get_tensor("CC")])
719720

720721
location_type = self._parse_location_type(location_type)

discretize/mixins/mpl_mod.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ def plot_slice(
450450
the given normal.
451451
452452
>>> M = discretize.TensorMesh([32, 32, 32])
453-
>>> v = discretize.utils.random_model(M.vnC, seed=789).reshape(-1, order='F')
453+
>>> v = discretize.utils.random_model(M.vnC, random_seed=789).reshape(-1, order='F')
454454
>>> x_slice, y_slice, z_slice = 0.75, 0.25, 0.9
455455
>>> plt.figure(figsize=(7.5, 3))
456456
>>> ax = plt.subplot(131)

discretize/tree_mesh.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Module containing the TreeMesh implementation."""
22

3+
import warnings
4+
35
# ___ ___ ___ ___ ___ ___
46
# /\ \ /\ \ /\ \ /\ \ /\ \ /\ \
57
# /::\ \ /::\ \ \:\ \ /::\ \ /::\ \ /::\ \
@@ -168,7 +170,7 @@ class TreeMesh(
168170
169171
diagonal_balance : bool, optional
170172
Whether to balance cells along the diagonal of the tree during construction.
171-
This will effect all calls to refine the tree.
173+
This will affect all calls to refine the tree.
172174
173175
Examples
174176
--------
@@ -232,9 +234,20 @@ class TreeMesh(
232234
_items = {"h", "origin", "cell_state"}
233235

234236
# inheriting stuff from BaseTensorMesh that isn't defined in _QuadTree
235-
def __init__(self, h=None, origin=None, diagonal_balance=False, **kwargs):
237+
def __init__(self, h=None, origin=None, diagonal_balance=None, **kwargs):
236238
if "x0" in kwargs:
237239
origin = kwargs.pop("x0")
240+
241+
if diagonal_balance is None:
242+
diagonal_balance = False
243+
warnings.warn(
244+
"In discretize v1.0 the TreeMesh will change the default value of "
245+
"diagonal_balance to True, which will likely slightly change meshes you have"
246+
"previously created. If you need to keep the current behavoir, explicitly set "
247+
"diagonal_balance=False.",
248+
FutureWarning,
249+
stacklevel=2,
250+
)
238251
super().__init__(h=h, origin=origin, diagonal_balance=diagonal_balance)
239252

240253
cell_state = kwargs.pop("cell_state", None)
@@ -925,7 +938,7 @@ def face_z_divergence(self): # NOQA D102
925938

926939
def point2index(self, locs): # NOQA D102
927940
# Documentation inherited from discretize.base.BaseMesh
928-
return self.get_containing_cell_indexes(locs)
941+
return self.get_containing_cells(locs)
929942

930943
def cell_levels_by_index(self, indices):
931944
"""Fast function to return a list of levels for the given cell indices.

discretize/utils/mesh_utils.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
num_types = [int, float]
1414

1515

16-
def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
16+
def random_model(
17+
shape, random_seed=None, anisotropy=None, its=100, bounds=None, seed=None
18+
):
1719
"""Create random tensor model.
1820
1921
Creates a random tensor model by convolving a kernel function with a
@@ -28,7 +30,7 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
2830
----------
2931
shape : (dim) tuple of int
3032
shape of the model.
31-
seed : numpy.random.Generator, int, optional
33+
random_seed : numpy.random.Generator, int, optional
3234
pick which model to produce, prints the seed if you don't choose
3335
anisotropy : numpy.ndarray, optional
3436
this is the kernel that is convolved with the model
@@ -55,7 +57,7 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
5557
>>> vmin, vmax = 0., 1.
5658
>>> mesh = TensorMesh([h, h])
5759
58-
>>> model = random_model(mesh.shape_cells, seed=4, bounds=[vmin, vmax])
60+
>>> model = random_model(mesh.shape_cells, random_seed=4, bounds=[vmin, vmax])
5961
6062
>>> fig = plt.figure(figsize=(5, 4))
6163
>>> ax = plt.subplot(111)
@@ -67,8 +69,17 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
6769
if bounds is None:
6870
bounds = [0, 1]
6971

70-
rng = np.random.default_rng(seed)
71-
if seed is None:
72+
if seed is not None:
73+
warnings.warn(
74+
"Deprecated in version 0.11.0. The `seed` keyword argument has been renamed to `random_seed` "
75+
"for consistency across the package. Please update your code to use the new keyword argument.",
76+
FutureWarning,
77+
stacklevel=2,
78+
)
79+
random_seed = seed
80+
81+
rng = np.random.default_rng(random_seed)
82+
if random_seed is None:
7283
print("Using a seed of: ", rng.bit_generator.seed_seq)
7384

7485
if type(shape) in num_types:

docs/_static/versions.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
"url": "https://discretize.simpeg.xyz/en/main/"
55
},
66
{
7-
"name": "0.10.0 (stable)",
8-
"version": "v0.10.0",
9-
"url": "https://discretize.simpeg.xyz/en/v0.10.0/",
7+
"name": "0.11.0 (stable)",
8+
"version": "v0.11.0",
9+
"url": "https://discretize.simpeg.xyz/en/v0.11.0/",
1010
"preferred": true
11+
},
12+
{
13+
"name": "0.10.0",
14+
"version": "v0.10.0",
15+
"url": "https://discretize.simpeg.xyz/en/v0.10.0/"
1116
}
1217
]
1318

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def linkcode_resolve(domain, info):
257257
"icon_links": [
258258
{
259259
"name": "GitHub",
260-
"url": "https://github.com/simpeg/simpeg",
260+
"url": "https://github.com/simpeg/discretize",
261261
"icon": "fab fa-github",
262262
},
263263
{

docs/release/0.11.0-notes.rst

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
.. currentmodule:: discretize
2+
3+
.. _0.11.0_notes:
4+
5+
===================================
6+
``discretize`` 0.11.0 Release Notes
7+
===================================
8+
9+
October 24, 2024
10+
11+
This minor release contains many bugfixes and updates related to new package builds.
12+
13+
Numpy 2
14+
-------
15+
`discretize` now fully supports `numpy` 2! It is both built against and tested against `numpy` 2.0. It still
16+
has a minimum required runtime of `numpy` 1.22 though, as building against numpy 2.0 emits ABI compatible calls for
17+
older numpy versions.
18+
19+
Of note to developers, we now require `numpy` 2.0 for building as it makes use of the `numpy-config` tool to locate
20+
the `numpy` include directory.
21+
22+
Python versions
23+
---------------
24+
`discretize` has bumped its minimum supported `python` version to 3.10, and is tested against versions 3.10-3.13. In the
25+
future we intended to stay in line with the minimum `python` version supported by the most recent `numpy` release.
26+
27+
28+
Random Generators
29+
-----------------
30+
`discretize` and its testing utilities now make use of ``numpy.random.RandomGenerator`` to make draws from random
31+
number generators instead of the deprecated ``numpy.random.rand`` functions. These functions now support a new keyword
32+
argument `random_seed` :
33+
34+
* :func:``discretize.tests.setup_mesh`` (only used when ``"random" in mesh_type``)
35+
* :func:``discretize.tests.check_derivative`` (only used when ``dx=None``)
36+
* :func:``discretize.tests.assert_isadjoint``
37+
* :func:``discretize.tests.OrderTest.orderTest`` (only used when ``"random" in mesh_type``)
38+
* :func:``discretize.utils.random_model``
39+
40+
Maintainers of downstream packages should explicitly set seeded generators when using these methods for testing
41+
purposess to ensure reproducibility.
42+
43+
44+
Cell Bounds
45+
-----------
46+
:class:``discretize.TensorMesh`` and :class:``discretize.TreeMesh`` now have a ``cell_bounds`` property that returns the
47+
``(x_min, x_max, y_min, y_max, z_min, z_max)`` of every cell in the mesh at once. Also now the
48+
:class:``discretize.tree_mesh.TreeCell`` has a corresponding ``bounds`` property.
49+
50+
51+
``TreeMesh`` updates
52+
--------------------
53+
You can now query a :class:``discretize.TreeMesh`` for cells contained in the same geometric primitives that are supported
54+
for refining. In addition there is a new :func:``discretize.TreeMesh.refine_plane`` method for refining along a plane.
55+
56+
57+
Contributors
58+
============
59+
60+
* @jcapriot
61+
* @santisoler
62+
* @prisae
63+
* @xiaolongw1223
64+
* @lheagy
65+
* @omid-b
66+
67+
Pull requests
68+
=============
69+
70+
* `#347 <https://github.com/simpeg/discretize/pull/347>`__: Replace deprecated Numpy's `product` by `prod`
71+
* `#351 <https://github.com/simpeg/discretize/pull/351>`__: Replace Slack links for Mattermost links
72+
* `#353 <https://github.com/simpeg/discretize/pull/353>`__: Fix typo in tutorials
73+
* `#354 <https://github.com/simpeg/discretize/pull/354>`__: Update year in LICENSE
74+
* `#356 <https://github.com/simpeg/discretize/pull/356>`__: Expose TreeMesh geometric intersections used for refine functions.
75+
* `#358 <https://github.com/simpeg/discretize/pull/358>`__: Replace hanging CurviMesh in docstring for CurvilinearMesh
76+
* `#360 <https://github.com/simpeg/discretize/pull/360>`__: Update use of `numpy`'s random number generators.
77+
* `#364 <https://github.com/simpeg/discretize/pull/364>`__: Fix slicer re #363
78+
* `#366 <https://github.com/simpeg/discretize/pull/366>`__: Add `TensorMesh.cell_bounds` property
79+
* `#367 <https://github.com/simpeg/discretize/pull/367>`__: Add `TreeCell.bounds` and `TreeMesh.cell_bounds` methods
80+
* `#368 <https://github.com/simpeg/discretize/pull/368>`__: Set minimum to Python 3.10 (and general CI Maintenance)
81+
* `#371 <https://github.com/simpeg/discretize/pull/371>`__: Add version switcher to discretize docs
82+
* `#372 <https://github.com/simpeg/discretize/pull/372>`__: Deploy docs to a new folder named after their tagged version
83+
* `#373 <https://github.com/simpeg/discretize/pull/373>`__: display dev doc banner
84+
* `#374 <https://github.com/simpeg/discretize/pull/374>`__: Bump pydata_sphinx_theme version to 0.15.4
85+
* `#375 <https://github.com/simpeg/discretize/pull/375>`__: Fix caching of internal projection matrices
86+
* `#376 <https://github.com/simpeg/discretize/pull/376>`__: Fix macos-latest build
87+
* `#379 <https://github.com/simpeg/discretize/pull/379>`__: Numpy2.0 updates
88+
* `#380 <https://github.com/simpeg/discretize/pull/380>`__: Create build_distributions.yml
89+
* `#381 <https://github.com/simpeg/discretize/pull/381>`__: 0.11.0 Release Notes

0 commit comments

Comments
 (0)