Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix invalid variable usages from wrapper outputs #79

Merged
merged 13 commits into from
Apr 10, 2020
32 changes: 18 additions & 14 deletions slycot/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# MA 02110-1301, USA.

from . import _wrapper
import warnings

def mc01td(dico,dp,p):
""" dp,stable,nz = mc01td(dico,dp,p)
Expand Down Expand Up @@ -62,11 +63,11 @@ def mc01td(dico,dp,p):
e.info = out[-1]
raise e
if out[-1] == 1:
warings.warn('entry P(x) is the zero polynomial.')
warnings.warn('entry P(x) is the zero polynomial.')
if out[-1] == 2:
warings.warn('P(x) may have zeros very close to stability boundary.')
warnings.warn('P(x) may have zeros very close to stability boundary.')
if out[-2] > 0:
warnings.warn('The degree of P(x) has been reduced to %i' %(dp-k))
warnings.warn('The degree of P(x) has been reduced to %i' %(dp-out[-2]))
return out[:-2]


Expand Down Expand Up @@ -127,7 +128,7 @@ def mb05md(a, delta, balanc='N'):
the (right) eigenvector matrix of A, where Lambda is the
diagonal matrix of eigenvalues.

VALr : output rank-1 array('c') with bounds (n)
VAL : output rank-1 array('c') with bounds (n)
Contains the eigenvalues of the matrix A. The eigenvalues
are unordered except that complex conjugate pairs of values
appear consecutively with the eigenvalue having positive
Expand All @@ -137,19 +138,21 @@ def mb05md(a, delta, balanc='N'):
arg_list = [ 'balanc', 'n', 'delta', 'a', 'lda'+hidden, 'v', 'ldv'+hidden,
'y','ldy'+hidden,'valr','vali',
'iwork'+hidden,'dwork'+hidden,'ldwork'+hidden,'info'+hidden]
out = _wrapper.mb05md(balanc=balanc,n=min(a.shape),delta=delta,a=a)
if out[-1] == 0:
return out[:-1]
elif out[-1] < 0:
error_text = "The following argument had an illegal value: "+arg_list[-out[-1]-1]
elif out[-1] > 0 and out[-1] <= n:
error_text = "Incomplete eigenvalue calculation, missing %i eigenvalues" % out[-1]
elif out[-1] == n+1:
n=min(a.shape)
(Ar,Vr,Yr,VALr,VALi,INFO) = _wrapper.mb05md(balanc=balanc,n=n,delta=delta,a=a)
if INFO == 0:
VAL=VALr+1J*VALi
return (Ar,Vr,Yr,VAL)
bnavigator marked this conversation as resolved.
Show resolved Hide resolved
elif INFO < 0:
error_text = "The following argument had an illegal value: "+arg_list[-INFO-1]
elif INFO > 0 and INFO <= n:
error_text = "Incomplete eigenvalue calculation, missing %i eigenvalues" % INFO
elif INFO == n+1:
error_text = "Eigenvector matrix singular"
elif out[-1] == n+2:
elif INFO == n+2:
error_text = "A matrix defective"
e = ValueError(error_text)
e.info = out[-1]
e.info = INFO
raise e

"""
Expand Down Expand Up @@ -187,6 +190,7 @@ def mb05nd(a, delta, tol=1e-7):
'exint', 'ldexin'+hidden, 'tol', 'iwork'+hidden,
'dwork'+hidden, 'ldwork'+hidden]
out = _wrapper.mb05nd(n=min(a.shape), delta=delta, a=a, tol=tol)
n = out[-4]
if out[-1] == 0:
return out[:-1]
elif out[-1] < 0:
Expand Down
23 changes: 0 additions & 23 deletions slycot/src/mathematical.pyf

This file was deleted.

8 changes: 4 additions & 4 deletions slycot/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,20 +690,20 @@ def sb02od(n,m,A,B,Q,R,dico,p=None,L=None,fact='N',uplo='U',sort='S',tol=0.0,ldw
out = _wrapper.sb02od_n(dico,n,m,A,B,Q,R,L,uplo=uplo,jobl=jobl,sort=sort,tol=tol,ldwork=ldwork)
if fact == 'C':
if p is None:
p = shape(Q)[0]
p = _np.shape(Q)[0]
out = _wrapper.sb02od_c(dico,n,m,p,A,B,Q,R,L,uplo=uplo,jobl=jobl,sort=sort,tol=tol,ldwork=ldwork)
if fact == 'D':
if p is None:
p = shape(R)[0]
p = _np.shape(R)[0]
out = _wrapper.sb02od_d(dico,n,m,p,A,B,Q,R,L,uplo=uplo,jobl=jobl,sort=sort,tol=tol,ldwork=ldwork)
if fact == 'B':
if p is None:
p = shape(Q)[0]
p = _np.shape(Q)[0]
out = _wrapper.sb02od_b(dico,n,m,p,A,B,Q,R,L,uplo=uplo,jobl=jobl,sort=sort,tol=tol,ldwork=ldwork)
if out[-1] < 0:
error_text = "The following argument had an illegal value: "+arg_list[-out[-1]-1]
e = ValueError(error_text)
e.info = info
e.info = out[-1]
raise e
if out[-1] == 1:
e = ValueError('the computed extended matrix pencil is singular, possibly due to rounding errors')
Expand Down
4 changes: 2 additions & 2 deletions slycot/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ def td04ad(rowcol,m,p,index,dcoeff,ucoeff,tol=0.0,ldwork=None):

kdcoef = max(index)+1
if rowcol == 'R':
porm = p
# porm = p
bnavigator marked this conversation as resolved.
Show resolved Hide resolved
if ucoeff.ndim != 3:
e = ValueError("The numerator is not a 3D array!")
e.info = -7
Expand All @@ -665,7 +665,7 @@ def td04ad(rowcol,m,p,index,dcoeff,ucoeff,tol=0.0,ldwork=None):
raise e
out = _wrapper.td04ad_r(m,p,index,dcoeff,ucoeff,n,tol,ldwork)
elif rowcol == 'C':
porm = m
# porm = m
if ucoeff.ndim != 3:
e = ValueError("The numerator is not a 3D array!")
e.info = -7
Expand Down