Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 1996-2011 Power System Engineering Research Center (PSERC) 2 # Copyright (C) 2011 Richard Lincoln 3 # 4 # PYPOWER is free software: you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published 6 # by the Free Software Foundation, either version 3 of the License, 7 # or (at your option) any later version. 8 # 9 # PYPOWER is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with PYPOWER. If not, see <http://www.gnu.org/licenses/>. 16 17 """Assigns B to A with one of the dimensions of A indexed. 18 """ 19 20 from numpy import ndim 21 2224 """Assigns B to A with one of the dimensions of A indexed. 25 26 @return: A after doing A(:, ..., :, IDX, :, ..., :) = B 27 where DIM determines in which dimension to place the IDX. 28 29 @see: L{get_reorder} 30 31 @author: Ray Zimmerman (PSERC Cornell) 32 @author: Richard Lincoln 33 """ 34 A = A.copy() 35 ndims = ndim(A) 36 if ndims == 1: 37 A[idx] = B 38 elif ndims == 2: 39 if dim == 0: 40 A[idx, :] = B 41 elif dim == 1: 42 A[:, idx] = B 43 else: 44 raise ValueError, 'dim (%d) may be 0 or 1' % dim 45 else: 46 raise ValueError, 'number of dimensions (%d) may be 1 or 2' % dim 47 48 return A49
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jul 29 18:21:30 2011 | http://epydoc.sourceforge.net |