Skip to content

Commit 563a73f

Browse files
Merge pull request #2913 from pybamm-team/develop
make release 23.4.1
2 parents 710a8d1 + 7275220 commit 563a73f

File tree

9 files changed

+23
-144
lines changed

9 files changed

+23
-144
lines changed

CHANGELOG.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
# [Unreleased](https://github.com/pybamm-team/PyBaMM/)
22

3+
# [v23.4.1](https://github.com/pybamm-team/PyBaMM/tree/v23.4) - 2023-05-01
4+
5+
## Bug fixes
6+
7+
- Fixed a performance regression introduced by citation tags ([#2862](https://github.com/pybamm-team/PyBaMM/pull/2862)). Citations tags functionality is removed for now.
8+
39
# [v23.4](https://github.com/pybamm-team/PyBaMM/tree/v23.4) - 2023-04-30
410

5-
# Features
11+
## Features
612

713
- Added verbose logging to `pybamm.print_citations()` and citation tags for the `pybamm.Citations` class so that users can now see where the citations were registered when running simulations ([#2862](https://github.com/pybamm-team/PyBaMM/pull/2862))
814
- PyBaMM is now natively supported on Apple silicon chips (`M1/M2`) ([#2435](https://github.com/pybamm-team/PyBaMM/pull/2435))
915
- PyBaMM is now supported on Python `3.10` and `3.11` ([#2435](https://github.com/pybamm-team/PyBaMM/pull/2435))
1016
- Updated to casadi 3.6, which required some changes to the casadi integrator. ([#2859](https://github.com/pybamm-team/PyBaMM/pull/2859))
1117

12-
# Optimizations
18+
## Optimizations
1319

1420
- Fixed deprecated `interp2d` method by switching to `xarray.DataArray` as the backend for `ProcessedVariable` ([#2907](https://github.com/pybamm-team/PyBaMM/pull/2907))
1521

@@ -19,7 +25,7 @@
1925
- Fixed a bug in the discretisation of initial conditions of a scaled variable ([#2856](https://github.com/pybamm-team/PyBaMM/pull/2856))
2026
- Fixed keyerror on "all" when getting sensitivities from IDAKLU solver([#2883](https://github.com/pybamm-team/PyBaMM/pull/2883))
2127

22-
# Breaking changes
28+
## Breaking changes
2329

2430
- Made `Jupyter` a development only dependency. Now `Jupyter` would not be a required dependency for users while installing `PyBaMM`. ([#2846](https://github.com/pybamm-team/PyBaMM/pull/2846))
2531

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ keywords:
2424
- "expression tree"
2525
- "python"
2626
- "symbolic differentiation"
27-
version: "23.4"
27+
version: "23.4.1"
2828
repository-code: "https://github.com/pybamm-team/PyBaMM"
2929
title: "Python Battery Mathematical Modelling (PyBaMM)"

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
author = "The PyBaMM Team"
2727

2828
# The short X.Y version
29-
version = "23.4"
29+
version = pybamm.__version__
3030
# The full version, including alpha/beta/rc tags
3131
release = version
3232

docs/source/_static/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"name": "latest", "version": "latest", "url": "https://pybamm.readthedocs.io/en/latest/"}, {"name": "stable", "version": "stable", "url": "https://pybamm.readthedocs.io/en/stable/"}, {"version": "v23.4", "url": "https://pybamm.readthedocs.io/en/v23.4/"}, {"version": "v23.3", "url": "https://pybamm.readthedocs.io/en/v23.3/"}, {"version": "v23.2", "url": "https://pybamm.readthedocs.io/en/v23.2/"}, {"version": "v23.1", "url": "https://pybamm.readthedocs.io/en/v23.1/"}, {"version": "v22.12", "url": "https://pybamm.readthedocs.io/en/v22.12/"}, {"version": "v22.11.1", "url": "https://pybamm.readthedocs.io/en/v22.11.1/"}, {"version": "v22.11", "url": "https://pybamm.readthedocs.io/en/v22.11/"}, {"version": "v22.10", "url": "https://pybamm.readthedocs.io/en/v22.10/"}, {"version": "v22.9", "url": "https://pybamm.readthedocs.io/en/v22.9/"}, {"version": "v22.8", "url": "https://pybamm.readthedocs.io/en/v22.8/"}, {"version": "v22.7", "url": "https://pybamm.readthedocs.io/en/v22.7/"}, {"version": "v22.6", "url": "https://pybamm.readthedocs.io/en/v22.6/"}, {"version": "v22.5", "url": "https://pybamm.readthedocs.io/en/v22.5/"}, {"version": "v22.4", "url": "https://pybamm.readthedocs.io/en/v22.4/"}, {"version": "v22.3", "url": "https://pybamm.readthedocs.io/en/v22.3/"}, {"version": "v22.2", "url": "https://pybamm.readthedocs.io/en/v22.3/"}, {"version": "v22.1", "url": "https://pybamm.readthedocs.io/en/v22.1/"}, {"version": "v21.12", "url": "https://pybamm.readthedocs.io/en/v21.12/"}, {"version": "v21.11", "url": "https://pybamm.readthedocs.io/en/v21.11/"}, {"version": "v21.10", "url": "https://pybamm.readthedocs.io/en/v21.10/"}, {"version": "v21.9", "url": "https://pybamm.readthedocs.io/en/v21.9/"}, {"version": "v21.08", "url": "https://pybamm.readthedocs.io/en/v21.08/"}, {"version": "v0.4.0", "url": "https://pybamm.readthedocs.io/en/v0.4.0/"}, {"version": "v0.3.0", "url": "https://pybamm.readthedocs.io/en/v0.3.0/"}, {"version": "v0.2.3", "url": "https://pybamm.readthedocs.io/en/v0.2.3/"}, {"version": "v0.2.2", "url": "https://pybamm.readthedocs.io/en/v0.2.2/"}, {"version": "v0.2.1", "url": "https://pybamm.readthedocs.io/en/v0.2.1/"}, {"version": "v0.2.0", "url": "https://pybamm.readthedocs.io/en/v0.2.0/"}, {"version": "v0.1.0", "url": "https://pybamm.readthedocs.io/en/v0.1.0/"}]
1+
[{"name": "latest", "version": "latest", "url": "https://pybamm.readthedocs.io/en/latest/"}, {"name": "stable", "version": "stable", "url": "https://pybamm.readthedocs.io/en/stable/"}, {"version": "v23.4.1", "url": "https://pybamm.readthedocs.io/en/v23.4.1/"}, {"version": "v23.4", "url": "https://pybamm.readthedocs.io/en/v23.4/"}, {"version": "v23.3", "url": "https://pybamm.readthedocs.io/en/v23.3/"}, {"version": "v23.2", "url": "https://pybamm.readthedocs.io/en/v23.2/"}, {"version": "v23.1", "url": "https://pybamm.readthedocs.io/en/v23.1/"}, {"version": "v22.12", "url": "https://pybamm.readthedocs.io/en/v22.12/"}, {"version": "v22.11.1", "url": "https://pybamm.readthedocs.io/en/v22.11.1/"}, {"version": "v22.11", "url": "https://pybamm.readthedocs.io/en/v22.11/"}, {"version": "v22.10", "url": "https://pybamm.readthedocs.io/en/v22.10/"}, {"version": "v22.9", "url": "https://pybamm.readthedocs.io/en/v22.9/"}, {"version": "v22.8", "url": "https://pybamm.readthedocs.io/en/v22.8/"}, {"version": "v22.7", "url": "https://pybamm.readthedocs.io/en/v22.7/"}, {"version": "v22.6", "url": "https://pybamm.readthedocs.io/en/v22.6/"}, {"version": "v22.5", "url": "https://pybamm.readthedocs.io/en/v22.5/"}, {"version": "v22.4", "url": "https://pybamm.readthedocs.io/en/v22.4/"}, {"version": "v22.3", "url": "https://pybamm.readthedocs.io/en/v22.3/"}, {"version": "v22.2", "url": "https://pybamm.readthedocs.io/en/v22.3/"}, {"version": "v22.1", "url": "https://pybamm.readthedocs.io/en/v22.1/"}, {"version": "v21.12", "url": "https://pybamm.readthedocs.io/en/v21.12/"}, {"version": "v21.11", "url": "https://pybamm.readthedocs.io/en/v21.11/"}, {"version": "v21.10", "url": "https://pybamm.readthedocs.io/en/v21.10/"}, {"version": "v21.9", "url": "https://pybamm.readthedocs.io/en/v21.9/"}, {"version": "v21.08", "url": "https://pybamm.readthedocs.io/en/v21.08/"}, {"version": "v0.4.0", "url": "https://pybamm.readthedocs.io/en/v0.4.0/"}, {"version": "v0.3.0", "url": "https://pybamm.readthedocs.io/en/v0.3.0/"}, {"version": "v0.2.3", "url": "https://pybamm.readthedocs.io/en/v0.2.3/"}, {"version": "v0.2.2", "url": "https://pybamm.readthedocs.io/en/v0.2.2/"}, {"version": "v0.2.1", "url": "https://pybamm.readthedocs.io/en/v0.2.1/"}, {"version": "v0.2.0", "url": "https://pybamm.readthedocs.io/en/v0.2.0/"}, {"version": "v0.1.0", "url": "https://pybamm.readthedocs.io/en/v0.1.0/"}]

pybamm/citations.py

Lines changed: 6 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import os
88
import warnings
99
import pybtex
10-
from inspect import stack
1110
from pybtex.database import parse_file, parse_string, Entry
1211
from pybtex.scanner import PybtexError
1312

@@ -36,9 +35,6 @@ def __init__(self):
3635
# Dict mapping citations keys to BibTex entries
3736
self._all_citations: dict[str, str] = dict()
3837

39-
# Dict mapping citation tags for use when registering citations
40-
self._citation_tags = dict()
41-
4238
# store citation error
4339
self._citation_err_msg = None
4440

@@ -52,21 +48,10 @@ def _reset(self):
5248
"""Reset citations to default only (only for testing purposes)"""
5349
# Initialize empty papers to cite
5450
self._papers_to_cite = set()
55-
# Initialize empty citation tags
56-
self._citation_tags = dict()
5751
# Register the PyBaMM paper and the numpy paper
5852
self.register("Sulzer2021")
5953
self.register("Harris2020")
6054

61-
def _caller_name():
62-
"""
63-
Returns the qualified name of classes that call :meth:`register` internally.
64-
This is used for tagging citations but only for verbose output
65-
"""
66-
# Attributed to https://stackoverflow.com/a/17065634
67-
caller_name = stack()[2][0].f_locals["self"].__class__.__qualname__
68-
return caller_name
69-
7055
def read_citations(self):
7156
"""Reads the citations in `pybamm.CITATIONS.txt`. Other works can be cited
7257
by passing a BibTeX citation to :meth:`register`.
@@ -93,14 +78,6 @@ def _add_citation(self, key, entry):
9378
# Add to database
9479
self._all_citations[key] = new_citation
9580

96-
def _add_citation_tag(self, key, entry):
97-
"""Adds a tag for a citation key which represents the name of the class that
98-
called :meth:`register`"""
99-
100-
# Add a citation tag to the citation_tags ordered dictionary with
101-
# the key being the citation itself and the value being the name of the class
102-
self._citation_tags[key] = entry
103-
10481
@property
10582
def _cited(self):
10683
"""Return a list of the BibTeX entries that have been cited"""
@@ -124,14 +101,6 @@ def register(self, key):
124101
# Check if citation is a known key
125102
if key in self._all_citations:
126103
self._papers_to_cite.add(key)
127-
# Add citation tags for the key
128-
# This is used for verbose output
129-
try:
130-
caller = Citations._caller_name()
131-
self._add_citation_tag(key, entry=caller)
132-
# Don't add citation tags if the citation is registered manually
133-
except KeyError: # pragma: no cover
134-
pass
135104
return
136105

137106
# Try to parse the citation using pybtex
@@ -150,54 +119,14 @@ def register(self, key):
150119
# Unable to parse / unknown key
151120
raise KeyError(f"Not a bibtex citation or known citation: {key}")
152121

153-
def tag_citations(self): # pragma: no cover
154-
"""Prints the citations tags for the citations that have been registered
155-
(non-manually). This is used for verbose output when printing citations
156-
such that it can be seen which citations were registered by PyBaMM classes.
157-
158-
To use, either call :meth:`tag_citations` after calling :meth:`register`
159-
for all citations, or enable verbose output with :meth:`print_citations`
160-
or :meth:`print`.
161-
162-
.. note::
163-
If a citation is registered manually, it will not be tagged.
164-
165-
Examples
166-
--------
167-
.. code-block:: python
168-
:linenos:
169-
170-
pybamm.citations.register("Doyle1993")
171-
pybamm.citations.print() or pybamm.print_citations()
172-
173-
will print the following:
174-
175-
.. code-block::
176-
177-
Citations registered:
178-
Sulzer2021 was cited due to the use of
179-
pybamm.models.full_battery_models.lithium_ion.dfn
180-
181-
"""
182-
if self._citation_tags:
183-
print("\n Citations registered: \n")
184-
for key, entry in self._citation_tags.items():
185-
print(f"{key} was cited due to the use of {entry}")
186-
187-
def print(self, filename=None, output_format="text", verbose=False):
188-
"""Print all citations that were used for running simulations. The verbose
189-
option is provided to print the citation tags for the citations that have
190-
been registered non-manually. This is available only upon printing
191-
to the terminal.
122+
def print(self, filename=None, output_format="text"):
123+
"""Print all citations that were used for running simulations.
192124
193125
Parameters
194126
----------
195127
filename : str, optional
196-
Filename to which to print citations. If None, citations are printed
197-
to the terminal.
198-
verbose: bool, optional
199-
If True, prints the citation tags for the citations that have been
200-
registered
128+
Filename to which to print citations. If None, citations are printed to the
129+
terminal.
201130
"""
202131
if output_format == "text":
203132
citations = pybtex.format_from_strings(
@@ -213,14 +142,12 @@ def print(self, filename=None, output_format="text", verbose=False):
213142

214143
if filename is None:
215144
print(citations)
216-
if verbose:
217-
self.tag_citations() # pragma: no cover
218145
else:
219146
with open(filename, "w") as f:
220147
f.write(citations)
221148

222149

223-
def print_citations(filename=None, output_format="text", verbose=False):
150+
def print_citations(filename=None, output_format="text"):
224151
"""See :meth:`Citations.print`"""
225152
if citations._citation_err_msg is not None:
226153
raise ImportError(
@@ -232,13 +159,7 @@ def print_citations(filename=None, output_format="text", verbose=False):
232159
f"{citations._citation_err_msg}"
233160
)
234161
else:
235-
if verbose: # pragma: no cover
236-
warnings.warn(
237-
"Verbose output is not available for printing to files, only to the terminal" # noqa: E501
238-
)
239-
pybamm.citations.print(filename, output_format, verbose=True)
240-
else:
241-
pybamm.citations.print(filename, output_format)
162+
pybamm.citations.print(filename, output_format)
242163

243164

244165
citations = Citations()

pybamm/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "23.4"
1+
__version__ = "23.4.1"

scripts/update_version.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ def update_version():
3232
file.seek(0)
3333
file.write(replace_version)
3434

35-
# docs/conf.py
36-
with open(os.path.join(pybamm.root_dir(), "docs", "conf.py"), "r+") as file:
37-
output = file.read()
38-
replace_version = re.sub('(?<=version = ")(.+)(?=")', release_version, output)
39-
file.truncate(0)
40-
file.seek(0)
41-
file.write(replace_version)
42-
4335
# CITATION.cff
4436
with open(os.path.join(pybamm.root_dir(), "CITATION.cff"), "r+") as file:
4537
output = file.read()
@@ -64,7 +56,7 @@ def update_version():
6456
) # noqa: E501
6557
file.truncate(0)
6658
file.seek(0)
67-
file.write(json.dumps(json_data))
59+
file.write(json.dumps(json_data, indent=4))
6860

6961
# vcpkg.json
7062
with open(os.path.join(pybamm.root_dir(), "vcpkg.json"), "r+") as file:

0 commit comments

Comments
 (0)