8000 Merge pull request #961 from bnavigator/python312 · bnavigator/python-control@6e9526c · GitHub
[go: up one dir, main page]

Skip to content

Commit 6e9526c

Browse files
authored
Merge pull request python-control#961 from bnavigator/python312
Support Python 3.12, Bump minimum support according to SPEC 0
2 parents 9509dfd + fd8dade commit 6e9526c

12 files changed

+64
-53
lines changed

.github/conda-env/build-env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
name: build-env
22
dependencies:
33
- boa
4-
- numpy !=1.23.0
4+
- numpy

.github/conda-env/doctest-env.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
name: test-env
1+
name: doctest-env
22
dependencies:
3-
- conda-build # for conda index
43
- pip
5-
- coverage
6-
- coveralls
74
- pytest
8-
- pytest-cov
95
- pytest-timeout
106
- pytest-xvfb
117
- numpy

.github/conda-env/test-env.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: test-env
22
dependencies:
3-
- conda-build # for conda index
43
- pip
54
- coverage
6-
- coveralls
75
- pytest
86
- pytest-cov
97
- pytest-timeout

.github/workflows/control-slycot-src.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Python
1515
uses: actions/setup-python@v4
1616
with:
17-
python-version: '3.11'
17+
python-version: '3.12'
1818
- name: Install Python dependencies and test tools
1919
run: pip install -v './python-control[test]'
2020

.github/workflows/doctest.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
- name: Setup Conda
1616
uses: conda-incubator/setup-miniconda@v2
1717
with:
18-
python-version: 3.11
19-
activate-environment: test-env
18+
python-version: 3.12
19+
activate-environment: doctest-env
2020
environment-file: .github/conda-env/doctest-env.yml
2121
miniforge-version: latest
2222
miniforge-variant: Mambaforge
@@ -32,8 +32,6 @@ jobs:
3232
3333
- name: Run doctest
3434
shell: bash -l {0}
35-
env:
36-
MPLBACKEND: ${{ matrix.mplbackend }}
3735
working-directory: doc
3836
run: |
3937
make html

.github/workflows/install_examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
--channel conda-forge \
1919
--strict-channel-priority \
2020
--quiet --yes \
21-
python=3.11 pip \
21+
python=3.12 pip \
2222
numpy matplotlib scipy \
2323
slycot pmw jupyter
2424

.github/workflows/os-blas-test-matrix.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,24 @@ jobs:
2121
- 'ubuntu'
2222
- 'macos'
2323
python:
24-
- '3.8'
25-
- '3.11'
24+
- '3.10'
25+
- '3.12'
2626
bla_vendor: [ 'unset' ]
2727
include:
2828
- os: 'ubuntu'
29-
python: '3.11'
29+
python: '3.12'
3030
bla_vendor: 'Generic'
3131
- os: 'ubuntu'
32-
python: '3.11'
32+
python: '3.12'
3333
bla_vendor: 'OpenBLAS'
3434
- os: 'macos'
35-
python: '3.11'
35+
python: '3.12'
3636
bla_vendor: 'Apple'
3737
- os: 'macos'
38-
python: '3.11'
38+
python: '3.12'
3939
bla_vendor: 'Generic'
4040
- os: 'macos'
41-
python: '3.11'
41+
python: '3.12'
4242
bla_vendor: 'OpenBLAS'
4343

4444
steps:
@@ -108,7 +108,7 @@ jobs:
108108
- 'macos'
109109
- 'windows'
110110
python:
111-
- '3.9'
111+
# build on one, expand matrix in conda-build from the Sylcot/conda-recipe/conda_build_config.yaml
112112
- '3.11'
113113

114114
steps:
@@ -133,14 +133,14 @@ jobs:
133133
shell: bash -l {0}
134134
run: |
135135
set -e
136-
numpyversion=$(python -c 'import numpy; print(numpy.version.version)')
137-
conda mambabuild --python "${{ matrix.python }}" --numpy $numpyversion conda-recipe
136+
conda mambabuild conda-recipe
138137
# preserve directory structure for custom conda channel
139138
find "${CONDA_PREFIX}/conda-bld" -maxdepth 2 -name 'slycot*.tar.bz2' | while read -r conda_pkg; do
140139
conda_platform=$(basename $(dirname "${conda_pkg}"))
141140
mkdir -p "slycot-conda-pkgs/${conda_platform}"
142141
cp "${conda_pkg}" "slycot-conda-pkgs/${conda_platform}/"
143142
done
143+
conda index --no-progress ./slycot-conda-pkgs
144144
- name: Save to local conda pkg channel
145145
uses: actions/upload-artifact@v3
146146
with:
@@ -247,7 +247,7 @@ jobs:
247247
- name: Install Wheel
248248
run: |
249249
python -m pip install --upgrade pip
250-
pip install matplotlib scipy pytest pytest-cov pytest-timeout coverage coveralls
250+
pip install matplotlib scipy pytest pytest-cov pytest-timeout coverage
251251
pip install slycot-wheels/${{ matrix.packagekey }}/slycot*.whl
252252
pip show slycot
253253
- name: Test with pytest
@@ -316,7 +316,6 @@ jobs:
316316
echo "libblas * *mkl" >> $CONDA_PREFIX/conda-meta/pinned
317317
;;
318318
esac
319-
conda index --no-progress ./slycot-conda-pkgs
320319
mamba install -c ./slycot-conda-pkgs slycot
321320
conda list
322321
- name: Test with pytest

