|
15 | 15 | import scipy.linalg.blas as blas |
16 | 16 | from scipy.sparse import isspmatrix |
17 | 17 |
|
18 | | -# from scipy.sparse.linalg import LinearOperator, aslinearoperator |
19 | | -from scipy.sparse.sputils import isintlike |
20 | | - |
21 | 18 | __all__ = [ |
22 | 19 | "ArgumentError", |
23 | 20 | "AssumptionError", |
@@ -143,6 +140,13 @@ def shape_vecs(*args): |
143 | 140 | return flat_vecs, ret_args |
144 | 141 |
|
145 | 142 |
|
| 143 | +def isint(x): |
| 144 | + try: |
| 145 | + return int(x) == x |
| 146 | + except: |
| 147 | + return False |
| 148 | + |
| 149 | + |
146 | 150 | def ip_euclid(X, Y): |
147 | 151 | """Euclidean inner product. |
148 | 152 |
|
@@ -1369,7 +1373,7 @@ class LinearOperator(object): |
1369 | 1373 | """ |
1370 | 1374 |
|
1371 | 1375 | def __init__(self, shape, dtype, dot=None, dot_adj=None): |
1372 | | - if len(shape) != 2 or not isintlike(shape[0]) or not isintlike(shape[1]): |
| 1376 | + if len(shape) != 2 or not isint(shape[0]) or not isint(shape[1]): |
1373 | 1377 | raise LinearOperatorError("shape must be (m,n) with m and n " "integer") |
1374 | 1378 | self.shape = shape |
1375 | 1379 | self.dtype = numpy.dtype(dtype) # defaults to float64 |
@@ -1525,7 +1529,7 @@ def __init__(self, A, p): |
1525 | 1529 | raise LinearOperatorError("LinearOperator expected as A") |
1526 | 1530 | if A.shape[0] != A.shape[1]: |
1527 | 1531 | raise LinearOperatorError("square LinearOperator expected as A") |
1528 | | - if not isintlike(p): |
| 1532 | + if not isint(p): |
1529 | 1533 | raise LinearOperatorError("integer expected as p") |
1530 | 1534 | self.args = (A, p) |
1531 | 1535 | super(_PowerLinearOperator, self).__init__( |
|
0 commit comments