partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
get_re_experiment
Returns an experiment that uses the Roth-Erev learning method.
examples/pyreto/thesis/ex5_1.py
def get_re_experiment(case, minor=1): """ Returns an experiment that uses the Roth-Erev learning method. """ gen = case.generators profile = array([1.0]) maxSteps = len(profile) experimentation = 0.55 recency = 0.3 tau = 100.0 decay = 0.99#9995 market = pyreto.SmartMarket(case,...
def get_re_experiment(case, minor=1): """ Returns an experiment that uses the Roth-Erev learning method. """ gen = case.generators profile = array([1.0]) maxSteps = len(profile) experimentation = 0.55 recency = 0.3 tau = 100.0 decay = 0.99#9995 market = pyreto.SmartMarket(case,...
[ "Returns", "an", "experiment", "that", "uses", "the", "Roth", "-", "Erev", "learning", "method", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/examples/pyreto/thesis/ex5_1.py#L44-L76
[ "def", "get_re_experiment", "(", "case", ",", "minor", "=", "1", ")", ":", "gen", "=", "case", ".", "generators", "profile", "=", "array", "(", "[", "1.0", "]", ")", "maxSteps", "=", "len", "(", "profile", ")", "experimentation", "=", "0.55", "recency"...
916514255db1ae1661406f0283df756baf960d14
train
get_q_experiment
Returns an experiment that uses Q-learning.
examples/pyreto/thesis/ex5_1.py
def get_q_experiment(case, minor=1): """ Returns an experiment that uses Q-learning. """ gen = case.generators profile = array([1.0]) maxSteps = len(profile) if minor == 1: alpha = 0.3 # Learning rate. gamma = 0.99 # Discount factor # The closer epsilon gets to 0, the m...
def get_q_experiment(case, minor=1): """ Returns an experiment that uses Q-learning. """ gen = case.generators profile = array([1.0]) maxSteps = len(profile) if minor == 1: alpha = 0.3 # Learning rate. gamma = 0.99 # Discount factor # The closer epsilon gets to 0, the m...
[ "Returns", "an", "experiment", "that", "uses", "Q", "-", "learning", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/examples/pyreto/thesis/ex5_1.py#L79-L133
[ "def", "get_q_experiment", "(", "case", ",", "minor", "=", "1", ")", ":", "gen", "=", "case", ".", "generators", "profile", "=", "array", "(", "[", "1.0", "]", ")", "maxSteps", "=", "len", "(", "profile", ")", "if", "minor", "==", "1", ":", "alpha"...
916514255db1ae1661406f0283df756baf960d14
train
Generator.q_limited
Is the machine at it's limit of reactive power?
pylon/generator.py
def q_limited(self): """ Is the machine at it's limit of reactive power? """ if (self.q >= self.q_max) or (self.q <= self.q_min): return True else: return False
def q_limited(self): """ Is the machine at it's limit of reactive power? """ if (self.q >= self.q_max) or (self.q <= self.q_min): return True else: return False
[ "Is", "the", "machine", "at", "it", "s", "limit", "of", "reactive", "power?" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L156-L162
[ "def", "q_limited", "(", "self", ")", ":", "if", "(", "self", ".", "q", ">=", "self", ".", "q_max", ")", "or", "(", "self", ".", "q", "<=", "self", ".", "q_min", ")", ":", "return", "True", "else", ":", "return", "False" ]
916514255db1ae1661406f0283df756baf960d14
train
Generator.total_cost
Computes total cost for the generator at the given output level.
pylon/generator.py
def total_cost(self, p=None, p_cost=None, pcost_model=None): """ Computes total cost for the generator at the given output level. """ p = self.p if p is None else p p_cost = self.p_cost if p_cost is None else p_cost pcost_model = self.pcost_model if pcost_model is None else pcost...
def total_cost(self, p=None, p_cost=None, pcost_model=None): """ Computes total cost for the generator at the given output level. """ p = self.p if p is None else p p_cost = self.p_cost if p_cost is None else p_cost pcost_model = self.pcost_model if pcost_model is None else pcost...
[ "Computes", "total", "cost", "for", "the", "generator", "at", "the", "given", "output", "level", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L180-L220
[ "def", "total_cost", "(", "self", ",", "p", "=", "None", ",", "p_cost", "=", "None", ",", "pcost_model", "=", "None", ")", ":", "p", "=", "self", ".", "p", "if", "p", "is", "None", "else", "p", "p_cost", "=", "self", ".", "p_cost", "if", "p_cost"...
916514255db1ae1661406f0283df756baf960d14
train
Generator.pwl_to_poly
Converts the first segment of the pwl cost to linear quadratic. FIXME: Curve-fit for all segments.
pylon/generator.py
def pwl_to_poly(self): """ Converts the first segment of the pwl cost to linear quadratic. FIXME: Curve-fit for all segments. """ if self.pcost_model == PW_LINEAR: x0 = self.p_cost[0][0] y0 = self.p_cost[0][1] x1 = self.p_cost[1][0] y1 = se...
def pwl_to_poly(self): """ Converts the first segment of the pwl cost to linear quadratic. FIXME: Curve-fit for all segments. """ if self.pcost_model == PW_LINEAR: x0 = self.p_cost[0][0] y0 = self.p_cost[0][1] x1 = self.p_cost[1][0] y1 = se...
[ "Converts", "the", "first", "segment", "of", "the", "pwl", "cost", "to", "linear", "quadratic", ".", "FIXME", ":", "Curve", "-", "fit", "for", "all", "segments", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L260-L275
[ "def", "pwl_to_poly", "(", "self", ")", ":", "if", "self", ".", "pcost_model", "==", "PW_LINEAR", ":", "x0", "=", "self", ".", "p_cost", "[", "0", "]", "[", "0", "]", "y0", "=", "self", ".", "p_cost", "[", "0", "]", "[", "1", "]", "x1", "=", ...
916514255db1ae1661406f0283df756baf960d14
train
Generator.poly_to_pwl
Sets the piece-wise linear cost attribute, converting the polynomial cost variable by evaluating at zero and then at n_points evenly spaced points between p_min and p_max.
pylon/generator.py
def poly_to_pwl(self, n_points=4): """ Sets the piece-wise linear cost attribute, converting the polynomial cost variable by evaluating at zero and then at n_points evenly spaced points between p_min and p_max. """ assert self.pcost_model == POLYNOMIAL p_min = self.p_min ...
def poly_to_pwl(self, n_points=4): """ Sets the piece-wise linear cost attribute, converting the polynomial cost variable by evaluating at zero and then at n_points evenly spaced points between p_min and p_max. """ assert self.pcost_model == POLYNOMIAL p_min = self.p_min ...
[ "Sets", "the", "piece", "-", "wise", "linear", "cost", "attribute", "converting", "the", "polynomial", "cost", "variable", "by", "evaluating", "at", "zero", "and", "then", "at", "n_points", "evenly", "spaced", "points", "between", "p_min", "and", "p_max", "." ...
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L278-L308
[ "def", "poly_to_pwl", "(", "self", ",", "n_points", "=", "4", ")", ":", "assert", "self", ".", "pcost_model", "==", "POLYNOMIAL", "p_min", "=", "self", ".", "p_min", "p_max", "=", "self", ".", "p_max", "p_cost", "=", "[", "]", "if", "p_min", ">", "0....
916514255db1ae1661406f0283df756baf960d14
train
Generator.get_offers
Returns quantity and price offers created from the cost function.
pylon/generator.py
def get_offers(self, n_points=6): """ Returns quantity and price offers created from the cost function. """ from pyreto.smart_market import Offer qtyprc = self._get_qtyprc(n_points) return [Offer(self, qty, prc) for qty, prc in qtyprc]
def get_offers(self, n_points=6): """ Returns quantity and price offers created from the cost function. """ from pyreto.smart_market import Offer qtyprc = self._get_qtyprc(n_points) return [Offer(self, qty, prc) for qty, prc in qtyprc]
[ "Returns", "quantity", "and", "price", "offers", "created", "from", "the", "cost", "function", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L311-L317
[ "def", "get_offers", "(", "self", ",", "n_points", "=", "6", ")", ":", "from", "pyreto", ".", "smart_market", "import", "Offer", "qtyprc", "=", "self", ".", "_get_qtyprc", "(", "n_points", ")", "return", "[", "Offer", "(", "self", ",", "qty", ",", "prc...
916514255db1ae1661406f0283df756baf960d14
train
Generator.get_bids
Returns quantity and price bids created from the cost function.
pylon/generator.py
def get_bids(self, n_points=6): """ Returns quantity and price bids created from the cost function. """ from pyreto.smart_market import Bid qtyprc = self._get_qtyprc(n_points) return [Bid(self, qty, prc) for qty, prc in qtyprc]
def get_bids(self, n_points=6): """ Returns quantity and price bids created from the cost function. """ from pyreto.smart_market import Bid qtyprc = self._get_qtyprc(n_points) return [Bid(self, qty, prc) for qty, prc in qtyprc]
[ "Returns", "quantity", "and", "price", "bids", "created", "from", "the", "cost", "function", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L320-L326
[ "def", "get_bids", "(", "self", ",", "n_points", "=", "6", ")", ":", "from", "pyreto", ".", "smart_market", "import", "Bid", "qtyprc", "=", "self", ".", "_get_qtyprc", "(", "n_points", ")", "return", "[", "Bid", "(", "self", ",", "qty", ",", "prc", "...
916514255db1ae1661406f0283df756baf960d14
train
Generator._get_qtyprc
Returns a list of tuples of the form (qty, prc) created from the cost function. If the cost function is polynomial it will be converted to piece-wise linear using poly_to_pwl(n_points).
pylon/generator.py
def _get_qtyprc(self, n_points=6): """ Returns a list of tuples of the form (qty, prc) created from the cost function. If the cost function is polynomial it will be converted to piece-wise linear using poly_to_pwl(n_points). """ if self.pcost_model == POLYNOMIAL: # C...
def _get_qtyprc(self, n_points=6): """ Returns a list of tuples of the form (qty, prc) created from the cost function. If the cost function is polynomial it will be converted to piece-wise linear using poly_to_pwl(n_points). """ if self.pcost_model == POLYNOMIAL: # C...
[ "Returns", "a", "list", "of", "tuples", "of", "the", "form", "(", "qty", "prc", ")", "created", "from", "the", "cost", "function", ".", "If", "the", "cost", "function", "is", "polynomial", "it", "will", "be", "converted", "to", "piece", "-", "wise", "l...
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L329-L351
[ "def", "_get_qtyprc", "(", "self", ",", "n_points", "=", "6", ")", ":", "if", "self", ".", "pcost_model", "==", "POLYNOMIAL", ":", "# Convert polynomial cost function to piece-wise linear.", "self", ".", "poly_to_pwl", "(", "n_points", ")", "n_segments", "=", "len...
916514255db1ae1661406f0283df756baf960d14
train
Generator.offers_to_pwl
Updates the piece-wise linear total cost function using the given offer blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info.
pylon/generator.py
def offers_to_pwl(self, offers): """ Updates the piece-wise linear total cost function using the given offer blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info. """ assert no...
def offers_to_pwl(self, offers): """ Updates the piece-wise linear total cost function using the given offer blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info. """ assert no...
[ "Updates", "the", "piece", "-", "wise", "linear", "total", "cost", "function", "using", "the", "given", "offer", "blocks", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L420-L466
[ "def", "offers_to_pwl", "(", "self", ",", "offers", ")", ":", "assert", "not", "self", ".", "is_load", "# Only apply offers associated with this generator.", "g_offers", "=", "[", "offer", "for", "offer", "in", "offers", "if", "offer", ".", "generator", "==", "s...
916514255db1ae1661406f0283df756baf960d14
train
Generator.bids_to_pwl
Updates the piece-wise linear total cost function using the given bid blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info.
pylon/generator.py
def bids_to_pwl(self, bids): """ Updates the piece-wise linear total cost function using the given bid blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info. """ assert self.is_...
def bids_to_pwl(self, bids): """ Updates the piece-wise linear total cost function using the given bid blocks. Based on off2case.m from MATPOWER by Ray Zimmerman, developed at PSERC Cornell. See U{http://www.pserc.cornell.edu/matpower/} for more info. """ assert self.is_...
[ "Updates", "the", "piece", "-", "wise", "linear", "total", "cost", "function", "using", "the", "given", "bid", "blocks", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L469-L508
[ "def", "bids_to_pwl", "(", "self", ",", "bids", ")", ":", "assert", "self", ".", "is_load", "# Apply only those bids associated with this dispatchable load.", "vl_bids", "=", "[", "bid", "for", "bid", "in", "bids", "if", "bid", ".", "vLoad", "==", "self", "]", ...
916514255db1ae1661406f0283df756baf960d14
train
Generator._offbids_to_points
Returns a list of points for a piece-wise linear function from the given offer/bid blocks.
pylon/generator.py
def _offbids_to_points(self, offbids, arebids=False): """ Returns a list of points for a piece-wise linear function from the given offer/bid blocks. """ # Sort offers/bids by price in ascending order. offbids.sort(key=lambda x: x.price, reverse=arebids) points = [(0.0, o...
def _offbids_to_points(self, offbids, arebids=False): """ Returns a list of points for a piece-wise linear function from the given offer/bid blocks. """ # Sort offers/bids by price in ascending order. offbids.sort(key=lambda x: x.price, reverse=arebids) points = [(0.0, o...
[ "Returns", "a", "list", "of", "points", "for", "a", "piece", "-", "wise", "linear", "function", "from", "the", "given", "offer", "/", "bid", "blocks", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L511-L534
[ "def", "_offbids_to_points", "(", "self", ",", "offbids", ",", "arebids", "=", "False", ")", ":", "# Sort offers/bids by price in ascending order.", "offbids", ".", "sort", "(", "key", "=", "lambda", "x", ":", "x", ".", "price", ",", "reverse", "=", "arebids",...
916514255db1ae1661406f0283df756baf960d14
train
Generator._adjust_limits
Sets the active power limits, 'p_max' and 'p_min', according to the pwl cost function points.
pylon/generator.py
def _adjust_limits(self): """ Sets the active power limits, 'p_max' and 'p_min', according to the pwl cost function points. """ if not self.is_load: # self.p_min = min([point[0] for point in self.p_cost]) self.p_max = max([point[0] for point in self.p_cost]) ...
def _adjust_limits(self): """ Sets the active power limits, 'p_max' and 'p_min', according to the pwl cost function points. """ if not self.is_load: # self.p_min = min([point[0] for point in self.p_cost]) self.p_max = max([point[0] for point in self.p_cost]) ...
[ "Sets", "the", "active", "power", "limits", "p_max", "and", "p_min", "according", "to", "the", "pwl", "cost", "function", "points", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/generator.py#L537-L549
[ "def", "_adjust_limits", "(", "self", ")", ":", "if", "not", "self", ".", "is_load", ":", "# self.p_min = min([point[0] for point in self.p_cost])", "self", ".", "p_max", "=", "max", "(", "[", "point", "[", "0", "]", "for", "point", "in", "self", "....
916514255db1ae1661406f0283df756baf960d14
train
MarketEnvironment.getSensors
Returns the currently visible state of the world as a numpy array of doubles.
pyreto/continuous/environment.py
def getSensors(self): """ Returns the currently visible state of the world as a numpy array of doubles. """ sensors = array([]) sensors = r_[sensors, self._getTotalDemandSensor()] # sensors = r_[sensors, self._getDemandSensor()] # sensors = r_[sensors, self._get...
def getSensors(self): """ Returns the currently visible state of the world as a numpy array of doubles. """ sensors = array([]) sensors = r_[sensors, self._getTotalDemandSensor()] # sensors = r_[sensors, self._getDemandSensor()] # sensors = r_[sensors, self._get...
[ "Returns", "the", "currently", "visible", "state", "of", "the", "world", "as", "a", "numpy", "array", "of", "doubles", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/environment.py#L63-L80
[ "def", "getSensors", "(", "self", ")", ":", "sensors", "=", "array", "(", "[", "]", ")", "sensors", "=", "r_", "[", "sensors", ",", "self", ".", "_getTotalDemandSensor", "(", ")", "]", "# sensors = r_[sensors, self._getDemandSensor()]", "# sensors = ...
916514255db1ae1661406f0283df756baf960d14
train
MarketEnvironment.performAction
Performs an action on the world that changes it's internal state. @param action: an action that should be executed in the Environment @type action: array: [ g1_prc, g2_prc, g1_qty, g2_qty, ... ]
pyreto/continuous/environment.py
def performAction(self, action): """ Performs an action on the world that changes it's internal state. @param action: an action that should be executed in the Environment @type action: array: [ g1_prc, g2_prc, g1_qty, g2_qty, ... ] """ self._lastAction = [] n = s...
def performAction(self, action): """ Performs an action on the world that changes it's internal state. @param action: an action that should be executed in the Environment @type action: array: [ g1_prc, g2_prc, g1_qty, g2_qty, ... ] """ self._lastAction = [] n = s...
[ "Performs", "an", "action", "on", "the", "world", "that", "changes", "it", "s", "internal", "state", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/environment.py#L83-L99
[ "def", "performAction", "(", "self", ",", "action", ")", ":", "self", ".", "_lastAction", "=", "[", "]", "n", "=", "self", ".", "numOffbids", "*", "len", "(", "self", ".", "generators", ")", "if", "self", ".", "maxWithhold", "is", "not", "None", ":",...
916514255db1ae1661406f0283df756baf960d14
train
MarketEnvironment.indim
The number of action values that the environment accepts.
pyreto/continuous/environment.py
def indim(self): """ The number of action values that the environment accepts. """ indim = self.numOffbids * len(self.generators) if self.maxWithhold is not None: return indim * 2 else: return indim
def indim(self): """ The number of action values that the environment accepts. """ indim = self.numOffbids * len(self.generators) if self.maxWithhold is not None: return indim * 2 else: return indim
[ "The", "number", "of", "action", "values", "that", "the", "environment", "accepts", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/environment.py#L103-L111
[ "def", "indim", "(", "self", ")", ":", "indim", "=", "self", ".", "numOffbids", "*", "len", "(", "self", ".", "generators", ")", "if", "self", ".", "maxWithhold", "is", "not", "None", ":", "return", "indim", "*", "2", "else", ":", "return", "indim" ]
916514255db1ae1661406f0283df756baf960d14
train
MarketEnvironment._getBusVoltageLambdaSensor
Returns an array of length nb where each value is the sum of the Lagrangian multipliers on the upper and the negative of the Lagrangian multipliers on the lower voltage limits.
pyreto/continuous/environment.py
def _getBusVoltageLambdaSensor(self): """ Returns an array of length nb where each value is the sum of the Lagrangian multipliers on the upper and the negative of the Lagrangian multipliers on the lower voltage limits. """ muVmin = array([b.mu_vmin for b in self.market.case.connected_bus...
def _getBusVoltageLambdaSensor(self): """ Returns an array of length nb where each value is the sum of the Lagrangian multipliers on the upper and the negative of the Lagrangian multipliers on the lower voltage limits. """ muVmin = array([b.mu_vmin for b in self.market.case.connected_bus...
[ "Returns", "an", "array", "of", "length", "nb", "where", "each", "value", "is", "the", "sum", "of", "the", "Lagrangian", "multipliers", "on", "the", "upper", "and", "the", "negative", "of", "the", "Lagrangian", "multipliers", "on", "the", "lower", "voltage",...
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/environment.py#L177-L185
[ "def", "_getBusVoltageLambdaSensor", "(", "self", ")", ":", "muVmin", "=", "array", "(", "[", "b", ".", "mu_vmin", "for", "b", "in", "self", ".", "market", ".", "case", ".", "connected_buses", "]", ")", "muVmax", "=", "array", "(", "[", "b", ".", "mu...
916514255db1ae1661406f0283df756baf960d14
train
flatten_component_refs
Flattens component refs in a tree :param container: class :param expression: original expression :param instance_prefix: prefix for instance :return: flattened expression
src/pymoca/tree.py
def flatten_component_refs( container: ast.Class, expression: ast.Union[ast.ConnectClause, ast.AssignmentStatement, ast.ForStatement, ast.Symbol], instance_prefix: str) -> ast.Union[ast.ConnectClause, ast.AssignmentStatement, ast.ForStatement, ast.Symbol]: """ Flattens component refs in ...
def flatten_component_refs( container: ast.Class, expression: ast.Union[ast.ConnectClause, ast.AssignmentStatement, ast.ForStatement, ast.Symbol], instance_prefix: str) -> ast.Union[ast.ConnectClause, ast.AssignmentStatement, ast.ForStatement, ast.Symbol]: """ Flattens component refs in ...
[ "Flattens", "component", "refs", "in", "a", "tree", ":", "param", "container", ":", "class", ":", "param", "expression", ":", "original", "expression", ":", "param", "instance_prefix", ":", "prefix", "for", "instance", ":", "return", ":", "flattened", "express...
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L657-L674
[ "def", "flatten_component_refs", "(", "container", ":", "ast", ".", "Class", ",", "expression", ":", "ast", ".", "Union", "[", "ast", ".", "ConnectClause", ",", "ast", ".", "AssignmentStatement", ",", "ast", ".", "ForStatement", ",", "ast", ".", "Symbol", ...
14b5eb7425e96689de6cc5c10f400895d586a978
train
fully_scope_function_calls
Turns the function references in this expression into fully scoped references (e.g. relative to absolute). The component references of all referenced functions are put into the functions set. :param node: collection for performing symbol lookup etc. :param expression: original expression :param fun...
src/pymoca/tree.py
def fully_scope_function_calls(node: ast.Tree, expression: ast.Expression, function_set: OrderedDict) -> ast.Expression: """ Turns the function references in this expression into fully scoped references (e.g. relative to absolute). The component references of all referenced functions are put into the fu...
def fully_scope_function_calls(node: ast.Tree, expression: ast.Expression, function_set: OrderedDict) -> ast.Expression: """ Turns the function references in this expression into fully scoped references (e.g. relative to absolute). The component references of all referenced functions are put into the fu...
[ "Turns", "the", "function", "references", "in", "this", "expression", "into", "fully", "scoped", "references", "(", "e", ".", "g", ".", "relative", "to", "absolute", ")", ".", "The", "component", "references", "of", "all", "referenced", "functions", "are", "...
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L702-L717
[ "def", "fully_scope_function_calls", "(", "node", ":", "ast", ".", "Tree", ",", "expression", ":", "ast", ".", "Expression", ",", "function_set", ":", "OrderedDict", ")", "->", "ast", ".", "Expression", ":", "expression_copy", "=", "copy", ".", "deepcopy", "...
14b5eb7425e96689de6cc5c10f400895d586a978
train
modify_symbol
Apply a modification to a symbol if the scope matches (or is None) :param sym: symbol to apply modifications for :param scope: scope of modification
src/pymoca/tree.py
def modify_symbol(sym: ast.Symbol, scope: ast.InstanceClass) -> None: """ Apply a modification to a symbol if the scope matches (or is None) :param sym: symbol to apply modifications for :param scope: scope of modification """ # We assume that we do not screw up the order of applying modificati...
def modify_symbol(sym: ast.Symbol, scope: ast.InstanceClass) -> None: """ Apply a modification to a symbol if the scope matches (or is None) :param sym: symbol to apply modifications for :param scope: scope of modification """ # We assume that we do not screw up the order of applying modificati...
[ "Apply", "a", "modification", "to", "a", "symbol", "if", "the", "scope", "matches", "(", "or", "is", "None", ")", ":", "param", "sym", ":", "symbol", "to", "apply", "modifications", "for", ":", "param", "scope", ":", "scope", "of", "modification" ]
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L720-L746
[ "def", "modify_symbol", "(", "sym", ":", "ast", ".", "Symbol", ",", "scope", ":", "ast", ".", "InstanceClass", ")", "->", "None", ":", "# We assume that we do not screw up the order of applying modifications", "# when \"moving up\" with the scope.", "apply_args", "=", "["...
14b5eb7425e96689de6cc5c10f400895d586a978
train
annotate_states
Finds all derivative expressions and annotates all differentiated symbols as states by adding state the prefix list :param node: node of tree to walk :return:
src/pymoca/tree.py
def annotate_states(node: ast.Node) -> None: """ Finds all derivative expressions and annotates all differentiated symbols as states by adding state the prefix list :param node: node of tree to walk :return: """ w = TreeWalker() w.walk(StateAnnotator(node), node)
def annotate_states(node: ast.Node) -> None: """ Finds all derivative expressions and annotates all differentiated symbols as states by adding state the prefix list :param node: node of tree to walk :return: """ w = TreeWalker() w.walk(StateAnnotator(node), node)
[ "Finds", "all", "derivative", "expressions", "and", "annotates", "all", "differentiated", "symbols", "as", "states", "by", "adding", "state", "the", "prefix", "list", ":", "param", "node", ":", "node", "of", "tree", "to", "walk", ":", "return", ":" ]
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L1044-L1052
[ "def", "annotate_states", "(", "node", ":", "ast", ".", "Node", ")", "->", "None", ":", "w", "=", "TreeWalker", "(", ")", "w", ".", "walk", "(", "StateAnnotator", "(", "node", ")", ",", "node", ")" ]
14b5eb7425e96689de6cc5c10f400895d586a978
train
flatten
This function takes a Tree and flattens it so that all subclasses instances are replaced by the their equations and symbols with name mangling of the instance name passed. :param root: The Tree to flatten :param class_name: The class that we want to create a flat model for :return: flat_class, a Cla...
src/pymoca/tree.py
def flatten(root: ast.Tree, class_name: ast.ComponentRef) -> ast.Class: """ This function takes a Tree and flattens it so that all subclasses instances are replaced by the their equations and symbols with name mangling of the instance name passed. :param root: The Tree to flatten :param class_na...
def flatten(root: ast.Tree, class_name: ast.ComponentRef) -> ast.Class: """ This function takes a Tree and flattens it so that all subclasses instances are replaced by the their equations and symbols with name mangling of the instance name passed. :param root: The Tree to flatten :param class_na...
[ "This", "function", "takes", "a", "Tree", "and", "flattens", "it", "so", "that", "all", "subclasses", "instances", "are", "replaced", "by", "the", "their", "equations", "and", "symbols", "with", "name", "mangling", "of", "the", "instance", "name", "passed", ...
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L1055-L1091
[ "def", "flatten", "(", "root", ":", "ast", ".", "Tree", ",", "class_name", ":", "ast", ".", "ComponentRef", ")", "->", "ast", ".", "Class", ":", "orig_class", "=", "root", ".", "find_class", "(", "class_name", ",", "copy", "=", "False", ")", "flat_clas...
14b5eb7425e96689de6cc5c10f400895d586a978
train
TreeWalker.skip_child
Skip certain childs in the tree walking. By default it prevents endless recursion by skipping references to e.g. parent nodes. :return: True if child needs to be skipped, False otherwise.
src/pymoca/tree.py
def skip_child(self, tree: ast.Node, child_name: str) -> bool: """ Skip certain childs in the tree walking. By default it prevents endless recursion by skipping references to e.g. parent nodes. :return: True if child needs to be skipped, False otherwise. """ if isinstance...
def skip_child(self, tree: ast.Node, child_name: str) -> bool: """ Skip certain childs in the tree walking. By default it prevents endless recursion by skipping references to e.g. parent nodes. :return: True if child needs to be skipped, False otherwise. """ if isinstance...
[ "Skip", "certain", "childs", "in", "the", "tree", "walking", ".", "By", "default", "it", "prevents", "endless", "recursion", "by", "skipping", "references", "to", "e", ".", "g", ".", "parent", "nodes", ".", ":", "return", ":", "True", "if", "child", "nee...
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L162-L171
[ "def", "skip_child", "(", "self", ",", "tree", ":", "ast", ".", "Node", ",", "child_name", ":", "str", ")", "->", "bool", ":", "if", "isinstance", "(", "tree", ",", "ast", ".", "Class", ")", "and", "child_name", "==", "'parent'", "or", "isinstance", ...
14b5eb7425e96689de6cc5c10f400895d586a978
train
TreeWalker.walk
Walks an AST tree recursively :param listener: :param tree: :return: None
src/pymoca/tree.py
def walk(self, listener: TreeListener, tree: ast.Node) -> None: """ Walks an AST tree recursively :param listener: :param tree: :return: None """ name = tree.__class__.__name__ if hasattr(listener, 'enterEvery'): getattr(listener, 'enterEvery')...
def walk(self, listener: TreeListener, tree: ast.Node) -> None: """ Walks an AST tree recursively :param listener: :param tree: :return: None """ name = tree.__class__.__name__ if hasattr(listener, 'enterEvery'): getattr(listener, 'enterEvery')...
[ "Walks", "an", "AST", "tree", "recursively", ":", "param", "listener", ":", ":", "param", "tree", ":", ":", "return", ":", "None" ]
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L176-L195
[ "def", "walk", "(", "self", ",", "listener", ":", "TreeListener", ",", "tree", ":", "ast", ".", "Node", ")", "->", "None", ":", "name", "=", "tree", ".", "__class__", ".", "__name__", "if", "hasattr", "(", "listener", ",", "'enterEvery'", ")", ":", "...
14b5eb7425e96689de6cc5c10f400895d586a978
train
TreeWalker.handle_walk
Handles tree walking, has to account for dictionaries and lists :param listener: listener that reacts to walked events :param tree: the tree to walk :return: None
src/pymoca/tree.py
def handle_walk(self, listener: TreeListener, tree: Union[ast.Node, dict, list]) -> None: """ Handles tree walking, has to account for dictionaries and lists :param listener: listener that reacts to walked events :param tree: the tree to walk :return: None """ if ...
def handle_walk(self, listener: TreeListener, tree: Union[ast.Node, dict, list]) -> None: """ Handles tree walking, has to account for dictionaries and lists :param listener: listener that reacts to walked events :param tree: the tree to walk :return: None """ if ...
[ "Handles", "tree", "walking", "has", "to", "account", "for", "dictionaries", "and", "lists", ":", "param", "listener", ":", "listener", "that", "reacts", "to", "walked", "events", ":", "param", "tree", ":", "the", "tree", "to", "walk", ":", "return", ":", ...
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/tree.py#L197-L213
[ "def", "handle_walk", "(", "self", ",", "listener", ":", "TreeListener", ",", "tree", ":", "Union", "[", "ast", ".", "Node", ",", "dict", ",", "list", "]", ")", "->", "None", ":", "if", "isinstance", "(", "tree", ",", "ast", ".", "Node", ")", ":", ...
14b5eb7425e96689de6cc5c10f400895d586a978
train
DoxyfileParse
Parse a Doxygen source file and return a dictionary of all the values. Values will be strings and lists of strings.
site_scons/site_tools/doxygen.py
def DoxyfileParse(file_contents): """ Parse a Doxygen source file and return a dictionary of all the values. Values will be strings and lists of strings. """ data = {} import shlex lex = shlex.shlex(instream = file_contents, posix = True) lex.wordchars += "*+./-:" lex.whitespace = lex.whites...
def DoxyfileParse(file_contents): """ Parse a Doxygen source file and return a dictionary of all the values. Values will be strings and lists of strings. """ data = {} import shlex lex = shlex.shlex(instream = file_contents, posix = True) lex.wordchars += "*+./-:" lex.whitespace = lex.whites...
[ "Parse", "a", "Doxygen", "source", "file", "and", "return", "a", "dictionary", "of", "all", "the", "values", ".", "Values", "will", "be", "strings", "and", "lists", "of", "strings", "." ]
melizalab/libtfr
python
https://github.com/melizalab/libtfr/blob/9f7e7705793d258a0b205f185b20e3bbcda473da/site_scons/site_tools/doxygen.py#L28-L97
[ "def", "DoxyfileParse", "(", "file_contents", ")", ":", "data", "=", "{", "}", "import", "shlex", "lex", "=", "shlex", ".", "shlex", "(", "instream", "=", "file_contents", ",", "posix", "=", "True", ")", "lex", ".", "wordchars", "+=", "\"*+./-:\"", "lex"...
9f7e7705793d258a0b205f185b20e3bbcda473da
train
DoxySourceScan
Doxygen Doxyfile source scanner. This should scan the Doxygen file and add any files used to generate docs to the list of source files.
site_scons/site_tools/doxygen.py
def DoxySourceScan(node, env, path): """ Doxygen Doxyfile source scanner. This should scan the Doxygen file and add any files used to generate docs to the list of source files. """ default_file_patterns = [ '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx', '*.ipp', '*.i++'...
def DoxySourceScan(node, env, path): """ Doxygen Doxyfile source scanner. This should scan the Doxygen file and add any files used to generate docs to the list of source files. """ default_file_patterns = [ '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx', '*.ipp', '*.i++'...
[ "Doxygen", "Doxyfile", "source", "scanner", ".", "This", "should", "scan", "the", "Doxygen", "file", "and", "add", "any", "files", "used", "to", "generate", "docs", "to", "the", "list", "of", "source", "files", "." ]
melizalab/libtfr
python
https://github.com/melizalab/libtfr/blob/9f7e7705793d258a0b205f185b20e3bbcda473da/site_scons/site_tools/doxygen.py#L99-L174
[ "def", "DoxySourceScan", "(", "node", ",", "env", ",", "path", ")", ":", "default_file_patterns", "=", "[", "'*.c'", ",", "'*.cc'", ",", "'*.cxx'", ",", "'*.cpp'", ",", "'*.c++'", ",", "'*.java'", ",", "'*.ii'", ",", "'*.ixx'", ",", "'*.ipp'", ",", "'*.i...
9f7e7705793d258a0b205f185b20e3bbcda473da
train
DoxyEmitter
Doxygen Doxyfile emitter
site_scons/site_tools/doxygen.py
def DoxyEmitter(source, target, env): """Doxygen Doxyfile emitter""" # possible output formats and their default values and output locations output_formats = { "HTML": ("YES", "html"), "LATEX": ("YES", "latex"), "RTF": ("NO", "rtf"), "MAN": ("YES", "man"), "XML": ("NO", "xml"), ...
def DoxyEmitter(source, target, env): """Doxygen Doxyfile emitter""" # possible output formats and their default values and output locations output_formats = { "HTML": ("YES", "html"), "LATEX": ("YES", "latex"), "RTF": ("NO", "rtf"), "MAN": ("YES", "man"), "XML": ("NO", "xml"), ...
[ "Doxygen", "Doxyfile", "emitter" ]
melizalab/libtfr
python
https://github.com/melizalab/libtfr/blob/9f7e7705793d258a0b205f185b20e3bbcda473da/site_scons/site_tools/doxygen.py#L181-L221
[ "def", "DoxyEmitter", "(", "source", ",", "target", ",", "env", ")", ":", "# possible output formats and their default values and output locations", "output_formats", "=", "{", "\"HTML\"", ":", "(", "\"YES\"", ",", "\"html\"", ")", ",", "\"LATEX\"", ":", "(", "\"YES...
9f7e7705793d258a0b205f185b20e3bbcda473da
train
generate
Add builders and construction variables for the Doxygen tool. This is currently for Doxygen 1.4.6.
site_scons/site_tools/doxygen.py
def generate(env): """ Add builders and construction variables for the Doxygen tool. This is currently for Doxygen 1.4.6. """ doxyfile_scanner = env.Scanner( DoxySourceScan, "DoxySourceScan", scan_check = DoxySourceScanCheck, ) import SCons.Builder doxyfile_builder = SCons.Bu...
def generate(env): """ Add builders and construction variables for the Doxygen tool. This is currently for Doxygen 1.4.6. """ doxyfile_scanner = env.Scanner( DoxySourceScan, "DoxySourceScan", scan_check = DoxySourceScanCheck, ) import SCons.Builder doxyfile_builder = SCons.Bu...
[ "Add", "builders", "and", "construction", "variables", "for", "the", "Doxygen", "tool", ".", "This", "is", "currently", "for", "Doxygen", "1", ".", "4", ".", "6", "." ]
melizalab/libtfr
python
https://github.com/melizalab/libtfr/blob/9f7e7705793d258a0b205f185b20e3bbcda473da/site_scons/site_tools/doxygen.py#L223-L249
[ "def", "generate", "(", "env", ")", ":", "doxyfile_scanner", "=", "env", ".", "Scanner", "(", "DoxySourceScan", ",", "\"DoxySourceScan\"", ",", "scan_check", "=", "DoxySourceScanCheck", ",", ")", "import", "SCons", ".", "Builder", "doxyfile_builder", "=", "SCons...
9f7e7705793d258a0b205f185b20e3bbcda473da
train
PosMetric.reset
Reset metric counter.
metrics/position.py
def reset(self): """Reset metric counter.""" self._positions = [] self._line = 1 self._curr = None # current scope we are analyzing self._scope = 0 self.language = None
def reset(self): """Reset metric counter.""" self._positions = [] self._line = 1 self._curr = None # current scope we are analyzing self._scope = 0 self.language = None
[ "Reset", "metric", "counter", "." ]
finklabs/metrics
python
https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/position.py#L87-L93
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_positions", "=", "[", "]", "self", ".", "_line", "=", "1", "self", ".", "_curr", "=", "None", "# current scope we are analyzing", "self", ".", "_scope", "=", "0", "self", ".", "language", "=", "None...
fd9974af498831664b9ae8e8f3834e1ec2e8a699
train
PosMetric.add_scope
we identified a scope and add it to positions.
metrics/position.py
def add_scope(self, scope_type, scope_name, scope_start, is_method=False): """we identified a scope and add it to positions.""" if self._curr is not None: self._curr['end'] = scope_start - 1 # close last scope self._curr = { 'type': scope_type, 'name': scope_name, ...
def add_scope(self, scope_type, scope_name, scope_start, is_method=False): """we identified a scope and add it to positions.""" if self._curr is not None: self._curr['end'] = scope_start - 1 # close last scope self._curr = { 'type': scope_type, 'name': scope_name, ...
[ "we", "identified", "a", "scope", "and", "add", "it", "to", "positions", "." ]
finklabs/metrics
python
https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/position.py#L95-L110
[ "def", "add_scope", "(", "self", ",", "scope_type", ",", "scope_name", ",", "scope_start", ",", "is_method", "=", "False", ")", ":", "if", "self", ".", "_curr", "is", "not", "None", ":", "self", ".", "_curr", "[", "'end'", "]", "=", "scope_start", "-",...
fd9974af498831664b9ae8e8f3834e1ec2e8a699
train
PosMetric.process_token
count lines and track position of classes and functions
metrics/position.py
def process_token(self, tok): """count lines and track position of classes and functions""" if tok[0] == Token.Text: count = tok[1].count('\n') if count: self._line += count # adjust linecount if self._detector.process(tok): pass # works bee...
def process_token(self, tok): """count lines and track position of classes and functions""" if tok[0] == Token.Text: count = tok[1].count('\n') if count: self._line += count # adjust linecount if self._detector.process(tok): pass # works bee...
[ "count", "lines", "and", "track", "position", "of", "classes", "and", "functions" ]
finklabs/metrics
python
https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/position.py#L112-L132
[ "def", "process_token", "(", "self", ",", "tok", ")", ":", "if", "tok", "[", "0", "]", "==", "Token", ".", "Text", ":", "count", "=", "tok", "[", "1", "]", ".", "count", "(", "'\\n'", ")", "if", "count", ":", "self", ".", "_line", "+=", "count"...
fd9974af498831664b9ae8e8f3834e1ec2e8a699
train
_Solver._unpack_model
Returns data from the OPF model.
pylon/solver.py
def _unpack_model(self, om): """ Returns data from the OPF model. """ buses = om.case.connected_buses branches = om.case.online_branches gens = om.case.online_generators cp = om.get_cost_params() # Bf = om._Bf # Pfinj = om._Pfinj return buses, bra...
def _unpack_model(self, om): """ Returns data from the OPF model. """ buses = om.case.connected_buses branches = om.case.online_branches gens = om.case.online_generators cp = om.get_cost_params() # Bf = om._Bf # Pfinj = om._Pfinj return buses, bra...
[ "Returns", "data", "from", "the", "OPF", "model", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L78-L90
[ "def", "_unpack_model", "(", "self", ",", "om", ")", ":", "buses", "=", "om", ".", "case", ".", "connected_buses", "branches", "=", "om", ".", "case", ".", "online_branches", "gens", "=", "om", ".", "case", ".", "online_generators", "cp", "=", "om", "....
916514255db1ae1661406f0283df756baf960d14
train
_Solver._dimension_data
Returns the problem dimensions.
pylon/solver.py
def _dimension_data(self, buses, branches, generators): """ Returns the problem dimensions. """ ipol = [i for i, g in enumerate(generators) if g.pcost_model == POLYNOMIAL] ipwl = [i for i, g in enumerate(generators) if g.pcost_model == PW_LINEAR] n...
def _dimension_data(self, buses, branches, generators): """ Returns the problem dimensions. """ ipol = [i for i, g in enumerate(generators) if g.pcost_model == POLYNOMIAL] ipwl = [i for i, g in enumerate(generators) if g.pcost_model == PW_LINEAR] n...
[ "Returns", "the", "problem", "dimensions", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L93-L112
[ "def", "_dimension_data", "(", "self", ",", "buses", ",", "branches", ",", "generators", ")", ":", "ipol", "=", "[", "i", "for", "i", ",", "g", "in", "enumerate", "(", "generators", ")", "if", "g", ".", "pcost_model", "==", "POLYNOMIAL", "]", "ipwl", ...
916514255db1ae1661406f0283df756baf960d14
train
_Solver._linear_constraints
Returns the linear problem constraints.
pylon/solver.py
def _linear_constraints(self, om): """ Returns the linear problem constraints. """ A, l, u = om.linear_constraints() # l <= A*x <= u # Indexes for equality, greater than (unbounded above), less than # (unbounded below) and doubly-bounded box constraints. # ieq = flatnonze...
def _linear_constraints(self, om): """ Returns the linear problem constraints. """ A, l, u = om.linear_constraints() # l <= A*x <= u # Indexes for equality, greater than (unbounded above), less than # (unbounded below) and doubly-bounded box constraints. # ieq = flatnonze...
[ "Returns", "the", "linear", "problem", "constraints", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L115-L149
[ "def", "_linear_constraints", "(", "self", ",", "om", ")", ":", "A", ",", "l", ",", "u", "=", "om", ".", "linear_constraints", "(", ")", "# l <= A*x <= u", "# Indexes for equality, greater than (unbounded above), less than", "# (unbounded below) and doubly-bounded box const...
916514255db1ae1661406f0283df756baf960d14
train
_Solver._var_bounds
Returns bounds on the optimisation variables.
pylon/solver.py
def _var_bounds(self): """ Returns bounds on the optimisation variables. """ x0 = array([]) xmin = array([]) xmax = array([]) for var in self.om.vars: x0 = r_[x0, var.v0] xmin = r_[xmin, var.vl] xmax = r_[xmax, var.vu] return ...
def _var_bounds(self): """ Returns bounds on the optimisation variables. """ x0 = array([]) xmin = array([]) xmax = array([]) for var in self.om.vars: x0 = r_[x0, var.v0] xmin = r_[xmin, var.vl] xmax = r_[xmax, var.vu] return ...
[ "Returns", "bounds", "on", "the", "optimisation", "variables", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L152-L164
[ "def", "_var_bounds", "(", "self", ")", ":", "x0", "=", "array", "(", "[", "]", ")", "xmin", "=", "array", "(", "[", "]", ")", "xmax", "=", "array", "(", "[", "]", ")", "for", "var", "in", "self", ".", "om", ".", "vars", ":", "x0", "=", "r_...
916514255db1ae1661406f0283df756baf960d14
train
_Solver._initial_interior_point
Selects an interior initial point for interior point solver.
pylon/solver.py
def _initial_interior_point(self, buses, generators, xmin, xmax, ny): """ Selects an interior initial point for interior point solver. """ Va = self.om.get_var("Va") va_refs = [b.v_angle * pi / 180.0 for b in buses if b.type == REFERENCE] x0 = (xmin + xmax) / 2...
def _initial_interior_point(self, buses, generators, xmin, xmax, ny): """ Selects an interior initial point for interior point solver. """ Va = self.om.get_var("Va") va_refs = [b.v_angle * pi / 180.0 for b in buses if b.type == REFERENCE] x0 = (xmin + xmax) / 2...
[ "Selects", "an", "interior", "initial", "point", "for", "interior", "point", "solver", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L167-L190
[ "def", "_initial_interior_point", "(", "self", ",", "buses", ",", "generators", ",", "xmin", ",", "xmax", ",", "ny", ")", ":", "Va", "=", "self", ".", "om", ".", "get_var", "(", "\"Va\"", ")", "va_refs", "=", "[", "b", ".", "v_angle", "*", "pi", "/...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver.solve
Solves DC optimal power flow and returns a results dict.
pylon/solver.py
def solve(self): """ Solves DC optimal power flow and returns a results dict. """ base_mva = self.om.case.base_mva Bf = self.om._Bf Pfinj = self.om._Pfinj # Unpack the OPF model. bs, ln, gn, cp = self._unpack_model(self.om) # Compute problem dimensions. ...
def solve(self): """ Solves DC optimal power flow and returns a results dict. """ base_mva = self.om.case.base_mva Bf = self.om._Bf Pfinj = self.om._Pfinj # Unpack the OPF model. bs, ln, gn, cp = self._unpack_model(self.om) # Compute problem dimensions. ...
[ "Solves", "DC", "optimal", "power", "flow", "and", "returns", "a", "results", "dict", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L218-L257
[ "def", "solve", "(", "self", ")", ":", "base_mva", "=", "self", ".", "om", ".", "case", ".", "base_mva", "Bf", "=", "self", ".", "om", ".", "_Bf", "Pfinj", "=", "self", ".", "om", ".", "_Pfinj", "# Unpack the OPF model.", "bs", ",", "ln", ",", "gn"...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver._pwl_costs
Returns the piece-wise linear components of the objective function.
pylon/solver.py
def _pwl_costs(self, ny, nxyz, ipwl): """ Returns the piece-wise linear components of the objective function. """ any_pwl = int(ny > 0) if any_pwl: y = self.om.get_var("y") # Sum of y vars. Npwl = csr_matrix((ones(ny), (zeros(ny), array(ipwl) + y.i1)))...
def _pwl_costs(self, ny, nxyz, ipwl): """ Returns the piece-wise linear components of the objective function. """ any_pwl = int(ny > 0) if any_pwl: y = self.om.get_var("y") # Sum of y vars. Npwl = csr_matrix((ones(ny), (zeros(ny), array(ipwl) + y.i1)))...
[ "Returns", "the", "piece", "-", "wise", "linear", "components", "of", "the", "objective", "function", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L260-L277
[ "def", "_pwl_costs", "(", "self", ",", "ny", ",", "nxyz", ",", "ipwl", ")", ":", "any_pwl", "=", "int", "(", "ny", ">", "0", ")", "if", "any_pwl", ":", "y", "=", "self", ".", "om", ".", "get_var", "(", "\"y\"", ")", "# Sum of y vars.", "Npwl", "=...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver._quadratic_costs
Returns the quadratic cost components of the objective function.
pylon/solver.py
def _quadratic_costs(self, generators, ipol, nxyz, base_mva): """ Returns the quadratic cost components of the objective function. """ npol = len(ipol) rnpol = range(npol) gpol = [g for g in generators if g.pcost_model == POLYNOMIAL] if [g for g in gpol if len(g.p_cost) ...
def _quadratic_costs(self, generators, ipol, nxyz, base_mva): """ Returns the quadratic cost components of the objective function. """ npol = len(ipol) rnpol = range(npol) gpol = [g for g in generators if g.pcost_model == POLYNOMIAL] if [g for g in gpol if len(g.p_cost) ...
[ "Returns", "the", "quadratic", "cost", "components", "of", "the", "objective", "function", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L280-L316
[ "def", "_quadratic_costs", "(", "self", ",", "generators", ",", "ipol", ",", "nxyz", ",", "base_mva", ")", ":", "npol", "=", "len", "(", "ipol", ")", "rnpol", "=", "range", "(", "npol", ")", "gpol", "=", "[", "g", "for", "g", "in", "generators", "i...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver._combine_costs
Combines pwl, polynomial and user-defined costs.
pylon/solver.py
def _combine_costs(self, Npwl, Hpwl, Cpwl, fparm_pwl, any_pwl, Npol, Hpol, Cpol, fparm_pol, npol, nw): """ Combines pwl, polynomial and user-defined costs. """ NN = vstack([n for n in [Npwl, Npol] if n is not None], "csr") if (Hpwl is not None) and (Hpol is not No...
def _combine_costs(self, Npwl, Hpwl, Cpwl, fparm_pwl, any_pwl, Npol, Hpol, Cpol, fparm_pol, npol, nw): """ Combines pwl, polynomial and user-defined costs. """ NN = vstack([n for n in [Npwl, Npol] if n is not None], "csr") if (Hpwl is not None) and (Hpol is not No...
[ "Combines", "pwl", "polynomial", "and", "user", "-", "defined", "costs", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L319-L337
[ "def", "_combine_costs", "(", "self", ",", "Npwl", ",", "Hpwl", ",", "Cpwl", ",", "fparm_pwl", ",", "any_pwl", ",", "Npol", ",", "Hpol", ",", "Cpol", ",", "fparm_pol", ",", "npol", ",", "nw", ")", ":", "NN", "=", "vstack", "(", "[", "n", "for", "...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver._transform_coefficients
Transforms quadratic coefficients for w into coefficients for x.
pylon/solver.py
def _transform_coefficients(self, NN, HHw, CCw, ffparm, polycf, any_pwl, npol, nw): """ Transforms quadratic coefficients for w into coefficients for x. """ nnw = any_pwl + npol + nw M = csr_matrix((ffparm[:, 3], (range(nnw), range(nnw)))) MR = M * ...
def _transform_coefficients(self, NN, HHw, CCw, ffparm, polycf, any_pwl, npol, nw): """ Transforms quadratic coefficients for w into coefficients for x. """ nnw = any_pwl + npol + nw M = csr_matrix((ffparm[:, 3], (range(nnw), range(nnw)))) MR = M * ...
[ "Transforms", "quadratic", "coefficients", "for", "w", "into", "coefficients", "for", "x", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L340-L354
[ "def", "_transform_coefficients", "(", "self", ",", "NN", ",", "HHw", ",", "CCw", ",", "ffparm", ",", "polycf", ",", "any_pwl", ",", "npol", ",", "nw", ")", ":", "nnw", "=", "any_pwl", "+", "npol", "+", "nw", "M", "=", "csr_matrix", "(", "(", "ffpa...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver._run_opf
Solves the either quadratic or linear program.
pylon/solver.py
def _run_opf(self, HH, CC, AA, ll, uu, xmin, xmax, x0, opt): """ Solves the either quadratic or linear program. """ N = self._nieq if HH.nnz > 0: solution = qps_pips(HH, CC, AA, ll, uu, xmin, xmax, x0, opt) else: solution = qps_pips(None, CC, AA, ll, uu, ...
def _run_opf(self, HH, CC, AA, ll, uu, xmin, xmax, x0, opt): """ Solves the either quadratic or linear program. """ N = self._nieq if HH.nnz > 0: solution = qps_pips(HH, CC, AA, ll, uu, xmin, xmax, x0, opt) else: solution = qps_pips(None, CC, AA, ll, uu, ...
[ "Solves", "the", "either", "quadratic", "or", "linear", "program", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L357-L367
[ "def", "_run_opf", "(", "self", ",", "HH", ",", "CC", ",", "AA", ",", "ll", ",", "uu", ",", "xmin", ",", "xmax", ",", "x0", ",", "opt", ")", ":", "N", "=", "self", ".", "_nieq", "if", "HH", ".", "nnz", ">", "0", ":", "solution", "=", "qps_p...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver._update_solution_data
Returns the voltage angle and generator set-point vectors.
pylon/solver.py
def _update_solution_data(self, s, HH, CC, C0): """ Returns the voltage angle and generator set-point vectors. """ x = s["x"] Va_v = self.om.get_var("Va") Pg_v = self.om.get_var("Pg") Va = x[Va_v.i1:Va_v.iN + 1] Pg = x[Pg_v.i1:Pg_v.iN + 1] # f = 0.5 * dot(...
def _update_solution_data(self, s, HH, CC, C0): """ Returns the voltage angle and generator set-point vectors. """ x = s["x"] Va_v = self.om.get_var("Va") Pg_v = self.om.get_var("Pg") Va = x[Va_v.i1:Va_v.iN + 1] Pg = x[Pg_v.i1:Pg_v.iN + 1] # f = 0.5 * dot(...
[ "Returns", "the", "voltage", "angle", "and", "generator", "set", "-", "point", "vectors", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L370-L386
[ "def", "_update_solution_data", "(", "self", ",", "s", ",", "HH", ",", "CC", ",", "C0", ")", ":", "x", "=", "s", "[", "\"x\"", "]", "Va_v", "=", "self", ".", "om", ".", "get_var", "(", "\"Va\"", ")", "Pg_v", "=", "self", ".", "om", ".", "get_va...
916514255db1ae1661406f0283df756baf960d14
train
DCOPFSolver._update_case
Calculates the result attribute values.
pylon/solver.py
def _update_case(self, bs, ln, gn, base_mva, Bf, Pfinj, Va, Pg, lmbda): """ Calculates the result attribute values. """ Pmis = self.om.get_lin_constraint("Pmis") Pf = self.om.get_lin_constraint("Pf") Pt = self.om.get_lin_constraint("Pt") Pg_v = self.om.get_var("Pg") ...
def _update_case(self, bs, ln, gn, base_mva, Bf, Pfinj, Va, Pg, lmbda): """ Calculates the result attribute values. """ Pmis = self.om.get_lin_constraint("Pmis") Pf = self.om.get_lin_constraint("Pf") Pt = self.om.get_lin_constraint("Pt") Pg_v = self.om.get_var("Pg") ...
[ "Calculates", "the", "result", "attribute", "values", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L389-L419
[ "def", "_update_case", "(", "self", ",", "bs", ",", "ln", ",", "gn", ",", "base_mva", ",", "Bf", ",", "Pfinj", ",", "Va", ",", "Pg", ",", "lmbda", ")", ":", "Pmis", "=", "self", ".", "om", ".", "get_lin_constraint", "(", "\"Pmis\"", ")", "Pf", "=...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._ref_bus_angle_constraint
Adds a constraint on the reference bus angles.
pylon/solver.py
def _ref_bus_angle_constraint(self, buses, Va, xmin, xmax): """ Adds a constraint on the reference bus angles. """ refs = [bus._i for bus in buses if bus.type == REFERENCE] Varefs = array([b.v_angle for b in buses if b.type == REFERENCE]) xmin[Va.i1 - 1 + refs] = Varefs ...
def _ref_bus_angle_constraint(self, buses, Va, xmin, xmax): """ Adds a constraint on the reference bus angles. """ refs = [bus._i for bus in buses if bus.type == REFERENCE] Varefs = array([b.v_angle for b in buses if b.type == REFERENCE]) xmin[Va.i1 - 1 + refs] = Varefs ...
[ "Adds", "a", "constraint", "on", "the", "reference", "bus", "angles", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L444-L453
[ "def", "_ref_bus_angle_constraint", "(", "self", ",", "buses", ",", "Va", ",", "xmin", ",", "xmax", ")", ":", "refs", "=", "[", "bus", ".", "_i", "for", "bus", "in", "buses", "if", "bus", ".", "type", "==", "REFERENCE", "]", "Varefs", "=", "array", ...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver.solve
Solves AC optimal power flow.
pylon/solver.py
def solve(self): """ Solves AC optimal power flow. """ case = self.om.case self._base_mva = case.base_mva # TODO: Find an explanation for this value. self.opt["cost_mult"] = 1e-4 # Unpack the OPF model. self._bs, self._ln, self._gn, _ = self._unpack_model...
def solve(self): """ Solves AC optimal power flow. """ case = self.om.case self._base_mva = case.base_mva # TODO: Find an explanation for this value. self.opt["cost_mult"] = 1e-4 # Unpack the OPF model. self._bs, self._ln, self._gn, _ = self._unpack_model...
[ "Solves", "AC", "optimal", "power", "flow", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L456-L504
[ "def", "solve", "(", "self", ")", ":", "case", "=", "self", ".", "om", ".", "case", "self", ".", "_base_mva", "=", "case", ".", "base_mva", "# TODO: Find an explanation for this value.", "self", ".", "opt", "[", "\"cost_mult\"", "]", "=", "1e-4", "# Unpack t...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._solve
Solves using Python Interior Point Solver (PIPS).
pylon/solver.py
def _solve(self, x0, A, l, u, xmin, xmax): """ Solves using Python Interior Point Solver (PIPS). """ s = pips(self._costfcn, x0, A, l, u, xmin, xmax, self._consfcn, self._hessfcn, self.opt) return s
def _solve(self, x0, A, l, u, xmin, xmax): """ Solves using Python Interior Point Solver (PIPS). """ s = pips(self._costfcn, x0, A, l, u, xmin, xmax, self._consfcn, self._hessfcn, self.opt) return s
[ "Solves", "using", "Python", "Interior", "Point", "Solver", "(", "PIPS", ")", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L507-L512
[ "def", "_solve", "(", "self", ",", "x0", ",", "A", ",", "l", ",", "u", ",", "xmin", ",", "xmax", ")", ":", "s", "=", "pips", "(", "self", ".", "_costfcn", ",", "x0", ",", "A", ",", "l", ",", "u", ",", "xmin", ",", "xmax", ",", "self", "."...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._f
Evaluates the objective function.
pylon/solver.py
def _f(self, x, user_data=None): """ Evaluates the objective function. """ p_gen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. q_gen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. # Polynomial cost of P and Q. xx = r_[p_gen, q_gen] * self._...
def _f(self, x, user_data=None): """ Evaluates the objective function. """ p_gen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. q_gen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. # Polynomial cost of P and Q. xx = r_[p_gen, q_gen] * self._...
[ "Evaluates", "the", "objective", "function", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L515-L539
[ "def", "_f", "(", "self", ",", "x", ",", "user_data", "=", "None", ")", ":", "p_gen", "=", "x", "[", "self", ".", "_Pg", ".", "i1", ":", "self", ".", "_Pg", ".", "iN", "+", "1", "]", "# Active generation in p.u.", "q_gen", "=", "x", "[", "self", ...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._df
Evaluates the cost gradient.
pylon/solver.py
def _df(self, x, user_data=None): """ Evaluates the cost gradient. """ p_gen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. q_gen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. # Polynomial cost of P and Q. xx = r_[p_gen, q_gen] * self._base...
def _df(self, x, user_data=None): """ Evaluates the cost gradient. """ p_gen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. q_gen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. # Polynomial cost of P and Q. xx = r_[p_gen, q_gen] * self._base...
[ "Evaluates", "the", "cost", "gradient", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L542-L573
[ "def", "_df", "(", "self", ",", "x", ",", "user_data", "=", "None", ")", ":", "p_gen", "=", "x", "[", "self", ".", "_Pg", ".", "i1", ":", "self", ".", "_Pg", ".", "iN", "+", "1", "]", "# Active generation in p.u.", "q_gen", "=", "x", "[", "self",...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._d2f
Evaluates the cost Hessian.
pylon/solver.py
def _d2f(self, x): """ Evaluates the cost Hessian. """ d2f_dPg2 = lil_matrix((self._ng, 1)) # w.r.t p.u. Pg d2f_dQg2 = lil_matrix((self._ng, 1)) # w.r.t p.u. Qg] for i in self._ipol: p_cost = list(self._gn[i].p_cost) d2f_dPg2[i, 0] = polyval(polyder(p_cos...
def _d2f(self, x): """ Evaluates the cost Hessian. """ d2f_dPg2 = lil_matrix((self._ng, 1)) # w.r.t p.u. Pg d2f_dQg2 = lil_matrix((self._ng, 1)) # w.r.t p.u. Qg] for i in self._ipol: p_cost = list(self._gn[i].p_cost) d2f_dPg2[i, 0] = polyval(polyder(p_cos...
[ "Evaluates", "the", "cost", "Hessian", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L576-L595
[ "def", "_d2f", "(", "self", ",", "x", ")", ":", "d2f_dPg2", "=", "lil_matrix", "(", "(", "self", ".", "_ng", ",", "1", ")", ")", "# w.r.t p.u. Pg", "d2f_dQg2", "=", "lil_matrix", "(", "(", "self", ".", "_ng", ",", "1", ")", ")", "# w.r.t p.u. Qg]", ...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._gh
Evaluates the constraint function values.
pylon/solver.py
def _gh(self, x): """ Evaluates the constraint function values. """ Pgen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. Qgen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. for i, gen in enumerate(self._gn): gen.p = Pgen[i] * self._base_m...
def _gh(self, x): """ Evaluates the constraint function values. """ Pgen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. Qgen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. for i, gen in enumerate(self._gn): gen.p = Pgen[i] * self._base_m...
[ "Evaluates", "the", "constraint", "function", "values", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L598-L654
[ "def", "_gh", "(", "self", ",", "x", ")", ":", "Pgen", "=", "x", "[", "self", ".", "_Pg", ".", "i1", ":", "self", ".", "_Pg", ".", "iN", "+", "1", "]", "# Active generation in p.u.", "Qgen", "=", "x", "[", "self", ".", "_Qg", ".", "i1", ":", ...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._costfcn
Evaluates the objective function, gradient and Hessian for OPF.
pylon/solver.py
def _costfcn(self, x): """ Evaluates the objective function, gradient and Hessian for OPF. """ f = self._f(x) df = self._df(x) d2f = self._d2f(x) return f, df, d2f
def _costfcn(self, x): """ Evaluates the objective function, gradient and Hessian for OPF. """ f = self._f(x) df = self._df(x) d2f = self._d2f(x) return f, df, d2f
[ "Evaluates", "the", "objective", "function", "gradient", "and", "Hessian", "for", "OPF", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L716-L723
[ "def", "_costfcn", "(", "self", ",", "x", ")", ":", "f", "=", "self", ".", "_f", "(", "x", ")", "df", "=", "self", ".", "_df", "(", "x", ")", "d2f", "=", "self", ".", "_d2f", "(", "x", ")", "return", "f", ",", "df", ",", "d2f" ]
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._consfcn
Evaluates nonlinear constraints and their Jacobian for OPF.
pylon/solver.py
def _consfcn(self, x): """ Evaluates nonlinear constraints and their Jacobian for OPF. """ h, g = self._gh(x) dh, dg = self._dgh(x) return h, g, dh, dg
def _consfcn(self, x): """ Evaluates nonlinear constraints and their Jacobian for OPF. """ h, g = self._gh(x) dh, dg = self._dgh(x) return h, g, dh, dg
[ "Evaluates", "nonlinear", "constraints", "and", "their", "Jacobian", "for", "OPF", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L726-L732
[ "def", "_consfcn", "(", "self", ",", "x", ")", ":", "h", ",", "g", "=", "self", ".", "_gh", "(", "x", ")", "dh", ",", "dg", "=", "self", ".", "_dgh", "(", "x", ")", "return", "h", ",", "g", ",", "dh", ",", "dg" ]
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._hessfcn
Evaluates Hessian of Lagrangian for AC OPF.
pylon/solver.py
def _hessfcn(self, x, lmbda): """ Evaluates Hessian of Lagrangian for AC OPF. """ Pgen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. Qgen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. for i, g in enumerate(self._gn): g.p = Pgen[i] * se...
def _hessfcn(self, x, lmbda): """ Evaluates Hessian of Lagrangian for AC OPF. """ Pgen = x[self._Pg.i1:self._Pg.iN + 1] # Active generation in p.u. Qgen = x[self._Qg.i1:self._Qg.iN + 1] # Reactive generation in p.u. for i, g in enumerate(self._gn): g.p = Pgen[i] * se...
[ "Evaluates", "Hessian", "of", "Lagrangian", "for", "AC", "OPF", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L735-L833
[ "def", "_hessfcn", "(", "self", ",", "x", ",", "lmbda", ")", ":", "Pgen", "=", "x", "[", "self", ".", "_Pg", ".", "i1", ":", "self", ".", "_Pg", ".", "iN", "+", "1", "]", "# Active generation in p.u.", "Qgen", "=", "x", "[", "self", ".", "_Qg", ...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._update_solution_data
Returns the voltage angle and generator set-point vectors.
pylon/solver.py
def _update_solution_data(self, s): """ Returns the voltage angle and generator set-point vectors. """ x = s["x"] # Va_var = self.om.get_var("Va") # Vm_var = self.om.get_var("Vm") # Pg_var = self.om.get_var("Pg") # Qg_var = self.om.get_var("Qg") Va = x[self._...
def _update_solution_data(self, s): """ Returns the voltage angle and generator set-point vectors. """ x = s["x"] # Va_var = self.om.get_var("Va") # Vm_var = self.om.get_var("Vm") # Pg_var = self.om.get_var("Pg") # Qg_var = self.om.get_var("Qg") Va = x[self._...
[ "Returns", "the", "voltage", "angle", "and", "generator", "set", "-", "point", "vectors", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L836-L857
[ "def", "_update_solution_data", "(", "self", ",", "s", ")", ":", "x", "=", "s", "[", "\"x\"", "]", "# Va_var = self.om.get_var(\"Va\")", "# Vm_var = self.om.get_var(\"Vm\")", "# Pg_var = self.om.get_var(\"Pg\")", "# Qg_var = self.om.get_var(\"Qg\")", "...
916514255db1ae1661406f0283df756baf960d14
train
PIPSSolver._update_case
Calculates the result attribute values.
pylon/solver.py
def _update_case(self, bs, ln, gn, base_mva, Yf, Yt, Va, Vm, Pg, Qg,lmbda): """ Calculates the result attribute values. """ V = Vm * exp(1j * Va) # Va_var = self.om.get_var("Va") Vm_var = self._Vm Pmis = self.om.get_nln_constraint("Pmis") Qmis = self.om.get_nln_co...
def _update_case(self, bs, ln, gn, base_mva, Yf, Yt, Va, Vm, Pg, Qg,lmbda): """ Calculates the result attribute values. """ V = Vm * exp(1j * Va) # Va_var = self.om.get_var("Va") Vm_var = self._Vm Pmis = self.om.get_nln_constraint("Pmis") Qmis = self.om.get_nln_co...
[ "Calculates", "the", "result", "attribute", "values", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/solver.py#L860-L917
[ "def", "_update_case", "(", "self", ",", "bs", ",", "ln", ",", "gn", ",", "base_mva", ",", "Yf", ",", "Yt", ",", "Va", ",", "Vm", ",", "Pg", ",", "Qg", ",", "lmbda", ")", ":", "V", "=", "Vm", "*", "exp", "(", "1j", "*", "Va", ")", "# ...
916514255db1ae1661406f0283df756baf960d14
train
Serializer.serialize
Serializes the given serializable object or collection of serializable objects. :param serializable: the object or objects to serialize :return: a serialization of the given object
hgijson/serialization.py
def serialize(self, serializable: Optional[Union[SerializableType, List[SerializableType]]]) \ -> PrimitiveJsonType: """ Serializes the given serializable object or collection of serializable objects. :param serializable: the object or objects to serialize :return: a serializ...
def serialize(self, serializable: Optional[Union[SerializableType, List[SerializableType]]]) \ -> PrimitiveJsonType: """ Serializes the given serializable object or collection of serializable objects. :param serializable: the object or objects to serialize :return: a serializ...
[ "Serializes", "the", "given", "serializable", "object", "or", "collection", "of", "serializable", "objects", ".", ":", "param", "serializable", ":", "the", "object", "or", "objects", "to", "serialize", ":", "return", ":", "a", "serialization", "of", "the", "gi...
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/serialization.py#L117-L141
[ "def", "serialize", "(", "self", ",", "serializable", ":", "Optional", "[", "Union", "[", "SerializableType", ",", "List", "[", "SerializableType", "]", "]", "]", ")", "->", "PrimitiveJsonType", ":", "if", "serializable", "is", "None", ":", "# Implements #17",...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
Serializer._serialize_property_value
Serializes the given value using the given serializer. :param to_serialize: the value to deserialize :param serializer_cls: the type of serializer to use :return: serialized value
hgijson/serialization.py
def _serialize_property_value(self, to_serialize: Any, serializer_cls: Type) -> Any: """ Serializes the given value using the given serializer. :param to_serialize: the value to deserialize :param serializer_cls: the type of serializer to use :return: serialized value """...
def _serialize_property_value(self, to_serialize: Any, serializer_cls: Type) -> Any: """ Serializes the given value using the given serializer. :param to_serialize: the value to deserialize :param serializer_cls: the type of serializer to use :return: serialized value """...
[ "Serializes", "the", "given", "value", "using", "the", "given", "serializer", ".", ":", "param", "to_serialize", ":", "the", "value", "to", "deserialize", ":", "param", "serializer_cls", ":", "the", "type", "of", "serializer", "to", "use", ":", "return", ":"...
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/serialization.py#L143-L152
[ "def", "_serialize_property_value", "(", "self", ",", "to_serialize", ":", "Any", ",", "serializer_cls", ":", "Type", ")", "->", "Any", ":", "serializer", "=", "self", ".", "_create_serializer_of_type_with_cache", "(", "serializer_cls", ")", "assert", "serializer", ...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
Serializer._create_serializer_of_type_with_cache
Creates a deserializer of the given type, exploiting a cache. :param serializer_type: the type of deserializer to create :return: the created serializer
hgijson/serialization.py
def _create_serializer_of_type_with_cache(self, serializer_type: Type) -> "Serializer": """ Creates a deserializer of the given type, exploiting a cache. :param serializer_type: the type of deserializer to create :return: the created serializer """ if serializer_type not ...
def _create_serializer_of_type_with_cache(self, serializer_type: Type) -> "Serializer": """ Creates a deserializer of the given type, exploiting a cache. :param serializer_type: the type of deserializer to create :return: the created serializer """ if serializer_type not ...
[ "Creates", "a", "deserializer", "of", "the", "given", "type", "exploiting", "a", "cache", ".", ":", "param", "serializer_type", ":", "the", "type", "of", "deserializer", "to", "create", ":", "return", ":", "the", "created", "serializer" ]
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/serialization.py#L154-L162
[ "def", "_create_serializer_of_type_with_cache", "(", "self", ",", "serializer_type", ":", "Type", ")", "->", "\"Serializer\"", ":", "if", "serializer_type", "not", "in", "self", ".", "_serializers_cache", ":", "self", ".", "_serializers_cache", "[", "serializer_type",...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
Deserializer.deserialize
Deserializes the given representation of the serialized object. :param to_deserialize: the serialized object as a dictionary :return: the deserialized object or collection of deserialized objects
hgijson/serialization.py
def deserialize(self, to_deserialize: PrimitiveJsonType) \ -> Optional[Union[SerializableType, List[SerializableType]]]: """ Deserializes the given representation of the serialized object. :param to_deserialize: the serialized object as a dictionary :return: the deserialized ...
def deserialize(self, to_deserialize: PrimitiveJsonType) \ -> Optional[Union[SerializableType, List[SerializableType]]]: """ Deserializes the given representation of the serialized object. :param to_deserialize: the serialized object as a dictionary :return: the deserialized ...
[ "Deserializes", "the", "given", "representation", "of", "the", "serialized", "object", ".", ":", "param", "to_deserialize", ":", "the", "serialized", "object", "as", "a", "dictionary", ":", "return", ":", "the", "deserialized", "object", "or", "collection", "of"...
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/serialization.py#L188-L237
[ "def", "deserialize", "(", "self", ",", "to_deserialize", ":", "PrimitiveJsonType", ")", "->", "Optional", "[", "Union", "[", "SerializableType", ",", "List", "[", "SerializableType", "]", "]", "]", ":", "if", "to_deserialize", "is", "None", ":", "# Implements...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
Deserializer._deserialize_property_value
Deserializes the given value using the given deserializer. :param to_deserialize: the value to deserialize :param deserializer_cls: the type of deserializer to use :return: deserialized value
hgijson/serialization.py
def _deserialize_property_value(self, to_deserialize: PrimitiveJsonType, deserializer_cls: Type) -> Any: """ Deserializes the given value using the given deserializer. :param to_deserialize: the value to deserialize :param deserializer_cls: the type of deserializer to use :return...
def _deserialize_property_value(self, to_deserialize: PrimitiveJsonType, deserializer_cls: Type) -> Any: """ Deserializes the given value using the given deserializer. :param to_deserialize: the value to deserialize :param deserializer_cls: the type of deserializer to use :return...
[ "Deserializes", "the", "given", "value", "using", "the", "given", "deserializer", ".", ":", "param", "to_deserialize", ":", "the", "value", "to", "deserialize", ":", "param", "deserializer_cls", ":", "the", "type", "of", "deserializer", "to", "use", ":", "retu...
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/serialization.py#L239-L248
[ "def", "_deserialize_property_value", "(", "self", ",", "to_deserialize", ":", "PrimitiveJsonType", ",", "deserializer_cls", ":", "Type", ")", "->", "Any", ":", "deserializer", "=", "self", ".", "_create_deserializer_of_type_with_cache", "(", "deserializer_cls", ")", ...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
Deserializer._create_deserializer_of_type_with_cache
Creates a deserializer of the given type, exploiting a cache. :param deserializer_type: the type of deserializer to create :return: the deserializer
hgijson/serialization.py
def _create_deserializer_of_type_with_cache(self, deserializer_type: Type) -> "Deserializer": """ Creates a deserializer of the given type, exploiting a cache. :param deserializer_type: the type of deserializer to create :return: the deserializer """ if deserializer_type ...
def _create_deserializer_of_type_with_cache(self, deserializer_type: Type) -> "Deserializer": """ Creates a deserializer of the given type, exploiting a cache. :param deserializer_type: the type of deserializer to create :return: the deserializer """ if deserializer_type ...
[ "Creates", "a", "deserializer", "of", "the", "given", "type", "exploiting", "a", "cache", ".", ":", "param", "deserializer_type", ":", "the", "type", "of", "deserializer", "to", "create", ":", "return", ":", "the", "deserializer" ]
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/serialization.py#L250-L258
[ "def", "_create_deserializer_of_type_with_cache", "(", "self", ",", "deserializer_type", ":", "Type", ")", "->", "\"Deserializer\"", ":", "if", "deserializer_type", "not", "in", "self", ".", "_deserializers_cache", ":", "self", ".", "_deserializers_cache", "[", "deser...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
sim
Simulates a Dae model. :model: The model to simulate :options: See opt dict below :user_callback: A routine to call after each integration step, f(t, x, y, m, p, c) -> ret (ret < 0 means abort)
src/pymoca/backends/xml/sim_scipy.py
def sim(model: HybridOde, options: Dict = None, # noqa: too-complex user_callback=None) -> Dict[str, np.array]: """ Simulates a Dae model. :model: The model to simulate :options: See opt dict below :user_callback: A routine to call after each integration step, f(t, x, y, m, p, c) -> ...
def sim(model: HybridOde, options: Dict = None, # noqa: too-complex user_callback=None) -> Dict[str, np.array]: """ Simulates a Dae model. :model: The model to simulate :options: See opt dict below :user_callback: A routine to call after each integration step, f(t, x, y, m, p, c) -> ...
[ "Simulates", "a", "Dae", "model", "." ]
pymoca/pymoca
python
https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/src/pymoca/backends/xml/sim_scipy.py#L16-L188
[ "def", "sim", "(", "model", ":", "HybridOde", ",", "options", ":", "Dict", "=", "None", ",", "# noqa: too-complex", "user_callback", "=", "None", ")", "->", "Dict", "[", "str", ",", "np", ".", "array", "]", ":", "if", "model", ".", "f_x_rhs", ".", "s...
14b5eb7425e96689de6cc5c10f400895d586a978
train
PickleReader.read
Loads a pickled case.
pylon/io/pickle.py
def read(self, file_or_filename): """ Loads a pickled case. """ if isinstance(file_or_filename, basestring): fname = os.path.basename(file_or_filename) logger.info("Unpickling case file [%s]." % fname) file = None try: file = open(...
def read(self, file_or_filename): """ Loads a pickled case. """ if isinstance(file_or_filename, basestring): fname = os.path.basename(file_or_filename) logger.info("Unpickling case file [%s]." % fname) file = None try: file = open(...
[ "Loads", "a", "pickled", "case", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/pickle.py#L45-L66
[ "def", "read", "(", "self", ",", "file_or_filename", ")", ":", "if", "isinstance", "(", "file_or_filename", ",", "basestring", ")", ":", "fname", "=", "os", ".", "path", ".", "basename", "(", "file_or_filename", ")", "logger", ".", "info", "(", "\"Unpickli...
916514255db1ae1661406f0283df756baf960d14
train
PickleWriter.write
Writes the case to file using pickle.
pylon/io/pickle.py
def write(self, file_or_filename): """ Writes the case to file using pickle. """ if isinstance(file_or_filename, basestring): fname = os.path.basename(file_or_filename) logger.info("Pickling case [%s]." % fname) file = None try: fi...
def write(self, file_or_filename): """ Writes the case to file using pickle. """ if isinstance(file_or_filename, basestring): fname = os.path.basename(file_or_filename) logger.info("Pickling case [%s]." % fname) file = None try: fi...
[ "Writes", "the", "case", "to", "file", "using", "pickle", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/pickle.py#L76-L97
[ "def", "write", "(", "self", ",", "file_or_filename", ")", ":", "if", "isinstance", "(", "file_or_filename", ",", "basestring", ")", ":", "fname", "=", "os", ".", "path", ".", "basename", "(", "file_or_filename", ")", "logger", ".", "info", "(", "\"Picklin...
916514255db1ae1661406f0283df756baf960d14
train
SLOCMetric.process_token
count comments and non-empty lines that contain code
metrics/sloc.py
def process_token(self, tok): """count comments and non-empty lines that contain code""" if(tok[0].__str__() in ('Token.Comment.Multiline', 'Token.Comment', 'Token.Literal.String.Doc')): self.comments += tok[1].count('\n')+1 elif(tok[0].__str__() in ('Token.Comment.Si...
def process_token(self, tok): """count comments and non-empty lines that contain code""" if(tok[0].__str__() in ('Token.Comment.Multiline', 'Token.Comment', 'Token.Literal.String.Doc')): self.comments += tok[1].count('\n')+1 elif(tok[0].__str__() in ('Token.Comment.Si...
[ "count", "comments", "and", "non", "-", "empty", "lines", "that", "contain", "code" ]
finklabs/metrics
python
https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/sloc.py#L34-L53
[ "def", "process_token", "(", "self", ",", "tok", ")", ":", "if", "(", "tok", "[", "0", "]", ".", "__str__", "(", ")", "in", "(", "'Token.Comment.Multiline'", ",", "'Token.Comment'", ",", "'Token.Literal.String.Doc'", ")", ")", ":", "self", ".", "comments",...
fd9974af498831664b9ae8e8f3834e1ec2e8a699
train
SLOCMetric.get_metrics
Calculate ratio_comment_to_code and return with the other values
metrics/sloc.py
def get_metrics(self): """Calculate ratio_comment_to_code and return with the other values""" if(self.sloc == 0): if(self.comments == 0): ratio_comment_to_code = 0.00 else: ratio_comment_to_code = 1.00 else: ratio_comment_to_cod...
def get_metrics(self): """Calculate ratio_comment_to_code and return with the other values""" if(self.sloc == 0): if(self.comments == 0): ratio_comment_to_code = 0.00 else: ratio_comment_to_code = 1.00 else: ratio_comment_to_cod...
[ "Calculate", "ratio_comment_to_code", "and", "return", "with", "the", "other", "values" ]
finklabs/metrics
python
https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/sloc.py#L68-L79
[ "def", "get_metrics", "(", "self", ")", ":", "if", "(", "self", ".", "sloc", "==", "0", ")", ":", "if", "(", "self", ".", "comments", "==", "0", ")", ":", "ratio_comment_to_code", "=", "0.00", "else", ":", "ratio_comment_to_code", "=", "1.00", "else", ...
fd9974af498831664b9ae8e8f3834e1ec2e8a699
train
CaseEnvironment.getSensors
Returns the currently visible state of the world as a numpy array of doubles.
pyreto/rlopf.py
def getSensors(self): """ Returns the currently visible state of the world as a numpy array of doubles. """ Pd = array([b.p_demand for b in self.case.buses if b.type == PQ]) logger.info("State: %s" % list(Pd)) return Pd
def getSensors(self): """ Returns the currently visible state of the world as a numpy array of doubles. """ Pd = array([b.p_demand for b in self.case.buses if b.type == PQ]) logger.info("State: %s" % list(Pd)) return Pd
[ "Returns", "the", "currently", "visible", "state", "of", "the", "world", "as", "a", "numpy", "array", "of", "doubles", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L100-L106
[ "def", "getSensors", "(", "self", ")", ":", "Pd", "=", "array", "(", "[", "b", ".", "p_demand", "for", "b", "in", "self", ".", "case", ".", "buses", "if", "b", ".", "type", "==", "PQ", "]", ")", "logger", ".", "info", "(", "\"State: %s\"", "%", ...
916514255db1ae1661406f0283df756baf960d14
train
CaseEnvironment.performAction
Perform an action on the world that changes it's internal state.
pyreto/rlopf.py
def performAction(self, action): """ Perform an action on the world that changes it's internal state. """ gs = [g for g in self.case.online_generators if g.bus.type !=REFERENCE] assert len(action) == len(gs) logger.info("Action: %s" % list(action)) # Set the output of ...
def performAction(self, action): """ Perform an action on the world that changes it's internal state. """ gs = [g for g in self.case.online_generators if g.bus.type !=REFERENCE] assert len(action) == len(gs) logger.info("Action: %s" % list(action)) # Set the output of ...
[ "Perform", "an", "action", "on", "the", "world", "that", "changes", "it", "s", "internal", "state", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L109-L137
[ "def", "performAction", "(", "self", ",", "action", ")", ":", "gs", "=", "[", "g", "for", "g", "in", "self", ".", "case", ".", "online_generators", "if", "g", ".", "bus", ".", "type", "!=", "REFERENCE", "]", "assert", "len", "(", "action", ")", "==...
916514255db1ae1661406f0283df756baf960d14
train
CaseEnvironment.reset
Re-initialises the environment.
pyreto/rlopf.py
def reset(self): """ Re-initialises the environment. """ logger.info("Reseting environment.") self._step = 0 # Reset the set-point of each generator to its original value. gs = [g for g in self.case.online_generators if g.bus.type !=REFERENCE] for i, g in enumer...
def reset(self): """ Re-initialises the environment. """ logger.info("Reseting environment.") self._step = 0 # Reset the set-point of each generator to its original value. gs = [g for g in self.case.online_generators if g.bus.type !=REFERENCE] for i, g in enumer...
[ "Re", "-", "initialises", "the", "environment", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L140-L162
[ "def", "reset", "(", "self", ")", ":", "logger", ".", "info", "(", "\"Reseting environment.\"", ")", "self", ".", "_step", "=", "0", "# Reset the set-point of each generator to its original value.", "gs", "=", "[", "g", "for", "g", "in", "self", ".", "case", "...
916514255db1ae1661406f0283df756baf960d14
train
MinimiseCostTask.getReward
Returns the reward corresponding to the last action performed.
pyreto/rlopf.py
def getReward(self): """ Returns the reward corresponding to the last action performed. """ on = self.env.case.online_generators generators = [g for g in on if g.bus.type != REFERENCE] cost = sum([g.total_cost() for g in generators]) ref_penalty = 1000.0 refs =...
def getReward(self): """ Returns the reward corresponding to the last action performed. """ on = self.env.case.online_generators generators = [g for g in on if g.bus.type != REFERENCE] cost = sum([g.total_cost() for g in generators]) ref_penalty = 1000.0 refs =...
[ "Returns", "the", "reward", "corresponding", "to", "the", "last", "action", "performed", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L191-L213
[ "def", "getReward", "(", "self", ")", ":", "on", "=", "self", ".", "env", ".", "case", ".", "online_generators", "generators", "=", "[", "g", "for", "g", "in", "on", "if", "g", ".", "bus", ".", "type", "!=", "REFERENCE", "]", "cost", "=", "sum", ...
916514255db1ae1661406f0283df756baf960d14
train
MinimiseCostTask.isFinished
Is the current episode over?
pyreto/rlopf.py
def isFinished(self): """ Is the current episode over? """ finished = (self.env._step == len(self.env.profile)) if finished: logger.info("Finished episode.") return finished
def isFinished(self): """ Is the current episode over? """ finished = (self.env._step == len(self.env.profile)) if finished: logger.info("Finished episode.") return finished
[ "Is", "the", "current", "episode", "over?" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L216-L222
[ "def", "isFinished", "(", "self", ")", ":", "finished", "=", "(", "self", ".", "env", ".", "_step", "==", "len", "(", "self", ".", "env", ".", "profile", ")", ")", "if", "finished", ":", "logger", ".", "info", "(", "\"Finished episode.\"", ")", "retu...
916514255db1ae1661406f0283df756baf960d14
train
MinimiseCostTask.getSensorLimits
Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)], one tuple per parameter, giving min and max for that parameter.
pyreto/rlopf.py
def getSensorLimits(self): """ Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)], one tuple per parameter, giving min and max for that parameter. """ limits = [] for i in range(len([b for b in self.env.case.buses if b.type == PQ])): limits.append((0.0,...
def getSensorLimits(self): """ Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)], one tuple per parameter, giving min and max for that parameter. """ limits = [] for i in range(len([b for b in self.env.case.buses if b.type == PQ])): limits.append((0.0,...
[ "Returns", "a", "list", "of", "2", "-", "tuples", "e", ".", "g", ".", "[", "(", "-", "3", ".", "14", "3", ".", "14", ")", "(", "-", "0", ".", "001", "0", ".", "001", ")", "]", "one", "tuple", "per", "parameter", "giving", "min", "and", "max...
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L228-L238
[ "def", "getSensorLimits", "(", "self", ")", ":", "limits", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "[", "b", "for", "b", "in", "self", ".", "env", ".", "case", ".", "buses", "if", "b", ".", "type", "==", "PQ", "]", ")", ")"...
916514255db1ae1661406f0283df756baf960d14
train
MinimiseCostTask.getActorLimits
Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)], one tuple per parameter, giving min and max for that parameter.
pyreto/rlopf.py
def getActorLimits(self): """ Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)], one tuple per parameter, giving min and max for that parameter. """ generators = [g for g in self.env.case.online_generators if g.bus.type != REFERENCE] limits =...
def getActorLimits(self): """ Returns a list of 2-tuples, e.g. [(-3.14, 3.14), (-0.001, 0.001)], one tuple per parameter, giving min and max for that parameter. """ generators = [g for g in self.env.case.online_generators if g.bus.type != REFERENCE] limits =...
[ "Returns", "a", "list", "of", "2", "-", "tuples", "e", ".", "g", ".", "[", "(", "-", "3", ".", "14", "3", ".", "14", ")", "(", "-", "0", ".", "001", "0", ".", "001", ")", "]", "one", "tuple", "per", "parameter", "giving", "min", "and", "max...
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L241-L253
[ "def", "getActorLimits", "(", "self", ")", ":", "generators", "=", "[", "g", "for", "g", "in", "self", ".", "env", ".", "case", ".", "online_generators", "if", "g", ".", "bus", ".", "type", "!=", "REFERENCE", "]", "limits", "=", "[", "]", "for", "g...
916514255db1ae1661406f0283df756baf960d14
train
OPFExperiment._oneInteraction
Does one interaction between the task and the agent.
pyreto/rlopf.py
def _oneInteraction(self): """ Does one interaction between the task and the agent. """ if self.doOptimization: raise Exception('When using a black-box learning algorithm, only full episodes can be done.') else: self.stepid += 1 self.agent.integrateObs...
def _oneInteraction(self): """ Does one interaction between the task and the agent. """ if self.doOptimization: raise Exception('When using a black-box learning algorithm, only full episodes can be done.') else: self.stepid += 1 self.agent.integrateObs...
[ "Does", "one", "interaction", "between", "the", "task", "and", "the", "agent", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L272-L288
[ "def", "_oneInteraction", "(", "self", ")", ":", "if", "self", ".", "doOptimization", ":", "raise", "Exception", "(", "'When using a black-box learning algorithm, only full episodes can be done.'", ")", "else", ":", "self", ".", "stepid", "+=", "1", "self", ".", "ag...
916514255db1ae1661406f0283df756baf960d14
train
OPFExperiment.doEpisodes
Does the the given number of episodes.
pyreto/rlopf.py
def doEpisodes(self, number=1): """ Does the the given number of episodes. """ env = self.task.env self.Pg = zeros((len(env.case.online_generators), len(env.profile))) rewards = super(OPFExperiment, self).doEpisodes(number) # Average the set-points for each period. ...
def doEpisodes(self, number=1): """ Does the the given number of episodes. """ env = self.task.env self.Pg = zeros((len(env.case.online_generators), len(env.profile))) rewards = super(OPFExperiment, self).doEpisodes(number) # Average the set-points for each period. ...
[ "Does", "the", "the", "given", "number", "of", "episodes", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/rlopf.py#L291-L302
[ "def", "doEpisodes", "(", "self", ",", "number", "=", "1", ")", ":", "env", "=", "self", ".", "task", ".", "env", "self", ".", "Pg", "=", "zeros", "(", "(", "len", "(", "env", ".", "case", ".", "online_generators", ")", ",", "len", "(", "env", ...
916514255db1ae1661406f0283df756baf960d14
train
AutomaticJSONEncoderClassBuilder.get_json_encoders_for_type
Gets the registered JSON encoder for the given type. :param type_to_encode: the type of object that is to be encoded :return: the encoder for the given object else `None` if unknown
hgijson/json_converters/automatic.py
def get_json_encoders_for_type(self, type_to_encode: type) -> Optional[Iterable[JSONEncoder]]: """ Gets the registered JSON encoder for the given type. :param type_to_encode: the type of object that is to be encoded :return: the encoder for the given object else `None` if unknown ...
def get_json_encoders_for_type(self, type_to_encode: type) -> Optional[Iterable[JSONEncoder]]: """ Gets the registered JSON encoder for the given type. :param type_to_encode: the type of object that is to be encoded :return: the encoder for the given object else `None` if unknown ...
[ "Gets", "the", "registered", "JSON", "encoder", "for", "the", "given", "type", ".", ":", "param", "type_to_encode", ":", "the", "type", "of", "object", "that", "is", "to", "be", "encoded", ":", "return", ":", "the", "encoder", "for", "the", "given", "obj...
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/json_converters/automatic.py#L83-L91
[ "def", "get_json_encoders_for_type", "(", "self", ",", "type_to_encode", ":", "type", ")", "->", "Optional", "[", "Iterable", "[", "JSONEncoder", "]", "]", ":", "if", "type_to_encode", "not", "in", "self", ".", "_json_encoders", ":", "return", "None", "return"...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
AutomaticJSONEncoderClassBuilder.register_json_encoder
Register the given JSON encoder for use with the given object type. :param encoder_type: the type of object to encode :param encoder: the JSON encoder :return: this builder
hgijson/json_converters/automatic.py
def register_json_encoder(self, encoder_type: type, encoder: JSONEncoder): """ Register the given JSON encoder for use with the given object type. :param encoder_type: the type of object to encode :param encoder: the JSON encoder :return: this builder """ self._js...
def register_json_encoder(self, encoder_type: type, encoder: JSONEncoder): """ Register the given JSON encoder for use with the given object type. :param encoder_type: the type of object to encode :param encoder: the JSON encoder :return: this builder """ self._js...
[ "Register", "the", "given", "JSON", "encoder", "for", "use", "with", "the", "given", "object", "type", ".", ":", "param", "encoder_type", ":", "the", "type", "of", "object", "to", "encode", ":", "param", "encoder", ":", "the", "JSON", "encoder", ":", "re...
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/json_converters/automatic.py#L93-L101
[ "def", "register_json_encoder", "(", "self", ",", "encoder_type", ":", "type", ",", "encoder", ":", "JSONEncoder", ")", ":", "self", ".", "_json_encoders", "[", "encoder_type", "]", "=", "encoder", "return", "self" ]
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
AutomaticJSONEncoderClassBuilder.build
Builds JSON encoder that uses the encoders registered at the point in time when this method is called. :return: the JSON encoder
hgijson/json_converters/automatic.py
def build(self) -> RegisteredTypeJSONEncoderType: """ Builds JSON encoder that uses the encoders registered at the point in time when this method is called. :return: the JSON encoder """ class_name = "%s_%s" % (_RegisteredTypeJSONEncoder.__class__.__name__, id(self)) # Us...
def build(self) -> RegisteredTypeJSONEncoderType: """ Builds JSON encoder that uses the encoders registered at the point in time when this method is called. :return: the JSON encoder """ class_name = "%s_%s" % (_RegisteredTypeJSONEncoder.__class__.__name__, id(self)) # Us...
[ "Builds", "JSON", "encoder", "that", "uses", "the", "encoders", "registered", "at", "the", "point", "in", "time", "when", "this", "method", "is", "called", ".", ":", "return", ":", "the", "JSON", "encoder" ]
wtsi-hgi/python-hgijson
python
https://github.com/wtsi-hgi/python-hgijson/blob/6e8ccb562eabcaa816a136268a16504c2e0d4664/hgijson/json_converters/automatic.py#L109-L123
[ "def", "build", "(", "self", ")", "->", "RegisteredTypeJSONEncoderType", ":", "class_name", "=", "\"%s_%s\"", "%", "(", "_RegisteredTypeJSONEncoder", ".", "__class__", ".", "__name__", ",", "id", "(", "self", ")", ")", "# Use encoders set at the point in time at which...
6e8ccb562eabcaa816a136268a16504c2e0d4664
train
getMethodByName
searches for an object with the name given inside the object given. "obj.child.meth" will return the meth obj.
contrib/public/services/jsonrpc/__init__.py
def getMethodByName(obj, name): """searches for an object with the name given inside the object given. "obj.child.meth" will return the meth obj. """ try:#to get a method by asking the service obj = obj._getMethodByName(name) except: #assumed a childObject is ment #split...
def getMethodByName(obj, name): """searches for an object with the name given inside the object given. "obj.child.meth" will return the meth obj. """ try:#to get a method by asking the service obj = obj._getMethodByName(name) except: #assumed a childObject is ment #split...
[ "searches", "for", "an", "object", "with", "the", "name", "given", "inside", "the", "object", "given", ".", "obj", ".", "child", ".", "meth", "will", "return", "the", "meth", "obj", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L168-L186
[ "def", "getMethodByName", "(", "obj", ",", "name", ")", ":", "try", ":", "#to get a method by asking the service", "obj", "=", "obj", ".", "_getMethodByName", "(", "name", ")", "except", ":", "#assumed a childObject is ment ", "#split the name from objName.childObjName......
916514255db1ae1661406f0283df756baf960d14
train
ResponseEvent.waitForResponse
blocks until the response arrived or timeout is reached.
contrib/public/services/jsonrpc/__init__.py
def waitForResponse(self, timeOut=None): """blocks until the response arrived or timeout is reached.""" self.__evt.wait(timeOut) if self.waiting(): raise Timeout() else: if self.response["error"]: raise Exception(self.response["error"]) ...
def waitForResponse(self, timeOut=None): """blocks until the response arrived or timeout is reached.""" self.__evt.wait(timeOut) if self.waiting(): raise Timeout() else: if self.response["error"]: raise Exception(self.response["error"]) ...
[ "blocks", "until", "the", "response", "arrived", "or", "timeout", "is", "reached", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L51-L60
[ "def", "waitForResponse", "(", "self", ",", "timeOut", "=", "None", ")", ":", "self", ".", "__evt", ".", "wait", "(", "timeOut", ")", "if", "self", ".", "waiting", "(", ")", ":", "raise", "Timeout", "(", ")", "else", ":", "if", "self", ".", "respon...
916514255db1ae1661406f0283df756baf960d14
train
SimpleMessageHandler.sendRequest
sends a request to the peer
contrib/public/services/jsonrpc/__init__.py
def sendRequest(self, name, args): """sends a request to the peer""" (respEvt, id) = self.newResponseEvent() self.sendMessage({"id":id, "method":name, "params": args}) return respEvt
def sendRequest(self, name, args): """sends a request to the peer""" (respEvt, id) = self.newResponseEvent() self.sendMessage({"id":id, "method":name, "params": args}) return respEvt
[ "sends", "a", "request", "to", "the", "peer" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L108-L112
[ "def", "sendRequest", "(", "self", ",", "name", ",", "args", ")", ":", "(", "respEvt", ",", "id", ")", "=", "self", ".", "newResponseEvent", "(", ")", "self", ".", "sendMessage", "(", "{", "\"id\"", ":", "id", ",", "\"method\"", ":", "name", ",", "...
916514255db1ae1661406f0283df756baf960d14
train
SimpleMessageHandler.sendResponse
sends a response to the peer
contrib/public/services/jsonrpc/__init__.py
def sendResponse(self, id, result, error): """sends a response to the peer""" self.sendMessage({"result":result, "error": error, "id":id})
def sendResponse(self, id, result, error): """sends a response to the peer""" self.sendMessage({"result":result, "error": error, "id":id})
[ "sends", "a", "response", "to", "the", "peer" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L114-L116
[ "def", "sendResponse", "(", "self", ",", "id", ",", "result", ",", "error", ")", ":", "self", ".", "sendMessage", "(", "{", "\"result\"", ":", "result", ",", "\"error\"", ":", "error", ",", "\"id\"", ":", "id", "}", ")" ]
916514255db1ae1661406f0283df756baf960d14
train
SimpleMessageHandler.newResponseEvent
creates a response event and adds it to a waiting list When the reponse arrives it will be removed from the list.
contrib/public/services/jsonrpc/__init__.py
def newResponseEvent(self): """creates a response event and adds it to a waiting list When the reponse arrives it will be removed from the list. """ respEvt = ResponseEvent() self.respLock.acquire() eid = id(respEvt) self.respEvents[eid] = respEvt self...
def newResponseEvent(self): """creates a response event and adds it to a waiting list When the reponse arrives it will be removed from the list. """ respEvt = ResponseEvent() self.respLock.acquire() eid = id(respEvt) self.respEvents[eid] = respEvt self...
[ "creates", "a", "response", "event", "and", "adds", "it", "to", "a", "waiting", "list", "When", "the", "reponse", "arrives", "it", "will", "be", "removed", "from", "the", "list", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L118-L127
[ "def", "newResponseEvent", "(", "self", ")", ":", "respEvt", "=", "ResponseEvent", "(", ")", "self", ".", "respLock", ".", "acquire", "(", ")", "eid", "=", "id", "(", "respEvt", ")", "self", ".", "respEvents", "[", "eid", "]", "=", "respEvt", "self", ...
916514255db1ae1661406f0283df756baf960d14
train
SimpleMessageHandler.handleResponse
handles a response by fireing the response event for the response coming in
contrib/public/services/jsonrpc/__init__.py
def handleResponse(self, resp): """handles a response by fireing the response event for the response coming in""" id=resp["id"] evt = self.respEvents[id] del(self.respEvents[id]) evt.handleResponse(resp)
def handleResponse(self, resp): """handles a response by fireing the response event for the response coming in""" id=resp["id"] evt = self.respEvents[id] del(self.respEvents[id]) evt.handleResponse(resp)
[ "handles", "a", "response", "by", "fireing", "the", "response", "event", "for", "the", "response", "coming", "in" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L145-L150
[ "def", "handleResponse", "(", "self", ",", "resp", ")", ":", "id", "=", "resp", "[", "\"id\"", "]", "evt", "=", "self", ".", "respEvents", "[", "id", "]", "del", "(", "self", ".", "respEvents", "[", "id", "]", ")", "evt", ".", "handleResponse", "("...
916514255db1ae1661406f0283df756baf960d14
train
SimpleServiceHandler.handleRequest
handles a request by calling the appropriete method the service exposes
contrib/public/services/jsonrpc/__init__.py
def handleRequest(self, req): """handles a request by calling the appropriete method the service exposes""" name = req["method"] params = req["params"] id=req["id"] obj=None try: #to get a callable obj obj = getMethodByName(self.service, name) except ...
def handleRequest(self, req): """handles a request by calling the appropriete method the service exposes""" name = req["method"] params = req["params"] id=req["id"] obj=None try: #to get a callable obj obj = getMethodByName(self.service, name) except ...
[ "handles", "a", "request", "by", "calling", "the", "appropriete", "method", "the", "service", "exposes" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L205-L227
[ "def", "handleRequest", "(", "self", ",", "req", ")", ":", "name", "=", "req", "[", "\"method\"", "]", "params", "=", "req", "[", "\"params\"", "]", "id", "=", "req", "[", "\"id\"", "]", "obj", "=", "None", "try", ":", "#to get a callable obj ", "obj",...
916514255db1ae1661406f0283df756baf960d14
train
SimpleServiceHandler.handleNotification
handles a notification request by calling the appropriete method the service exposes
contrib/public/services/jsonrpc/__init__.py
def handleNotification(self, req): """handles a notification request by calling the appropriete method the service exposes""" name = req["method"] params = req["params"] try: #to get a callable obj obj = getMethodByName(self.service, name) rslt = obj(*params) ...
def handleNotification(self, req): """handles a notification request by calling the appropriete method the service exposes""" name = req["method"] params = req["params"] try: #to get a callable obj obj = getMethodByName(self.service, name) rslt = obj(*params) ...
[ "handles", "a", "notification", "request", "by", "calling", "the", "appropriete", "method", "the", "service", "exposes" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/jsonrpc/__init__.py#L229-L237
[ "def", "handleNotification", "(", "self", ",", "req", ")", ":", "name", "=", "req", "[", "\"method\"", "]", "params", "=", "req", "[", "\"params\"", "]", "try", ":", "#to get a callable obj ", "obj", "=", "getMethodByName", "(", "self", ".", "service", ","...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader.read
Parses a PSAT data file and returns a case object file_or_filename: File object or path to PSAT data file return: Case object
pylon/io/psat.py
def read(self, file_or_filename): """ Parses a PSAT data file and returns a case object file_or_filename: File object or path to PSAT data file return: Case object """ self.file_or_filename = file_or_filename logger.info("Parsing PSAT case file [%s]." % file_or_...
def read(self, file_or_filename): """ Parses a PSAT data file and returns a case object file_or_filename: File object or path to PSAT data file return: Case object """ self.file_or_filename = file_or_filename logger.info("Parsing PSAT case file [%s]." % file_or_...
[ "Parses", "a", "PSAT", "data", "file", "and", "returns", "a", "case", "object" ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L54-L101
[ "def", "read", "(", "self", ",", "file_or_filename", ")", ":", "self", ".", "file_or_filename", "=", "file_or_filename", "logger", ".", "info", "(", "\"Parsing PSAT case file [%s].\"", "%", "file_or_filename", ")", "t0", "=", "time", ".", "time", "(", ")", "se...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_bus_array_construct
Returns a construct for an array of bus data.
pylon/io/psat.py
def _get_bus_array_construct(self): """ Returns a construct for an array of bus data. """ bus_no = integer.setResultsName("bus_no") v_base = real.setResultsName("v_base") # kV v_magnitude = Optional(real).setResultsName("v_magnitude") v_angle = Optional(real).setResultsNa...
def _get_bus_array_construct(self): """ Returns a construct for an array of bus data. """ bus_no = integer.setResultsName("bus_no") v_base = real.setResultsName("v_base") # kV v_magnitude = Optional(real).setResultsName("v_magnitude") v_angle = Optional(real).setResultsNa...
[ "Returns", "a", "construct", "for", "an", "array", "of", "bus", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L107-L128
[ "def", "_get_bus_array_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "v_base", "=", "real", ".", "setResultsName", "(", "\"v_base\"", ")", "# kV", "v_magnitude", "=", "Optional", "(", "real", ")", ...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_line_array_construct
Returns a construct for an array of line data.
pylon/io/psat.py
def _get_line_array_construct(self): """ Returns a construct for an array of line data. """ from_bus = integer.setResultsName("fbus") to_bus = integer.setResultsName("tbus") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV ...
def _get_line_array_construct(self): """ Returns a construct for an array of line data. """ from_bus = integer.setResultsName("fbus") to_bus = integer.setResultsName("tbus") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV ...
[ "Returns", "a", "construct", "for", "an", "array", "of", "line", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L131-L160
[ "def", "_get_line_array_construct", "(", "self", ")", ":", "from_bus", "=", "integer", ".", "setResultsName", "(", "\"fbus\"", ")", "to_bus", "=", "integer", ".", "setResultsName", "(", "\"tbus\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_slack_array_construct
Returns a construct for an array of slack bus data.
pylon/io/psat.py
def _get_slack_array_construct(self): """ Returns a construct for an array of slack bus data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV v_magnitude = real.setResultsName("...
def _get_slack_array_construct(self): """ Returns a construct for an array of slack bus data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV v_magnitude = real.setResultsName("...
[ "Returns", "a", "construct", "for", "an", "array", "of", "slack", "bus", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L163-L190
[ "def", "_get_slack_array_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "v_rating", "=", "real", ".", "setResultsName"...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_pv_array_construct
Returns a construct for an array of PV generator data.
pylon/io/psat.py
def _get_pv_array_construct(self): """ Returns a construct for an array of PV generator data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV p = real.setResultsName("p") # p.u....
def _get_pv_array_construct(self): """ Returns a construct for an array of PV generator data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV p = real.setResultsName("p") # p.u....
[ "Returns", "a", "construct", "for", "an", "array", "of", "PV", "generator", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L193-L217
[ "def", "_get_pv_array_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "v_rating", "=", "real", ".", "setResultsName", ...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_pq_array_construct
Returns a construct for an array of PQ load data.
pylon/io/psat.py
def _get_pq_array_construct(self): """ Returns a construct for an array of PQ load data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV p = real.setResultsName("p") # p.u. ...
def _get_pq_array_construct(self): """ Returns a construct for an array of PQ load data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA v_rating = real.setResultsName("v_rating") # kV p = real.setResultsName("p") # p.u. ...
[ "Returns", "a", "construct", "for", "an", "array", "of", "PQ", "load", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L220-L242
[ "def", "_get_pq_array_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "v_rating", "=", "real", ".", "setResultsName", ...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_demand_array_construct
Returns a construct for an array of power demand data.
pylon/io/psat.py
def _get_demand_array_construct(self): """ Returns a construct for an array of power demand data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA p_direction = real.setResultsName("p_direction") # p.u. q_direction = real.setR...
def _get_demand_array_construct(self): """ Returns a construct for an array of power demand data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA p_direction = real.setResultsName("p_direction") # p.u. q_direction = real.setR...
[ "Returns", "a", "construct", "for", "an", "array", "of", "power", "demand", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L245-L278
[ "def", "_get_demand_array_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "p_direction", "=", "real", ".", "setResultsN...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_supply_array_construct
Returns a construct for an array of power supply data.
pylon/io/psat.py
def _get_supply_array_construct(self): """ Returns a construct for an array of power supply data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA p_direction = real.setResultsName("p_direction") # CPF p_bid_max = real.setResu...
def _get_supply_array_construct(self): """ Returns a construct for an array of power supply data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA p_direction = real.setResultsName("p_direction") # CPF p_bid_max = real.setResu...
[ "Returns", "a", "construct", "for", "an", "array", "of", "power", "supply", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L281-L316
[ "def", "_get_supply_array_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "p_direction", "=", "real", ".", "setResultsN...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_generator_ramping_construct
Returns a construct for an array of generator ramping data.
pylon/io/psat.py
def _get_generator_ramping_construct(self): """ Returns a construct for an array of generator ramping data. """ supply_no = integer.setResultsName("supply_no") s_rating = real.setResultsName("s_rating") # MVA up_rate = real.setResultsName("up_rate") # p.u./h down_rate = r...
def _get_generator_ramping_construct(self): """ Returns a construct for an array of generator ramping data. """ supply_no = integer.setResultsName("supply_no") s_rating = real.setResultsName("s_rating") # MVA up_rate = real.setResultsName("up_rate") # p.u./h down_rate = r...
[ "Returns", "a", "construct", "for", "an", "array", "of", "generator", "ramping", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L319-L340
[ "def", "_get_generator_ramping_construct", "(", "self", ")", ":", "supply_no", "=", "integer", ".", "setResultsName", "(", "\"supply_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "up_rate", "=", "real", ".", "setR...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader._get_load_ramping_construct
Returns a construct for an array of load ramping data.
pylon/io/psat.py
def _get_load_ramping_construct(self): """ Returns a construct for an array of load ramping data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA up_rate = real.setResultsName("up_rate") # p.u./h down_rate = real.setResultsNa...
def _get_load_ramping_construct(self): """ Returns a construct for an array of load ramping data. """ bus_no = integer.setResultsName("bus_no") s_rating = real.setResultsName("s_rating") # MVA up_rate = real.setResultsName("up_rate") # p.u./h down_rate = real.setResultsNa...
[ "Returns", "a", "construct", "for", "an", "array", "of", "load", "ramping", "data", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L343-L363
[ "def", "_get_load_ramping_construct", "(", "self", ")", ":", "bus_no", "=", "integer", ".", "setResultsName", "(", "\"bus_no\"", ")", "s_rating", "=", "real", ".", "setResultsName", "(", "\"s_rating\"", ")", "# MVA", "up_rate", "=", "real", ".", "setResultsName"...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader.push_bus
Adds a Bus object to the case.
pylon/io/psat.py
def push_bus(self, tokens): """ Adds a Bus object to the case. """ logger.debug("Pushing bus data: %s" % tokens) bus = Bus() bus.name = tokens["bus_no"] bus.v_magnitude = tokens["v_magnitude"] bus.v_angle = tokens["v_angle"] bus.v_magnitude = tokens["v_ma...
def push_bus(self, tokens): """ Adds a Bus object to the case. """ logger.debug("Pushing bus data: %s" % tokens) bus = Bus() bus.name = tokens["bus_no"] bus.v_magnitude = tokens["v_magnitude"] bus.v_angle = tokens["v_angle"] bus.v_magnitude = tokens["v_ma...
[ "Adds", "a", "Bus", "object", "to", "the", "case", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L369-L381
[ "def", "push_bus", "(", "self", ",", "tokens", ")", ":", "logger", ".", "debug", "(", "\"Pushing bus data: %s\"", "%", "tokens", ")", "bus", "=", "Bus", "(", ")", "bus", ".", "name", "=", "tokens", "[", "\"bus_no\"", "]", "bus", ".", "v_magnitude", "="...
916514255db1ae1661406f0283df756baf960d14
train
PSATReader.sort_buses
Sorts bus list according to name (bus_no).
pylon/io/psat.py
def sort_buses(self, tokens): """ Sorts bus list according to name (bus_no). """ self.case.buses.sort(key=lambda obj: obj.name)
def sort_buses(self, tokens): """ Sorts bus list according to name (bus_no). """ self.case.buses.sort(key=lambda obj: obj.name)
[ "Sorts", "bus", "list", "according", "to", "name", "(", "bus_no", ")", "." ]
rwl/pylon
python
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/psat.py#L384-L387
[ "def", "sort_buses", "(", "self", ",", "tokens", ")", ":", "self", ".", "case", ".", "buses", ".", "sort", "(", "key", "=", "lambda", "obj", ":", "obj", ".", "name", ")" ]
916514255db1ae1661406f0283df756baf960d14