diff --git a/.github/workflows/build_distributions.yml b/.github/workflows/build_distributions.yml index 6dff9ce6c..d494cf741 100644 --- a/.github/workflows/build_distributions.yml +++ b/.github/workflows/build_distributions.yml @@ -18,13 +18,6 @@ jobs: - name: Build wheels uses: pypa/cibuildwheel@v2.21.3 - # env: - # CIBW_SOME_OPTION: value - # ... - # with: - # package-dir: . - # output-dir: wheelhouse - # config-file: "{package}/pyproject.toml" - uses: actions/upload-artifact@v4 with: @@ -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/ diff --git a/README.rst b/README.rst index 1185ad205..750047f49 100644 --- a/README.rst +++ b/README.rst @@ -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 ^^^^^^^^^^^^^^^^^ diff --git a/discretize/base/base_tensor_mesh.py b/discretize/base/base_tensor_mesh.py index dcd28f346..58375b19c 100644 --- a/discretize/base/base_tensor_mesh.py +++ b/discretize/base/base_tensor_mesh.py @@ -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) diff --git a/discretize/mixins/mpl_mod.py b/discretize/mixins/mpl_mod.py index fecff2235..c58fda18a 100644 --- a/discretize/mixins/mpl_mod.py +++ b/discretize/mixins/mpl_mod.py @@ -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) diff --git a/discretize/utils/mesh_utils.py b/discretize/utils/mesh_utils.py index 7aeeaf0d8..ec9583893 100644 --- a/discretize/utils/mesh_utils.py +++ b/discretize/utils/mesh_utils.py @@ -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 @@ -29,7 +31,7 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None): ---------- 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 @@ -56,7 +58,7 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None): >>> 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) @@ -68,8 +70,17 @@ def random_model(shape, seed=None, anisotropy=None, its=100, bounds=None): if bounds is None: bounds = [0, 1] - rng = np.random.default_rng(seed) - if seed is None: + if seed is not None: + warnings.warn( + "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 + + rng = np.random.default_rng(random_seed) + if random_seed is None: print("Using a seed of: ", rng.bit_generator.seed_seq) if type(shape) in num_types: diff --git a/docs/conf.py b/docs/conf.py index e0165cb41..41b37b634 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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", }, { diff --git a/docs/release/0.11.0-notes.rst b/docs/release/0.11.0-notes.rst new file mode 100644 index 000000000..7c12e4262 --- /dev/null +++ b/docs/release/0.11.0-notes.rst @@ -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 `__: Replace deprecated Numpy's `product` by `prod` +* `#351 `__: Replace Slack links for Mattermost links +* `#353 `__: Fix typo in tutorials +* `#354 `__: Update year in LICENSE +* `#356 `__: Expose TreeMesh geometric intersections used for refine functions. +* `#358 `__: Replace hanging CurviMesh in docstring for CurvilinearMesh +* `#360 `__: Update use of `numpy`'s random number generators. +* `#364 `__: Fix slicer re #363 +* `#366 `__: Add `TensorMesh.cell_bounds` property +* `#367 `__: Add `TreeCell.bounds` and `TreeMesh.cell_bounds` methods +* `#368 `__: Set minimum to Python 3.10 (and general CI Maintenance) +* `#371 `__: Add version switcher to discretize docs +* `#372 `__: Deploy docs to a new folder named after their tagged version +* `#373 `__: display dev doc banner +* `#374 `__: Bump pydata_sphinx_theme version to 0.15.4 +* `#375 `__: Fix caching of internal projection matrices +* `#376 `__: Fix macos-latest build +* `#379 `__: Numpy2.0 updates +* `#380 `__: Create build_distributions.yml +* `#381 `__: 0.11.0 Release Notes diff --git a/docs/release/index.rst b/docs/release/index.rst index beefd65dd..1b6cc7b39 100644 --- a/docs/release/index.rst +++ b/docs/release/index.rst @@ -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> diff --git a/examples/plot_image.py b/examples/plot_image.py index c31f6deae..27a896507 100644 --- a/examples/plot_image.py +++ b/examples/plot_image.py @@ -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) v = discretize.utils.mkvc(v) O = discretize.TreeMesh([32, 32])