Skip to content

Commit ff5fb39

Browse files
committed
fix up deprecation warnings in response to @bnavigator review
1 parent f633874 commit ff5fb39

File tree

3 files changed

+34
-33
lines changed

3 files changed

+34
-33
lines changed

control/lti.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,39 @@ def __init__(self, inputs=1, outputs=1, dt=None):
5252
self.dt = dt
5353

5454
#
55-
# Getter and setter functions for legacy input/output attributes
55+
# Getter and setter functions for legacy state attributes
5656
#
57-
# For this iteration, generate a pending deprecation warning whenever
58-
# the getter/setter is called. For a future iteration, turn it into a
59-
# deprecation warning.
57+
# For this iteration, generate a deprecation warning whenever the
58+
# getter/setter is called. For a future iteration, turn it into a
59+
# future warning, so that users will see it.
6060
#
6161

6262
@property
6363
def inputs(self):
64-
raise PendingDeprecationWarning(
65-
"The LTI `inputs` attribute will be deprecated in a future "
66-
"release. Use `ninputs` instead.")
64+
warn("The LTI `inputs` attribute will be deprecated in a future "
65+
"release. Use `ninputs` instead.",
66+
PendingDeprecationWarning, stacklevel=2)
6767
return self.ninputs
6868

6969
@inputs.setter
7070
def inputs(self, value):
71-
raise PendingDeprecationWarning(
72-
"The LTI `inputs` attribute will be deprecated in a future "
73-
"release. Use `ninputs` instead.")
74-
71+
warn("The LTI `inputs` attribute will be deprecated in a future "
72+
"release. Use `ninputs` instead.",
73+
PendingDeprecationWarning, stacklevel=2)
7574
self.ninputs = value
7675

7776
@property
7877
def outputs(self):
79-
raise PendingDeprecationWarning(
80-
"The LTI `outputs` attribute will be deprecated in a future "
81-
"release. Use `noutputs` instead.")
78+
warn("The LTI `outputs` attribute will be deprecated in a future "
79+
"release. Use `noutputs` instead.",
80+
PendingDeprecationWarning, stacklevel=2)
8281
return self.noutputs
8382

8483
@outputs.setter
8584
def outputs(self, value):
86-
raise PendingDeprecationWarning(
87-
"The LTI `outputs` attribute will be deprecated in a future "
88-
"release. Use `noutputs` instead.")
85+
warn("The LTI `outputs` attribute will be deprecated in a future "
86+
"release. Use `noutputs` instead.",
87+
PendingDeprecationWarning, stacklevel=2)
8988
self.noutputs = value
9089

9190
def isdtime(self, strict=False):

control/statesp.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -333,24 +333,23 @@ def __init__(self, *args, **kwargs):
333333
#
334334
# Getter and setter functions for legacy state attributes
335335
#
336-
# For this iteration, generate a pending deprecation warning whenever
337-
# the getter/setter is called. For a future iteration, turn it into a
338-
# deprecation warning.
336+
# For this iteration, generate a deprecation warning whenever the
337+
# getter/setter is called. For a future iteration, turn it into a
338+
# future warning, so that users will see it.
339339
#
340340

341341
@property
342342
def states(self):
343-
raise PendingDeprecationWarning(
344-
"The StateSpace `states` attribute will be deprecated in a future "
345-
"release. Use `nstates` instead.")
343+
warn("The StateSpace `states` attribute will be deprecated in a "
344+
"future release. Use `nstates` instead.",
345+
PendingDeprecationWarning, stacklevel=2)
346346
return self.nstates
347347

348348
@states.setter
349349
def states(self, value):
350-
raise PendingDeprecationWarning(
351-
"The StateSpace `states` attribute will be deprecated in a future "
352-
"release. Use `nstates` instead.")
353-
# raise PendingDeprecationWarning(
350+
warn("The StateSpace `states` attribute will be deprecated in a "
351+
"future release. Use `nstates` instead.",
352+
PendingDeprecationWarning, stacklevel=2)
354353
self.nstates = value
355354

356355
def _remove_useless_states(self):

control/tests/lti_test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,16 @@ def test_squeeze_exceptions(self, fcn):
251251
sys([[0.1, 1], [1, 10]])
252252
evalfr(sys, [[0.1, 1], [1, 10]])
253253

254-
with pytest.raises(PendingDeprecationWarning, match="LTI `inputs`"):
255-
assert sys.inputs == sys.ninputs
254+
with pytest.warns(PendingDeprecationWarning, match="LTI `inputs`"):
255+
ninputs = sys.inputs
256+
assert ninputs == sys.ninputs
256257

257-
with pytest.raises(PendingDeprecationWarning, match="LTI `outputs`"):
258-
assert sys.outputs == sys.noutputs
258+
with pytest.warns(PendingDeprecationWarning, match="LTI `outputs`"):
259+
noutputs = sys.outputs
260+
assert noutputs == sys.noutputs
259261

260262
if isinstance(sys, ct.StateSpace):
261-
with pytest.raises(
263+
with pytest.warns(
262264
PendingDeprecationWarning, match="StateSpace `states`"):
263-
assert sys.states == sys.nstates
265+
nstates = sys.states
266+
assert nstates == sys.nstates

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy