diff options
author | Travis Oliphant <oliphant@enthought.com> | 2005-11-18 20:32:30 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2005-11-18 20:32:30 +0000 |
commit | d9b385071c9b7ca71ef3b3da693770dd078c9fae (patch) | |
tree | 7370a0f17f8db48fd5de9e5a0221b8d3cc4dd7dd /scipy/base/matrix.py | |
parent | 4f869af51776d774f7555313ce879a1100eb8f80 (diff) | |
download | numpy-d9b385071c9b7ca71ef3b3da693770dd078c9fae.tar.gz |
Fixed autocasting tests to casting tests.. Inplace casting is not supported.
Diffstat (limited to 'scipy/base/matrix.py')
-rw-r--r-- | scipy/base/matrix.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/scipy/base/matrix.py b/scipy/base/matrix.py index 623ae1660..372b0ad38 100644 --- a/scipy/base/matrix.py +++ b/scipy/base/matrix.py @@ -1,5 +1,5 @@ -__all__ = ['matrix', 'bmat', 'mat'] +__all__ = ['matrix', 'bmat', 'mat', 'asmatrix'] import numeric as N from numeric import ArrayType, concatenate, integer, multiply, power @@ -44,6 +44,12 @@ def _convert_from_string(data): newdata.append(newrow) return newdata +def asmatrix(data, dtype=None): + """ Returns 'data' as a matrix. Unlike matrix(), no copy is performed + if 'data' is already a matrix or array. Equivalent to: + matrix(data, copy=False) + """ + return matrix(data, dtype=dtype, copy=False) class matrix(N.ndarray): __array_priority__ = 10.0 @@ -75,16 +81,16 @@ class matrix(N.ndarray): elif ndim == 1: shape = (1,shape[0]) - fortran = False; - if (ndim == 2) and arr.flags['FORTRAN']: + fortran = False + if (ndim == 2) and arr.flags.fortran: fortran = True - - if not (fortran or arr.flags['CONTIGUOUS']): + + if not (fortran or arr.flags.contiguous): arr = arr.copy() ret = N.ndarray.__new__(matrix, shape, arr.dtype, buffer=arr, fortran=fortran, - swap=arr.flags['S']) + swap=arr.flags.swapped) return ret def __array_finalize__(self, obj): |