Skip to content

Commit

Permalink
Compatibility with new versions of numpy and scipy
Browse files Browse the repository at this point in the history
  • Loading branch information
robertobucher committed Jul 11, 2024
1 parent 12774fd commit 7ee165b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions resources/blocks/rcpBlk/linear/cssBlk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from supsisim.RCPblk import RCPblk
from control import tf2ss, TransferFunction
from numpy import reshape, hstack, mat, shape, size, zeros
from numpy import reshape, hstack, asmatrix, shape, size, zeros

def cssBlk(pin,pout,sys,X0=[]):
"""
Expand Down Expand Up @@ -43,15 +43,15 @@ def cssBlk(pin,pout,sys,X0=[]):
if(size(X0) == nx):
X0 = reshape(X0,(1,size(X0)),'C')
else:
X0 = mat(zeros((1,nx)))
X0 = asmatrix(zeros((1,nx)))

indA = 1
indB = indA + nx*nx
indC = indB + nx*ni
indD = indC + nx*no
indX = indD + ni*no
intPar = [nx,ni,no, indA, indB, indC, indD, indX]
realPar = hstack((mat([0.0]),a,b,c,d,X0))
realPar = hstack((asmatrix([0.0]),a,b,c,d,X0))

if d.any() == True:
uy = 1
Expand Down
4 changes: 2 additions & 2 deletions resources/blocks/rcpBlk/linear/dssBlk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from supsisim.RCPblk import RCPblk
from control import tf2ss, TransferFunction
from numpy import reshape, hstack, mat, shape, size, zeros
from numpy import reshape, hstack, asmatrix, shape, size, zeros

def dssBlk(pin,pout,sys,X0=[]):
"""
Expand Down Expand Up @@ -44,7 +44,7 @@ def dssBlk(pin,pout,sys,X0=[]):
if(size(X0) == nx):
X0 = reshape(X0,(1,size(X0)),'C')
else:
X0 = mat(zeros((1,nx)))
X0 = asmatrix(zeros((1,nx)))

indA = 0
indB = nx*nx
Expand Down
4 changes: 2 additions & 2 deletions resources/blocks/rcpBlk/linear/matmultBlk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from supsisim.RCPblk import RCPblk
from control import tf2ss, TransferFunction
from numpy import reshape, shape, size, mat
from numpy import reshape, shape, size, asmatrix

def matmultBlk(pin, pout, Gains):
"""
Expand All @@ -21,7 +21,7 @@ def matmultBlk(pin, pout, Gains):
"""

Gains = mat(Gains)
Gains = asmatrix(Gains)
n,m = shape(Gains)
if(size(pin) != m):
raise ValueError("Block should have %i input port; received %i." % (m,size(pin)))
Expand Down
4 changes: 2 additions & 2 deletions toolbox/supsictrl/supsictrl/ctrl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@ def set_aw(sys,poles):
"""
sys = ct.ss(sys)
Ts = sys.dt
den_old = sp.poly(la.eigvals(sys.A))
den_old = np.poly(la.eigvals(sys.A))
sys = ct.tf(sys)
den = sp.poly(poles)
den = np.poly(poles)
tmp = ct.tf(den_old,den,sys.dt)
sys_in = tmp*sys
sys_in = sys_in.minreal()
Expand Down
8 changes: 4 additions & 4 deletions toolbox/supsisim/supsisim/RCPgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
sch2blks - Generate block list fron schematic
"""
from numpy import nonzero, ones, mat, size, array, zeros
from numpy import nonzero, ones, asmatrix, size, array, zeros
from os import environ
import copy
import sys
Expand Down Expand Up @@ -99,7 +99,7 @@ def genCode(model, Tsamp, blocks, rkstep = 10):
blk = Blocks[n]
if (size(blk.realPar) != 0):
strLn = "static double realPar_" + str(n) +"[] = {"
strLn += str(mat(blk.realPar).tolist())[2:-2] + "};\n"
strLn += str(asmatrix(blk.realPar).tolist())[2:-2] + "};\n"
strLn += "static char *realParNames_" + str(n) + "[] = {"
tmp = 0
if (size(blk.realPar) != size(blk.realParNames)):
Expand All @@ -118,7 +118,7 @@ def genCode(model, Tsamp, blocks, rkstep = 10):
f.write(strLn)
if (size(blk.intPar) != 0):
strLn = "static int intPar_" + str(n) +"[] = {"
strLn += str(mat(blk.intPar).tolist())[2:-2] + "};\n"
strLn += str(asmatrix(blk.intPar).tolist())[2:-2] + "};\n"
strLn += "static char *intParNames_" + str(n) + "[] = {"
tmp = 0
for i in range(0, size(blk.intPar)):
Expand All @@ -129,7 +129,7 @@ def genCode(model, Tsamp, blocks, rkstep = 10):
strLn += "};\n"
f.write(strLn)
strLn = "static int nx_" + str(n) +"[] = {"
strLn += str(mat(blk.nx).tolist())[2:-2] + "};\n"
strLn += str(asmatrix(blk.nx).tolist())[2:-2] + "};\n"
f.write(strLn)
f.write("\n")

Expand Down

0 comments on commit 7ee165b

Please sign in to comment.