From 7ee165bed1a2a7acdbf077b91d98da42c5845674 Mon Sep 17 00:00:00 2001 From: Roberto Bucher Date: Thu, 11 Jul 2024 20:45:46 +0200 Subject: [PATCH] Compatibility with new versions of numpy and scipy --- resources/blocks/rcpBlk/linear/cssBlk.py | 6 +++--- resources/blocks/rcpBlk/linear/dssBlk.py | 4 ++-- resources/blocks/rcpBlk/linear/matmultBlk.py | 4 ++-- toolbox/supsictrl/supsictrl/ctrl_utils.py | 4 ++-- toolbox/supsisim/supsisim/RCPgen.py | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/resources/blocks/rcpBlk/linear/cssBlk.py b/resources/blocks/rcpBlk/linear/cssBlk.py index aefd6b28..1b9ce82c 100644 --- a/resources/blocks/rcpBlk/linear/cssBlk.py +++ b/resources/blocks/rcpBlk/linear/cssBlk.py @@ -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=[]): """ @@ -43,7 +43,7 @@ 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 @@ -51,7 +51,7 @@ def cssBlk(pin,pout,sys,X0=[]): 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 diff --git a/resources/blocks/rcpBlk/linear/dssBlk.py b/resources/blocks/rcpBlk/linear/dssBlk.py index ba29e72d..85861e4f 100644 --- a/resources/blocks/rcpBlk/linear/dssBlk.py +++ b/resources/blocks/rcpBlk/linear/dssBlk.py @@ -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=[]): """ @@ -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 diff --git a/resources/blocks/rcpBlk/linear/matmultBlk.py b/resources/blocks/rcpBlk/linear/matmultBlk.py index f5038a08..edb3bfdf 100644 --- a/resources/blocks/rcpBlk/linear/matmultBlk.py +++ b/resources/blocks/rcpBlk/linear/matmultBlk.py @@ -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): """ @@ -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))) diff --git a/toolbox/supsictrl/supsictrl/ctrl_utils.py b/toolbox/supsictrl/supsictrl/ctrl_utils.py index 3ebde732..df144ff3 100644 --- a/toolbox/supsictrl/supsictrl/ctrl_utils.py +++ b/toolbox/supsictrl/supsictrl/ctrl_utils.py @@ -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() diff --git a/toolbox/supsisim/supsisim/RCPgen.py b/toolbox/supsisim/supsisim/RCPgen.py index 93268ef5..34cf0ec9 100644 --- a/toolbox/supsisim/supsisim/RCPgen.py +++ b/toolbox/supsisim/supsisim/RCPgen.py @@ -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 @@ -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)): @@ -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)): @@ -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")