Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

## Breaking Changes

- [#938](https://github.com/pybop-team/PyBOP/pull/938) - Make SALib an optional dependency and remove `sensitivity_analysis` in favour of using SALib directly.
- [#942](https://github.com/pybop-team/PyBOP/pull/942) - Adds `evaluate_batch` to the costs and ensures that an `Evaluation` is returned.

# [v26.3](https://github.com/pybop-team/PyBOP/tree/v26.3) - 2026-03-05
Expand Down
26 changes: 22 additions & 4 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,43 @@ For those who prefer to install PyBOP from a local clone of the repository or wi
In editable mode, changes you make to the source code will immediately affect the PyBOP installation without the need for reinstallation.

Optional Dependencies
-----------------
``plotly`` - For plotting, PyBOP uses plotly. It can be installed with:
---------------------
``plotly`` - For plotting, PyBOP uses `plotly <https://plotly.com/python/>`_. It can be installed with:

.. code-block:: console

pip install pybop[plot]

``scikit-fem`` - This is a dependency for the multi-dimensional pybamm models, and can be installed using:
``salib`` - To compute sensitivities, PyBOP can be paired with the `Sensitivity Analysis Library (SALib) <https://salib.readthedocs.io/en/latest/>`_:

.. code-block:: console

pip install pybop[salib]

``scikit-fem`` - This is a dependency for the multi-dimensional PyBaMM models, and can be installed using:

.. code-block:: console

pip install pybop[scifem]

``bpx`` - To use the Faraday Institution's Battery Parameter eXchange (BPX) package install the optional requirement:
``bpx`` - To use the Faraday Institution's `Battery Parameter eXchange (BPX) package <https://bpxstandard.com/>`_:

.. code-block:: console

pip install pybop[bpx]

``ep-bolfi`` - To use Expectation Propagation with Bayesian Optimization for Likelihood-Free Inference (`EP-BOLFI <https://github.com/YannickNoelStephanKuhn/EP-BOLFI>`_):

.. code-block:: console

pip install pybop[ep-bolfi]

``pyprobe`` - To import data from battery cyclers, use `Python Processing for Battery Experiments (PyProBE) <https://pyprobe.readthedocs.io/en/latest/>`_:

.. code-block:: console

pip install pybop[pyprobe]

To install all the optional dependencies, the command ``pip install pybop[all]`` is available. For more information on the optional packages, users are directed towards the `pyproject.toml <https://github.com/pybop-team/PyBOP/blob/develop/pyproject.toml>`_.

Verifying Installation
Expand Down
49 changes: 0 additions & 49 deletions pybop/analysis/sensitivity_analysis.py

This file was deleted.

20 changes: 0 additions & 20 deletions pybop/problems/problem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np

from pybop.analysis.sensitivity_analysis import sensitivity_analysis
from pybop.costs.base_cost import BaseCost
from pybop.costs.evaluation import Evaluation
from pybop.parameters.parameter import Inputs, Parameters
Expand Down Expand Up @@ -227,25 +226,6 @@ def get_finite_initial_cost(self):
raise ValueError("The initial parameter values return an infinite cost.")
return cost0

def sensitivity_analysis(
self, n_samples: int = 256, calc_second_order: bool = False
) -> dict:
"""
Computes the parameter sensitivities on the combined cost function using
SOBOL analysis. See pybop.analysis.sensitivity_analysis for more details.

Parameters
----------
n_samples : int, optional
Number of samples for SOBOL sensitivity analysis, performs best as a
power of 2, i.e. 128, 256, etc.
calc_second_order : bool, optional
Whether to calculate second-order sensitivities.
"""
return sensitivity_analysis(
problem=self, n_samples=n_samples, calc_second_order=calc_second_order
)

@property
def cost(self):
return self._cost
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ dependencies = [
"numpy>=1.26",
"scipy>=1.12",
"pints>=0.6.0",
"SALib>=1.5",
]

[project.optional-dependencies]
plot = ["plotly>=6"]
salib = ["SALib>=1.5"]
scifem = [
"scikit-fem>=8.1.0" # scikit-fem is a dependency for the multi-dimensional pybamm models
]
Expand All @@ -51,7 +51,7 @@ ep-bolfi = [
pyprobe = [
"PyProBE-Data>=2.5.0;python_version >= '3.11' and python_version < '3.13'"
]
all = ["pybop[plot,scifem,bpx,pyprobe,ep-bolfi]"]
all = ["pybop[plot,salib,scifem,bpx,pyprobe,ep-bolfi]"]

[dependency-groups]
docs = [
Expand Down
19 changes: 0 additions & 19 deletions tests/unit/test_problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,22 +226,3 @@ def test_problem_construct_with_model_predict(self, parameters, model, dataset):
problem_output["Voltage [V]"].data,
atol=1e-6,
)

def test_parameter_sensitivities(self, simulator, dataset):
cost = pybop.MeanAbsoluteError(dataset)
problem = pybop.Problem(simulator, cost)
n_params = len(problem.parameters)
result = problem.sensitivity_analysis(4, calc_second_order=True)

# Assertions
assert isinstance(result, dict)
assert "S1" in result
assert "ST" in result
assert isinstance(result["S1"], np.ndarray)
assert isinstance(result["S2"], np.ndarray)
assert isinstance(result["ST"], np.ndarray)
assert isinstance(result["S1_conf"], np.ndarray)
assert isinstance(result["ST_conf"], np.ndarray)
assert isinstance(result["S2_conf"], np.ndarray)
assert result["S1"].shape == (n_params,)
assert result["ST"].shape == (n_params,)
Loading