.github/workflows/python-package-conda.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ jobs:
1616
max-parallel: 5
1717
fail-fast: false
1818
matrix:
19-
python-version: ['3.8', '3.11']
19+
python-version: ['3.10', '3.12']
2020
slycot: ["", "conda"]
2121
pandas: [""]
2222
cvxopt: ["", "conda"]
2323
mplbackend: [""]
2424
include:
25-
- python-version: '3.11'
25+
- python-version: '3.12'
2626
slycot: conda
2727
pandas: conda
2828
cvxopt: conda
@@ -61,20 +61,27 @@ jobs:
6161
shell: bash -l {0}
6262
env:
6363
MPLBACKEND: ${{ matrix.mplbackend }}
64-
run: pytest -v --cov=control --cov-config=.coveragerc control/tests
64+
run: |
65+
pytest -v --cov=control --cov-config=.coveragerc control/tests
66+
coverage xml
6567
66-
- name: Coveralls parallel
67-
# https://github.com/coverallsapp/github-action
68-
uses: AndreMiras/coveralls-python-action@develop
68+
- name: report coverage
69+
uses: coverallsapp/github-action@v2
6970
with:
71+
flag-name: conda-pytest_py${{ matrix.python-version }}_${{ matrix.slycot || 'no' }}-Slycot_${{ matrix.pandas || 'no' }}-Pandas_${{ matrix.cvxopt || 'no' }}_CVXOPT-${{ matrix.mplbackend && format('; {0}', matrix.mplbackend) }}
7072
parallel: true
73+
file: coverage.xml
7174

72-
coveralls:
73-
name: coveralls completion
74-
needs: test-linux-conda
75+
coveralls-final:
76+
name: Finalize parallel coveralls
77+
if: always()
78+
needs:
79+
- test-linux-conda
7580
runs-on: ubuntu-latest
7681
steps:
7782
- name: Coveralls Finished
78-
uses: AndreMiras/coveralls-python-action@develop
83+
uses: coverallsapp/github-action@v2
7984
with:
80-
parallel-finished: true
85+
parallel-finished: true
86+
87+

control/config.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ def __missing__(self, key):
4848
else:
4949
raise KeyError(key)
5050

51+
# New get function for Python 3.12+ to replicate old behavior
52+
def get(self, key, defval=None):
53+
# If the key exists, return it
54+
if self.__contains__(key):
55+
return self[key]
56+
57+
# If not, see if it is deprecated
58+
repl = self._check_deprecation(key)
59+
if self.__contains__(repl):
60+
return self.get(repl, defval)
61+
62+
# Otherwise, call the usual dict.get() method
63+
return super().get(key, defval)
64+
5165
def _check_deprecation(self, key):
5266
if self.__contains__(f"deprecated.{key}"):
5367
repl = self[f"deprecated.{key}"]

control/tests/interconnect_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,16 @@ def test_linear_interconnect():
409409
ct.StateSpace)
410410

411411
# Interconnections with nonliner I/O systems should not be linear
412-
assert ~isinstance(
412+
assert not isinstance(
413413
ct.interconnect([nl_ctrl, ss_plant, sumblk], inputs='r', outputs='y'),
414414
ct.StateSpace)
415-
assert ~isinstance(
415+
assert not isinstance(
416416
ct.interconnect([nl_ctrl, tf_plant, sumblk], inputs='r', outputs='y'),
417417
ct.StateSpace)
418-
assert ~isinstance(
418+
assert not isinstance(
419419
ct.interconnect([ss_ctrl, nl_plant, sumblk], inputs='r', outputs='y'),
420420
ct.StateSpace)
421-
assert ~isinstance(
421+
assert not isinstance(
422422
ct.interconnect([tf_ctrl, nl_plant, sumblk], inputs='r', outputs='y'),
423423
ct.StateSpace)
424424

0 commit comments

Comments
 (0)
0