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
2 changes: 1 addition & 1 deletion .github/workflows/test_on_pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
os: [ubuntu-latest, windows-latest, macos-15-intel, macos-14]
python-version: ["3.10", "3.11", "3.12"]
exclude: # We run the coverage tests on macos-14 with Python 3.12
- os: macos-14
Expand Down
2 changes: 1 addition & 1 deletion pybop/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#
# Dataset class
#
from ._dataset import Dataset, import_pybrobe_result
from ._dataset import Dataset, import_pyprobe_result

#
# Transformation classes
Expand Down
39 changes: 26 additions & 13 deletions pybop/_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,21 +179,33 @@ def get_subset(self, index: list | np.ndarray):
return Dataset(data, domain=self.domain)


def import_pybrobe_result(
def import_pyprobe_result(
result: PyprobeResult,
columns: list[str],
pyprobe_columns: list[str] | None = None,
columns: list[str] = [
"Time [s]",
"Current function [A]",
"Voltage [V]",
"Discharge capacity [Ah]",
],
pyprobe_columns: list[str] | None = [
"Time [s]",
"Current [A]",
"Voltage [V]",
"Capacity [Ah]",
],
) -> Dataset:
"""Import a PyprobeResult into a dictionary
"""
Import a pyprobe.Result into a dictionary

Args:
result (str):
A pybrobe Result object
columns (list of strings):
A list of columns to import.
pyprobe_columns:
An optional list of pyprobe columns names if any of them are not the same as in PyBoP.
Otherwise the column names are assumed to be identical with PyBoP.
Parameters
----------
result : str
A pyprobe.Result object.
columns : list[str]
A list of columns to import.
pyprobe_columns : list[str]
An optional list of pyprobe columns names if any of them are not the same as in PyBOP.
Otherwise the column names are assumed to be identical with PyBOP.

"""
if pyprobe_columns is None:
Expand Down Expand Up @@ -223,8 +235,9 @@ def import_pybrobe_result(
elif pyprobe_columns[i] in [
"Current [A]",
"Capacity [Ah]",
"Discharge capacity [A.h]",
]:
# The sign convention in PyProBE is that positive current is charging,
# the convention in PyBaMM is that positive current means discharging
data_dict[col] = -1.0 * result.get(pyprobe_columns[i])
else:
data_dict[col] = result.get(pyprobe_columns[i])
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ bpx = [
"bpx>=0.5, <0.6",
]

pybrobe = [
pyprobe = [
"PyProBE-Data;python_version>='3.11'"
]

all = ["pybop[plot,scifem,bpx,pybrobe]"]
all = ["pybop[plot,scifem,bpx,pyprobe]"]

[tool.setuptools.packages.find]
include = ["pybop", "pybop.*"]
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def test_pybamm_import(self):
@pytest.mark.skipif(
sys.version_info < (3, 11), reason="requires python3.11 or higher"
)
def test_pyrobe_import(self):
def test_pyprobe_import(self):
"""
Function to test import of PyProBE result into a pybop.dataset.
Function to test import of PyProBE Result into a pybop.Dataset.
PyProBE requires Python 3.11 or higher.
"""
import pyprobe
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_pyrobe_import(self):
cell.import_pybamm_solution("US06 DFN", ["US06"], solution)

# Import data from PyProBE into pybop.dataset
dataset_pyprobe = pybop.import_pybrobe_result(
dataset_pyprobe = pybop.import_pyprobe_result(
cell.procedure["US06 DFN"],
[
"Time [s]",
Expand All @@ -191,7 +191,7 @@ def test_pyrobe_import(self):
)

# Different choice of parameters where column names are identical between pyprobe and pybamm
dataset_pyprobe2 = pybop.import_pybrobe_result(
dataset_pyprobe2 = pybop.import_pyprobe_result(
cell.procedure["US06 DFN"],
[
"Time [s]",
Expand Down
Loading