|
5 | 5 | #
|
6 | 6 | # Author: Bjorn Olofsson
|
7 | 7 |
|
8 |
| -# Python 3 compatibility (needs to go here) |
9 |
| -from __future__ import print_function |
10 |
| - |
11 | 8 | # Copyright (c) 2011, All rights reserved.
|
12 | 9 |
|
13 | 10 | # Redistribution and use in source and binary forms, with or without
|
|
44 | 41 | from .exception import ControlSlycot, ControlArgument
|
45 | 42 | from .statesp import _ssmatrix
|
46 | 43 |
|
| 44 | +# Make sure we have access to the right slycot routines |
| 45 | +try: |
| 46 | + from slycot import sb03md57 |
| 47 | + # wrap without the deprecation warning |
| 48 | + def sb03md(n, C, A, U, dico, job='X',fact='N',trana='N',ldwork=None): |
| 49 | + ret = sb03md57(A, U, C, dico, job, fact, trana, ldwork) |
| 50 | + return ret[2:] |
| 51 | +except ImportError: |
| 52 | + try: |
| 53 | + from slycot import sb03md |
| 54 | + except ImportError: |
| 55 | + sb03md = None |
| 56 | + |
| 57 | +try: |
| 58 | + from slycot import sb04md |
| 59 | +except ImportError: |
| 60 | + sb04md = None |
| 61 | + |
| 62 | +try: |
| 63 | + from slycot import sb04qd |
| 64 | +except ImportError: |
| 65 | + sb0qmd = None |
| 66 | + |
| 67 | +try: |
| 68 | + from slycot import sg03ad |
| 69 | +except ImportError: |
| 70 | + sb04ad = None |
| 71 | + |
47 | 72 | __all__ = ['lyap', 'dlyap', 'dare', 'care']
|
48 | 73 |
|
49 | 74 | #
|
@@ -93,17 +118,12 @@ def lyap(A, Q, C=None, E=None):
|
93 | 118 | state space operations. See :func:`~control.use_numpy_matrix`.
|
94 | 119 | """
|
95 | 120 |
|
96 |
| - # Make sure we have access to the right slycot routines |
97 |
| - try: |
98 |
| - from slycot import sb03md |
99 |
| - except ImportError: |
| 121 | + if sb03md is None: |
100 | 122 | raise ControlSlycot("can't find slycot module 'sb03md'")
|
101 |
| - |
102 |
| - try: |
103 |
| - from slycot import sb04md |
104 |
| - except ImportError: |
| 123 | + if sb04md is None: |
105 | 124 | raise ControlSlycot("can't find slycot module 'sb04md'")
|
106 | 125 |
|
| 126 | + |
107 | 127 | # Reshape 1-d arrays
|
108 | 128 | if len(shape(A)) == 1:
|
109 | 129 | A = A.reshape(1, A.size)
|
@@ -279,19 +299,11 @@ def dlyap(A, Q, C=None, E=None):
|
279 | 299 | of the same dimension. """
|
280 | 300 |
|
281 | 301 | # Make sure we have access to the right slycot routines
|
282 |
| - try: |
283 |
| - from slycot import sb03md |
284 |
| - except ImportError: |
| 302 | + if sb03md is None: |
285 | 303 | raise ControlSlycot("can't find slycot module 'sb03md'")
|
286 |
| - |
287 |
| - try: |
288 |
| - from slycot import sb04qd |
289 |
| - except ImportError: |
| 304 | + if sb04qd is None: |
290 | 305 | raise ControlSlycot("can't find slycot module 'sb04qd'")
|
291 |
| - |
292 |
| - try: |
293 |
| - from slycot import sg03ad |
294 |
| - except ImportError: |
| 306 | + if sg03ad is None: |
295 | 307 | raise ControlSlycot("can't find slycot module 'sg03ad'")
|
296 | 308 |
|
297 | 309 | # Reshape 1-d arrays
|
|
0 commit comments