Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/pybamm-team/PyBaMM into …
Browse files Browse the repository at this point in the history
…nox-cleanup
  • Loading branch information
Saransh-cpp committed Aug 2, 2023
2 parents f1a06fe + 61e04b3 commit b7dd9ab
Show file tree
Hide file tree
Showing 121 changed files with 4,142 additions and 3,716 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# activated pre-commit - https://github.com/pybamm-team/PyBaMM/pull/2272
0054efe388d2d17301f7e0554449eac9a7d3b7fc
# activated pre-commit for notebooks - https://github.com/pybamm-team/PyBaMM/pull/3110
a63e49ece0f9336d1f5c2562f7459e555c6e6693
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,9 @@ results/
!docs/source/examples/notebooks/models/spm1.png
!docs/source/examples/notebooks/models/spm2.png

# do not ignore images in _static folder in docs
!docs/_static/favicon/favicon.png
!docs/_static/pybamm_logo.png

# tests
test_callback.log
22 changes: 15 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ ci:
autofix_commit_msg: "style: pre-commit fixes"

repos:
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.278"
rev: "v0.0.281"
hooks:
- id: ruff
args: [--ignore=E741, --exclude=__init__.py]
args: [--fix, --ignore=E741, --exclude=__init__.py]

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-ruff
additional_dependencies: [ruff==0.0.280]
args: ["--fix","--ignore=E501,E402"]

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.15.0"
hooks:
- id: blacken-docs
additional_dependencies: [black==22.12.0]
5 changes: 5 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ sphinx:
configuration: docs/conf.py
fail_on_warning: false

formats:
- pdf
- epub
- htmlzip

# Set the version of Python and other tools you might need
build:
# Install Graphviz to build SVG files
Expand Down
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

## Breaking changes

