Skip to content

Commit 9ab8fbc

Browse files
authored
Merge pull request #381 from jcapriot/v0.11.0_staging
0.11.0 Release Notes
2 parents 40501f0 + 70e128d commit 9ab8fbc

File tree

9 files changed

+120
-21
lines changed

9 files changed

+120
-21
lines changed

.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/[email protected]
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
@@ -721,6 +721,7 @@ def _get_interpolation_matrix(
721721
raise ValueError("Points outside of mesh")
722722
else:
723723
indZeros = np.logical_not(self.is_inside(loc))
724+
loc = loc.copy()
724725
loc[indZeros, :] = np.array([v.mean() for v in self.get_tensor("CC")])
725726

726727
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
@@ -495,7 +495,7 @@ def plot_slice(
495495
the given normal.
496496
497497
>>> M = discretize.TensorMesh([32, 32, 32])
498-
>>> v = discretize.utils.random_model(M.vnC, seed=789).reshape(-1, order='F')
498+
>>> v = discretize.utils.random_model(M.vnC, random_seed=789).reshape(-1, order='F')
499499
>>> x_slice, y_slice, z_slice = 0.75, 0.25, 0.9
500500
>>> plt.figure(figsize=(7.5, 3))
501501
>>> ax = plt.subplot(131)

discretize/utils/mesh_utils.py

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

1616

17-
def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
17+
def random_model(
18+
shape, random_seed=None, anisotropy=None, its=100, bounds=None, seed=None
19+
):
1820
"""Create random tensor model.
1921
2022
Creates a random tensor model by convolving a kernel function with a
@@ -29,7 +31,7 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
2931
----------
3032
shape : (dim) tuple of int
3133
shape of the model.
32-
seed : numpy.random.Generator, int, optional
34+
random_seed : numpy.random.Generator, int, optional
3335
pick which model to produce, prints the seed if you don't choose
3436
anisotropy : numpy.ndarray, optional
3537
this is the kernel that is convolved with the model
@@ -56,7 +58,7 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
5658
>>> vmin, vmax = 0., 1.
5759
>>> mesh = TensorMesh([h, h])
5860
59-
>>> model = random_model(mesh.shape_cells, seed=4, bounds=[vmin, vmax])
61+
>>> model = random_model(mesh.shape_cells, random_seed=4, bounds=[vmin, vmax])
6062
6163
>>> fig = plt.figure(figsize=(5, 4))
6264
>>> ax = plt.subplot(111)
@@ -68,8 +70,17 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
6870
if bounds is None:
6971
bounds = [0, 1]
7072

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

7586
if type(shape) in num_types:

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

docs/release/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Release Notes
44
.. toctree::
55
:maxdepth: 2
66

7+
0.11.0 <0.11.0-notes>
78
0.10.0 <0.10.0-notes>
89
0.9.0 <0.9.0-notes>
910
0.8.3 <0.8.3-notes>

examples/plot_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def run(plotIt=True):
1313
M = discretize.TensorMesh([32, 32])
14-
v = discretize.utils.random_model(M.vnC, seed=789)
14+
v = discretize.utils.random_model(M.vnC, random_seed=789)
1515
v = discretize.utils.mkvc(v)
1616

1717
O = discretize.TreeMesh([32, 32])

0 commit comments

Comments
 (0)