Skip to content

Commit

Permalink
Updt. matrix generation for incompatible pybamm/python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
BradyPlanden committed Feb 20, 2024
1 parent dc9effe commit 7e8fd4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pip install -e "path/to/pybop"
To check whether PyBOP has been installed correctly, run one of the examples in the following section. For a development installation, please refer to the [contributing guide](https://github.com/pybop-team/PyBOP/blob/develop/CONTRIBUTING.md#Installation).

### Prerequisites
To use and/or contribute to PyBOP, first install Python (3.8-3.11). On a Debian-based distribution, this looks like:
To use and/or contribute to PyBOP, first install Python (3.8 — 3.12). On a Debian-based distribution, this looks like:

```bash
sudo apt update
Expand Down
28 changes: 22 additions & 6 deletions scripts/ci/build_matrix.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,38 @@
python_version=("3.8" "3.9" "3.10" "3.11" "3.12")
os=("ubuntu-latest" "windows-latest" "macos-latest")
# This command fetches the last three PyBaMM versions excluding release candidates from PyPI
pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 3 | awk '{print "\"" $1 "\"" }' | paste -sd " " -))
pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 3 | paste -sd " " -))

# open dict
json='{
"include": [
'
# Function to check if a PyBaMM version is compatible with a Python version
is_compatible() {
local pybamm_ver="$1"
local py_ver="$2"

# Compatibility check
if [[ "$pybamm_ver" == "23.5" && "$py_ver" == "3.12" ]]; then
return 1 # Incompatible
elif [[ "$pybamm_ver" == "23.9" && "$py_ver" == "3.12" ]]; then
return 1 # Incompatible
fi

return 0 # Compatible
}

# loop through each combination of variables to generate matrix components
for py_ver in "${python_version[@]}"; do
for os_type in "${os[@]}"; do
for pybamm_ver in "${pybamm_version[@]}"; do
json+='{
"os": "'$os_type'",
"python_version": "'$py_ver'",
"pybamm_version": '$pybamm_ver'
},'
if is_compatible "$pybamm_ver" "$py_ver"; then
json+='{
"os": "'$os_type'",
"python_version": "'$py_ver'",
"pybamm_version": "'$pybamm_ver'"
},'
fi
done
done
done
Expand Down

0 comments on commit 7e8fd4c

Please sign in to comment.