- Added option to use an empirical hysteresis model for the diffusivity and exchange-current density ([#3194](https://github.com/pybamm-team/PyBaMM/pull/3194))
- Double-layer capacity can now be provided as a function of temperature ([#3174](https://github.com/pybamm-team/PyBaMM/pull/3174))
- `pybamm_install_jax` is deprecated. It is now replaced with `pip install pybamm[jax]` ([#3163](https://github.com/pybamm-team/PyBaMM/pull/3163))
- PyBaMM now has optional dependencies that can be installed with the pattern `pip install pybamm[option]` e.g. `pybamm[plot]` ([#3044](https://github.com/pybamm-team/PyBaMM/pull/3044))

## Bug fixes

- Fixed a bug where the "basic" lithium-ion models gave incorrect results when using nonlinear particle diffusivity ([#3207](https://github.com/pybamm-team/PyBaMM/pull/3207))
- Particle size distributions now work with SPMe and NewmanTobias models ([#3207](https://github.com/pybamm-team/PyBaMM/pull/3207))
- Fix to simulate c_rate steps with drive cycles ([#3186](https://github.com/pybamm-team/PyBaMM/pull/3186))
- Parameters in `Prada2013` have been updated to better match those given in the paper, which is a 2.3 Ah cell, instead of the mix-and-match with the 1.1 Ah cell from Lain2019.
- Error generated when invalid parameter values are passed.
- Thevenin() model is now constructed with standard variables: `Time [s], Time [min], Time [h]` ([#3143](https://github.com/pybamm-team/PyBaMM/pull/3143))
- Error generated when invalid parameter values are passed. ([#3132](https://github.com/pybamm-team/PyBaMM/pull/3132))
- Thevenin() model is now constructed with standard variables: `Time [s], Time [min], Time [h]` ([#3143](https://github.com/pybamm-team/PyBaMM/pull/3143))
- Fix SEI Example Notebook ([#3166](https://github.com/pybamm-team/PyBaMM/pull/3166))

# [v23.5](https://github.com/pybamm-team/PyBaMM/tree/v23.5) - 2023-06-18

Expand All @@ -27,7 +34,7 @@

## Bug fixes

- Realign 'count' increment in CasadiSolver._integrate() ([#2986](https://github.com/pybamm-team/PyBaMM/pull/2986))
- Realign 'count' increment in CasadiSolver.\_integrate() ([#2986](https://github.com/pybamm-team/PyBaMM/pull/2986))
- Fix `pybamm_install_odes` and update the required SUNDIALS version ([#2958](https://github.com/pybamm-team/PyBaMM/pull/2958))
- Fixed a bug where all data included in a BPX was incorrectly assumed to be given as a function of time.([#2957](https://github.com/pybamm-team/PyBaMM/pull/2957))
- Remove brew install for Mac from the recommended developer installation options for SUNDIALS ([#2925](https://github.com/pybamm-team/PyBaMM/pull/2925))
Expand Down
45 changes: 22 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,7 @@ pre-commit run ruff

ruff is configured inside the file `pre-commit-config.yaml`, allowing us to ignore some errors. If you think this should be added or removed, please submit an [issue](#issues)

When you commit your changes they will be checked against ruff automatically (see [infrastructure](#infrastructure)).

### Black

We use [black](https://black.readthedocs.io/en/stable/) to automatically configure our code to adhere to PEP8. Black can be used in two ways:

1. Command line: navigate to the PyBaMM directory in a console and type

```bash
black {source_file_or_directory}
```

2. Editor: black can be [configured](https://test-black.readthedocs.io/en/latest/editor_integration.html) to automatically reformat a Python script each time the script is saved in an editor.

If you want to use black in your editor, you may need to change the max line length in your editor settings.

Even when code has been formatted by black, you should still make sure that it adheres to the PEP8 standard set by [ruff](#ruff).
When you commit your changes they will be checked against ruff automatically (see [Pre-commit checks](#pre-commit-checks)).

### Naming

Expand Down Expand Up @@ -219,13 +203,20 @@ This also means that, if you can't fix the bug yourself, it will be much easier
2. Set break points, either in your IDE or using the Python debugging module. To use the latter, add the following line where you want to set the break point

```python
import ipdb; ipdb.set_trace()
import ipdb

ipdb.set_trace()
```

This will start the [Python interactive debugger](https://gist.github.com/mono0926/6326015). If you want to be able to use magic commands from `ipython`, such as `%timeit`, then set

```python
from IPython import embed; embed(); import ipdb; ipdb.set_trace()
from IPython import embed

embed()
import ipdb

ipdb.set_trace()
```

at the break point instead.
Expand All @@ -237,14 +228,17 @@ This also means that, if you can't fix the bug yourself, it will be much easier
try:
do_something_complicated()
except ValueError:
import ipdb; ipdb.set_trace()
import ipdb

ipdb.set_trace()
```

This will start the debugger at the point where the `ValueError` was raised, and allow you to investigate further. Sometimes, it is more informative to put the try-except block further up the call stack than exactly where the error is raised.
2. Warnings. If functions are raising warnings instead of errors, it can be hard to pinpoint where this is coming from. Here, you can use the `warnings` module to convert warnings to errors:

```python
import warnings

warnings.simplefilter("error")
```

Expand All @@ -270,7 +264,12 @@ This also means that, if you can't fix the bug yourself, it will be much easier
Sometimes, a bit of code will take much longer than you expect to run. In this case, you can set

```python
from IPython import embed; embed(); import ipdb; ipdb.set_trace()
from IPython import embed

embed()
import ipdb

ipdb.set_trace()
```

as above, and then use some of the profiling tools. In order of increasing detail:
Expand Down Expand Up @@ -389,7 +388,7 @@ Documentation is built using https://readthedocs.org/ and published on http://do

### Google Colab

Editable notebooks are made available using [Google Colab](https://colab.research.google.com/notebooks/intro.ipynb) [here](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/develop/).
Editable notebooks are made available using [Google Colab](https://colab.research.google.com/notebooks/intro.ipynb) [here](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/main/).

### GitHub

Expand All @@ -402,4 +401,4 @@ GitHub does some magic with particular filenames. In particular:
## Acknowledgements

This CONTRIBUTING.md file, along with large sections of the code infrastructure,
was copied from the excellent [Pints GitHub repo](https://github.com/pints-team/pints)
was copied from the excellent [Pints GitHub repo](https://github.com/pints-team/pints)
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/main/)
[![DOI](https://zenodo.org/badge/DOI/10.5334/jors.309.svg)](https://doi.org/10.5334/jors.309)
[![release](https://img.shields.io/github/v/release/pybamm-team/PyBaMM?color=yellow)](https://github.com/pybamm-team/PyBaMM/releases)
[![black code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
[![code style](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-60-orange.svg)](#-contributors)
Expand Down Expand Up @@ -82,7 +82,7 @@ sim.plot()

However, much greater customisation is available. It is possible to change the physics, parameter values, geometry, submesh type, number of submesh points, methods for spatial discretisation and solver for integration (see DFN [script](https://github.com/pybamm-team/PyBaMM/blob/develop/examples/scripts/DFN.py) or [notebook](https://github.com/pybamm-team/PyBaMM/blob/develop/docs/source/examples/notebooks/models/DFN.ipynb)).

For new users we recommend the [Getting Started](https://github.com/pybamm-team/PyBaMM/tree/develop/docs/source/examples/notebooks/getting_started/) guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM, and can either be downloaded and used locally, or used online through [Google Colab](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/develop).
For new users we recommend the [Getting Started](https://github.com/pybamm-team/PyBaMM/tree/develop/docs/source/examples/notebooks/getting_started/) guides. These are intended to be very simple step-by-step guides to show the basic functionality of PyBaMM, and can either be downloaded and used locally, or used online through [Google Colab](https://colab.research.google.com/github/pybamm-team/PyBaMM/blob/main/).

Further details can be found in a number of [detailed examples](https://github.com/pybamm-team/PyBaMM/tree/develop/examples), hosted here on
github. In addition, there is a [full API documentation](https://docs.pybamm.org/en/latest/source/api/index.html),
Expand All @@ -94,7 +94,7 @@ Note that the examples on the default `develop` branch are tested on the latest

## Versioning

PyBaMM uses [CalVer](https://calver.org/), which means that we make new releases every month with the version number `YY.MM`. There is no difference between releases that increment the year and releases that increment the month; in particular, releases that increment the month may introduce breaking changes. Breaking changes for each release are communicated via the [CHANGELOG](CHANGELOG.md), and come with deprecation warnings or errors that are kept for at least one year (12 releases). If you find a breaking change that is not documented, or think it should be undone, please open an issue on [GitHub](https://github.com/pybamm-team/pybamm).
PyBaMM makes releases every four months and we use [CalVer](https://calver.org/), which means that the version number is `YY.MM`. The releases happen, approximately, at the end of January, May and September. There is no difference between releases that increment the year and releases that increment the month; in particular, releases that increment the month may introduce breaking changes. Breaking changes for each release are communicated via the [CHANGELOG](CHANGELOG.md), and come with deprecation warnings or errors that are kept for at least one year (3 releases). If you find a breaking change that is not documented, or think it should be undone, please open an issue on [GitHub](https://github.com/pybamm-team/pybamm).

## 🚀 Installing PyBaMM

Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
113 changes: 79 additions & 34 deletions docs/source/_static/pybamm.css → docs/_static/pybamm.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,6 @@ h3 {
letter-spacing: -0.03em;
}

/* Style the active version button.
- latest: orange
- stable: green
- old, PR: red
Colors from:
Wong, B. Points of view: Color blindness.
Nat Methods 8, 441 (2011). https://doi.org/10.1038/nmeth.1618
*/

/* If the active version has the name "latest", style it orange */
.version-switcher__button[data-active-version-name*="latest"] {
background-color: #e69f00;
border-color: #e69f00;
color: #000000;
}

/* green for `stable` */
.version-switcher__button[data-active-version-name*="stable"] {
background-color: #009e73;
border-color: #009e73;
}

/* red for `old` */
.version-switcher__button:not(
[data-active-version-name*="latest"],
[data-active-version-name*="stable"]
) {
background-color: #980f0f;
border-color: #980f0f;
}

/* Main page overview cards */

.sd-card {
Expand Down Expand Up @@ -167,3 +133,82 @@ html[data-theme="dark"] h3 {
.tooltipster-sidetip.tooltipster-shadow.tooltipster-left .tooltipster-arrow-border {
border-left-color: var(--pst-color-background) !important;
}

/* Custom styles for Algolia DocSearch v3 items and modals */
/* to make them congruous with PST on light and dark themes */

@import url("https://cdn.jsdelivr.net/npm/@docsearch/css@3");

.DocSearch-Modal {
margin: 150px auto auto;
background: var(--pst-color-background);
}

.DocSearch-Container {
z-index: 2000;
}

kbd.DocSearch-Commands-Key {
border: 0;
box-shadow: var(--docsearch-key-shadow);
margin: 1px 5px 1px 0px;
padding: inherit;
}

.DocSearch-Button-Key {
width: 24px;
}
/* Do not add custom padding for keyboard buttons */

kbd:not(.compound) {
padding: 0rem 0rem;
}

html[data-theme="dark"] kbd.DocSearch-Commands-Key {
color: var(--pst-color-border);
}

html[data-theme="dark"] .DocSearch-Commands-Key {
background: linear-gradient(-26.5deg,#30474f,#31355b)
}

.DocSearch-Hit-source {
background: var(--pst-color-background);
}
.DocSearch-Button {
border-radius: 6px;
}

.DocSearch-Footer {
background: var(--pst-color-background);
}

/* Should be for both light and dark */

:root {
--docsearch-primary-color: var(--pst-color-info);
--docsearch-searchbox-focus-background: var(--pst-color-background);
--docsearch-footer-background: var(--pst-color-on-background)
}

/* Logo in dark theme */

html[data-theme="dark"] .DocSearch-Logo svg path.cls-1,
html[data-theme="dark"] .DocSearch-Logo svg path.cls-2,
html[data-theme="dark"] .DocSearch-Logo svg rect.cls-1 {
fill: var(--pst-color-white);
}

/* Logo in light theme */

html[data-theme="light"] .DocSearch-Logo svg path.cls-1,
html[data-theme="light"] .DocSearch-Logo svg path.cls-2,
html[data-theme="light"] .DocSearch-Logo svg rect.cls-1 {
fill: var(--pst-color-primary);
}

/* Search field dark theme corrections */

html[data-theme="dark"] .DocSearch-Button {
background: var(--pst-color-on-surface);
}
File renamed without changes
File renamed without changes
File renamed without changes.
4 changes: 4 additions & 0 deletions docs/_templates/algolia-searchbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<!-- Algolia overrides the PyData theme's searchbox with this template -->
<div role="search">
<div id="algolia-docsearch"></div>
</div>
Loading

0 comments on commit b7dd9ab

Please sign in to comment.