Package pypower :: Module remove_userfcn
[hide private]
[frames] | no frames]

Source Code for Module pypower.remove_userfcn

 1  # Copyright (C) 2009-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  """Removes a userfcn from the list to be called for a case. 
18  """ 
19   
20 -def remove_userfcn(ppc, stage, fcn):
21 """Removes a userfcn from the list to be called for a case. 22 23 A userfcn is a callback function that can be called automatically by 24 PYPOWER at one of various stages in a simulation. This function removes 25 the last instance of the userfcn for the given C{stage} with the function 26 handle specified by C{fcn}. 27 28 @see: L{add_userfcn}, L{run_userfcn}, L{toggle_reserves}, 29 L{toggle_iflims}, L{runopf_w_res} 30 31 @author: Ray Zimmerman (PSERC Cornell) 32 @author: Richard Lincoln 33 """ 34 n = len(ppc['userfcn'][stage]) 35 36 for k in range(n - 1, -1, -1): 37 if ppc['userfcn'][stage][k]['fcn'] == fcn: 38 del ppc['userfcn'][stage][k] 39 break 40 41 return ppc
42