Skip to content

Update to latest (0.25.0+)#15

Merged
jedman merged 194 commits intoKoBoldMetals:mainfrom
simpeg:main
Dec 5, 2025
Merged

Update to latest (0.25.0+)#15
jedman merged 194 commits intoKoBoldMetals:mainfrom
simpeg:main

Conversation

@nwilliams-kobold
Copy link
Copy Markdown

Bring in the latest updates from simpeg.

santisoler and others added 30 commits May 10, 2024 11:33
Rename rst files in `docs/content/api` and replace `SimPEG` for `simpeg`
in `docs/content/api/index.rst`.

Fixes #1437
Replace usage of `SimPEG` for `simpeg` in the Getting Started
documentation pages.
Add checks to validate the `survey` and `lineID` inputs in the
`convert_survey_3d_to_2d_lines` function. Add tests to check if errors
are raised after passing invalid arguments. Improve the docstring of the
function.
Always use the Pydata Sphinx theme for building the docs. Remove the
`try` statement that used to check if the theme was installed and
defaulted to the default theme if it wasn't.
Remove the `**kwargs` from the constructor of `UniformBackgroundField`.
Make `receiver_list`, `amplitude`, `inclination` and `declination` as
required arguments without any default value. Include type hints in the
signature of the constructor. Add check for type of receivers to the
constructor of `UniformBackgroundField`. Add test that checks the value
of `UniformBackgroundField.b0`, passing `receiver_list` as an actual
list of point receivers and as `None`. Add test that checks if the error
is raised after passing invalid receiver type. Minor improvements to the
docstring of the class.
)

