Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteb401a9

Browse files
committed
fix up deprecation warnings in response to@bnavigator review
1 parentf633874 commiteb401a9

File tree

3 files changed

+35
-34
lines changed

3 files changed

+35
-34
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 legacyinput/output attributes
55+
# Getter and setter functions for legacystate attributes
5656
#
57-
# For this iteration, generate apendingdeprecation warning whenever
58-
#thegetter/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
definputs(self):
64-
raisePendingDeprecationWarning(
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+
DeprecationWarning,stacklevel=2)
6767
returnself.ninputs
6868

6969
@inputs.setter
7070
definputs(self,value):
71-
raisePendingDeprecationWarning(
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+
DeprecationWarning,stacklevel=2)
7574
self.ninputs=value
7675

7776
@property
7877
defoutputs(self):
79-
raisePendingDeprecationWarning(
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+
DeprecationWarning,stacklevel=2)
8281
returnself.noutputs
8382

8483
@outputs.setter
8584
defoutputs(self,value):
86-
raisePendingDeprecationWarning(
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+
DeprecationWarning,stacklevel=2)
8988
self.noutputs=value
9089

9190
defisdtime(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 apendingdeprecation warning whenever
337-
#thegetter/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
defstates(self):
343-
raisePendingDeprecationWarning(
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+
DeprecationWarning,stacklevel=2)
346346
returnself.nstates
347347

348348
@states.setter
349349
defstates(self,value):
350-
raisePendingDeprecationWarning(
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+
DeprecationWarning,stacklevel=2)
354353
self.nstates=value
355354

356355
def_remove_useless_states(self):

‎control/tests/lti_test.py

Lines changed: 10 additions & 7 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-
withpytest.raises(PendingDeprecationWarning,match="LTI `inputs`"):
255-
assertsys.inputs==sys.ninputs
254+
withpytest.warns(DeprecationWarning,match="LTI `inputs`"):
255+
ninputs=sys.inputs
256+
assertninputs==sys.ninputs
256257

257-
withpytest.raises(PendingDeprecationWarning,match="LTI `outputs`"):
258-
assertsys.outputs==sys.noutputs
258+
withpytest.warns(DeprecationWarning,match="LTI `outputs`"):
259+
noutputs=sys.outputs
260+
assertnoutputs==sys.noutputs
259261

260262
ifisinstance(sys,ct.StateSpace):
261-
withpytest.raises(
262-
PendingDeprecationWarning,match="StateSpace `states`"):
263-
assertsys.states==sys.nstates
263+
withpytest.warns(
264+
DeprecationWarning,match="StateSpace `states`"):
265+
nstates=sys.states
266+
assertnstates==sys.nstates

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp