Skip to content

Commit 37c95b6

Browse files
authored
Merge branch 'master' into vector-frd-feedback
2 parents 323ae3d + 4f681ab commit 37c95b6

34 files changed

+258
-667
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
strategy:
1111
max-parallel: 5
1212
matrix:
13-
python-version: [3.6, 3.9]
13+
python-version: [3.7, 3.9]
1414
slycot: ["", "conda"]
1515
array-and-matrix: [0]
1616
include:

.travis.yml

-112
This file was deleted.

control/canonical.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import numpy as np
1010

11-
from numpy import zeros, zeros_like, shape, poly, iscomplex, vstack, hstack, dot, \
11+
from numpy import zeros, zeros_like, shape, poly, iscomplex, vstack, hstack, \
1212
transpose, empty, finfo, float64
1313
from numpy.linalg import solve, matrix_rank, eig
1414

@@ -149,7 +149,7 @@ def observable_form(xsys):
149149
raise ValueError("Transformation matrix singular to working precision.")
150150

151151
# Finally, compute the output matrix
152-
zsys.B = Tzx.dot(xsys.B)
152+
zsys.B = Tzx @ xsys.B
153153

154154
return zsys, Tzx
155155

@@ -189,13 +189,13 @@ def rsolve(M, y):
189189

190190
# Update the system matrices
191191
if not inverse:
192-
zsys.A = rsolve(T, dot(T, zsys.A)) / timescale
193-
zsys.B = dot(T, zsys.B) / timescale
192+
zsys.A = rsolve(T, T @ zsys.A) / timescale
193+
zsys.B = T @ zsys.B / timescale
194194
zsys.C = rsolve(T, zsys.C)
195195
else:
196-
zsys.A = solve(T, zsys.A).dot(T) / timescale
196+
zsys.A = solve(T, zsys.A) @ T / timescale
197197
zsys.B = solve(T, zsys.B) / timescale
198-
zsys.C = zsys.C.dot(T)
198+
zsys.C = zsys.C @ T
199199

200200
return zsys
201201

@@ -405,8 +405,8 @@ def bdschur(a, condmax=None, sort=None):
405405
permidx = np.hstack([blkidxs[i] for i in sortidx])
406406
rperm = np.eye(amodal.shape[0])[permidx]
407407

408-
tmodal = tmodal.dot(rperm)
409-
amodal = rperm.dot(amodal).dot(rperm.T)
408+
tmodal = tmodal @ rperm
409+
amodal = rperm @ amodal @ rperm.T
410410
blksizes = blksizes[sortidx]
411411

412412
elif sort is None:

control/delay.py

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#
4343
# $Id$
4444

45-
from __future__ import division
4645

4746
__all__ = ['pade']
4847

control/flatsys/flatsys.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ def traj_const(null_coeffs):
462462
for type, fun, lb, ub in traj_constraints:
463463
if type == sp.optimize.LinearConstraint:
464464
# `fun` is A matrix associated with polytope...
465-
values.append(
466-
np.dot(fun, np.hstack([states, inputs])))
465+
values.append(fun @ np.hstack([states, inputs]))
467466
elif type == sp.optimize.NonlinearConstraint:
468467
values.append(fun(states, inputs))
469468
else:

control/flatsys/linflat.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def __init__(self, linsys, inputs=None, outputs=None, states=None,
110110

111111
# Compute the flat output variable z = C x
112112
Cfz = np.zeros(np.shape(linsys.C)); Cfz[0, 0] = 1
113-
self.Cf = np.dot(Cfz, Tr)
113+
self.Cf = Cfz @ Tr
114114

115115
# Compute the flat flag from the state (and input)
116116
def forward(self, x, u):
@@ -122,11 +122,11 @@ def forward(self, x, u):
122122
x = np.reshape(x, (-1, 1))
123123
u = np.reshape(u, (1, -1))
124124
zflag = [np.zeros(self.nstates + 1)]
125-
zflag[0][0] = np.dot(self.Cf, x)
125+
zflag[0][0] = self.Cf @ x
126126
H = self.Cf # initial state transformation
127127
for i in range(1, self.nstates + 1):
128-
zflag[0][i] = np.dot(H, np.dot(self.A, x) + np.dot(self.B, u))
129-
H = np.dot(H, self.A) # derivative for next iteration
128+
zflag[0][i] = H @ (self.A @ x + self.B @ u)
129+
H = H @ self.A # derivative for next iteration
130130
return zflag
131131

132132
# Compute state and input from flat flag
@@ -137,6 +137,6 @@ def reverse(self, zflag):
137137
138138
"""
139139
z = zflag[0][0:-1]
140-
x = np.dot(self.Tinv, z)
141-
u = zflag[0][-1] - np.dot(self.F, z)
140+
x = self.Tinv @ z
141+
u = zflag[0][-1] - self.F @ z
142142
return np.reshape(x, self.nstates), np.reshape(u, self.ninputs)

control/frdata.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
# Author: M.M. (Rene) van Paassen (using xferfcn.py as basis)
3636
# Date: 02 Oct 12
3737

38-
from __future__ import division
3938

4039
"""
4140
Frequency response data representation and functions.
@@ -48,7 +47,7 @@
4847
from warnings import warn
4948
import numpy as np
5049
from numpy import angle, array, empty, ones, \
51-
real, imag, absolute, eye, linalg, where, dot, sort
50+
real, imag, absolute, eye, linalg, where, sort
5251
from scipy.interpolate import splprep, splev
5352
from .lti import LTI, _process_frequency_response
5453
from . import config
@@ -302,7 +301,7 @@ def __mul__(self, other):
302301
fresp = empty((outputs, inputs, len(self.omega)),
303302
dtype=self.fresp.dtype)
304303
for i in range(len(self.omega)):
305-
fresp[:, :, i] = dot(self.fresp[:, :, i], other.fresp[:, :, i])
304+
fresp[:, :, i] = self.fresp[:, :, i] @ other.fresp[:, :, i]
306305
return FRD(fresp, self.omega,
307306
smooth=(self.ifunc is not None) and
308307
(other.ifunc is not None))
@@ -330,7 +329,7 @@ def __rmul__(self, other):
330329
fresp = empty((outputs, inputs, len(self.omega)),
331330
dtype=self.fresp.dtype)
332331
for i in range(len(self.omega)):
333-
fresp[:, :, i] = dot(other.fresp[:, :, i], self.fresp[:, :, i])
332+
fresp[:, :, i] = other.fresp[:, :, i] @ self.fresp[:, :, i]
334333
return FRD(fresp, self.omega,
335334
smooth=(self.ifunc is not None) and
336335
(other.ifunc is not None))
@@ -538,6 +537,7 @@ def feedback(self, other=1, sign=-1):
538537
"FRD.feedback, inputs/outputs mismatch")
539538

540539
# TODO: handle omega re-mapping
540+
541541
# reorder array axes in order to leverage numpy broadcasting
542542
myfresp = np.moveaxis(self.fresp, 2, 0)
543543
otherfresp = np.moveaxis(other.fresp, 2, 0)

control/iosys.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -843,14 +843,14 @@ def _update_params(self, params={}, warning=True):
843843

844844
def _rhs(self, t, x, u):
845845
# Convert input to column vector and then change output to 1D array
846-
xdot = np.dot(self.A, np.reshape(x, (-1, 1))) \
847-
+ np.dot(self.B, np.reshape(u, (-1, 1)))
846+
xdot = self.A @ np.reshape(x, (-1, 1)) \
847+
+ self.B @ np.reshape(u, (-1, 1))
848848
return np.array(xdot).reshape((-1,))
849849

850850
def _out(self, t, x, u):
851851
# Convert input to column vector and then change output to 1D array
852-
y = np.dot(self.C, np.reshape(x, (-1, 1))) \
853-
+ np.dot(self.D, np.reshape(u, (-1, 1)))
852+
y = self.C @ np.reshape(x, (-1, 1)) \
853+
+ self.D @ np.reshape(u, (-1, 1))
854854
return np.array(y).reshape((-1,))
855855

856856

@@ -1197,7 +1197,7 @@ def _out(self, t, x, u):
11971197
ulist, ylist = self._compute_static_io(t, x, u)
11981198

11991199
# Make the full set of subsystem outputs to system output
1200-
return np.dot(self.output_map, ylist)
1200+
return self.output_map @ ylist
12011201

12021202
def _compute_static_io(self, t, x, u):
12031203
# Figure out the total number of inputs and outputs
@@ -1239,7 +1239,7 @@ def _compute_static_io(self, t, x, u):
12391239
output_index += sys.noutputs
12401240

12411241
# Compute inputs based on connection map
1242-
new_ulist = np.dot(self.connect_map, ylist[:noutputs]) \
1242+
new_ulist = self.connect_map @ ylist[:noutputs] \
12431243
+ np.dot(self.input_map, u)
12441244

12451245
# Check to see if any of the inputs changed

control/margins.py

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
margins.margin
1010
"""
1111

12-
# Python 3 compatibility (needs to go here)
13-
from __future__ import print_function
14-
1512
"""Copyright (c) 2011 by California Institute of Technology
1613
All rights reserved.
1714

0 commit comments

Comments
 (0)