Join the multiprocessing queues in the `MultiprocessingMetaSimulation`
when the simulation is joined.
Add a new issue template for opening maintenance issues.
Add instructions to the Contributing to SimPEG pages on how to update
the environment once it's already created.
Since latest versions of `conda` make use of `libmamba` that achieves
the same performance as `mamba` while installing packages and creating
environments, we can stop recommending `mamba` to our users as a better
alternative for `conda`. Update the admonitions in the instructions to
install simpeg and to set up the environment for contributors. Mention
the minimum version of `conda` that uses `libmamba` by default. Replace
recommendations for Mambaforge to Miniforge.
Fix bug in the constructor of beta estimator directive classes: the
`seed` argument was being passed as a positional argument to the
parent's constructor, which would assign it to the `n_pw_iter` attribute
instead to the `seed`, leading to unwanted behaviours. Pass the
arguments to the constructor through keywords to make it more explicit
and less prone to errors. Add tests that would fail without this bugfix.
Remove the `n_pw_iter` and the `method` arguments from the constructor
of `BaseBetaEstimator`.
Remove `**kwargs` from the constructor of the class, add `current` as
one of the arguments. Improve the logic and error messages for the
`location`, `location_a` and `location_b` arguments. Add tests for these
new checks. Update docstring of the constructor to reflect latest
changes. Fix the expected shape of the `location_a` and `location_b`
arguments.
Replace the usage of legacy `numpy.random.seed()` in SimPEG codebase for
the Numpy random number generator object that can be created through the
`numpy.random.default_rng()` function. Add a new `typing` module that
contain new type aliases, and create a new `RandomSeed` type alias for
variables accepted by `numpy.random.default_rng()`. Extend the accepted
values for `seed` arguments in several methods and functions to be
`None` or `RandomSeed`. Apply these replacements to directives,
`eigenvalue_by_power_iteration()`, `create_random_model()`, utility
functions on `test_utils.py` and usage of
`eigenvalue_by_power_iteration()` in tests. Update documentation and
type hint of `make_synthetic_model()` allowing it to get a Numpy
`Generator` as `random_seed`. Add a new documentation page for the new
`typing` module.
Extend docstrings for the 3D field and simulation classes for FDEM and
TDEM modules. Provide mathematical background for the implementations.
Update format of docstrings following numpydoc style. Add a few
constructor methods for some classes to fix some missing properties in
child classes.
Add new implementation of the magnetic simulation using the integral
formulation based on [Choclo](https://www.fatiando.org/choclo) and
Numba. Allow users to run the simulation with Choclo as engine through a
new `engine` argument of the constructor of the simulation class. Add
`numba_parallel` argument to control if the simulation should be run in
parallel or in a single thread. Move common methods and properties of
the gravity and magnetic simulation to the base class for potential
field simulations. Add new `potential_fields/_numba_utils.py` file with
functions that are needed both in the magnetic and gravity Numba
implementations. Refactor and extend tests for the magnetic simulation,
including tests that assert the accuracy of the new implementation
against analytic solutions. Add new tests for the base class for
potential field simulations. Update examples using Choclo as engine,
include admonitions instructing how to use it.

---------

Co-authored-by: Jacob Edman <jacob.edman@koboldmetals.com>
Co-authored-by: Joseph Capriotti <josephrcapriotti@gmail.com>
Fix minor typos in EM docstrings.
Update call of `_print_verbose_msg_init_end` in
`GaussianMixtureWithPrior`: since `scikit-learn>=1.5.0` it requires two
positional arguments. Use a `try-except` block to maintain support for
older versions of `scikit-learn`. Create a new private method for the
`GaussianMixtureWithPrior` class to wrap the
`_print_verbose_msg_init_end` method including the `try-except` block.
Add tests.

Fix #1475
Add a version switcher to the navbar of the docs, using the built in one
in PyData Sphinx theme. Point to the experimental `versions.json` file
located in `doctest.simpeg.xyz` that should serve the files in
[simpeg/simpeg-doctest](https://github.com/simpeg/simpeg-doctest). Add
experimental staged to Azure Pipelines that pushes docs to the
`simpeg-doctest` repository. One is triggered nightly and deploys the
latest docs in `main` to the `dev` branch in `simpeg-doctest` and
updates the `dev` submodule in `gh-pages`. The other one is triggered
after a release and pushes the new version of the docs to `gh-pages`
branch in `simpeg-doctest` onto a new folder, while also updating the
`latest` link.
Make use of the `random_seed` argument of the `make_synthetic_data`
method in magnetic tests. Remove the lines that set a global
`np.random.seed` in those tests.

Part of the solution to #1289
Update the `linkcode_resolve` function in Sphinx configuration file so
the links to the source code of each function, class or method points to
the actual code corresponding to that version, and not always to the
code in `main`. Update some Azure configurations: checkout simpeg repo
without shallow depth and fetching tags. Clean up the working directory
before installing SimPEG so the version doesn't have an extra hash.

---------

Co-authored-by: Joseph Capriotti <josephrcapriotti@gmail.com>
Fix issues in the new (experimental) scripts for deployment of docs to
`simpeg-doctest`. Fetch the `gh-pages` before trying to checkout it.
This is needed because we clone the repo with `--depth 1`. When passing
this option, git appends the `--single-branch` option meaning the `dev`
branch is the only branch that is being cloned. Improve how we clone the
`simpeg-doctest` repo: clone quietly to reduce output lines, and specify
the branch while deploying release docs (in case the default branch in
the repo gets changed).
Include the version of SimPEG being used to run a simulation in the
inversion log.

Fixes #1474
Replace the usage of the deprecated functions in `numpy.random` module
for the Numpy's random number generator class and its methods, in most
of the FDEM tests. Increase number of iterations for checking
derivatives where needed.

Part of the solution to #1289

---------

Co-authored-by: Lindsey Heagy <lindseyheagy@gmail.com>
Add a new `random_seed` argument to the `test()` method of objective
functions to control their random state. Use Numpy's random number
generator for managing the random state and the generation of random
numbers. Minor improvements to the implementation of the test methods.
Update tests that make use of these methods, and make them to use a seed
in every case.

Part of the solution to #1289
Add `random_seed` argument to `IdentityMap.test`. Add a new
`random_seed` argument to the `test` method of `IdentityMap` to control
the random state for creating the `m` array if it's not provided. Update
tests to use the `random_seed`. If the `m` array is passed while running
the `test()` method, specify the keyword for the argument to avoid
relying only on its position.
Replace the usage of the deprecated functions in `numpy.random` module
for the Numpy's random number generator class and its methods, in most
of the TDEM tests.

Part of the solution to #1289
Make use of the `random_seed` arguments in a few objective function
tests that were missed in previous PR.

Related to #1448.
Correcting contour colors in a gravity plot in the User Guide for a
gravity plot: correctly use the color limits both in the contours and
while building the custom color bar.
Configure Sphinx autodoc to hide type hints from signatures of
functions, methods and classes to improve readability. Expected types
for each parameter should be listed in the docstring.
Remove the `simpeg/maps.py` file and create a new `simpeg/maps`
directory. Add private files for each category of map classes inside the
new submodule. Make these classes public through the
`simpeg/maps/__init__.py`.
Moves simpeg to a pyproject.toml based setup.

* as much configuration as possible in `pyproject.toml`
* general repository cleanup
* ci shell scripts
lheagy and others added 28 commits September 23, 2025 16:34
Add new `_faceDiv` attribute to the `Fields3DMagneticField` and
`Fields3DCurrentDensity` that holds the face divergence, needed to
compute charge density. Add tests.
Create a custom RST landing page using `sphinx-design` that includes
cards to the main sections of the docs. Move some content from the old
landing page (present in the `README.rst`) into new sections in the User
Guide: `citing.rst` and `about-simpeg.rst`.
Add a new page to the How to Guide that explains how to move a mesh to a
given survey area. This is handy when working with real-world data,
whose coordinates are going to be given in projected plain coordinates.
Add an admonition pointing users to the respective tutorials in User
Tutorials.
Apply some minor improvements to the docs of `UpdateSensitivityWeights`:
add admonition, fix usage of the `class` directive, update class names
mentioned in the docs, improve list of options for different arguments.
Update the iteration write out order.

For the longest time, the iteration printers have written out mismatched
values at each iteration, and also did not print the last value of the
inversion.

This updates the write outs to happen after the line-search (matching
the behavior of the save directives), but before the directives
themselves alter the objective function.

I've also removed several un-needed notifications:
* setting bfgsH0
  * only set on BFGS subclasses and 
* if the UpdatePreconditioner directive is not in the directive list (It
handles the appoxHinv).
* Removes the repeated notifications about no nans in the model, and
instead raises an error if the model vector has any nans.

Writers:
* The iteration writer formatting logic was rather convoluted to me, so
I refactored it a bit to make it a little easier to understand what it
was doing...
Fix wrong B field when using the magnetic dipole source with the H-J
formulation. When using the magnetic vector potential to define the
source term in the H-J formulation, multiply by the face integration
matrix before taking the curl and multiply by the inverse edge
integration matrix afterwards.
Bump minimum required version of Python to 3.11.
Add a new page to the docs that specify the guidelines we follow to
support older versions of Python and Numpy.
Remove most of the DC tutorials, and add an admonition pointing users to
the respective tutorials in User Tutorials.

Part of #1555
Improve the assertions in dipole source tests for EM. Compute the root
mean square of the difference between the numerical and analytic fields
in FDEM, and check it's below a certain tolerance. Use
`np.testing.assert_allclose` in TDEM tests to compare the predicted data
for both the B and H formulations.
…CG minimizers (#1703)

#### Summary
Updates the minimizer constructors used in exampled, tutorials, and
tests to no longer use the deprecated arguments related to conjugate
gradient minimizers.

#### What does this implement/fix?
<!--Please explain your changes.-->

#### Additional information
After passing build, we'll want to check how well the examples &
tutorials that use `ProjectedGNCG` match previous results. As these now
use a relative tolerance on CG vs. an absolute tolerance. I suspect they
will not change much as most of them were terminated by the `cg_maxiter`
condition previously.

---------

Co-authored-by: Santiago Soler <santisoler@fastmail.com>
Make the `ComplexMap.deriv` to return a sparse diagonal matrix instead
of a `LinearOperator`. This makes the method to match the signature of
other mappings. Add tests that check the expected behaviour.

---------

Co-authored-by: Joseph Capriotti <josephrcapriotti@gmail.com>
Co-authored-by: Santiago Soler <santisoler@fastmail.com>
Standardize signature of `deriv` method across mappings: make sure they
are all defined as `deriv(m, v=None)`. Implement the dot product between
the derivative matrix and `v` if `v` is not `None`. Add tests for the
modified methods.

---------

Co-authored-by: Santiago Soler <santisoler@fastmail.com>
Update how mappings are being used in regularizations: regularize on
`mapping(m) - mapping(m_ref)` instead of `mapping(m - m_ref)`. Update
implementations and documentation of `Smallness`,
`SmoothnessFirstOrder`, `SmoothnessSecondOrder`, and
`SmoothnessFullGradient`: the `f_m` will compute difference of the
mapped model and reference model, while the `f_m_deriv` will not make
use of the reference model now, since it's not carried out in the
derivative. Add tests to check this intended behaviour.
#### Fixes for pymatsolver 0.4.0
<!-- Add a summary of this Pull Request -->

#### PR Checklist
* [x] If this is a work in progress PR, set as a Draft PR
* [x] Linted my code according to the [style
guides](https://docs.simpeg.xyz/latest/content/getting_started/contributing/code-style.html).
* [x] Added
[tests](https://docs.simpeg.xyz/latest/content/getting_started/contributing/testing.html)
to verify changes to the code.
* [x] Added necessary documentation to any new functions/classes
following the
expect
[style](https://docs.simpeg.xyz/latest/content/getting_started/contributing/documentation.html).
* [x] Marked as ready for review (if this is was a draft PR), and
converted
      to a Pull Request
* [x] Tagged ``@simpeg/simpeg-developers`` when ready for review.

#### What does this implement/fix?
Squeeze these two locations in the SimulationDC operation (to be
consistent on output of `__inner_mat_mul `operation)

#### Additional information
The `__inner_mat_mul` function will "squeeze" out single length second
axes, so this fix causes it to be consistent for this operation in CG.
This function had to perform this way because of the way pymatsoler
previously handled single length array inputs.
Remove the duplicated current being multiplied when computing the `Mejs`
in `LineCurrent`. Add a test that checks that the electric fields are
linear in the current.
Apply some fixes to LaTeX equations in some regularization classes.
Make the `get_indices_block` function to always return an array of
integers for the cells that belong to the specified block, instead of
returning a tuple with just a single array. Improve its implementation.
Fix it for 1D mesh since it wasn't working properly. Improve error
messages: raise better errors than just `AssertError`s and improve
messages. Avoid overwriting the `p0` and `p1` arrays in-place if they
are not provided in the right order (west-south-bottom and then
east-north-top). Add tests for the function. Update usage of the
function across tests and examples. This introduces a backward
incompatible change.
Remove the `Data.index_dictionary` property. Remove the `gtg_diagonal`
property from gravity simulation. Remove the `components` property from
gravity and magnetic surveys. Remove the
`HasModel.deleteTheseOnModelUpdate` property.
Add new `shift_to_discrete_topography` function that shifts locations
relative to discrete surface topography. Add also a new
`get_discrete_topography` function that generates discrete topography
locations out of a mesh and its active cells. We measure electric fields
at the Earth's surface when performing MT surveys. Like DC/IP, the
original measurement locations of the electric fields can end up in air
cells when we define discrete surface topography. These functions allow
the user to shift locations relative to discrete topography on Tensor
and Tree meshes. For Airborne NSEM, they also allow the user to preserve
the original flight heights. Deprecate the following functions:
`gettopoCC`, `drapeTopotoLoc`, and `closestPointsGrid`.

---------

Co-authored-by: Santiago Soler <santisoler@fastmail.com>
Deprecate the unused `force` and `topography` arguments of the method.
Add tests to check the warnings are raised.
Fix a few LaTeX equations in
`simpeg.potential_fields.magnetics.Simulation3DDifferential` that
weren't rendering correctly.
Implement the B field computation from a closed-loop wire source in the
TDEM code. We first compute the vector potential using the Biot-Savart
Law (implemented in geoana) and then take the curl to get the initial
B-field. Adds the computation of B with a step-off waveform using the B
or H formulations.

---------

Co-authored-by: Joseph Capriotti <josephrcapriotti@gmail.com>
Co-authored-by: Santiago Soler <santisoler@fastmail.com>
)

Allow passing `ramp_start` and `ramp_end` to the `RampOffWaveform` TDEM
source and fix issue with waveform being wrong at times before
`-epsilon`. Deprecate the `off_time` argument.
Add changelog for next release of SimPEG: v0.25.0. Add the new version
to the version switcher.

---------

Co-authored-by: Joseph Capriotti <josephrcapriotti@gmail.com>
Co-authored-by: Lindsey Heagy <lindseyheagy@gmail.com>
Forgot to add the new release notes to the index, so they can show up in
the website. Update the release date. Minor corrections to RST syntax.
Fix the name of the `threshold_value` argument in the docstring of the
`UpdateSensitivityWeights` directive.
@jedman jedman merged commit 1d7fe37 into KoBoldMetals:main Dec 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.