Skip to content
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

0.11.0 Release Notes #381

Merged
merged 10 commits into from
Oct 25, 2024
14 changes: 5 additions & 9 deletions .github/workflows/build_distributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ jobs:

- name: Build wheels
uses: pypa/[email protected]
# env:
# CIBW_SOME_OPTION: value
# ...
# with:
# package-dir: .
# output-dir: wheelhouse
# config-file: "{package}/pyproject.toml"

- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -63,5 +56,8 @@ jobs:
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
# with:
# To test: repository-url: https://test.pypi.org/legacy/
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true
packages-dir: ./dist/
9 changes: 5 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,25 @@ Currently, discretize supports:

Installing
^^^^^^^^^^
**discretize** is on conda-forge
**discretize** is on conda-forge, and is the recommended installation method.

.. code:: shell

conda install -c conda-forge discretize

**discretize** is on pypi
Prebuilt wheels of **discretize** are on pypi for most platforms

.. code:: shell

pip install discretize

To install from source
To install from source, note this requires a `c++` compiler supporting the `c++17` standard.

.. code:: shell

git clone https://github.com/simpeg/discretize.git
python setup.py install
cd discretize
pip install .

Citing discretize
^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions discretize/base/base_tensor_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ def _get_interpolation_matrix(
raise ValueError("Points outside of mesh")
else:
indZeros = np.logical_not(self.is_inside(loc))
loc = loc.copy()
loc[indZeros, :] = np.array([v.mean() for v in self.get_tensor("CC")])

location_type = self._parse_location_type(location_type)
Expand Down
2 changes: 1 addition & 1 deletion discretize/mixins/mpl_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def plot_slice(
the given normal.

>>> M = discretize.TensorMesh([32, 32, 32])
>>> v = discretize.utils.random_model(M.vnC, seed=789).reshape(-1, order='F')
>>> v = discretize.utils.random_model(M.vnC, random_seed=789).reshape(-1, order='F')
>>> x_slice, y_slice, z_slice = 0.75, 0.25, 0.9
>>> plt.figure(figsize=(7.5, 3))
>>> ax = plt.subplot(131)
Expand Down
21 changes: 16 additions & 5 deletions discretize/utils/mesh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
num_types = [int, float]


def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None):
def random_model(
shape, random_seed=None, anisotropy=None, its=100, bounds=None, seed=None
):
"""Create random tensor model.

Creates a random tensor model by convolving a kernel function with a
Expand All @@ -29,7 +31,7 @@
----------
shape : (dim) tuple of int
shape of the model.
seed : numpy.random.Generator, int, optional
random_seed : numpy.random.Generator, int, optional
pick which model to produce, prints the seed if you don't choose
anisotropy : numpy.ndarray, optional
this is the kernel that is convolved with the model
Expand All @@ -56,7 +58,7 @@
>>> vmin, vmax = 0., 1.
>>> mesh = TensorMesh([h, h])

>>> model = random_model(mesh.shape_cells, seed=4, bounds=[vmin, vmax])
>>> model = random_model(mesh.shape_cells, random_seed=4, bounds=[vmin, vmax])

>>> fig = plt.figure(figsize=(5, 4))
>>> ax = plt.subplot(111)
Expand All @@ -68,8 +70,17 @@
if bounds is None:
bounds = [0, 1]

rng = np.random.default_rng(seed)
if seed is None:
if seed is not None:
warnings.warn(

Check warning on line 74 in discretize/utils/mesh_utils.py

View check run for this annotation

Codecov / codecov/patch

discretize/utils/mesh_utils.py#L74

Added line #L74 was not covered by tests
"Deprecated in version 0.11.0. The `seed` keyword argument has been renamed to `random_seed` "
"for consistency across the package. Please update your code to use the new keyword argument.",
FutureWarning,
stacklevel=2,
)
random_seed = seed

Check warning on line 80 in discretize/utils/mesh_utils.py

View check run for this annotation

Codecov / codecov/patch

discretize/utils/mesh_utils.py#L80

Added line #L80 was not covered by tests

rng = np.random.default_rng(random_seed)

Check warning on line 82 in discretize/utils/mesh_utils.py

View check run for this annotation

Codecov / codecov/patch

discretize/utils/mesh_utils.py#L82

Added line #L82 was not covered by tests
if random_seed is None:
print("Using a seed of: ", rng.bit_generator.seed_seq)

if type(shape) in num_types:
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def linkcode_resolve(domain, info):
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/simpeg/simpeg",
"url": "https://github.com/simpeg/discretize",
"icon": "fab fa-github",
},
{
Expand Down
89 changes: 89 additions & 0 deletions docs/release/0.11.0-notes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
.. currentmodule:: discretize

.. _0.11.0_notes:

===================================
``discretize`` 0.11.0 Release Notes
===================================

October 24, 2024

This minor release contains many bugfixes and updates related to new package builds.

Numpy 2
-------
`discretize` now fully supports `numpy` 2! It is both built against and tested against `numpy` 2.0. It still
has a minimum required runtime of `numpy` 1.22 though, as building against numpy 2.0 emits ABI compatible calls for
older numpy versions.

Of note to developers, we now require `numpy` 2.0 for building as it makes use of the `numpy-config` tool to locate
the `numpy` include directory.

Python versions
---------------
`discretize` has bumped its minimum supported `python` version to 3.10, and is tested against versions 3.10-3.13. In the
future we intended to stay in line with the minimum `python` version supported by the most recent `numpy` release.


Random Generators
-----------------
`discretize` and its testing utilities now make use of ``numpy.random.RandomGenerator`` to make draws from random
number generators instead of the deprecated ``numpy.random.rand`` functions. These functions now support a new keyword
argument `random_seed` :

* :func:``discretize.tests.setup_mesh`` (only used when ``"random" in mesh_type``)
* :func:``discretize.tests.check_derivative`` (only used when ``dx=None``)
* :func:``discretize.tests.assert_isadjoint``
* :func:``discretize.tests.OrderTest.orderTest`` (only used when ``"random" in mesh_type``)
* :func:``discretize.utils.random_model``

Maintainers of downstream packages should explicitly set seeded generators when using these methods for testing
purposess to ensure reproducibility.


Cell Bounds
-----------
:class:``discretize.TensorMesh`` and :class:``discretize.TreeMesh`` now have a ``cell_bounds`` property that returns the
``(x_min, x_max, y_min, y_max, z_min, z_max)`` of every cell in the mesh at once. Also now the
:class:``discretize.tree_mesh.TreeCell`` has a corresponding ``bounds`` property.


``TreeMesh`` updates
--------------------
You can now query a :class:``discretize.TreeMesh`` for cells contained in the same geometric primitives that are supported
for refining. In addition there is a new :func:``discretize.TreeMesh.refine_plane`` method for refining along a plane.


Contributors
============

* @jcapriot
* @santisoler
* @prisae
* @xiaolongw1223
* @lheagy
* @omid-b

Pull requests
=============

* `#347 <https://github.com/simpeg/discretize/pull/347>`__: Replace deprecated Numpy's `product` by `prod`
* `#351 <https://github.com/simpeg/discretize/pull/351>`__: Replace Slack links for Mattermost links
* `#353 <https://github.com/simpeg/discretize/pull/353>`__: Fix typo in tutorials
* `#354 <https://github.com/simpeg/discretize/pull/354>`__: Update year in LICENSE
* `#356 <https://github.com/simpeg/discretize/pull/356>`__: Expose TreeMesh geometric intersections used for refine functions.
* `#358 <https://github.com/simpeg/discretize/pull/358>`__: Replace hanging CurviMesh in docstring for CurvilinearMesh
* `#360 <https://github.com/simpeg/discretize/pull/360>`__: Update use of `numpy`'s random number generators.
* `#364 <https://github.com/simpeg/discretize/pull/364>`__: Fix slicer re #363
* `#366 <https://github.com/simpeg/discretize/pull/366>`__: Add `TensorMesh.cell_bounds` property
* `#367 <https://github.com/simpeg/discretize/pull/367>`__: Add `TreeCell.bounds` and `TreeMesh.cell_bounds` methods
* `#368 <https://github.com/simpeg/discretize/pull/368>`__: Set minimum to Python 3.10 (and general CI Maintenance)
* `#371 <https://github.com/simpeg/discretize/pull/371>`__: Add version switcher to discretize docs
* `#372 <https://github.com/simpeg/discretize/pull/372>`__: Deploy docs to a new folder named after their tagged version
* `#373 <https://github.com/simpeg/discretize/pull/373>`__: display dev doc banner
* `#374 <https://github.com/simpeg/discretize/pull/374>`__: Bump pydata_sphinx_theme version to 0.15.4
* `#375 <https://github.com/simpeg/discretize/pull/375>`__: Fix caching of internal projection matrices
* `#376 <https://github.com/simpeg/discretize/pull/376>`__: Fix macos-latest build
* `#379 <https://github.com/simpeg/discretize/pull/379>`__: Numpy2.0 updates
* `#380 <https://github.com/simpeg/discretize/pull/380>`__: Create build_distributions.yml
* `#381 <https://github.com/simpeg/discretize/pull/381>`__: 0.11.0 Release Notes
1 change: 1 addition & 0 deletions docs/release/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release Notes
.. toctree::
:maxdepth: 2

0.11.0 <0.11.0-notes>
0.10.0 <0.10.0-notes>
0.9.0 <0.9.0-notes>
0.8.3 <0.8.3-notes>
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def run(plotIt=True):
M = discretize.TensorMesh([32, 32])
v = discretize.utils.random_model(M.vnC, seed=789)
v = discretize.utils.random_model(M.vnC, random_seed=789)

Check warning on line 14 in examples/plot_image.py

View check run for this annotation

Codecov / codecov/patch

examples/plot_image.py#L14

Added line #L14 was not covered by tests
v = discretize.utils.mkvc(v)

O = discretize.TreeMesh([32, 32])
Expand Down