Skip to content

Commit

Permalink
style: add pyupgrade rules to ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjholland committed Feb 23, 2025
1 parent d228428 commit 0d559aa
Show file tree
Hide file tree
Showing 28 changed files with 219 additions and 238 deletions.
2 changes: 1 addition & 1 deletion docs/source/examples/comparing-pyprobe-performance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@
"compression_priority = [\"performance\", \"file size\", \"uncompressed\"]\n",
"\n",
"times = np.zeros((len(compression_priority), repeats))\n",
"file_sizes = np.zeros((len(compression_priority)))\n",
"file_sizes = np.zeros(len(compression_priority))\n",
"for i, priority in enumerate(compression_priority):\n",
" cell.process_cycler_file(\n",
" cycler=\"neware\",\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/filtering-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"metadata": {},
"outputs": [],
"source": [
"with open(data_directory + \"/README.yaml\", \"r\") as file:\n",
"with open(data_directory + \"/README.yaml\") as file:\n",
" readme = file.read()\n",
" print(readme)"
]
Expand Down
4 changes: 2 additions & 2 deletions docs/source/examples/getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
"source": [
"import yaml\n",
"\n",
"pprint(yaml.safe_load(open(data_directory + \"/README.yaml\", \"r\")))"
"pprint(yaml.safe_load(open(data_directory + \"/README.yaml\")))"
]
},
{
Expand Down Expand Up @@ -358,7 +358,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.8"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/working-with-pybamm-models.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"metadata": {},
"outputs": [],
"source": [
"with open(data_directory + \"/README.yaml\", \"r\") as file:\n",
"with open(data_directory + \"/README.yaml\") as file:\n",
" readme = file.read()\n",
" print(readme)"
]
Expand Down
8 changes: 3 additions & 5 deletions pyprobe/analysis/base/degradation_mode_analysis_functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""A module containing functions for degradation mode analysis."""

from typing import Tuple

import numpy as np
import scipy.interpolate as interp
import scipy.optimize as opt
Expand Down Expand Up @@ -75,7 +73,7 @@ def calc_electrode_capacities(
x_ne_lo: float,
x_ne_hi: float,
cell_capacity: float,
) -> Tuple[float, float, float]:
) -> tuple[float, float, float]:
"""Calculate the electrode capacities.
Args:
Expand Down Expand Up @@ -238,7 +236,7 @@ def calculate_dma_parameters(
pe_capacity: NDArray[np.float64],
ne_capacity: NDArray[np.float64],
li_inventory: NDArray[np.float64],
) -> Tuple[
) -> tuple[
NDArray[np.float64],
NDArray[np.float64],
NDArray[np.float64],
Expand Down Expand Up @@ -269,7 +267,7 @@ def average_OCV_curves(
discharge_SOC: NDArray[np.float64],
discharge_OCV: NDArray[np.float64],
discharge_current: NDArray[np.float64],
) -> Tuple[NDArray[np.float64], NDArray[np.float64]]:
) -> tuple[NDArray[np.float64], NDArray[np.float64]]:
"""Average the charge and discharge OCV curves.
Args:
Expand Down
10 changes: 4 additions & 6 deletions pyprobe/analysis/base/differentiation_functions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
"""Module containing functions for differentiating experimental data."""

from typing import List, Tuple

import numpy as np
import scipy.interpolate as interp
from numpy.typing import NDArray


def get_x_sections(x: NDArray[np.float64]) -> List[slice]:
def get_x_sections(x: NDArray[np.float64]) -> list[slice]:
"""Split the x data into uniformly sampled sections.
Args:
Expand Down Expand Up @@ -59,7 +57,7 @@ def get_dx(x: NDArray[np.float64]) -> float:

def get_dy_and_counts(
y: NDArray[np.float64], dy: float
) -> Tuple[float, NDArray[np.float64], NDArray[np.float64]]:
) -> tuple[float, NDArray[np.float64], NDArray[np.float64]]:
"""Get the y sampling interval, bin midpoints and counts.
Args:
Expand Down Expand Up @@ -99,7 +97,7 @@ def y_sampling_interval(y: NDArray[np.float64]) -> float:

def calc_gradient_with_LEAN(
x: NDArray[np.float64], y: NDArray[np.float64], k: int, gradient: str
) -> Tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]:
) -> tuple[NDArray[np.float64], NDArray[np.float64], NDArray[np.float64]]:
r"""Calculate the gradient of the data, assuming x is uniformly spaced.
Args:
Expand Down Expand Up @@ -129,7 +127,7 @@ def calc_gradient_with_LEAN(


def smooth_gradient(
gradient: NDArray[np.float64], alpha: List[float]
gradient: NDArray[np.float64], alpha: list[float]
) -> NDArray[np.float64]:
"""Smooth the calculated gradient.
Expand Down
Loading

0 comments on commit 0d559aa

Please sign in to comment.