Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
bump to Python 3.12, with small fixes
  • Loading branch information
murrayrm authored and bnavigator committed Jan 12, 2024
commit c17e3a02d51326e59db51ca9214863fd8ab1d0e9
4 changes: 2 additions & 2 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
max-parallel: 5
fail-fast: false
matrix:
python-version: ['3.8', '3.11']
python-version: ['3.8', '3.12']
slycot: ["", "conda"]
pandas: [""]
cvxopt: ["", "conda"]
mplbackend: [""]
include:
- python-version: '3.11'
- python-version: '3.12'
slycot: conda
pandas: conda
cvxopt: conda
Expand Down
14 changes: 14 additions & 0 deletions control/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ def __missing__(self, key):
else:
raise KeyError(key)

# New get function for Python 3.12+ to replicate old behavior
def get(self, key, defval=None):
# If the key exists, return it
if self.__contains__(key):
return self[key]

# If not, see if it is deprecated
repl = self._check_deprecation(key)
if self.__contains__(repl):
return self.get(repl, defval)

# Otherwise, call the usual dict.get() method
return super().get(key, defval)

def _check_deprecation(self, key):
if self.__contains__(f"deprecated.{key}"):
repl = self[f"deprecated.{key}"]
Expand Down
8 changes: 4 additions & 4 deletions control/tests/interconnect_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,16 @@ def test_linear_interconnect():
ct.StateSpace)

# Interconnections with nonliner I/O systems should not be linear
assert ~isinstance(
assert not isinstance(
ct.interconnect([nl_ctrl, ss_plant, sumblk], inputs='r', outputs='y'),
ct.StateSpace)
assert ~isinstance(
assert not isinstance(
ct.interconnect([nl_ctrl, tf_plant, sumblk], inputs='r', outputs='y'),
ct.StateSpace)
assert ~isinstance(
assert not isinstance(
ct.interconnect([ss_ctrl, nl_plant, sumblk], inputs='r', outputs='y'),
ct.StateSpace)
assert ~isinstance(
assert not isinstance(
ct.interconnect([tf_ctrl, nl_plant, sumblk], inputs='r', outputs='y'),
ct.StateSpace)

Expand Down
12 changes: 6 additions & 6 deletions control/tests/iosys_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1579,12 +1579,12 @@ def test_linear_interconnection():
assert isinstance(ss_siso*ss_siso, ct.StateSpace)
assert isinstance(tf_siso*ss_siso, ct.TransferFunction)
assert isinstance(ss_siso*tf_siso, ct.StateSpace)
assert ~isinstance(ss_siso*nl_siso, ct.StateSpace)
assert ~isinstance(nl_siso*ss_siso, ct.StateSpace)
assert ~isinstance(nl_siso*nl_siso, ct.StateSpace)
assert ~isinstance(tf_siso*nl_siso, ct.StateSpace)
assert ~isinstance(nl_siso*tf_siso, ct.StateSpace)
assert ~isinstance(nl_siso*nl_siso, ct.StateSpace)
assert not isinstance(ss_siso*nl_siso, ct.StateSpace)
assert not isinstance(nl_siso*ss_siso, ct.StateSpace)
assert not isinstance(nl_siso*nl_siso, ct.StateSpace)
assert not isinstance(tf_siso*nl_siso, ct.StateSpace)
assert not isinstance(nl_siso*tf_siso, ct.StateSpace)
assert not isinstance(nl_siso*nl_siso, ct.StateSpace)


def predprey(t, x, u, params={}):
Expand Down