Changeset 721
- Timestamp:
- 08/09/10 13:04:56 (1 year ago)
- Files:
-
- PythonPackages/FuncDesigner/FuncDesigner/ooFun.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
PythonPackages/FuncDesigner/FuncDesigner/ooFun.py
r720 r721 22 22 SparseMatrixConstructor = lambda *args, **kwargs: scipy.sparse.lil_matrix(*args, **kwargs) 23 23 from scipy import sparse 24 from scipy.sparse import hstack as HstackSP 24 from scipy.sparse import hstack as HstackSP, isspmatrix_csc, isspmatrix_csr 25 25 def Hstack(Tuple): 26 26 ind = where([isscalar(elem) or prod(elem.shape)!=0 for elem in Tuple])[0].tolist() … … 728 728 else: 729 729 t1, t2 = self._considerSparse(t1, val) 730 if t1.ndim > 1 or t2.ndim > 1:731 # warning! t1,t2 can be sparse matrices, so I don't use t = atleast_2d(t) directly732 if t2.ndim < 2:733 assert t1.ndim > 1, 'error in FuncDesigner kernel, inform developers'734 if t1.shape[1] != t2.shape[0]:735 t2 = t2.reshape(1, -1)736 else:737 # hence these are ndarrays738 if self._getFuncCalcEngine(x).size > 1:739 t1 = t1.reshape(-1, 1)740 t2 = t2.reshape(1, -1)741 else:742 t1 = t1.reshape(1, -1)743 t2 = t2.reshape(-1, 1)730 # if t1.ndim > 1 or t2.ndim > 1: 731 # # warning! t1,t2 can be sparse matrices, so I don't use t = atleast_2d(t) directly 732 # if t2.ndim < 2: 733 # #assert t1.ndim > 1, 'error in FuncDesigner kernel, inform developers' 734 # if t1.shape[1] != t2.shape[0]: 735 # t2 = t2.reshape(1, -1) 736 # else: 737 # # hence these are ndarrays 738 # if self._getFuncCalcEngine(x).size > 1: 739 # t1 = t1.reshape(-1, 1) 740 # t2 = t2.reshape(1, -1) 741 # else: 742 # t1 = t1.reshape(1, -1) 743 # t2 = t2.reshape(-1, 1) 744 744 745 if not (isinstance(t1, ndarray) and isinstance(t2, ndarray)):745 if not type(t1) == type(t2) == ndarray: 746 746 # CHECKME: is it trigger somewhere? 747 747 if not scipyInstalled: 748 748 self.pWarn(scipyAbsentMsg) 749 rr = atleast_1d(dot(t1, t2))749 rr = dot(t1, t2) 750 750 else: 751 t1 = t1 if is instance(t1, scipy.sparse.csc_matrix) else t1.tocsc() if isspmatrix(t1) else scipy.sparse.csc_matrix(t1)752 t2 = t2 if is instance(t2, scipy.sparse.csr_matrix) else t2.tocsr() if isspmatrix(t2) else scipy.sparse.csr_matrix(t2)751 t1 = t1 if isspmatrix_csc(t1) else t1.tocsc() if isspmatrix(t1) else scipy.sparse.csc_matrix(t1) 752 t2 = t2 if isspmatrix_csr(t2) else t2.tocsr() if isspmatrix(t2) else scipy.sparse.csr_matrix(t2) 753 753 if t2.shape[0] != t1.shape[1]: 754 754 if t2.shape[1] == t1.shape[1]: … … 760 760 rr = rr.toarray() 761 761 else: 762 rr = atleast_1d(dot(t1, t2))762 rr = dot(t1, t2) 763 763 #assert rr.ndim>1 764 764 … … 775 775 r[key] = rr 776 776 777 dp = dict([(key, Copy(value)) for key, value in r.items()]) 778 779 self._d_val_prev = dp 777 self._d_val_prev = dict([(key, Copy(value)) for key, value in r.items()]) 780 778 self._d_key_prev = dict([(elem, Copy(x[elem])) for elem in dep]) if involveStore else None 781 779 return r
