diff --git a/.github/workflows/benchmark_on_push.yml b/.github/workflows/benchmark_on_push.yml index 6ac55b6ea4..58cb9e6918 100644 --- a/.github/workflows/benchmark_on_push.yml +++ b/.github/workflows/benchmark_on_push.yml @@ -23,10 +23,10 @@ jobs: - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: persist-credentials: false - - name: Set up Python 3.12 + - name: Set up Python 3.13 uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.12 + python-version: 3.13 - name: Install Linux system dependencies diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 48416a091b..7acac7b7ad 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -18,7 +18,7 @@ jobs: persist-credentials: true - uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.12 + python-version: 3.13 - name: Build wheel run: pipx run build --outdir deploy diff --git a/.github/workflows/run_periodic_tests.yml b/.github/workflows/run_periodic_tests.yml index c998784f02..989f8e8e44 100644 --- a/.github/workflows/run_periodic_tests.yml +++ b/.github/workflows/run_periodic_tests.yml @@ -31,7 +31,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-15-intel, macos-latest, windows-latest ] - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] name: Tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: @@ -79,15 +79,15 @@ jobs: run: uv tool install nox - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12' + if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.13' run: nox -s unit - name: Run coverage tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' run: nox -s coverage - name: Upload coverage report - if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: token: ${{ secrets.CODECOV_TOKEN }} @@ -101,7 +101,7 @@ jobs: contents: read strategy: fail-fast: false - name: Doctests (ubuntu-latest / Python 3.11) + name: Doctests (ubuntu-latest / Python 3.13) steps: - name: Check out PyBaMM repository @@ -119,7 +119,7 @@ jobs: - name: Set up Python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.11 + python-version: 3.13 - uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 with: @@ -141,7 +141,7 @@ jobs: contents: read strategy: fail-fast: false - name: Example notebooks (ubuntu-latest / Python 3.12) + name: Example notebooks (ubuntu-latest / Python 3.13) steps: - name: Check out PyBaMM repository @@ -155,10 +155,10 @@ jobs: sudo apt-get install gfortran gcc graphviz pandoc sudo apt-get install libopenblas-dev texlive-latex-extra dvipng - - name: Set up Python 3.12 + - name: Set up Python 3.13 uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.12 + python-version: 3.13 - uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 with: @@ -168,7 +168,7 @@ jobs: - name: Install nox run: uv tool install nox - - name: Run example notebooks tests for GNU/Linux with Python 3.12 + - name: Run example notebooks tests for GNU/Linux with Python 3.13 run: nox -s examples run_scripts_tests: @@ -177,7 +177,7 @@ jobs: contents: read strategy: fail-fast: false - name: Example scripts (ubuntu-latest / Python 3.12) + name: Example scripts (ubuntu-latest / Python 3.13) steps: - name: Check out PyBaMM repository @@ -191,10 +191,10 @@ jobs: sudo apt-get install gfortran gcc graphviz sudo apt-get install libopenblas-dev texlive-latex-extra dvipng - - name: Set up Python 3.12 + - name: Set up Python 3.13 uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.12 + python-version: 3.13 - uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 with: @@ -204,5 +204,5 @@ jobs: - name: Install nox run: uv tool install nox - - name: Run example scripts tests for GNU/Linux with Python 3.12 + - name: Run example scripts tests for GNU/Linux with Python 3.13 run: nox -s scripts diff --git a/.github/workflows/test_on_push.yml b/.github/workflows/test_on_push.yml index 47695ea998..5c366a873c 100644 --- a/.github/workflows/test_on_push.yml +++ b/.github/workflows/test_on_push.yml @@ -49,7 +49,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-15-intel, macos-latest, windows-latest] - python-version: ["3.10", "3.11", "3.12"] + python-version: ["3.10", "3.11", "3.12", "3.13"] name: Tests (${{ matrix.os }} / Python ${{ matrix.python-version }}) steps: @@ -106,21 +106,21 @@ jobs: run: uv tool install nox - name: Run unit tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.12' + if: matrix.os != 'ubuntu-latest' || matrix.python-version != '3.13' run: nox -s unit - name: Run coverage tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' run: nox -s coverage - name: Upload coverage report - if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 with: token: ${{ secrets.CODECOV_TOKEN }} - name: Run integration tests for ${{ matrix.os }} with Python ${{ matrix.python-version }} - if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12' + if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13' run: nox -s integration run_doctests: @@ -129,7 +129,7 @@ jobs: contents: read strategy: fail-fast: false - name: Doctests (ubuntu-latest / Python 3.11) + name: Doctests (ubuntu-latest / Python 3.13) steps: - name: Check out PyBaMM repository @@ -155,7 +155,7 @@ jobs: id: setup-python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.11 + python-version: 3.13 - uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 with: @@ -177,7 +177,7 @@ jobs: contents: read strategy: fail-fast: false - name: Example notebooks (ubuntu-latest / Python 3.12) + name: Example notebooks (ubuntu-latest / Python 3.13) steps: - name: Check out PyBaMM repository @@ -198,11 +198,11 @@ jobs: sudo dot -c sudo apt-get install libopenblas-dev texlive-latex-extra dvipng - - name: Set up Python 3.12 + - name: Set up Python 3.13 id: setup-python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.12 + python-version: 3.13 - uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 with: @@ -212,7 +212,7 @@ jobs: - name: Install nox run: uv tool install nox - - name: Run example notebooks tests for GNU/Linux with Python 3.12 + - name: Run example notebooks tests for GNU/Linux with Python 3.13 run: nox -s examples run_scripts_tests: @@ -221,7 +221,7 @@ jobs: contents: read strategy: fail-fast: false - name: Example scripts (ubuntu-latest / Python 3.12) + name: Example scripts (ubuntu-latest / Python 3.13) steps: - name: Check out PyBaMM repository @@ -242,11 +242,11 @@ jobs: sudo dot -c sudo apt-get install libopenblas-dev texlive-latex-extra dvipng - - name: Set up Python 3.12 + - name: Set up Python 3.13 id: setup-python uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0 with: - python-version: 3.12 + python-version: 3.13 - uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6 with: @@ -256,5 +256,5 @@ jobs: - name: Install nox run: uv tool install nox - - name: Run example scripts tests for GNU/Linux with Python 3.12 + - name: Run example scripts tests for GNU/Linux with Python 3.13 run: nox -s scripts diff --git a/.readthedocs.yaml b/.readthedocs.yaml index fda913d7b4..aad095e159 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -19,7 +19,7 @@ build: - "graphviz" os: ubuntu-22.04 tools: - python: "3.12" + python: "3.13" jobs: pre_build: - python -m sphinx -b linkcheck -D linkcheck_timeout=20 docs/ ./linkcheck_output diff --git a/CHANGELOG.md b/CHANGELOG.md index a14fafc633..1995099dff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features +- Added support for Python 3.13. ([#5330](https://github.com/pybamm-team/PyBaMM/pull/5330)) - Reduced the time to build `Simulation`s by creating a post-processing step for variables. ([#5308](https://github.com/pybamm-team/PyBaMM/pull/5308)) - Adds the ability to observe custom variables from a `Solution` object using `Solution.observe(symbol)`. ([#5308](https://github.com/pybamm-team/PyBaMM/pull/5308)) - Added inverse kinetics for linear kinetics. ([#5303](https://github.com/pybamm-team/PyBaMM/pull/5303)) diff --git a/docs/conf.py b/docs/conf.py index 713c03c4ab..39a8b08cb5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -161,8 +161,8 @@ "plausible_analytics_domain": "docs.pybamm.org", "plausible_analytics_url": "https://plausible.io/js/script.js", }, - "pygment_light_style": "xcode", - "pygment_dark_style": "monokai", + "pygments_light_style": "xcode", + "pygments_dark_style": "monokai", "footer_start": [ "copyright", "sphinx-version", diff --git a/docs/source/user_guide/installation/gnu-linux-mac.rst b/docs/source/user_guide/installation/gnu-linux-mac.rst index a9d1ef6ff0..2fd4a6b6ec 100644 --- a/docs/source/user_guide/installation/gnu-linux-mac.rst +++ b/docs/source/user_guide/installation/gnu-linux-mac.rst @@ -6,7 +6,7 @@ GNU/Linux & macOS Prerequisites ------------- -To use PyBaMM, you must have Python 3.10, 3.11, or 3.12 installed. +To use PyBaMM, you must have Python 3.10, 3.11, 3.12, 3.13 installed. .. tab:: Debian-based distributions (Debian, Ubuntu) @@ -43,7 +43,7 @@ User install We recommend to install PyBaMM within a virtual environment, in order not to alter any distribution Python files. -First, make sure you are using Python 3.10, 3.11, or 3.12. +First, make sure you are using Python 3.10, 3.11, 3.12, 3.13. To create a virtual environment ``env`` within your current directory type: .. code:: bash diff --git a/docs/source/user_guide/installation/install-from-source.rst b/docs/source/user_guide/installation/install-from-source.rst index fa467957e1..1ab20e4d21 100644 --- a/docs/source/user_guide/installation/install-from-source.rst +++ b/docs/source/user_guide/installation/install-from-source.rst @@ -28,7 +28,7 @@ or download the source archive on the repository's homepage. To install PyBaMM, you will need: -- Python 3 (PyBaMM supports versions 3.9, 3.10, 3.11, and 3.12) +- Python 3 (PyBaMM supports versions 3.10, 3.11, 3.12, and 3.13) - The Python headers file for your current Python version. - A BLAS library (for instance `openblas `_). - A C compiler (ex: ``gcc``). diff --git a/noxfile.py b/noxfile.py index 7e9c8dc744..5fc72972b4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -51,7 +51,7 @@ def run_integration(session): set_environment_variables(PYBAMM_ENV, session=session) if ( "CI" in os.environ - and sys.version_info[:2] == (3, 12) + and sys.version_info[:2] >= (3, 12) and sys.platform == "linux" ): session.install("pytest-github-actions-annotate-failures") diff --git a/pyproject.toml b/pyproject.toml index 041f08605d..c8d309685c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,7 +9,7 @@ license = { file = "LICENSE.txt" } description = "Python Battery Mathematical Modelling" authors = [{ name = "The PyBaMM Team", email = "pybamm@pybamm.org" }] maintainers = [{ name = "The PyBaMM Team", email = "pybamm@pybamm.org" }] -requires-python = ">=3.10, <3.13" +requires-python = ">=3.10, <3.14" readme = { file = "README.md", content-type = "text/markdown" } classifiers = [ "Development Status :: 5 - Production/Stable", @@ -22,6 +22,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: Scientific/Engineering", ] dependencies = [ diff --git a/src/pybamm/__init__.py b/src/pybamm/__init__.py index 3d69a5f2a7..2926afaa44 100644 --- a/src/pybamm/__init__.py +++ b/src/pybamm/__init__.py @@ -230,7 +230,6 @@ "citations", "config", "discretisations", - "doc_utils", "experiment", "expression_tree", "geometry", diff --git a/src/pybamm/doc_utils.py b/src/pybamm/doc_utils.py deleted file mode 100644 index 0e53579c43..0000000000 --- a/src/pybamm/doc_utils.py +++ /dev/null @@ -1,35 +0,0 @@ -# -# Documentation utilities for actions on PyBaMM classes -# -from inspect import getmro - - -def copy_parameter_doc_from_parent(cls): - """ - Add parameters from the base class to the docstring (Sphinx - documentation). This constructs a new docstring by concatenating with - formatting the base class docstring with the derived class. The - base class docstring is truncated at the **Parameters** section. - - Usage: as a decorator @copy_parameter_doc_from_parent on derived - class definition. - """ - base_cls = getmro(cls)[1] - parameters_section = "".join(base_cls.__doc__.partition("Parameters")[1:]) - cls.__doc__ += f"\n\n {parameters_section}" - return cls - - -# also implemented as a Sphinx extension in docs/sphinx_extend_parent.py, but this is -# not automatic, so we need to use the decorator manually in the class definition -def doc_extend_parent(cls): - """ - Add a link to the base class in the docstring (Sphinx documentation) via the - **Extends** directive. Constructs a new docstring element by concatenating - with formatting the method resolution order (MRO) of the derived class. - - Usage: as a decorator @doc_extend_parent on derived class definition. - """ - base_cls_name = f"{getmro(cls)[1].__module__}.{getmro(cls)[1].__name__}" - cls.__doc__ += f"\n\n **Extends:** :class:`{base_cls_name}`\n " - return cls diff --git a/src/pybamm/models/submodels/electrode/ohm/full_ohm.py b/src/pybamm/models/submodels/electrode/ohm/full_ohm.py index 737e2cb611..f18245623e 100644 --- a/src/pybamm/models/submodels/electrode/ohm/full_ohm.py +++ b/src/pybamm/models/submodels/electrode/ohm/full_ohm.py @@ -2,15 +2,25 @@ # Full model of electrode employing Ohm's law # import pybamm -from pybamm.doc_utils import copy_parameter_doc_from_parent, doc_extend_parent from .base_ohm import BaseModel -@copy_parameter_doc_from_parent -@doc_extend_parent class Full(BaseModel): - """Full model of electrode employing Ohm's law.""" + """This submodel implements Ohm's law for electrodes, accounting for full resistance effects. + + The model solves for the electrode potential distribution using the effective conductivity, + which is the product of the material conductivity and the transport efficiency. + + .. math:: + \\nabla \\cdot (\\sigma_{\text{eff}} \\nabla \\phi_s) = -a_j + + where: + - :math:`\\sigma_{\text{eff}} = \\sigma \\cdot \\tau_{\text{or}}` is the effective conductivity + - :math:`\\phi_s` is the electrode potential + - :math:`a_j` is the volumetric interfacial current density + + """ def __init__(self, param, domain, options=None): super().__init__(param, domain, options=options) diff --git a/tests/unit/test_doc_utils.py b/tests/unit/test_doc_utils.py deleted file mode 100644 index b7a6d9eaf8..0000000000 --- a/tests/unit/test_doc_utils.py +++ /dev/null @@ -1,65 +0,0 @@ -# -# Unit tests for doc_utils. These do not test how the actual documentation -# is generated, but rather that the docstrings are correctly modified -# - -from inspect import getmro - -from pybamm.doc_utils import copy_parameter_doc_from_parent, doc_extend_parent - - -class TestDocUtils: - def test_copy_parameter_doc_from_parent(self): - """Test if parameters from the parent class are copied to - child class docstring""" - - class Base: - """Base class for testing docstring parameter inheritance - - Parameters: - ---------- - foo : str - description for foo - bar : str - description for bar.""" - - def __init__(self, foo, bar): - pass - - @copy_parameter_doc_from_parent - class Derived(Base): - """Derived class for testing docstring parameter inheritance""" - - def __init__(self, foo, bar): - super().__init__(foo, bar) - - base_parameters = "".join(Base.__doc__.partition("Parameters")[1:]) - derived_parameters = "".join(Derived.__doc__.partition("Parameters")[1:]) - # check that the parameters section is in the docstring - assert base_parameters == derived_parameters - - def test_doc_extend_parent(self): - """Test if the child class has the Extends directive in its docstring""" - - class Base: - """Base class for testing doc_utils.doc_extend_parent""" - - def __init__(self, foo, bar): - pass - - @doc_extend_parent - class Derived(Base): - """Derived class for testing doc_utils.doc_extend_parent""" - - def __init__(self, param): - super().__init__(param) - - # check that the Extends directive is in the docstring - assert "**Extends:**" in Derived.__doc__ - - # check that the Extends directive maps to the correct base class - base_cls_name = f"{getmro(Derived)[1].__module__}.{getmro(Derived)[1].__name__}" - assert ( - Derived.__doc__.partition("**Extends:**")[2].strip() - == f":class:`{base_cls_name}`" - )