Skip to content

Commit

Permalink
Divide examples into folders (#559)
Browse files Browse the repository at this point in the history
* Divide examples into folders

* Update file paths

* Update CHANGELOG.md

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
NicolaCourtier and pre-commit-ci[bot] authored Nov 22, 2024
1 parent b2873c9 commit 4116c5c
Show file tree
Hide file tree
Showing 58 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Features

- [#282](https://github.com/pybop-team/PyBOP/issues/282) - Restructures the examples directory.
- [#396](https://github.com/pybop-team/PyBOP/issues/396) - Adds `ecm_with_tau.py` example script.
- [#452](https://github.com/pybop-team/PyBOP/issues/452) - Extends `cell_mass` and `approximate_capacity` for half-cell models.
- [#544](https://github.com/pybop-team/PyBOP/issues/544) - Allows iterative plotting using `StandardPlot`.
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"source": [
"## Importing Parameters\n",
"\n",
"This can be completed by importing a JSON representation, such as the one in the PyBOP [examples](https://github.com/pybop-team/PyBOP/blob/develop/examples/scripts/parameters/initial_ecm_parameters.json). To import via JSON, either download the example file, or create your own and update the path below to reference the corresponding file."
"This can be completed by importing a JSON representation, such as the one in the PyBOP [examples](https://github.com/pybop-team/PyBOP/blob/develop/examples/parameters/initial_ecm_parameters.json). To import via JSON, either download the example file, or create your own and update the path below to reference the corresponding file."
]
},
{
Expand All @@ -115,7 +115,7 @@
"outputs": [],
"source": [
"# parameter_set = pybop.ParameterSet(\n",
"# json_path=\"examples/scripts/parameters/initial_ecm_parameters.json\"\n",
"# json_path=\"examples/parameters/initial_ecm_parameters.json\"\n",
"# )\n",
"# parameter_set.import_parameters()"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
"metadata": {},
"outputs": [],
"source": [
"file_loc = r\"../data/Samsung_INR21700/sample_hppc_pulse.xlsx\"\n",
"file_loc = r\"../../data/Samsung_INR21700/sample_hppc_pulse.xlsx\"\n",
"df = pd.read_excel(file_loc, index_col=None, na_values=[\"NA\"])\n",
"df = df.drop_duplicates(subset=[\"Time\"], keep=\"first\")\n",
"\n",
Expand Down Expand Up @@ -459,7 +459,7 @@
"metadata": {},
"outputs": [],
"source": [
"file_loc = r\"../data/Samsung_INR21700/sample_drive_cycle.xlsx\"\n",
"file_loc = r\"../../data/Samsung_INR21700/sample_drive_cycle.xlsx\"\n",
"df = pd.read_excel(file_loc, sheet_name=\"Sheet3\", index_col=None, na_values=[\"NA\"])\n",
"\n",
"# Remove duplicate rows, keeping the first occurrence\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
"metadata": {},
"outputs": [],
"source": [
"file_loc = r\"../data/Samsung_INR21700/multipulse_hppc.xlsx\"\n",
"file_loc = r\"../../data/Samsung_INR21700/multipulse_hppc.xlsx\"\n",
"df = pd.read_excel(file_loc, index_col=None, na_values=[\"NA\"])\n",
"df = df.drop_duplicates(subset=[\"Time\"], keep=\"first\")\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"outputs": [],
"source": [
"ocv_df = pd.read_csv(\n",
" \"../data/Tesla_4680/T-cell_pOCV_data.txt\",\n",
" \"../../data/Tesla_4680/T-cell_pOCV_data.txt\",\n",
" sep=\"\\t\",\n",
" decimal=\",\",\n",
")"
Expand Down Expand Up @@ -217,7 +217,7 @@
],
"source": [
"cycling_df = pd.read_csv(\n",
" \"../data/Tesla_4680/601-828_Capacity_03_MB_CB1_subset.txt\",\n",
" \"../../data/Tesla_4680/601-828_Capacity_03_MB_CB1_subset.txt\",\n",
" sep=\"\\t\",\n",
")\n",
"filter_cycling = cycling_df.loc[54811:61000].copy() # Full cycle is [54811:127689]\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,15 @@
"outputs": [],
"source": [
"ocp = loadmat(\n",
" \"../data/LG_M50_ECM/data/LGM50_5Ah_OCV.mat\", simplify_cells=True, mat_dtype=False\n",
" \"../../data/LG_M50_ECM/data/LGM50_5Ah_OCV.mat\", simplify_cells=True, mat_dtype=False\n",
")\n",
"pulse_data = loadmat(\n",
" \"../data/LG_M50_ECM/data/LGM50_5Ah_Pulse.mat\", simplify_cells=True, mat_dtype=False\n",
" \"../../data/LG_M50_ECM/data/LGM50_5Ah_Pulse.mat\",\n",
" simplify_cells=True,\n",
" mat_dtype=False,\n",
")\n",
"rate_data = loadmat(\n",
" \"../data/LG_M50_ECM/data/LGM50_5Ah_RateTest.mat\",\n",
" \"../../data/LG_M50_ECM/data/LGM50_5Ah_RateTest.mat\",\n",
" simplify_cells=True,\n",
" mat_dtype=False,\n",
")"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"source": [
"# Load the parameters\n",
"parameter_set = pybop.ParameterSet(\n",
" json_path=\"../scripts/parameters/initial_ecm_parameters.json\"\n",
" json_path=\"../../parameters/initial_ecm_parameters.json\"\n",
")\n",
"parameter_set.import_parameters()\n",
"# Define the model\n",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pybop

# Form dataset
Measurements = pd.read_csv("examples/scripts/Chen_example.csv", comment="#").to_numpy()
Measurements = pd.read_csv("examples/data/Chen_example.csv", comment="#").to_numpy()
dataset = pybop.Dataset(
{
"Time [s]": Measurements[:, 0],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/integration/test_monte_carlo_thevenin.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def setup(self):
@pytest.fixture
def model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
parameter_set.params.update(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_thevenin_parameterisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def setup(self):
@pytest.fixture
def model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
parameter_set.params.update(
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def setup(self):
@pytest.fixture
def model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
parameter_set.params.update(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def test_basemodel(self):
@pytest.mark.unit
def test_thevenin_model(self):
parameter_set = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
parameter_set.import_parameters()
assert parameter_set["Open-circuit voltage [V]"] == "default"
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/test_parameter_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_ecm_parameter_sets(self):
json_params.import_parameters()

json_params = pybop.ParameterSet(
json_path="examples/scripts/parameters/initial_ecm_parameters.json"
json_path="examples/parameters/initial_ecm_parameters.json"
)
json_params.import_parameters()

Expand Down Expand Up @@ -94,14 +94,14 @@ def test_ecm_parameter_sets(self):
),
)
params.export_parameters(
"examples/scripts/parameters/fit_ecm_parameters.json", fit_params=parameters
"examples/parameters/fit_ecm_parameters.json", fit_params=parameters
)

# Test error when there no parameters to export
empty_params = pybop.ParameterSet()
with pytest.raises(ValueError):
empty_params.export_parameters(
"examples/scripts/parameters/fit_ecm_parameters.json"
"examples/parameters/fit_ecm_parameters.json"
)

@pytest.mark.unit
Expand All @@ -115,7 +115,7 @@ def test_bpx_parameter_sets(self):
bpx_parameters.import_from_bpx()

bpx_parameters = pybop.ParameterSet(
json_path="examples/scripts/parameters/example_BPX.json"
json_path="examples/parameters/example_BPX.json"
)
bpx_parameters.import_from_bpx()

Expand Down

0 comments on commit 4116c5c

Please sign in to comment.