Skip to content

Commit

Permalink
Loop over subfolders to test examples (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolaCourtier authored Dec 10, 2024
1 parent 3bd12e0 commit bc24f34
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/scripts/battery_parameterisation/ecm_CMAES.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Import the ECM parameter set from JSON
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()

Expand Down Expand Up @@ -81,7 +81,7 @@

# Export the parameters to JSON
parameter_set.export_parameters(
"examples/scripts/parameters/fit_ecm_parameters.json", fit_params=parameters
"examples/parameters/fit_ecm_parameters.json", fit_params=parameters
)

# Plot the time series
Expand Down
4 changes: 1 addition & 3 deletions examples/scripts/getting_started/BPX_spm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import pybop

# Define model
bpx_parameters = pybop.ParameterSet(
json_path="examples/scripts/parameters/example_BPX.json"
)
bpx_parameters = pybop.ParameterSet(json_path="examples/parameters/example_BPX.json")
parameter_set = bpx_parameters.import_from_bpx()
model = pybop.lithium_ion.SPM(parameter_set=parameter_set)

Expand Down
7 changes: 4 additions & 3 deletions tests/examples/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def list_of_examples():
path_to_example_scripts = os.path.join(
pybop.script_path, "..", "examples", "scripts"
)
for example in os.listdir(path_to_example_scripts):
if example.endswith(".py"):
examples_list.append(os.path.join(path_to_example_scripts, example))
for dirpath, _, filenames in os.walk(path_to_example_scripts):
for file in filenames:
if file.endswith(".py"):
examples_list.append(os.path.join(dirpath, file))
return examples_list

@pytest.mark.parametrize("example", list_of_examples())
Expand Down

0 comments on commit bc24f34

Please sign in to comment.