Skip to content

Commit 992bf0e

Browse files
Merge pull request #580 from murrayrm/fix_is_py3.8+
change u == 0 test to avoid py3.8+ syntax warning
2 parents 55d7e2b + 89dcf3c commit 992bf0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

control/statesp.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1238,7 +1238,7 @@ def dcgain(self, warn_infinite=False):
12381238
"""
12391239
return self._dcgain(warn_infinite)
12401240

1241-
def dynamics(self, t, x, u=0):
1241+
def dynamics(self, t, x, u=None):
12421242
"""Compute the dynamics of the system
12431243
12441244
Given input `u` and state `x`, returns the dynamics of the state-space
@@ -1274,7 +1274,7 @@ def dynamics(self, t, x, u=0):
12741274
x = np.reshape(x, (-1, 1)) # force to a column in case matrix
12751275
if np.size(x) != self.nstates:
12761276
raise ValueError("len(x) must be equal to number of states")
1277-
if u is 0:
1277+
if u is None:
12781278
return self.A.dot(x).reshape((-1,)) # return as row vector
12791279
else: # received t, x, and u, ignore t
12801280
u = np.reshape(u, (-1, 1)) # force to a column in case matrix
@@ -1283,7 +1283,7 @@ def dynamics(self, t, x, u=0):
12831283
return self.A.dot(x).reshape((-1,)) \
12841284
+ self.B.dot(u).reshape((-1,)) # return as row vector
12851285

1286-
def output(self, t, x, u=0):
1286+
def output(self, t, x, u=None):
12871287
"""Compute the output of the system
12881288
12891289
Given input `u` and state `x`, returns the output `y` of the
@@ -1317,7 +1317,7 @@ def output(self, t, x, u=0):
13171317
if np.size(x) != self.nstates:
13181318
raise ValueError("len(x) must be equal to number of states")
13191319

1320-
if u is 0:
1320+
if u is None:
13211321
return self.C.dot(x).reshape((-1,)) # return as row vector
13221322
else: # received t, x, and u, ignore t
13231323
u = np.reshape(u, (-1, 1)) # force to a column in case matrix

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