repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
Legobot/Legobot
Legobot/Connectors/Discord.py
Discord.handle
def handle(self, message): ''' Attempts to send a message to the specified destination in Discord. Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send. ''' logger.debug(message) if Utilities.isNotEmpty(message['...
python
def handle(self, message): ''' Attempts to send a message to the specified destination in Discord. Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send. ''' logger.debug(message) if Utilities.isNotEmpty(message['...
[ "def", "handle", "(", "self", ",", "message", ")", ":", "logger", ".", "debug", "(", "message", ")", "if", "Utilities", ".", "isNotEmpty", "(", "message", "[", "'metadata'", "]", "[", "'opts'", "]", ")", ":", "target", "=", "message", "[", "'metadata'"...
Attempts to send a message to the specified destination in Discord. Extends Legobot.Lego.handle() Args: message (Legobot.Message): message w/ metadata to send.
[ "Attempts", "to", "send", "a", "message", "to", "the", "specified", "destination", "in", "Discord", ".", "Extends", "Legobot", ".", "Lego", ".", "handle", "()" ]
train
https://github.com/Legobot/Legobot/blob/d13da172960a149681cb5151ce34b2f3a58ad32b/Legobot/Connectors/Discord.py#L300-L312
cuihantao/andes
andes/variables/dae.py
DAE.resize
def resize(self): """Resize dae and and extend for init1 variables """ yext = self.m - len(self.y) xext = self.n - len(self.x) if yext > 0: yzeros = zeros(yext, 1) yones = ones(yext, 1) self.y = matrix([self.y, yzeros], (self.m, 1), 'd') ...
python
def resize(self): """Resize dae and and extend for init1 variables """ yext = self.m - len(self.y) xext = self.n - len(self.x) if yext > 0: yzeros = zeros(yext, 1) yones = ones(yext, 1) self.y = matrix([self.y, yzeros], (self.m, 1), 'd') ...
[ "def", "resize", "(", "self", ")", ":", "yext", "=", "self", ".", "m", "-", "len", "(", "self", ".", "y", ")", "xext", "=", "self", ".", "n", "-", "len", "(", "self", ".", "x", ")", "if", "yext", ">", "0", ":", "yzeros", "=", "zeros", "(", ...
Resize dae and and extend for init1 variables
[ "Resize", "dae", "and", "and", "extend", "for", "init1", "variables" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L356-L376
cuihantao/andes
andes/variables/dae.py
DAE.hard_limit
def hard_limit(self, yidx, ymin, ymax, min_set=None, max_set=None): """Set hard limits for algebraic variables and reset the equation mismatches :param yidx: algebraic variable indices :param ymin: lower limit to check for :param ymax: upper limit to check for :param min_set: op...
python
def hard_limit(self, yidx, ymin, ymax, min_set=None, max_set=None): """Set hard limits for algebraic variables and reset the equation mismatches :param yidx: algebraic variable indices :param ymin: lower limit to check for :param ymax: upper limit to check for :param min_set: op...
[ "def", "hard_limit", "(", "self", ",", "yidx", ",", "ymin", ",", "ymax", ",", "min_set", "=", "None", ",", "max_set", "=", "None", ")", ":", "yidx", "=", "matrix", "(", "yidx", ")", "yval", "=", "self", ".", "y", "[", "yidx", "]", "ny", "=", "l...
Set hard limits for algebraic variables and reset the equation mismatches :param yidx: algebraic variable indices :param ymin: lower limit to check for :param ymax: upper limit to check for :param min_set: optional lower limit to set (``ymin`` as default) :param max_set: optiona...
[ "Set", "hard", "limits", "for", "algebraic", "variables", "and", "reset", "the", "equation", "mismatches" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L378-L435
cuihantao/andes
andes/variables/dae.py
DAE.hard_limit_remote
def hard_limit_remote(self, yidx, ridx, rtype='y', rmin=None, rmax=None, min_yset=0, max_yset=0): """Limit the output of yidx if t...
python
def hard_limit_remote(self, yidx, ridx, rtype='y', rmin=None, rmax=None, min_yset=0, max_yset=0): """Limit the output of yidx if t...
[ "def", "hard_limit_remote", "(", "self", ",", "yidx", ",", "ridx", ",", "rtype", "=", "'y'", ",", "rmin", "=", "None", ",", "rmax", "=", "None", ",", "min_yset", "=", "0", ",", "max_yset", "=", "0", ")", ":", "ny", "=", "len", "(", "yidx", ")", ...
Limit the output of yidx if the remote y is not within the limits This function needs to be modernized.
[ "Limit", "the", "output", "of", "yidx", "if", "the", "remote", "y", "is", "not", "within", "the", "limits" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L437-L481
cuihantao/andes
andes/variables/dae.py
DAE.anti_windup
def anti_windup(self, xidx, xmin, xmax): """ Anti-windup limiter for state variables. Resets the limited variables and differential equations. :param xidx: state variable indices :param xmin: lower limit :param xmax: upper limit :type xidx: matrix, list ...
python
def anti_windup(self, xidx, xmin, xmax): """ Anti-windup limiter for state variables. Resets the limited variables and differential equations. :param xidx: state variable indices :param xmin: lower limit :param xmax: upper limit :type xidx: matrix, list ...
[ "def", "anti_windup", "(", "self", ",", "xidx", ",", "xmin", ",", "xmax", ")", ":", "xidx", "=", "matrix", "(", "xidx", ")", "xval", "=", "self", ".", "x", "[", "xidx", "]", "fval", "=", "self", ".", "f", "[", "xidx", "]", "if", "isinstance", "...
Anti-windup limiter for state variables. Resets the limited variables and differential equations. :param xidx: state variable indices :param xmin: lower limit :param xmax: upper limit :type xidx: matrix, list :type xmin: matrix, float, int, list :type xmax: mat...
[ "Anti", "-", "windup", "limiter", "for", "state", "variables", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L483-L531
cuihantao/andes
andes/variables/dae.py
DAE.reset_Ac
def reset_Ac(self): """ Reset ``dae.Ac`` sparse matrix for disabled equations due to hard_limit and anti_windup limiters. :return: None """ if self.ac_reset is False: return mn = self.m + self.n x = index(aandb(self.zxmin, self.zxmax), 0.) ...
python
def reset_Ac(self): """ Reset ``dae.Ac`` sparse matrix for disabled equations due to hard_limit and anti_windup limiters. :return: None """ if self.ac_reset is False: return mn = self.m + self.n x = index(aandb(self.zxmin, self.zxmax), 0.) ...
[ "def", "reset_Ac", "(", "self", ")", ":", "if", "self", ".", "ac_reset", "is", "False", ":", "return", "mn", "=", "self", ".", "m", "+", "self", ".", "n", "x", "=", "index", "(", "aandb", "(", "self", ".", "zxmin", ",", "self", ".", "zxmax", ")...
Reset ``dae.Ac`` sparse matrix for disabled equations due to hard_limit and anti_windup limiters. :return: None
[ "Reset", "dae", ".", "Ac", "sparse", "matrix", "for", "disabled", "equations", "due", "to", "hard_limit", "and", "anti_windup", "limiters", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L533-L563
cuihantao/andes
andes/variables/dae.py
DAE.get_size
def get_size(self, m): """ Return the 2-D size of a Jacobian matrix in tuple """ nrow, ncol = 0, 0 if m[0] == 'F': nrow = self.n elif m[0] == 'G': nrow = self.m if m[1] == 'x': ncol = self.n elif m[1] == 'y': ...
python
def get_size(self, m): """ Return the 2-D size of a Jacobian matrix in tuple """ nrow, ncol = 0, 0 if m[0] == 'F': nrow = self.n elif m[0] == 'G': nrow = self.m if m[1] == 'x': ncol = self.n elif m[1] == 'y': ...
[ "def", "get_size", "(", "self", ",", "m", ")", ":", "nrow", ",", "ncol", "=", "0", ",", "0", "if", "m", "[", "0", "]", "==", "'F'", ":", "nrow", "=", "self", ".", "n", "elif", "m", "[", "0", "]", "==", "'G'", ":", "nrow", "=", "self", "."...
Return the 2-D size of a Jacobian matrix in tuple
[ "Return", "the", "2", "-", "D", "size", "of", "a", "Jacobian", "matrix", "in", "tuple" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L565-L580
cuihantao/andes
andes/variables/dae.py
DAE.add_jac
def add_jac(self, m, val, row, col): """Add tuples (val, row, col) to the Jacobian matrix ``m`` Implemented in numpy.arrays for temporary storage. """ assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx0', 'Fy0', 'Gx0', 'Gy0'), \ 'Wrong Jacobian matrix name <{0}>'.format(m) if...
python
def add_jac(self, m, val, row, col): """Add tuples (val, row, col) to the Jacobian matrix ``m`` Implemented in numpy.arrays for temporary storage. """ assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx0', 'Fy0', 'Gx0', 'Gy0'), \ 'Wrong Jacobian matrix name <{0}>'.format(m) if...
[ "def", "add_jac", "(", "self", ",", "m", ",", "val", ",", "row", ",", "col", ")", ":", "assert", "m", "in", "(", "'Fx'", ",", "'Fy'", ",", "'Gx'", ",", "'Gy'", ",", "'Fx0'", ",", "'Fy0'", ",", "'Gx0'", ",", "'Gy0'", ")", ",", "'Wrong Jacobian mat...
Add tuples (val, row, col) to the Jacobian matrix ``m`` Implemented in numpy.arrays for temporary storage.
[ "Add", "tuples", "(", "val", "row", "col", ")", "to", "the", "Jacobian", "matrix", "m" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L582-L595
cuihantao/andes
andes/variables/dae.py
DAE.temp_to_spmatrix
def temp_to_spmatrix(self, ty): """ Convert Jacobian tuples to matrices :param ty: name of the matrices to convert in ``('jac0','jac')`` :return: None """ assert ty in ('jac0', 'jac') jac0s = ['Fx0', 'Fy0', 'Gx0', 'Gy0'] jacs = ['Fx', 'Fy', 'Gx', 'Gy'] ...
python
def temp_to_spmatrix(self, ty): """ Convert Jacobian tuples to matrices :param ty: name of the matrices to convert in ``('jac0','jac')`` :return: None """ assert ty in ('jac0', 'jac') jac0s = ['Fx0', 'Fy0', 'Gx0', 'Gy0'] jacs = ['Fx', 'Fy', 'Gx', 'Gy'] ...
[ "def", "temp_to_spmatrix", "(", "self", ",", "ty", ")", ":", "assert", "ty", "in", "(", "'jac0'", ",", "'jac'", ")", "jac0s", "=", "[", "'Fx0'", ",", "'Fy0'", ",", "'Gx0'", ",", "'Gy0'", "]", "jacs", "=", "[", "'Fx'", ",", "'Fy'", ",", "'Gx'", ",...
Convert Jacobian tuples to matrices :param ty: name of the matrices to convert in ``('jac0','jac')`` :return: None
[ "Convert", "Jacobian", "tuples", "to", "matrices" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L597-L622
cuihantao/andes
andes/variables/dae.py
DAE.set_jac
def set_jac(self, m, val, row, col): """ Set the values at (row, col) to val in Jacobian m :param m: Jacobian name :param val: values to set :param row: row indices :param col: col indices :return: None """ assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx...
python
def set_jac(self, m, val, row, col): """ Set the values at (row, col) to val in Jacobian m :param m: Jacobian name :param val: values to set :param row: row indices :param col: col indices :return: None """ assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx...
[ "def", "set_jac", "(", "self", ",", "m", ",", "val", ",", "row", ",", "col", ")", ":", "assert", "m", "in", "(", "'Fx'", ",", "'Fy'", ",", "'Gx'", ",", "'Gy'", ",", "'Fx0'", ",", "'Fy0'", ",", "'Gx0'", ",", "'Gy0'", ")", ",", "'Wrong Jacobian mat...
Set the values at (row, col) to val in Jacobian m :param m: Jacobian name :param val: values to set :param row: row indices :param col: col indices :return: None
[ "Set", "the", "values", "at", "(", "row", "col", ")", "to", "val", "in", "Jacobian", "m" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L624-L644
cuihantao/andes
andes/variables/dae.py
DAE.apply_set
def apply_set(self, ty): """ Apply Jacobian set values to matrices :param ty: Jacobian type in ``('jac0', 'jac')`` :return: """ assert ty in ('jac0', 'jac') if ty == 'jac0': todo = ['Fx0', 'Fy0', 'Gx0', 'Gy0'] else: todo = ['Fx', ...
python
def apply_set(self, ty): """ Apply Jacobian set values to matrices :param ty: Jacobian type in ``('jac0', 'jac')`` :return: """ assert ty in ('jac0', 'jac') if ty == 'jac0': todo = ['Fx0', 'Fy0', 'Gx0', 'Gy0'] else: todo = ['Fx', ...
[ "def", "apply_set", "(", "self", ",", "ty", ")", ":", "assert", "ty", "in", "(", "'jac0'", ",", "'jac'", ")", "if", "ty", "==", "'jac0'", ":", "todo", "=", "[", "'Fx0'", ",", "'Fy0'", ",", "'Gx0'", ",", "'Gy0'", "]", "else", ":", "todo", "=", "...
Apply Jacobian set values to matrices :param ty: Jacobian type in ``('jac0', 'jac')`` :return:
[ "Apply", "Jacobian", "set", "values", "to", "matrices" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L646-L665
cuihantao/andes
andes/variables/dae.py
DAE.show
def show(self, eq, value=None): """Show equation or variable array along with the names""" if eq in ['f', 'x']: key = 'unamex' elif eq in ['g', 'y']: key = 'unamey' if value: value = list(value) else: value = list(self.__dict__[eq]...
python
def show(self, eq, value=None): """Show equation or variable array along with the names""" if eq in ['f', 'x']: key = 'unamex' elif eq in ['g', 'y']: key = 'unamey' if value: value = list(value) else: value = list(self.__dict__[eq]...
[ "def", "show", "(", "self", ",", "eq", ",", "value", "=", "None", ")", ":", "if", "eq", "in", "[", "'f'", ",", "'x'", "]", ":", "key", "=", "'unamex'", "elif", "eq", "in", "[", "'g'", ",", "'y'", "]", ":", "key", "=", "'unamey'", "if", "value...
Show equation or variable array along with the names
[ "Show", "equation", "or", "variable", "array", "along", "with", "the", "names" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L667-L683
cuihantao/andes
andes/variables/dae.py
DAE.find_val
def find_val(self, eq, val): """Return the name of the equation having the given value""" if eq not in ('f', 'g', 'q'): return elif eq in ('f', 'q'): key = 'unamex' elif eq == 'g': key = 'unamey' idx = 0 for m, n in zip(self.system.varn...
python
def find_val(self, eq, val): """Return the name of the equation having the given value""" if eq not in ('f', 'g', 'q'): return elif eq in ('f', 'q'): key = 'unamex' elif eq == 'g': key = 'unamey' idx = 0 for m, n in zip(self.system.varn...
[ "def", "find_val", "(", "self", ",", "eq", ",", "val", ")", ":", "if", "eq", "not", "in", "(", "'f'", ",", "'g'", ",", "'q'", ")", ":", "return", "elif", "eq", "in", "(", "'f'", ",", "'q'", ")", ":", "key", "=", "'unamex'", "elif", "eq", "=="...
Return the name of the equation having the given value
[ "Return", "the", "name", "of", "the", "equation", "having", "the", "given", "value" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L685-L698
cuihantao/andes
andes/variables/dae.py
DAE.reset_small
def reset_small(self, eq): """Reset numbers smaller than 1e-12 in f and g equations""" assert eq in ('f', 'g') for idx, var in enumerate(self.__dict__[eq]): if abs(var) <= 1e-12: self.__dict__[eq][idx] = 0
python
def reset_small(self, eq): """Reset numbers smaller than 1e-12 in f and g equations""" assert eq in ('f', 'g') for idx, var in enumerate(self.__dict__[eq]): if abs(var) <= 1e-12: self.__dict__[eq][idx] = 0
[ "def", "reset_small", "(", "self", ",", "eq", ")", ":", "assert", "eq", "in", "(", "'f'", ",", "'g'", ")", "for", "idx", ",", "var", "in", "enumerate", "(", "self", ".", "__dict__", "[", "eq", "]", ")", ":", "if", "abs", "(", "var", ")", "<=", ...
Reset numbers smaller than 1e-12 in f and g equations
[ "Reset", "numbers", "smaller", "than", "1e", "-", "12", "in", "f", "and", "g", "equations" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L700-L705
cuihantao/andes
andes/variables/dae.py
DAE.check_diag
def check_diag(self, jac, name): """ Check matrix ``jac`` for diagonal elements that equals 0 """ system = self.system pos = [] names = [] pairs = '' size = jac.size diag = jac[0:size[0] ** 2:size[0] + 1] for idx in range(size[0]): ...
python
def check_diag(self, jac, name): """ Check matrix ``jac`` for diagonal elements that equals 0 """ system = self.system pos = [] names = [] pairs = '' size = jac.size diag = jac[0:size[0] ** 2:size[0] + 1] for idx in range(size[0]): ...
[ "def", "check_diag", "(", "self", ",", "jac", ",", "name", ")", ":", "system", "=", "self", ".", "system", "pos", "=", "[", "]", "names", "=", "[", "]", "pairs", "=", "''", "size", "=", "jac", ".", "size", "diag", "=", "jac", "[", "0", ":", "...
Check matrix ``jac`` for diagonal elements that equals 0
[ "Check", "matrix", "jac", "for", "diagonal", "elements", "that", "equals", "0" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L713-L735
DiamondLightSource/python-workflows
workflows/logging/__init__.py
get_exception_source
def get_exception_source(): """Returns full file path, file name, line number, function name, and line contents causing the last exception.""" _, _, tb = sys.exc_info() while tb.tb_next: tb = tb.tb_next f = tb.tb_frame lineno = tb.tb_lineno co = f.f_code filefullpath = co.co_file...
python
def get_exception_source(): """Returns full file path, file name, line number, function name, and line contents causing the last exception.""" _, _, tb = sys.exc_info() while tb.tb_next: tb = tb.tb_next f = tb.tb_frame lineno = tb.tb_lineno co = f.f_code filefullpath = co.co_file...
[ "def", "get_exception_source", "(", ")", ":", "_", ",", "_", ",", "tb", "=", "sys", ".", "exc_info", "(", ")", "while", "tb", ".", "tb_next", ":", "tb", "=", "tb", ".", "tb_next", "f", "=", "tb", ".", "tb_frame", "lineno", "=", "tb", ".", "tb_lin...
Returns full file path, file name, line number, function name, and line contents causing the last exception.
[ "Returns", "full", "file", "path", "file", "name", "line", "number", "function", "name", "and", "line", "contents", "causing", "the", "last", "exception", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/logging/__init__.py#L9-L27
DiamondLightSource/python-workflows
workflows/logging/__init__.py
CallbackHandler.prepare
def prepare(self, record): # Function taken from Python 3.6 QueueHandler """ Prepares a record for queuing. The object returned by this method is enqueued. The base implementation formats the record to merge the message and arguments, and removes unpickleable items from t...
python
def prepare(self, record): # Function taken from Python 3.6 QueueHandler """ Prepares a record for queuing. The object returned by this method is enqueued. The base implementation formats the record to merge the message and arguments, and removes unpickleable items from t...
[ "def", "prepare", "(", "self", ",", "record", ")", ":", "# Function taken from Python 3.6 QueueHandler", "# The format operation gets traceback text into record.exc_text", "# (if there's exception data), and also puts the message into", "# record.message. We can then use this to replace the or...
Prepares a record for queuing. The object returned by this method is enqueued. The base implementation formats the record to merge the message and arguments, and removes unpickleable items from the record in-place. You might want to override this method if you want to convert ...
[ "Prepares", "a", "record", "for", "queuing", ".", "The", "object", "returned", "by", "this", "method", "is", "enqueued", ".", "The", "base", "implementation", "formats", "the", "record", "to", "merge", "the", "message", "and", "arguments", "and", "removes", ...
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/logging/__init__.py#L38-L60
DiamondLightSource/python-workflows
workflows/logging/__init__.py
CallbackHandler.emit
def emit(self, record): """Send a LogRecord to the callback function, after preparing it for serialization.""" try: self._callback(self.prepare(record)) except Exception: self.handleError(record)
python
def emit(self, record): """Send a LogRecord to the callback function, after preparing it for serialization.""" try: self._callback(self.prepare(record)) except Exception: self.handleError(record)
[ "def", "emit", "(", "self", ",", "record", ")", ":", "try", ":", "self", ".", "_callback", "(", "self", ".", "prepare", "(", "record", ")", ")", "except", "Exception", ":", "self", ".", "handleError", "(", "record", ")" ]
Send a LogRecord to the callback function, after preparing it for serialization.
[ "Send", "a", "LogRecord", "to", "the", "callback", "function", "after", "preparing", "it", "for", "serialization", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/logging/__init__.py#L62-L68
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.update_status
def update_status(self, status_code=None): """Update the service status kept inside the frontend (_service_status). The status is broadcast over the network immediately. If the status changes to IDLE then this message is delayed. The IDLE status is only broadcast if it is held for over 0...
python
def update_status(self, status_code=None): """Update the service status kept inside the frontend (_service_status). The status is broadcast over the network immediately. If the status changes to IDLE then this message is delayed. The IDLE status is only broadcast if it is held for over 0...
[ "def", "update_status", "(", "self", ",", "status_code", "=", "None", ")", ":", "if", "status_code", "is", "not", "None", ":", "self", ".", "_service_status", "=", "status_code", "self", ".", "_utilization", ".", "update_status", "(", "status_code", ")", "# ...
Update the service status kept inside the frontend (_service_status). The status is broadcast over the network immediately. If the status changes to IDLE then this message is delayed. The IDLE status is only broadcast if it is held for over 0.5 seconds. When the status does not change it...
[ "Update", "the", "service", "status", "kept", "inside", "the", "frontend", "(", "_service_status", ")", ".", "The", "status", "is", "broadcast", "over", "the", "network", "immediately", ".", "If", "the", "status", "changes", "to", "IDLE", "then", "this", "me...
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L134-L170
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.run
def run(self): """The main loop of the frontend. Here incoming messages from the service are processed and forwarded to the corresponding callback methods.""" self.log.debug("Entered main loop") while not self.shutdown: # If no service is running slow down the main loop ...
python
def run(self): """The main loop of the frontend. Here incoming messages from the service are processed and forwarded to the corresponding callback methods.""" self.log.debug("Entered main loop") while not self.shutdown: # If no service is running slow down the main loop ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Entered main loop\"", ")", "while", "not", "self", ".", "shutdown", ":", "# If no service is running slow down the main loop", "if", "not", "self", ".", "_pipe_service", ":", "time", ...
The main loop of the frontend. Here incoming messages from the service are processed and forwarded to the corresponding callback methods.
[ "The", "main", "loop", "of", "the", "frontend", ".", "Here", "incoming", "messages", "from", "the", "service", "are", "processed", "and", "forwarded", "to", "the", "corresponding", "callback", "methods", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L172-L252
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.send_command
def send_command(self, command): """Send command to service via the command queue.""" if self._pipe_commands: self._pipe_commands.send(command) else: if self.shutdown: # Stop delivering messages in shutdown. self.log.info( ...
python
def send_command(self, command): """Send command to service via the command queue.""" if self._pipe_commands: self._pipe_commands.send(command) else: if self.shutdown: # Stop delivering messages in shutdown. self.log.info( ...
[ "def", "send_command", "(", "self", ",", "command", ")", ":", "if", "self", ".", "_pipe_commands", ":", "self", ".", "_pipe_commands", ".", "send", "(", "command", ")", "else", ":", "if", "self", ".", "shutdown", ":", "# Stop delivering messages in shutdown.",...
Send command to service via the command queue.
[ "Send", "command", "to", "service", "via", "the", "command", "queue", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L254-L268
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.process_transport_command
def process_transport_command(self, header, message): """Parse a command coming in through the transport command subscription""" if not isinstance(message, dict): return relevant = False if "host" in message: # Filter by host if message["host"] != self.__hostid:...
python
def process_transport_command(self, header, message): """Parse a command coming in through the transport command subscription""" if not isinstance(message, dict): return relevant = False if "host" in message: # Filter by host if message["host"] != self.__hostid:...
[ "def", "process_transport_command", "(", "self", ",", "header", ",", "message", ")", ":", "if", "not", "isinstance", "(", "message", ",", "dict", ")", ":", "return", "relevant", "=", "False", "if", "\"host\"", "in", "message", ":", "# Filter by host", "if", ...
Parse a command coming in through the transport command subscription
[ "Parse", "a", "command", "coming", "in", "through", "the", "transport", "command", "subscription" ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L270-L294
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.parse_band_log
def parse_band_log(self, message): """Process incoming logging messages from the service.""" if "payload" in message and hasattr(message["payload"], "name"): record = message["payload"] for k in dir(record): if k.startswith("workflows_exc_"): s...
python
def parse_band_log(self, message): """Process incoming logging messages from the service.""" if "payload" in message and hasattr(message["payload"], "name"): record = message["payload"] for k in dir(record): if k.startswith("workflows_exc_"): s...
[ "def", "parse_band_log", "(", "self", ",", "message", ")", ":", "if", "\"payload\"", "in", "message", "and", "hasattr", "(", "message", "[", "\"payload\"", "]", ",", "\"name\"", ")", ":", "record", "=", "message", "[", "\"payload\"", "]", "for", "k", "in...
Process incoming logging messages from the service.
[ "Process", "incoming", "logging", "messages", "from", "the", "service", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L296-L315
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.parse_band_request_termination
def parse_band_request_termination(self, message): """Service declares it should be terminated.""" self.log.debug("Service requests termination") self._terminate_service() if not self.restart_service: self.shutdown = True
python
def parse_band_request_termination(self, message): """Service declares it should be terminated.""" self.log.debug("Service requests termination") self._terminate_service() if not self.restart_service: self.shutdown = True
[ "def", "parse_band_request_termination", "(", "self", ",", "message", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Service requests termination\"", ")", "self", ".", "_terminate_service", "(", ")", "if", "not", "self", ".", "restart_service", ":", "self",...
Service declares it should be terminated.
[ "Service", "declares", "it", "should", "be", "terminated", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L317-L322
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.parse_band_set_name
def parse_band_set_name(self, message): """Process incoming message indicating service name change.""" if message.get("name"): self._service_name = message["name"] else: self.log.warning( "Received broken record on set_name band\nMessage: %s", str(message)...
python
def parse_band_set_name(self, message): """Process incoming message indicating service name change.""" if message.get("name"): self._service_name = message["name"] else: self.log.warning( "Received broken record on set_name band\nMessage: %s", str(message)...
[ "def", "parse_band_set_name", "(", "self", ",", "message", ")", ":", "if", "message", ".", "get", "(", "\"name\"", ")", ":", "self", ".", "_service_name", "=", "message", "[", "\"name\"", "]", "else", ":", "self", ".", "log", ".", "warning", "(", "\"Re...
Process incoming message indicating service name change.
[ "Process", "incoming", "message", "indicating", "service", "name", "change", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L324-L331
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.parse_band_status_update
def parse_band_status_update(self, message): """Process incoming status updates from the service.""" self.log.debug("Status update: " + str(message)) self.update_status(status_code=message["statuscode"])
python
def parse_band_status_update(self, message): """Process incoming status updates from the service.""" self.log.debug("Status update: " + str(message)) self.update_status(status_code=message["statuscode"])
[ "def", "parse_band_status_update", "(", "self", ",", "message", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Status update: \"", "+", "str", "(", "message", ")", ")", "self", ".", "update_status", "(", "status_code", "=", "message", "[", "\"statuscode...
Process incoming status updates from the service.
[ "Process", "incoming", "status", "updates", "from", "the", "service", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L333-L336
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.get_status
def get_status(self): """Returns a dictionary containing all relevant status information to be broadcast across the network.""" return { "host": self.__hostid, "status": self._service_status_announced, "statustext": CommonService.human_readable_state.get( ...
python
def get_status(self): """Returns a dictionary containing all relevant status information to be broadcast across the network.""" return { "host": self.__hostid, "status": self._service_status_announced, "statustext": CommonService.human_readable_state.get( ...
[ "def", "get_status", "(", "self", ")", ":", "return", "{", "\"host\"", ":", "self", ".", "__hostid", ",", "\"status\"", ":", "self", ".", "_service_status_announced", ",", "\"statustext\"", ":", "CommonService", ".", "human_readable_state", ".", "get", "(", "s...
Returns a dictionary containing all relevant status information to be broadcast across the network.
[ "Returns", "a", "dictionary", "containing", "all", "relevant", "status", "information", "to", "be", "broadcast", "across", "the", "network", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L342-L355
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.exponential_backoff
def exponential_backoff(self): """A function that keeps waiting longer and longer the more rapidly it is called. It can be used to increasingly slow down service starts when they keep failing.""" last_service_switch = self._service_starttime if not last_service_switch: return...
python
def exponential_backoff(self): """A function that keeps waiting longer and longer the more rapidly it is called. It can be used to increasingly slow down service starts when they keep failing.""" last_service_switch = self._service_starttime if not last_service_switch: return...
[ "def", "exponential_backoff", "(", "self", ")", ":", "last_service_switch", "=", "self", ".", "_service_starttime", "if", "not", "last_service_switch", ":", "return", "time_since_last_switch", "=", "time", ".", "time", "(", ")", "-", "last_service_switch", "if", "...
A function that keeps waiting longer and longer the more rapidly it is called. It can be used to increasingly slow down service starts when they keep failing.
[ "A", "function", "that", "keeps", "waiting", "longer", "and", "longer", "the", "more", "rapidly", "it", "is", "called", ".", "It", "can", "be", "used", "to", "increasingly", "slow", "down", "service", "starts", "when", "they", "keep", "failing", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L357-L375
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend.switch_service
def switch_service(self, new_service=None): """Start a new service in a subprocess. :param new_service: Either a service name or a service class. If not set, start up a new instance of the previous class :return: True on success, False on failure. """ ...
python
def switch_service(self, new_service=None): """Start a new service in a subprocess. :param new_service: Either a service name or a service class. If not set, start up a new instance of the previous class :return: True on success, False on failure. """ ...
[ "def", "switch_service", "(", "self", ",", "new_service", "=", "None", ")", ":", "if", "new_service", ":", "self", ".", "_service_factory", "=", "new_service", "with", "self", ".", "__lock", ":", "# Terminate existing service if necessary", "if", "self", ".", "_...
Start a new service in a subprocess. :param new_service: Either a service name or a service class. If not set, start up a new instance of the previous class :return: True on success, False on failure.
[ "Start", "a", "new", "service", "in", "a", "subprocess", ".", ":", "param", "new_service", ":", "Either", "a", "service", "name", "or", "a", "service", "class", ".", "If", "not", "set", "start", "up", "a", "new", "instance", "of", "the", "previous", "c...
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L377-L428
DiamondLightSource/python-workflows
workflows/frontend/__init__.py
Frontend._terminate_service
def _terminate_service(self): """Force termination of running service. Disconnect queues, end queue feeder threads. Wait for service process to clear, drop all references.""" with self.__lock: if self._service: self._service.terminate() if self._pi...
python
def _terminate_service(self): """Force termination of running service. Disconnect queues, end queue feeder threads. Wait for service process to clear, drop all references.""" with self.__lock: if self._service: self._service.terminate() if self._pi...
[ "def", "_terminate_service", "(", "self", ")", ":", "with", "self", ".", "__lock", ":", "if", "self", ".", "_service", ":", "self", ".", "_service", ".", "terminate", "(", ")", "if", "self", ".", "_pipe_commands", ":", "self", ".", "_pipe_commands", ".",...
Force termination of running service. Disconnect queues, end queue feeder threads. Wait for service process to clear, drop all references.
[ "Force", "termination", "of", "running", "service", ".", "Disconnect", "queues", "end", "queue", "feeder", "threads", ".", "Wait", "for", "service", "process", "to", "clear", "drop", "all", "references", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L430-L449
cuihantao/andes
andes/utils/solver.py
Solver.symbolic
def symbolic(self, A): """ Return the symbolic factorization of sparse matrix ``A`` Parameters ---------- sparselib Library name in ``umfpack`` and ``klu`` A Sparse matrix Returns symbolic factorization ------- ""...
python
def symbolic(self, A): """ Return the symbolic factorization of sparse matrix ``A`` Parameters ---------- sparselib Library name in ``umfpack`` and ``klu`` A Sparse matrix Returns symbolic factorization ------- ""...
[ "def", "symbolic", "(", "self", ",", "A", ")", ":", "if", "self", ".", "sparselib", "==", "'umfpack'", ":", "return", "umfpack", ".", "symbolic", "(", "A", ")", "elif", "self", ".", "sparselib", "==", "'klu'", ":", "return", "klu", ".", "symbolic", "...
Return the symbolic factorization of sparse matrix ``A`` Parameters ---------- sparselib Library name in ``umfpack`` and ``klu`` A Sparse matrix Returns symbolic factorization -------
[ "Return", "the", "symbolic", "factorization", "of", "sparse", "matrix", "A" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L17-L38
cuihantao/andes
andes/utils/solver.py
Solver.numeric
def numeric(self, A, F): """ Return the numeric factorization of sparse matrix ``A`` using symbolic factorization ``F`` Parameters ---------- A Sparse matrix F Symbolic factorization Returns ------- N Numeric f...
python
def numeric(self, A, F): """ Return the numeric factorization of sparse matrix ``A`` using symbolic factorization ``F`` Parameters ---------- A Sparse matrix F Symbolic factorization Returns ------- N Numeric f...
[ "def", "numeric", "(", "self", ",", "A", ",", "F", ")", ":", "if", "self", ".", "sparselib", "==", "'umfpack'", ":", "return", "umfpack", ".", "numeric", "(", "A", ",", "F", ")", "elif", "self", ".", "sparselib", "==", "'klu'", ":", "return", "klu"...
Return the numeric factorization of sparse matrix ``A`` using symbolic factorization ``F`` Parameters ---------- A Sparse matrix F Symbolic factorization Returns ------- N Numeric factorization of ``A``
[ "Return", "the", "numeric", "factorization", "of", "sparse", "matrix", "A", "using", "symbolic", "factorization", "F" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L40-L60
cuihantao/andes
andes/utils/solver.py
Solver.solve
def solve(self, A, F, N, b): """ Solve linear system ``Ax = b`` using numeric factorization ``N`` and symbolic factorization ``F``. Store the solution in ``b``. Parameters ---------- A Sparse matrix F Symbolic factorization N ...
python
def solve(self, A, F, N, b): """ Solve linear system ``Ax = b`` using numeric factorization ``N`` and symbolic factorization ``F``. Store the solution in ``b``. Parameters ---------- A Sparse matrix F Symbolic factorization N ...
[ "def", "solve", "(", "self", ",", "A", ",", "F", ",", "N", ",", "b", ")", ":", "if", "self", ".", "sparselib", "==", "'umfpack'", ":", "umfpack", ".", "solve", "(", "A", ",", "N", ",", "b", ")", "elif", "self", ".", "sparselib", "==", "'klu'", ...
Solve linear system ``Ax = b`` using numeric factorization ``N`` and symbolic factorization ``F``. Store the solution in ``b``. Parameters ---------- A Sparse matrix F Symbolic factorization N Numeric factorization b ...
[ "Solve", "linear", "system", "Ax", "=", "b", "using", "numeric", "factorization", "N", "and", "symbolic", "factorization", "F", ".", "Store", "the", "solution", "in", "b", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L62-L86
cuihantao/andes
andes/utils/solver.py
Solver.linsolve
def linsolve(self, A, b): """ Solve linear equation set ``Ax = b`` and store the solutions in ``b``. Parameters ---------- A Sparse matrix b RHS of the equation Returns ------- None """ if self.sparselib =...
python
def linsolve(self, A, b): """ Solve linear equation set ``Ax = b`` and store the solutions in ``b``. Parameters ---------- A Sparse matrix b RHS of the equation Returns ------- None """ if self.sparselib =...
[ "def", "linsolve", "(", "self", ",", "A", ",", "b", ")", ":", "if", "self", ".", "sparselib", "==", "'umfpack'", ":", "return", "umfpack", ".", "linsolve", "(", "A", ",", "b", ")", "elif", "self", ".", "sparselib", "==", "'klu'", ":", "return", "kl...
Solve linear equation set ``Ax = b`` and store the solutions in ``b``. Parameters ---------- A Sparse matrix b RHS of the equation Returns ------- None
[ "Solve", "linear", "equation", "set", "Ax", "=", "b", "and", "store", "the", "solutions", "in", "b", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L88-L108
cuihantao/andes
andes/models/bus.py
Bus._varname_inj
def _varname_inj(self): """Customize varname for bus injections""" # Bus Pi if not self.n: return m = self.system.dae.m xy_idx = range(m, self.n + m) self.system.varname.append( listname='unamey', xy_idx=xy_idx, var_name='P'...
python
def _varname_inj(self): """Customize varname for bus injections""" # Bus Pi if not self.n: return m = self.system.dae.m xy_idx = range(m, self.n + m) self.system.varname.append( listname='unamey', xy_idx=xy_idx, var_name='P'...
[ "def", "_varname_inj", "(", "self", ")", ":", "# Bus Pi", "if", "not", "self", ".", "n", ":", "return", "m", "=", "self", ".", "system", ".", "dae", ".", "m", "xy_idx", "=", "range", "(", "m", ",", "self", ".", "n", "+", "m", ")", "self", ".", ...
Customize varname for bus injections
[ "Customize", "varname", "for", "bus", "injections" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L57-L86
cuihantao/andes
andes/models/bus.py
Bus.init0
def init0(self, dae): """Set bus Va and Vm initial values""" if not self.system.pflow.config.flatstart: dae.y[self.a] = self.angle + 1e-10 * uniform(self.n) dae.y[self.v] = self.voltage else: dae.y[self.a] = matrix(0.0, (self...
python
def init0(self, dae): """Set bus Va and Vm initial values""" if not self.system.pflow.config.flatstart: dae.y[self.a] = self.angle + 1e-10 * uniform(self.n) dae.y[self.v] = self.voltage else: dae.y[self.a] = matrix(0.0, (self...
[ "def", "init0", "(", "self", ",", "dae", ")", ":", "if", "not", "self", ".", "system", ".", "pflow", ".", "config", ".", "flatstart", ":", "dae", ".", "y", "[", "self", ".", "a", "]", "=", "self", ".", "angle", "+", "1e-10", "*", "uniform", "("...
Set bus Va and Vm initial values
[ "Set", "bus", "Va", "and", "Vm", "initial", "values" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L88-L96
cuihantao/andes
andes/models/bus.py
Bus.gisland
def gisland(self, dae): """Reset g(x) for islanded buses and areas""" if (not self.islanded_buses) and (not self.island_sets): return a, v = list(), list() # for islanded areas without a slack bus # TODO: fix for islanded sets without sw # for island in self...
python
def gisland(self, dae): """Reset g(x) for islanded buses and areas""" if (not self.islanded_buses) and (not self.island_sets): return a, v = list(), list() # for islanded areas without a slack bus # TODO: fix for islanded sets without sw # for island in self...
[ "def", "gisland", "(", "self", ",", "dae", ")", ":", "if", "(", "not", "self", ".", "islanded_buses", ")", "and", "(", "not", "self", ".", "island_sets", ")", ":", "return", "a", ",", "v", "=", "list", "(", ")", ",", "list", "(", ")", "# for isla...
Reset g(x) for islanded buses and areas
[ "Reset", "g", "(", "x", ")", "for", "islanded", "buses", "and", "areas" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L98-L120
cuihantao/andes
andes/models/bus.py
Bus.gyisland
def gyisland(self, dae): """Reset gy(x) for islanded buses and areas""" if self.system.Bus.islanded_buses: a = self.system.Bus.islanded_buses v = [self.system.Bus.n + item for item in a] dae.set_jac(Gy, 1e-6, a, a) dae.set_jac(Gy, 1e-6, v, v)
python
def gyisland(self, dae): """Reset gy(x) for islanded buses and areas""" if self.system.Bus.islanded_buses: a = self.system.Bus.islanded_buses v = [self.system.Bus.n + item for item in a] dae.set_jac(Gy, 1e-6, a, a) dae.set_jac(Gy, 1e-6, v, v)
[ "def", "gyisland", "(", "self", ",", "dae", ")", ":", "if", "self", ".", "system", ".", "Bus", ".", "islanded_buses", ":", "a", "=", "self", ".", "system", ".", "Bus", ".", "islanded_buses", "v", "=", "[", "self", ".", "system", ".", "Bus", ".", ...
Reset gy(x) for islanded buses and areas
[ "Reset", "gy", "(", "x", ")", "for", "islanded", "buses", "and", "areas" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L122-L128
cuihantao/andes
andes/models/bus.py
BusOld.gisland
def gisland(self, dae): """Reset g(x) for islanded buses and areas""" if not (self.islanded_buses and self.island_sets): return a, v = list(), list() # for islanded areas without a slack bus for island in self.island_sets: nosw = 1 for item i...
python
def gisland(self, dae): """Reset g(x) for islanded buses and areas""" if not (self.islanded_buses and self.island_sets): return a, v = list(), list() # for islanded areas without a slack bus for island in self.island_sets: nosw = 1 for item i...
[ "def", "gisland", "(", "self", ",", "dae", ")", ":", "if", "not", "(", "self", ".", "islanded_buses", "and", "self", ".", "island_sets", ")", ":", "return", "a", ",", "v", "=", "list", "(", ")", ",", "list", "(", ")", "# for islanded areas without a sl...
Reset g(x) for islanded buses and areas
[ "Reset", "g", "(", "x", ")", "for", "islanded", "buses", "and", "areas" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L234-L255
DiamondLightSource/python-workflows
workflows/transport/__init__.py
get_known_transports
def get_known_transports(): """Return a dictionary of all known transport mechanisms.""" if not hasattr(get_known_transports, "cache"): setattr( get_known_transports, "cache", { e.name: e.load() for e in pkg_resources.iter_entry_points(...
python
def get_known_transports(): """Return a dictionary of all known transport mechanisms.""" if not hasattr(get_known_transports, "cache"): setattr( get_known_transports, "cache", { e.name: e.load() for e in pkg_resources.iter_entry_points(...
[ "def", "get_known_transports", "(", ")", ":", "if", "not", "hasattr", "(", "get_known_transports", ",", "\"cache\"", ")", ":", "setattr", "(", "get_known_transports", ",", "\"cache\"", ",", "{", "e", ".", "name", ":", "e", ".", "load", "(", ")", "for", "...
Return a dictionary of all known transport mechanisms.
[ "Return", "a", "dictionary", "of", "all", "known", "transport", "mechanisms", "." ]
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/transport/__init__.py#L21-L32
cuihantao/andes
andes/models/wind.py
WindBase.windspeed
def windspeed(self, t): """Return the wind speed list at time `t`""" ws = [0] * self.n for i in range(self.n): q = ceil(t / self.dt[i]) q_prev = 0 if q == 0 else q - 1 r = t % self.dt[i] r = 0 if abs(r) < 1e-6 else r if r == 0: ...
python
def windspeed(self, t): """Return the wind speed list at time `t`""" ws = [0] * self.n for i in range(self.n): q = ceil(t / self.dt[i]) q_prev = 0 if q == 0 else q - 1 r = t % self.dt[i] r = 0 if abs(r) < 1e-6 else r if r == 0: ...
[ "def", "windspeed", "(", "self", ",", "t", ")", ":", "ws", "=", "[", "0", "]", "*", "self", ".", "n", "for", "i", "in", "range", "(", "self", ".", "n", ")", ":", "q", "=", "ceil", "(", "t", "/", "self", ".", "dt", "[", "i", "]", ")", "q...
Return the wind speed list at time `t`
[ "Return", "the", "wind", "speed", "list", "at", "time", "t" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/wind.py#L82-L101
cuihantao/andes
andes/models/synchronous.py
SynBase.set_vf0
def set_vf0(self, vf): """set value for self.vf0 and dae.y[self.vf]""" self.vf0 = vf self.system.dae.y[self.vf] = matrix(vf)
python
def set_vf0(self, vf): """set value for self.vf0 and dae.y[self.vf]""" self.vf0 = vf self.system.dae.y[self.vf] = matrix(vf)
[ "def", "set_vf0", "(", "self", ",", "vf", ")", ":", "self", ".", "vf0", "=", "vf", "self", ".", "system", ".", "dae", ".", "y", "[", "self", ".", "vf", "]", "=", "matrix", "(", "vf", ")" ]
set value for self.vf0 and dae.y[self.vf]
[ "set", "value", "for", "self", ".", "vf0", "and", "dae", ".", "y", "[", "self", ".", "vf", "]" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/synchronous.py#L114-L117
cuihantao/andes
andes/system.py
PowerSystem.setup
def setup(self): """ Set up the power system object by executing the following workflow: * Sort the loaded models to meet the initialization sequence * Create call strings for routines * Call the ``setup`` function of the loaded models * Assign addresses for the load...
python
def setup(self): """ Set up the power system object by executing the following workflow: * Sort the loaded models to meet the initialization sequence * Create call strings for routines * Call the ``setup`` function of the loaded models * Assign addresses for the load...
[ "def", "setup", "(", "self", ")", ":", "self", ".", "devman", ".", "sort_device", "(", ")", "self", ".", "call", ".", "setup", "(", ")", "self", ".", "model_setup", "(", ")", "self", ".", "xy_addr0", "(", ")", "self", ".", "dae", ".", "setup", "(...
Set up the power system object by executing the following workflow: * Sort the loaded models to meet the initialization sequence * Create call strings for routines * Call the ``setup`` function of the loaded models * Assign addresses for the loaded models * Call ``dae.setup...
[ "Set", "up", "the", "power", "system", "object", "by", "executing", "the", "following", "workflow", ":" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L187-L211
cuihantao/andes
andes/system.py
PowerSystem.to_sysbase
def to_sysbase(self): """ Convert model parameters to system base. This function calls the ``data_to_sys_base`` function of the loaded models. Returns ------- None """ if self.config.base: for item in self.devman.devices: self....
python
def to_sysbase(self): """ Convert model parameters to system base. This function calls the ``data_to_sys_base`` function of the loaded models. Returns ------- None """ if self.config.base: for item in self.devman.devices: self....
[ "def", "to_sysbase", "(", "self", ")", ":", "if", "self", ".", "config", ".", "base", ":", "for", "item", "in", "self", ".", "devman", ".", "devices", ":", "self", ".", "__dict__", "[", "item", "]", ".", "data_to_sys_base", "(", ")" ]
Convert model parameters to system base. This function calls the ``data_to_sys_base`` function of the loaded models. Returns ------- None
[ "Convert", "model", "parameters", "to", "system", "base", ".", "This", "function", "calls", "the", "data_to_sys_base", "function", "of", "the", "loaded", "models", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L213-L224
cuihantao/andes
andes/system.py
PowerSystem.to_elembase
def to_elembase(self): """ Convert parameters back to element base. This function calls the ```data_to_elem_base``` function. Returns ------- None """ if self.config.base: for item in self.devman.devices: self.__dict__[item].da...
python
def to_elembase(self): """ Convert parameters back to element base. This function calls the ```data_to_elem_base``` function. Returns ------- None """ if self.config.base: for item in self.devman.devices: self.__dict__[item].da...
[ "def", "to_elembase", "(", "self", ")", ":", "if", "self", ".", "config", ".", "base", ":", "for", "item", "in", "self", ".", "devman", ".", "devices", ":", "self", ".", "__dict__", "[", "item", "]", ".", "data_to_elem_base", "(", ")" ]
Convert parameters back to element base. This function calls the ```data_to_elem_base``` function. Returns ------- None
[ "Convert", "parameters", "back", "to", "element", "base", ".", "This", "function", "calls", "the", "data_to_elem_base", "function", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L226-L237
cuihantao/andes
andes/system.py
PowerSystem.group_add
def group_add(self, name='Ungrouped'): """ Dynamically add a group instance to the system if not exist. Parameters ---------- name : str, optional ('Ungrouped' as default) Name of the group Returns ------- None """ if not hasa...
python
def group_add(self, name='Ungrouped'): """ Dynamically add a group instance to the system if not exist. Parameters ---------- name : str, optional ('Ungrouped' as default) Name of the group Returns ------- None """ if not hasa...
[ "def", "group_add", "(", "self", ",", "name", "=", "'Ungrouped'", ")", ":", "if", "not", "hasattr", "(", "self", ",", "name", ")", ":", "self", ".", "__dict__", "[", "name", "]", "=", "Group", "(", "self", ",", "name", ")", "self", ".", "loaded_gro...
Dynamically add a group instance to the system if not exist. Parameters ---------- name : str, optional ('Ungrouped' as default) Name of the group Returns ------- None
[ "Dynamically", "add", "a", "group", "instance", "to", "the", "system", "if", "not", "exist", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L239-L254
cuihantao/andes
andes/system.py
PowerSystem.model_import
def model_import(self): """ Import and instantiate the non-JIT models and the JIT models. Models defined in ``jits`` and ``non_jits`` in ``models/__init__.py`` will be imported and instantiated accordingly. Returns ------- None """ # non-JIT mode...
python
def model_import(self): """ Import and instantiate the non-JIT models and the JIT models. Models defined in ``jits`` and ``non_jits`` in ``models/__init__.py`` will be imported and instantiated accordingly. Returns ------- None """ # non-JIT mode...
[ "def", "model_import", "(", "self", ")", ":", "# non-JIT models", "for", "file", ",", "pair", "in", "non_jits", ".", "items", "(", ")", ":", "for", "cls", ",", "name", "in", "pair", ".", "items", "(", ")", ":", "themodel", "=", "importlib", ".", "imp...
Import and instantiate the non-JIT models and the JIT models. Models defined in ``jits`` and ``non_jits`` in ``models/__init__.py`` will be imported and instantiated accordingly. Returns ------- None
[ "Import", "and", "instantiate", "the", "non", "-", "JIT", "models", "and", "the", "JIT", "models", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L256-L283
cuihantao/andes
andes/system.py
PowerSystem.routine_import
def routine_import(self): """ Dynamically import routines as defined in ``routines/__init__.py``. The command-line argument ``--routine`` is defined in ``__cli__`` in each routine file. A routine instance will be stored in the system instance with the name being all lower case. ...
python
def routine_import(self): """ Dynamically import routines as defined in ``routines/__init__.py``. The command-line argument ``--routine`` is defined in ``__cli__`` in each routine file. A routine instance will be stored in the system instance with the name being all lower case. ...
[ "def", "routine_import", "(", "self", ")", ":", "for", "r", "in", "routines", ".", "__all__", ":", "file", "=", "importlib", ".", "import_module", "(", "'.'", "+", "r", ".", "lower", "(", ")", ",", "'andes.routines'", ")", "self", ".", "__dict__", "[",...
Dynamically import routines as defined in ``routines/__init__.py``. The command-line argument ``--routine`` is defined in ``__cli__`` in each routine file. A routine instance will be stored in the system instance with the name being all lower case. For example, a routine for power flow...
[ "Dynamically", "import", "routines", "as", "defined", "in", "routines", "/", "__init__", ".", "py", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L285-L304
cuihantao/andes
andes/system.py
PowerSystem.model_setup
def model_setup(self): """ Call the ``setup`` function of the loaded models. This function is to be called after parsing all the data files during the system set up. Returns ------- None """ for device in self.devman.devices: if self.__dict__[...
python
def model_setup(self): """ Call the ``setup`` function of the loaded models. This function is to be called after parsing all the data files during the system set up. Returns ------- None """ for device in self.devman.devices: if self.__dict__[...
[ "def", "model_setup", "(", "self", ")", ":", "for", "device", "in", "self", ".", "devman", ".", "devices", ":", "if", "self", ".", "__dict__", "[", "device", "]", ".", "n", ":", "try", ":", "self", ".", "__dict__", "[", "device", "]", ".", "setup",...
Call the ``setup`` function of the loaded models. This function is to be called after parsing all the data files during the system set up. Returns ------- None
[ "Call", "the", "setup", "function", "of", "the", "loaded", "models", ".", "This", "function", "is", "to", "be", "called", "after", "parsing", "all", "the", "data", "files", "during", "the", "system", "set", "up", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L306-L320
cuihantao/andes
andes/system.py
PowerSystem.xy_addr0
def xy_addr0(self): """ Assign indicies and variable names for variables used in power flow For each loaded model with the ``pflow`` flag as ``True``, the following functions are called sequentially: * ``_addr()`` * ``_intf_network()`` * ``_intf_ctrl()`` ...
python
def xy_addr0(self): """ Assign indicies and variable names for variables used in power flow For each loaded model with the ``pflow`` flag as ``True``, the following functions are called sequentially: * ``_addr()`` * ``_intf_network()`` * ``_intf_ctrl()`` ...
[ "def", "xy_addr0", "(", "self", ")", ":", "for", "device", ",", "pflow", "in", "zip", "(", "self", ".", "devman", ".", "devices", ",", "self", ".", "call", ".", "pflow", ")", ":", "if", "pflow", ":", "self", ".", "__dict__", "[", "device", "]", "...
Assign indicies and variable names for variables used in power flow For each loaded model with the ``pflow`` flag as ``True``, the following functions are called sequentially: * ``_addr()`` * ``_intf_network()`` * ``_intf_ctrl()`` After resizing the ``varname`` inst...
[ "Assign", "indicies", "and", "variable", "names", "for", "variables", "used", "in", "power", "flow" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L322-L350
cuihantao/andes
andes/system.py
PowerSystem.rmgen
def rmgen(self, idx): """ Remove the static generators if their dynamic models exist Parameters ---------- idx : list A list of static generator idx Returns ------- None """ stagens = [] for device, stagen in zip(self.d...
python
def rmgen(self, idx): """ Remove the static generators if their dynamic models exist Parameters ---------- idx : list A list of static generator idx Returns ------- None """ stagens = [] for device, stagen in zip(self.d...
[ "def", "rmgen", "(", "self", ",", "idx", ")", ":", "stagens", "=", "[", "]", "for", "device", ",", "stagen", "in", "zip", "(", "self", ".", "devman", ".", "devices", ",", "self", ".", "call", ".", "stagen", ")", ":", "if", "stagen", ":", "stagens...
Remove the static generators if their dynamic models exist Parameters ---------- idx : list A list of static generator idx Returns ------- None
[ "Remove", "the", "static", "generators", "if", "their", "dynamic", "models", "exist" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L370-L389
cuihantao/andes
andes/system.py
PowerSystem.check_event
def check_event(self, sim_time): """ Check for event occurrance for``Event`` group models at ``sim_time`` Parameters ---------- sim_time : float The current simulation time Returns ------- list A list of model names who report (an...
python
def check_event(self, sim_time): """ Check for event occurrance for``Event`` group models at ``sim_time`` Parameters ---------- sim_time : float The current simulation time Returns ------- list A list of model names who report (an...
[ "def", "check_event", "(", "self", ",", "sim_time", ")", ":", "ret", "=", "[", "]", "for", "model", "in", "self", ".", "__dict__", "[", "'Event'", "]", ".", "all_models", ":", "if", "self", ".", "__dict__", "[", "model", "]", ".", "is_time", "(", "...
Check for event occurrance for``Event`` group models at ``sim_time`` Parameters ---------- sim_time : float The current simulation time Returns ------- list A list of model names who report (an) event(s) at ``sim_time``
[ "Check", "for", "event", "occurrance", "for", "Event", "group", "models", "at", "sim_time" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L391-L413
cuihantao/andes
andes/system.py
PowerSystem.get_event_times
def get_event_times(self): """ Return event times of Fault, Breaker and other timed events Returns ------- list A sorted list of event times """ times = [] times.extend(self.Breaker.get_times()) for model in self.__dict__['Event'].al...
python
def get_event_times(self): """ Return event times of Fault, Breaker and other timed events Returns ------- list A sorted list of event times """ times = [] times.extend(self.Breaker.get_times()) for model in self.__dict__['Event'].al...
[ "def", "get_event_times", "(", "self", ")", ":", "times", "=", "[", "]", "times", ".", "extend", "(", "self", ".", "Breaker", ".", "get_times", "(", ")", ")", "for", "model", "in", "self", ".", "__dict__", "[", "'Event'", "]", ".", "all_models", ":",...
Return event times of Fault, Breaker and other timed events Returns ------- list A sorted list of event times
[ "Return", "event", "times", "of", "Fault", "Breaker", "and", "other", "timed", "events" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L415-L434
cuihantao/andes
andes/system.py
PowerSystem.load_config
def load_config(self, conf_path): """ Load config from an ``andes.conf`` file. This function creates a ``configparser.ConfigParser`` object to read the specified conf file and calls the ``load_config`` function of the config instances of the system and the routines. Par...
python
def load_config(self, conf_path): """ Load config from an ``andes.conf`` file. This function creates a ``configparser.ConfigParser`` object to read the specified conf file and calls the ``load_config`` function of the config instances of the system and the routines. Par...
[ "def", "load_config", "(", "self", ",", "conf_path", ")", ":", "if", "conf_path", "is", "None", ":", "return", "conf", "=", "configparser", ".", "ConfigParser", "(", ")", "conf", ".", "read", "(", "conf_path", ")", "self", ".", "config", ".", "load_confi...
Load config from an ``andes.conf`` file. This function creates a ``configparser.ConfigParser`` object to read the specified conf file and calls the ``load_config`` function of the config instances of the system and the routines. Parameters ---------- conf_path : None or...
[ "Load", "config", "from", "an", "andes", ".", "conf", "file", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L436-L464
cuihantao/andes
andes/system.py
PowerSystem.dump_config
def dump_config(self, file_path): """ Dump system and routine configurations to an rc-formatted file. Parameters ---------- file_path : str path to the configuration file. The user will be prompted if the file already exists. Returns ----...
python
def dump_config(self, file_path): """ Dump system and routine configurations to an rc-formatted file. Parameters ---------- file_path : str path to the configuration file. The user will be prompted if the file already exists. Returns ----...
[ "def", "dump_config", "(", "self", ",", "file_path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "file_path", ")", ":", "logger", ".", "debug", "(", "'File {} alreay exist. Overwrite? [y/N]'", ".", "format", "(", "file_path", ")", ")", "choice", ...
Dump system and routine configurations to an rc-formatted file. Parameters ---------- file_path : str path to the configuration file. The user will be prompted if the file already exists. Returns ------- None
[ "Dump", "system", "and", "routine", "configurations", "to", "an", "rc", "-", "formatted", "file", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L466-L494
cuihantao/andes
andes/system.py
PowerSystem.check_islands
def check_islands(self, show_info=False): """ Check the connectivity for the ac system Parameters ---------- show_info : bool Show information when the system has islands. To be used when initializing power flow. Returns ------- N...
python
def check_islands(self, show_info=False): """ Check the connectivity for the ac system Parameters ---------- show_info : bool Show information when the system has islands. To be used when initializing power flow. Returns ------- N...
[ "def", "check_islands", "(", "self", ",", "show_info", "=", "False", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'Line'", ")", ":", "logger", ".", "error", "(", "'<Line> device not found.'", ")", "return", "self", ".", "Line", ".", "connectivity",...
Check the connectivity for the ac system Parameters ---------- show_info : bool Show information when the system has islands. To be used when initializing power flow. Returns ------- None
[ "Check", "the", "connectivity", "for", "the", "ac", "system" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L496-L550
cuihantao/andes
andes/system.py
PowerSystem.get_busdata
def get_busdata(self, sort_names=False): """ get ac bus data from solved power flow """ if self.pflow.solved is False: logger.error('Power flow not solved when getting bus data.') return tuple([False] * 8) idx = self.Bus.idx names = self.Bus.name ...
python
def get_busdata(self, sort_names=False): """ get ac bus data from solved power flow """ if self.pflow.solved is False: logger.error('Power flow not solved when getting bus data.') return tuple([False] * 8) idx = self.Bus.idx names = self.Bus.name ...
[ "def", "get_busdata", "(", "self", ",", "sort_names", "=", "False", ")", ":", "if", "self", ".", "pflow", ".", "solved", "is", "False", ":", "logger", ".", "error", "(", "'Power flow not solved when getting bus data.'", ")", "return", "tuple", "(", "[", "Fal...
get ac bus data from solved power flow
[ "get", "ac", "bus", "data", "from", "solved", "power", "flow" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L552-L578
cuihantao/andes
andes/system.py
PowerSystem.get_nodedata
def get_nodedata(self, sort_names=False): """ get dc node data from solved power flow """ if not self.Node.n: return if not self.pflow.solved: logger.error('Power flow not solved when getting bus data.') return tuple([False] * 7) idx = ...
python
def get_nodedata(self, sort_names=False): """ get dc node data from solved power flow """ if not self.Node.n: return if not self.pflow.solved: logger.error('Power flow not solved when getting bus data.') return tuple([False] * 7) idx = ...
[ "def", "get_nodedata", "(", "self", ",", "sort_names", "=", "False", ")", ":", "if", "not", "self", ".", "Node", ".", "n", ":", "return", "if", "not", "self", ".", "pflow", ".", "solved", ":", "logger", ".", "error", "(", "'Power flow not solved when get...
get dc node data from solved power flow
[ "get", "dc", "node", "data", "from", "solved", "power", "flow" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L580-L599
cuihantao/andes
andes/system.py
PowerSystem.get_linedata
def get_linedata(self, sort_names=False): """ get line data from solved power flow """ if not self.pflow.solved: logger.error('Power flow not solved when getting line data.') return tuple([False] * 7) idx = self.Line.idx fr = self.Line.bus1 ...
python
def get_linedata(self, sort_names=False): """ get line data from solved power flow """ if not self.pflow.solved: logger.error('Power flow not solved when getting line data.') return tuple([False] * 7) idx = self.Line.idx fr = self.Line.bus1 ...
[ "def", "get_linedata", "(", "self", ",", "sort_names", "=", "False", ")", ":", "if", "not", "self", ".", "pflow", ".", "solved", ":", "logger", ".", "error", "(", "'Power flow not solved when getting line data.'", ")", "return", "tuple", "(", "[", "False", "...
get line data from solved power flow
[ "get", "line", "data", "from", "solved", "power", "flow" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L601-L629
cuihantao/andes
andes/system.py
Group.register_model
def register_model(self, model): """ Register ``model`` to this group :param model: model name :return: None """ assert isinstance(model, str) if model not in self.all_models: self.all_models.append(model)
python
def register_model(self, model): """ Register ``model`` to this group :param model: model name :return: None """ assert isinstance(model, str) if model not in self.all_models: self.all_models.append(model)
[ "def", "register_model", "(", "self", ",", "model", ")", ":", "assert", "isinstance", "(", "model", ",", "str", ")", "if", "model", "not", "in", "self", ".", "all_models", ":", "self", ".", "all_models", ".", "append", "(", "model", ")" ]
Register ``model`` to this group :param model: model name :return: None
[ "Register", "model", "to", "this", "group" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L651-L661
cuihantao/andes
andes/system.py
Group.register_element
def register_element(self, model, idx): """ Register element with index ``idx`` to ``model`` :param model: model name :param idx: element idx :return: final element idx """ if idx is None: idx = model + '_' + str(len(self._idx_model)) self._...
python
def register_element(self, model, idx): """ Register element with index ``idx`` to ``model`` :param model: model name :param idx: element idx :return: final element idx """ if idx is None: idx = model + '_' + str(len(self._idx_model)) self._...
[ "def", "register_element", "(", "self", ",", "model", ",", "idx", ")", ":", "if", "idx", "is", "None", ":", "idx", "=", "model", "+", "'_'", "+", "str", "(", "len", "(", "self", ".", "_idx_model", ")", ")", "self", ".", "_idx_model", "[", "idx", ...
Register element with index ``idx`` to ``model`` :param model: model name :param idx: element idx :return: final element idx
[ "Register", "element", "with", "index", "idx", "to", "model" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L663-L678
cuihantao/andes
andes/system.py
Group.get_field
def get_field(self, field, idx): """ Return the field ``field`` of elements ``idx`` in the group :param field: field name :param idx: element idx :return: values of the requested field """ ret = [] scalar = False # TODO: ensure idx is unique in t...
python
def get_field(self, field, idx): """ Return the field ``field`` of elements ``idx`` in the group :param field: field name :param idx: element idx :return: values of the requested field """ ret = [] scalar = False # TODO: ensure idx is unique in t...
[ "def", "get_field", "(", "self", ",", "field", ",", "idx", ")", ":", "ret", "=", "[", "]", "scalar", "=", "False", "# TODO: ensure idx is unique in this Group", "if", "isinstance", "(", "idx", ",", "(", "int", ",", "float", ",", "str", ")", ")", ":", "...
Return the field ``field`` of elements ``idx`` in the group :param field: field name :param idx: element idx :return: values of the requested field
[ "Return", "the", "field", "field", "of", "elements", "idx", "in", "the", "group" ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L680-L705
cuihantao/andes
andes/system.py
Group.set_field
def set_field(self, field, idx, value): """ Set the field ``field`` of elements ``idx`` to ``value``. This function does not if the field is valid for all models. :param field: field name :param idx: element idx :param value: value of fields to set :return: None...
python
def set_field(self, field, idx, value): """ Set the field ``field`` of elements ``idx`` to ``value``. This function does not if the field is valid for all models. :param field: field name :param idx: element idx :param value: value of fields to set :return: None...
[ "def", "set_field", "(", "self", ",", "field", ",", "idx", ",", "value", ")", ":", "if", "isinstance", "(", "idx", ",", "(", "int", ",", "float", ",", "str", ")", ")", ":", "idx", "=", "[", "idx", "]", "if", "isinstance", "(", "value", ",", "("...
Set the field ``field`` of elements ``idx`` to ``value``. This function does not if the field is valid for all models. :param field: field name :param idx: element idx :param value: value of fields to set :return: None
[ "Set", "the", "field", "field", "of", "elements", "idx", "to", "value", "." ]
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L707-L730
DiamondLightSource/python-workflows
workflows/contrib/start_service.py
ServiceStarter.run
def run( self, cmdline_args=None, program_name="start_service", version=workflows.version(), **kwargs ): """Example command line interface to start services. :param cmdline_args: List of command line arguments to pass to parser :param program_name: Nam...
python
def run( self, cmdline_args=None, program_name="start_service", version=workflows.version(), **kwargs ): """Example command line interface to start services. :param cmdline_args: List of command line arguments to pass to parser :param program_name: Nam...
[ "def", "run", "(", "self", ",", "cmdline_args", "=", "None", ",", "program_name", "=", "\"start_service\"", ",", "version", "=", "workflows", ".", "version", "(", ")", ",", "*", "*", "kwargs", ")", ":", "# Enumerate all known services", "known_services", "=", ...
Example command line interface to start services. :param cmdline_args: List of command line arguments to pass to parser :param program_name: Name of the command line tool to display in help :param version: Version number to print when run with '--version'
[ "Example", "command", "line", "interface", "to", "start", "services", ".", ":", "param", "cmdline_args", ":", "List", "of", "command", "line", "arguments", "to", "pass", "to", "parser", ":", "param", "program_name", ":", "Name", "of", "the", "command", "line...
train
https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/start_service.py#L49-L145
webstack/webstack-django-sorting
webstack_django_sorting/util.py
get_sort_field
def get_sort_field(request): """ Retrieve field used for sorting a queryset :param request: HTTP request :return: the sorted field name, prefixed with "-" if ordering is descending """ sort_direction = request.GET.get("dir") field_name = (request.GET.get("sort") or "") if sort_direction els...
python
def get_sort_field(request): """ Retrieve field used for sorting a queryset :param request: HTTP request :return: the sorted field name, prefixed with "-" if ordering is descending """ sort_direction = request.GET.get("dir") field_name = (request.GET.get("sort") or "") if sort_direction els...
[ "def", "get_sort_field", "(", "request", ")", ":", "sort_direction", "=", "request", ".", "GET", ".", "get", "(", "\"dir\"", ")", "field_name", "=", "(", "request", ".", "GET", ".", "get", "(", "\"sort\"", ")", "or", "\"\"", ")", "if", "sort_direction", ...
Retrieve field used for sorting a queryset :param request: HTTP request :return: the sorted field name, prefixed with "-" if ordering is descending
[ "Retrieve", "field", "used", "for", "sorting", "a", "queryset" ]
train
https://github.com/webstack/webstack-django-sorting/blob/e78bfb890da1da6eb3cc12a7151390317ac4be99/webstack_django_sorting/util.py#L4-L15
webstack/webstack-django-sorting
webstack_django_sorting/templatetags/sorting_tags.py
anchor
def anchor(parser, token): """ Parses a tag that's supposed to be in this format '{% anchor field title %}' Title may be a "string", _("trans string"), or variable """ bits = [b for b in token.split_contents()] if len(bits) < 2: raise template.TemplateSyntaxError("anchor tag takes at lea...
python
def anchor(parser, token): """ Parses a tag that's supposed to be in this format '{% anchor field title %}' Title may be a "string", _("trans string"), or variable """ bits = [b for b in token.split_contents()] if len(bits) < 2: raise template.TemplateSyntaxError("anchor tag takes at lea...
[ "def", "anchor", "(", "parser", ",", "token", ")", ":", "bits", "=", "[", "b", "for", "b", "in", "token", ".", "split_contents", "(", ")", "]", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "template", ".", "TemplateSyntaxError", "(", "\"a...
Parses a tag that's supposed to be in this format '{% anchor field title %}' Title may be a "string", _("trans string"), or variable
[ "Parses", "a", "tag", "that", "s", "supposed", "to", "be", "in", "this", "format", "{", "%", "anchor", "field", "title", "%", "}", "Title", "may", "be", "a", "string", "_", "(", "trans", "string", ")", "or", "variable" ]
train
https://github.com/webstack/webstack-django-sorting/blob/e78bfb890da1da6eb3cc12a7151390317ac4be99/webstack_django_sorting/templatetags/sorting_tags.py#L25-L51
iliana/python-simplemediawiki
simplemediawiki.py
MediaWiki._fetch_http
def _fetch_http(self, url, params, force_get=False): """ Standard HTTP request handler for this class with gzip and cookie support. This was separated out of :py:func:`MediaWiki.call` to make :py:func:`MediaWiki.normalize_api_url` useful. .. note:: This function shoul...
python
def _fetch_http(self, url, params, force_get=False): """ Standard HTTP request handler for this class with gzip and cookie support. This was separated out of :py:func:`MediaWiki.call` to make :py:func:`MediaWiki.normalize_api_url` useful. .. note:: This function shoul...
[ "def", "_fetch_http", "(", "self", ",", "url", ",", "params", ",", "force_get", "=", "False", ")", ":", "params", "[", "'format'", "]", "=", "'json'", "if", "sys", ".", "version_info", "[", "0", "]", "==", "3", ":", "fixed", "=", "urllib", ".", "ur...
Standard HTTP request handler for this class with gzip and cookie support. This was separated out of :py:func:`MediaWiki.call` to make :py:func:`MediaWiki.normalize_api_url` useful. .. note:: This function should not be used. Use :py:func:`MediaWiki.call` instead. ...
[ "Standard", "HTTP", "request", "handler", "for", "this", "class", "with", "gzip", "and", "cookie", "support", ".", "This", "was", "separated", "out", "of", ":", "py", ":", "func", ":", "MediaWiki", ".", "call", "to", "make", ":", "py", ":", "func", ":"...
train
https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L120-L167
iliana/python-simplemediawiki
simplemediawiki.py
MediaWiki.call
def call(self, params): """ Make an API call to the wiki. *params* is a dictionary of query string arguments. For example, to get basic information about the wiki, run: >>> wiki.call({'action': 'query', 'meta': 'siteinfo'}) which would make a call to ``http://domain/w/a...
python
def call(self, params): """ Make an API call to the wiki. *params* is a dictionary of query string arguments. For example, to get basic information about the wiki, run: >>> wiki.call({'action': 'query', 'meta': 'siteinfo'}) which would make a call to ``http://domain/w/a...
[ "def", "call", "(", "self", ",", "params", ")", ":", "return", "json", ".", "loads", "(", "self", ".", "_fetch_http", "(", "self", ".", "_api_url", ",", "params", ")", ")" ]
Make an API call to the wiki. *params* is a dictionary of query string arguments. For example, to get basic information about the wiki, run: >>> wiki.call({'action': 'query', 'meta': 'siteinfo'}) which would make a call to ``http://domain/w/api.php?action=query&meta=siteinfo&format=jso...
[ "Make", "an", "API", "call", "to", "the", "wiki", ".", "*", "params", "*", "is", "a", "dictionary", "of", "query", "string", "arguments", ".", "For", "example", "to", "get", "basic", "information", "about", "the", "wiki", "run", ":" ]
train
https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L169-L183
iliana/python-simplemediawiki
simplemediawiki.py
MediaWiki.normalize_api_url
def normalize_api_url(self): """ Checks that the API URL used to initialize this object actually returns JSON. If it doesn't, make some educated guesses and try to find the correct URL. :returns: a valid API URL or ``None`` """ def tester(self, api_url): ...
python
def normalize_api_url(self): """ Checks that the API URL used to initialize this object actually returns JSON. If it doesn't, make some educated guesses and try to find the correct URL. :returns: a valid API URL or ``None`` """ def tester(self, api_url): ...
[ "def", "normalize_api_url", "(", "self", ")", ":", "def", "tester", "(", "self", ",", "api_url", ")", ":", "\"\"\"\n Attempts to fetch general information about the MediaWiki instance\n in order to test whether *api_url* will return JSON.\n \"\"\"", "da...
Checks that the API URL used to initialize this object actually returns JSON. If it doesn't, make some educated guesses and try to find the correct URL. :returns: a valid API URL or ``None``
[ "Checks", "that", "the", "API", "URL", "used", "to", "initialize", "this", "object", "actually", "returns", "JSON", ".", "If", "it", "doesn", "t", "make", "some", "educated", "guesses", "and", "try", "to", "find", "the", "correct", "URL", "." ]
train
https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L185-L217
iliana/python-simplemediawiki
simplemediawiki.py
MediaWiki.login
def login(self, user, passwd): """ Logs into the wiki with username *user* and password *passwd*. Returns ``True`` on successful login. :param user: username :param passwd: password :returns: ``True`` on successful login, otherwise ``False`` """ def do_lo...
python
def login(self, user, passwd): """ Logs into the wiki with username *user* and password *passwd*. Returns ``True`` on successful login. :param user: username :param passwd: password :returns: ``True`` on successful login, otherwise ``False`` """ def do_lo...
[ "def", "login", "(", "self", ",", "user", ",", "passwd", ")", ":", "def", "do_login", "(", "self", ",", "user", ",", "passwd", ",", "token", "=", "None", ")", ":", "\"\"\"\n Login function that handles CSRF protection (see `MediaWiki bug\n 23076`...
Logs into the wiki with username *user* and password *passwd*. Returns ``True`` on successful login. :param user: username :param passwd: password :returns: ``True`` on successful login, otherwise ``False``
[ "Logs", "into", "the", "wiki", "with", "username", "*", "user", "*", "and", "password", "*", "passwd", "*", ".", "Returns", "True", "on", "successful", "login", "." ]
train
https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L219-L250
iliana/python-simplemediawiki
simplemediawiki.py
MediaWiki.limits
def limits(self, low, high): """ Convenience function for determining appropriate limits in the API. If the (usually logged-in) client has the ``apihighlimits`` right, it will return *high*; otherwise it will return *low*. It's generally a good idea to use the highest limit poss...
python
def limits(self, low, high): """ Convenience function for determining appropriate limits in the API. If the (usually logged-in) client has the ``apihighlimits`` right, it will return *high*; otherwise it will return *low*. It's generally a good idea to use the highest limit poss...
[ "def", "limits", "(", "self", ",", "low", ",", "high", ")", ":", "if", "self", ".", "_high_limits", "is", "None", ":", "result", "=", "self", ".", "call", "(", "{", "'action'", ":", "'query'", ",", "'meta'", ":", "'userinfo'", ",", "'uiprop'", ":", ...
Convenience function for determining appropriate limits in the API. If the (usually logged-in) client has the ``apihighlimits`` right, it will return *high*; otherwise it will return *low*. It's generally a good idea to use the highest limit possible; this reduces the amount of HTTP req...
[ "Convenience", "function", "for", "determining", "appropriate", "limits", "in", "the", "API", ".", "If", "the", "(", "usually", "logged", "-", "in", ")", "client", "has", "the", "apihighlimits", "right", "it", "will", "return", "*", "high", "*", ";", "othe...
train
https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L263-L287
iliana/python-simplemediawiki
simplemediawiki.py
MediaWiki.namespaces
def namespaces(self, psuedo=True): """ Fetches a list of namespaces for this wiki and returns them as a dictionary of namespace IDs corresponding to namespace names. If *psuedo* is ``True``, the dictionary will also list psuedo-namespaces, which are the "Special:" and "Media:" na...
python
def namespaces(self, psuedo=True): """ Fetches a list of namespaces for this wiki and returns them as a dictionary of namespace IDs corresponding to namespace names. If *psuedo* is ``True``, the dictionary will also list psuedo-namespaces, which are the "Special:" and "Media:" na...
[ "def", "namespaces", "(", "self", ",", "psuedo", "=", "True", ")", ":", "if", "self", ".", "_namespaces", "is", "None", ":", "result", "=", "self", ".", "call", "(", "{", "'action'", ":", "'query'", ",", "'meta'", ":", "'siteinfo'", ",", "'siprop'", ...
Fetches a list of namespaces for this wiki and returns them as a dictionary of namespace IDs corresponding to namespace names. If *psuedo* is ``True``, the dictionary will also list psuedo-namespaces, which are the "Special:" and "Media:" namespaces (special because they have no content ...
[ "Fetches", "a", "list", "of", "namespaces", "for", "this", "wiki", "and", "returns", "them", "as", "a", "dictionary", "of", "namespace", "IDs", "corresponding", "to", "namespace", "names", ".", "If", "*", "psuedo", "*", "is", "True", "the", "dictionary", "...
train
https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L289-L319
LettError/ufoProcessor
Lib/ufoProcessor/sp3.py
SuperpolatorReader.readLocationElement
def readLocationElement(self, locationElement): """ Format 0 location reader """ if self._strictAxisNames and not self.documentObject.axes: raise DesignSpaceDocumentError("No axes defined") loc = {} for dimensionElement in locationElement.findall(".dimension"): di...
python
def readLocationElement(self, locationElement): """ Format 0 location reader """ if self._strictAxisNames and not self.documentObject.axes: raise DesignSpaceDocumentError("No axes defined") loc = {} for dimensionElement in locationElement.findall(".dimension"): di...
[ "def", "readLocationElement", "(", "self", ",", "locationElement", ")", ":", "if", "self", ".", "_strictAxisNames", "and", "not", "self", ".", "documentObject", ".", "axes", ":", "raise", "DesignSpaceDocumentError", "(", "\"No axes defined\"", ")", "loc", "=", "...
Format 0 location reader
[ "Format", "0", "location", "reader" ]
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/sp3.py#L303-L330
LettError/ufoProcessor
Lib/ufoProcessor/__init__.py
build
def build( documentPath, outputUFOFormatVersion=3, roundGeometry=True, verbose=True, # not supported logPath=None, # not supported progressFunc=None, # not supported processRules=True, logger=None, useVarlib=False, ...
python
def build( documentPath, outputUFOFormatVersion=3, roundGeometry=True, verbose=True, # not supported logPath=None, # not supported progressFunc=None, # not supported processRules=True, logger=None, useVarlib=False, ...
[ "def", "build", "(", "documentPath", ",", "outputUFOFormatVersion", "=", "3", ",", "roundGeometry", "=", "True", ",", "verbose", "=", "True", ",", "# not supported", "logPath", "=", "None", ",", "# not supported", "progressFunc", "=", "None", ",", "# not support...
Simple builder for UFO designspaces.
[ "Simple", "builder", "for", "UFO", "designspaces", "." ]
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L89-L124
LettError/ufoProcessor
Lib/ufoProcessor/__init__.py
DesignSpaceProcessor.getInfoMutator
def getInfoMutator(self): """ Returns a info mutator """ if self._infoMutator: return self._infoMutator infoItems = [] for sourceDescriptor in self.sources: if sourceDescriptor.layerName is not None: continue loc = Location(sourceDescri...
python
def getInfoMutator(self): """ Returns a info mutator """ if self._infoMutator: return self._infoMutator infoItems = [] for sourceDescriptor in self.sources: if sourceDescriptor.layerName is not None: continue loc = Location(sourceDescri...
[ "def", "getInfoMutator", "(", "self", ")", ":", "if", "self", ".", "_infoMutator", ":", "return", "self", ".", "_infoMutator", "infoItems", "=", "[", "]", "for", "sourceDescriptor", "in", "self", ".", "sources", ":", "if", "sourceDescriptor", ".", "layerName...
Returns a info mutator
[ "Returns", "a", "info", "mutator" ]
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L346-L363
LettError/ufoProcessor
Lib/ufoProcessor/__init__.py
DesignSpaceProcessor.getKerningMutator
def getKerningMutator(self, pairs=None): """ Return a kerning mutator, collect the sources, build mathGlyphs. If no pairs are given: calculate the whole table. If pairs are given then query the sources for a value and make a mutator only with those values. """ if self._ke...
python
def getKerningMutator(self, pairs=None): """ Return a kerning mutator, collect the sources, build mathGlyphs. If no pairs are given: calculate the whole table. If pairs are given then query the sources for a value and make a mutator only with those values. """ if self._ke...
[ "def", "getKerningMutator", "(", "self", ",", "pairs", "=", "None", ")", ":", "if", "self", ".", "_kerningMutator", "and", "pairs", "==", "self", ".", "_kerningMutatorPairs", ":", "return", "self", ".", "_kerningMutator", "kerningItems", "=", "[", "]", "if",...
Return a kerning mutator, collect the sources, build mathGlyphs. If no pairs are given: calculate the whole table. If pairs are given then query the sources for a value and make a mutator only with those values.
[ "Return", "a", "kerning", "mutator", "collect", "the", "sources", "build", "mathGlyphs", ".", "If", "no", "pairs", "are", "given", ":", "calculate", "the", "whole", "table", ".", "If", "pairs", "are", "given", "then", "query", "the", "sources", "for", "a",...
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L365-L405
LettError/ufoProcessor
Lib/ufoProcessor/__init__.py
DesignSpaceProcessor.collectMastersForGlyph
def collectMastersForGlyph(self, glyphName, decomposeComponents=False): """ Return a glyph mutator.defaultLoc decomposeComponents = True causes the source glyphs to be decomposed first before building the mutator. That gives you instances that do not depend on a complete font...
python
def collectMastersForGlyph(self, glyphName, decomposeComponents=False): """ Return a glyph mutator.defaultLoc decomposeComponents = True causes the source glyphs to be decomposed first before building the mutator. That gives you instances that do not depend on a complete font...
[ "def", "collectMastersForGlyph", "(", "self", ",", "glyphName", ",", "decomposeComponents", "=", "False", ")", ":", "items", "=", "[", "]", "empties", "=", "[", "]", "foundEmpty", "=", "False", "for", "sourceDescriptor", "in", "self", ".", "sources", ":", ...
Return a glyph mutator.defaultLoc decomposeComponents = True causes the source glyphs to be decomposed first before building the mutator. That gives you instances that do not depend on a complete font. If you're calculating previews for instance. XXX check glyphs in laye...
[ "Return", "a", "glyph", "mutator", ".", "defaultLoc", "decomposeComponents", "=", "True", "causes", "the", "source", "glyphs", "to", "be", "decomposed", "first", "before", "building", "the", "mutator", ".", "That", "gives", "you", "instances", "that", "do", "n...
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L454-L553
LettError/ufoProcessor
Lib/ufoProcessor/__init__.py
DesignSpaceProcessor.makeInstance
def makeInstance(self, instanceDescriptor, doRules=False, glyphNames=None, pairs=None, bend=False): """ Generate a font object for this instance """ font = self._instantiateFont(None) # make fonty things here loc = Location(instanceDescript...
python
def makeInstance(self, instanceDescriptor, doRules=False, glyphNames=None, pairs=None, bend=False): """ Generate a font object for this instance """ font = self._instantiateFont(None) # make fonty things here loc = Location(instanceDescript...
[ "def", "makeInstance", "(", "self", ",", "instanceDescriptor", ",", "doRules", "=", "False", ",", "glyphNames", "=", "None", ",", "pairs", "=", "None", ",", "bend", "=", "False", ")", ":", "font", "=", "self", ".", "_instantiateFont", "(", "None", ")", ...
Generate a font object for this instance
[ "Generate", "a", "font", "object", "for", "this", "instance" ]
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L597-L812
LettError/ufoProcessor
Lib/ufoProcessor/__init__.py
DesignSpaceProcessor._instantiateFont
def _instantiateFont(self, path): """ Return a instance of a font object with all the given subclasses""" try: return self.fontClass(path, layerClass=self.layerClass, libClass=self.libClass, kerningClass=self.kerningClass, group...
python
def _instantiateFont(self, path): """ Return a instance of a font object with all the given subclasses""" try: return self.fontClass(path, layerClass=self.layerClass, libClass=self.libClass, kerningClass=self.kerningClass, group...
[ "def", "_instantiateFont", "(", "self", ",", "path", ")", ":", "try", ":", "return", "self", ".", "fontClass", "(", "path", ",", "layerClass", "=", "self", ".", "layerClass", ",", "libClass", "=", "self", ".", "libClass", ",", "kerningClass", "=", "self"...
Return a instance of a font object with all the given subclasses
[ "Return", "a", "instance", "of", "a", "font", "object", "with", "all", "the", "given", "subclasses" ]
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L831-L848
LettError/ufoProcessor
Lib/ufoProcessor/emptyPen.py
checkGlyphIsEmpty
def checkGlyphIsEmpty(glyph, allowWhiteSpace=True): """ This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen. Additionally, the unicode of the glyph is checked against a list of known unicode whitespace characters. This makes it possible to filter out gl...
python
def checkGlyphIsEmpty(glyph, allowWhiteSpace=True): """ This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen. Additionally, the unicode of the glyph is checked against a list of known unicode whitespace characters. This makes it possible to filter out gl...
[ "def", "checkGlyphIsEmpty", "(", "glyph", ",", "allowWhiteSpace", "=", "True", ")", ":", "whiteSpace", "=", "[", "0x9", ",", "# horizontal tab", "0xa", ",", "# line feed", "0xb", ",", "# vertical tab", "0xc", ",", "# form feed", "0xd", ",", "# carriage return", ...
This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen. Additionally, the unicode of the glyph is checked against a list of known unicode whitespace characters. This makes it possible to filter out glyphs that have a valid reason to be empty and those that can...
[ "This", "will", "establish", "if", "the", "glyph", "is", "completely", "empty", "by", "drawing", "the", "glyph", "with", "an", "EmptyPen", ".", "Additionally", "the", "unicode", "of", "the", "glyph", "is", "checked", "against", "a", "list", "of", "known", ...
train
https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/emptyPen.py#L34-L75
signetlabdei/sem
sem/runner.py
SimulationRunner.configure_and_build
def configure_and_build(self, show_progress=True, optimized=True, skip_configuration=False): """ Configure and build the ns-3 code. Args: show_progress (bool): whether or not to display a progress bar during compilation. optimi...
python
def configure_and_build(self, show_progress=True, optimized=True, skip_configuration=False): """ Configure and build the ns-3 code. Args: show_progress (bool): whether or not to display a progress bar during compilation. optimi...
[ "def", "configure_and_build", "(", "self", ",", "show_progress", "=", "True", ",", "optimized", "=", "True", ",", "skip_configuration", "=", "False", ")", ":", "# Only configure if necessary", "if", "not", "skip_configuration", ":", "configuration_command", "=", "["...
Configure and build the ns-3 code. Args: show_progress (bool): whether or not to display a progress bar during compilation. optimized (bool): whether to use an optimized build. If False, use a standard ./waf configure. skip_configuration (bool...
[ "Configure", "and", "build", "the", "ns", "-", "3", "code", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L108-L154
signetlabdei/sem
sem/runner.py
SimulationRunner.get_build_output
def get_build_output(self, process): """ Parse the output of the ns-3 build process to extract the information that is needed to draw the progress bar. Args: process: the subprocess instance to listen to. """ while True: output = process.stdout.r...
python
def get_build_output(self, process): """ Parse the output of the ns-3 build process to extract the information that is needed to draw the progress bar. Args: process: the subprocess instance to listen to. """ while True: output = process.stdout.r...
[ "def", "get_build_output", "(", "self", ",", "process", ")", ":", "while", "True", ":", "output", "=", "process", ".", "stdout", ".", "readline", "(", ")", "if", "output", "==", "b''", "and", "process", ".", "poll", "(", ")", "is", "not", "None", ":"...
Parse the output of the ns-3 build process to extract the information that is needed to draw the progress bar. Args: process: the subprocess instance to listen to.
[ "Parse", "the", "output", "of", "the", "ns", "-", "3", "build", "process", "to", "extract", "the", "information", "that", "is", "needed", "to", "draw", "the", "progress", "bar", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L156-L181
signetlabdei/sem
sem/runner.py
SimulationRunner.get_available_parameters
def get_available_parameters(self): """ Return a list of the parameters made available by the script. """ # At the moment, we rely on regex to extract the list of available # parameters. This solution will break if the format of the output # changes, but this is the best...
python
def get_available_parameters(self): """ Return a list of the parameters made available by the script. """ # At the moment, we rely on regex to extract the list of available # parameters. This solution will break if the format of the output # changes, but this is the best...
[ "def", "get_available_parameters", "(", "self", ")", ":", "# At the moment, we rely on regex to extract the list of available", "# parameters. This solution will break if the format of the output", "# changes, but this is the best option that is currently available.", "result", "=", "subproces...
Return a list of the parameters made available by the script.
[ "Return", "a", "list", "of", "the", "parameters", "made", "available", "by", "the", "script", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L183-L215
signetlabdei/sem
sem/runner.py
SimulationRunner.run_simulations
def run_simulations(self, parameter_list, data_folder): """ Run several simulations using a certain combination of parameters. Yields results as simulations are completed. Args: parameter_list (list): list of parameter combinations to simulate. data_folder (str)...
python
def run_simulations(self, parameter_list, data_folder): """ Run several simulations using a certain combination of parameters. Yields results as simulations are completed. Args: parameter_list (list): list of parameter combinations to simulate. data_folder (str)...
[ "def", "run_simulations", "(", "self", ",", "parameter_list", ",", "data_folder", ")", ":", "for", "idx", ",", "parameter", "in", "enumerate", "(", "parameter_list", ")", ":", "current_result", "=", "{", "'params'", ":", "{", "}", ",", "'meta'", ":", "{", ...
Run several simulations using a certain combination of parameters. Yields results as simulations are completed. Args: parameter_list (list): list of parameter combinations to simulate. data_folder (str): folder in which to save subfolders containing simulation o...
[ "Run", "several", "simulations", "using", "a", "certain", "combination", "of", "parameters", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L221-L280
signetlabdei/sem
sem/utils.py
list_param_combinations
def list_param_combinations(param_ranges): """ Create a list of all parameter combinations from a dictionary specifying desired parameter values as lists. Example: >>> param_ranges = {'a': [1], 'b': [2, 3]} >>> list_param_combinations(param_ranges) [{'a': 1, 'b': 2}, {'a': 1, '...
python
def list_param_combinations(param_ranges): """ Create a list of all parameter combinations from a dictionary specifying desired parameter values as lists. Example: >>> param_ranges = {'a': [1], 'b': [2, 3]} >>> list_param_combinations(param_ranges) [{'a': 1, 'b': 2}, {'a': 1, '...
[ "def", "list_param_combinations", "(", "param_ranges", ")", ":", "# Convert non-list values to single-element lists", "# This is required to make sure product work.", "for", "key", "in", "param_ranges", ":", "if", "not", "isinstance", "(", "param_ranges", "[", "key", "]", "...
Create a list of all parameter combinations from a dictionary specifying desired parameter values as lists. Example: >>> param_ranges = {'a': [1], 'b': [2, 3]} >>> list_param_combinations(param_ranges) [{'a': 1, 'b': 2}, {'a': 1, 'b': 3}] Additionally, this function is robust in c...
[ "Create", "a", "list", "of", "all", "parameter", "combinations", "from", "a", "dictionary", "specifying", "desired", "parameter", "values", "as", "lists", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/utils.py#L13-L38
signetlabdei/sem
sem/utils.py
get_command_from_result
def get_command_from_result(script, result, debug=False): """ Return the command that is needed to obtain a certain result. Args: params (dict): Dictionary containing parameter: value pairs. debug (bool): Whether the command should include the debugging template. """ if ...
python
def get_command_from_result(script, result, debug=False): """ Return the command that is needed to obtain a certain result. Args: params (dict): Dictionary containing parameter: value pairs. debug (bool): Whether the command should include the debugging template. """ if ...
[ "def", "get_command_from_result", "(", "script", ",", "result", ",", "debug", "=", "False", ")", ":", "if", "not", "debug", ":", "command", "=", "\"python waf --run \\\"\"", "+", "script", "+", "\" \"", "+", "\" \"", ".", "join", "(", "[", "'--%s=%s'", "%"...
Return the command that is needed to obtain a certain result. Args: params (dict): Dictionary containing parameter: value pairs. debug (bool): Whether the command should include the debugging template.
[ "Return", "the", "command", "that", "is", "needed", "to", "obtain", "a", "certain", "result", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/utils.py#L41-L59
signetlabdei/sem
sem/utils.py
automatic_parser
def automatic_parser(result, dtypes={}, converters={}): """ Try and automatically convert strings formatted as tables into nested list structures. Under the hood, this function essentially applies the genfromtxt function to all files in the output, and passes it the additional kwargs. Args: ...
python
def automatic_parser(result, dtypes={}, converters={}): """ Try and automatically convert strings formatted as tables into nested list structures. Under the hood, this function essentially applies the genfromtxt function to all files in the output, and passes it the additional kwargs. Args: ...
[ "def", "automatic_parser", "(", "result", ",", "dtypes", "=", "{", "}", ",", "converters", "=", "{", "}", ")", ":", "np", ".", "seterr", "(", "all", "=", "'raise'", ")", "parsed", "=", "{", "}", "for", "filename", ",", "contents", "in", "result", "...
Try and automatically convert strings formatted as tables into nested list structures. Under the hood, this function essentially applies the genfromtxt function to all files in the output, and passes it the additional kwargs. Args: result (dict): the result to parse. dtypes (dict): a dicti...
[ "Try", "and", "automatically", "convert", "strings", "formatted", "as", "tables", "into", "nested", "list", "structures", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/utils.py#L69-L99
signetlabdei/sem
sem/manager.py
CampaignManager.new
def new(cls, ns_path, script, campaign_dir, runner_type='Auto', overwrite=False, optimized=True, check_repo=True): """ Create a new campaign from an ns-3 installation and a campaign directory. This method will create a DatabaseManager, which will install a database i...
python
def new(cls, ns_path, script, campaign_dir, runner_type='Auto', overwrite=False, optimized=True, check_repo=True): """ Create a new campaign from an ns-3 installation and a campaign directory. This method will create a DatabaseManager, which will install a database i...
[ "def", "new", "(", "cls", ",", "ns_path", ",", "script", ",", "campaign_dir", ",", "runner_type", "=", "'Auto'", ",", "overwrite", "=", "False", ",", "optimized", "=", "True", ",", "check_repo", "=", "True", ")", ":", "# Convert paths to be absolute", "ns_pa...
Create a new campaign from an ns-3 installation and a campaign directory. This method will create a DatabaseManager, which will install a database in the specified campaign_dir. If a database is already available at the ns_path described in the specified campaign_dir and its con...
[ "Create", "a", "new", "campaign", "from", "an", "ns", "-", "3", "installation", "and", "a", "campaign", "directory", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L57-L136
signetlabdei/sem
sem/manager.py
CampaignManager.load
def load(cls, campaign_dir, ns_path=None, runner_type='Auto', optimized=True, check_repo=True): """ Load an existing simulation campaign. Note that specifying an ns-3 installation is not compulsory when using this method: existing results will be available, but in order to ...
python
def load(cls, campaign_dir, ns_path=None, runner_type='Auto', optimized=True, check_repo=True): """ Load an existing simulation campaign. Note that specifying an ns-3 installation is not compulsory when using this method: existing results will be available, but in order to ...
[ "def", "load", "(", "cls", ",", "campaign_dir", ",", "ns_path", "=", "None", ",", "runner_type", "=", "'Auto'", ",", "optimized", "=", "True", ",", "check_repo", "=", "True", ")", ":", "# Convert paths to be absolute", "if", "ns_path", "is", "not", "None", ...
Load an existing simulation campaign. Note that specifying an ns-3 installation is not compulsory when using this method: existing results will be available, but in order to run additional simulations it will be necessary to specify a SimulationRunner object, and assign it to the Campai...
[ "Load", "an", "existing", "simulation", "campaign", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L139-L176
signetlabdei/sem
sem/manager.py
CampaignManager.create_runner
def create_runner(ns_path, script, runner_type='Auto', optimized=True): """ Create a SimulationRunner from a string containing the desired class implementation, and return it. Args: ns_path (str): path to the ns-3 installation to employ in this ...
python
def create_runner(ns_path, script, runner_type='Auto', optimized=True): """ Create a SimulationRunner from a string containing the desired class implementation, and return it. Args: ns_path (str): path to the ns-3 installation to employ in this ...
[ "def", "create_runner", "(", "ns_path", ",", "script", ",", "runner_type", "=", "'Auto'", ",", "optimized", "=", "True", ")", ":", "# locals() contains a dictionary pairing class names with class", "# objects: we can create the object using the desired class starting", "# from it...
Create a SimulationRunner from a string containing the desired class implementation, and return it. Args: ns_path (str): path to the ns-3 installation to employ in this SimulationRunner. script (str): ns-3 script that will be executed to run simulations. ...
[ "Create", "a", "SimulationRunner", "from", "a", "string", "containing", "the", "desired", "class", "implementation", "and", "return", "it", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L178-L208
signetlabdei/sem
sem/manager.py
CampaignManager.run_simulations
def run_simulations(self, param_list, show_progress=True): """ Run several simulations specified by a list of parameter combinations. Note: this function does not verify whether we already have the required simulations in the database - it just runs all the parameter combination...
python
def run_simulations(self, param_list, show_progress=True): """ Run several simulations specified by a list of parameter combinations. Note: this function does not verify whether we already have the required simulations in the database - it just runs all the parameter combination...
[ "def", "run_simulations", "(", "self", ",", "param_list", ",", "show_progress", "=", "True", ")", ":", "# Make sure we have a runner to run simulations with.", "# This can happen in case the simulation campaign is loaded and not", "# created from scratch.", "if", "self", ".", "ru...
Run several simulations specified by a list of parameter combinations. Note: this function does not verify whether we already have the required simulations in the database - it just runs all the parameter combinations that are specified in the list. Args: param_list (list):...
[ "Run", "several", "simulations", "specified", "by", "a", "list", "of", "parameter", "combinations", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L214-L288
signetlabdei/sem
sem/manager.py
CampaignManager.get_missing_simulations
def get_missing_simulations(self, param_list, runs=None): """ Return a list of the simulations among the required ones that are not available in the database. Args: param_list (list): a list of dictionaries containing all the parameters combinations. ...
python
def get_missing_simulations(self, param_list, runs=None): """ Return a list of the simulations among the required ones that are not available in the database. Args: param_list (list): a list of dictionaries containing all the parameters combinations. ...
[ "def", "get_missing_simulations", "(", "self", ",", "param_list", ",", "runs", "=", "None", ")", ":", "params_to_simulate", "=", "[", "]", "if", "runs", "is", "not", "None", ":", "# Get next available runs from the database", "next_runs", "=", "self", ".", "db",...
Return a list of the simulations among the required ones that are not available in the database. Args: param_list (list): a list of dictionaries containing all the parameters combinations. runs (int): an integer representing how many repetitions are wanted ...
[ "Return", "a", "list", "of", "the", "simulations", "among", "the", "required", "ones", "that", "are", "not", "available", "in", "the", "database", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L290-L332
signetlabdei/sem
sem/manager.py
CampaignManager.run_missing_simulations
def run_missing_simulations(self, param_list, runs=None): """ Run the simulations from the parameter list that are not yet available in the database. This function also makes sure that we have at least runs replications for each parameter combination. Additionally, para...
python
def run_missing_simulations(self, param_list, runs=None): """ Run the simulations from the parameter list that are not yet available in the database. This function also makes sure that we have at least runs replications for each parameter combination. Additionally, para...
[ "def", "run_missing_simulations", "(", "self", ",", "param_list", ",", "runs", "=", "None", ")", ":", "# If we are passed a dictionary, we need to expand this", "if", "isinstance", "(", "param_list", ",", "dict", ")", ":", "param_list", "=", "list_param_combinations", ...
Run the simulations from the parameter list that are not yet available in the database. This function also makes sure that we have at least runs replications for each parameter combination. Additionally, param_list can either be a list containing the desired parameter combinati...
[ "Run", "the", "simulations", "from", "the", "parameter", "list", "that", "are", "not", "yet", "available", "in", "the", "database", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L334-L360
signetlabdei/sem
sem/manager.py
CampaignManager.get_results_as_numpy_array
def get_results_as_numpy_array(self, parameter_space, result_parsing_function, runs): """ Return the results relative to the desired parameter space in the form of a numpy array. Args: parameter_space (dict): dictionary containing ...
python
def get_results_as_numpy_array(self, parameter_space, result_parsing_function, runs): """ Return the results relative to the desired parameter space in the form of a numpy array. Args: parameter_space (dict): dictionary containing ...
[ "def", "get_results_as_numpy_array", "(", "self", ",", "parameter_space", ",", "result_parsing_function", ",", "runs", ")", ":", "return", "np", ".", "array", "(", "self", ".", "get_space", "(", "self", ".", "db", ".", "get_complete_results", "(", ")", ",", ...
Return the results relative to the desired parameter space in the form of a numpy array. Args: parameter_space (dict): dictionary containing parameter/list-of-values pairs. result_parsing_function (function): user-defined function, taking a result...
[ "Return", "the", "results", "relative", "to", "the", "desired", "parameter", "space", "in", "the", "form", "of", "a", "numpy", "array", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L366-L383
signetlabdei/sem
sem/manager.py
CampaignManager.save_to_mat_file
def save_to_mat_file(self, parameter_space, result_parsing_function, filename, runs): """ Return the results relative to the desired parameter space in the form of a .mat file. Args: parameter_space (dict): dictionary contain...
python
def save_to_mat_file(self, parameter_space, result_parsing_function, filename, runs): """ Return the results relative to the desired parameter space in the form of a .mat file. Args: parameter_space (dict): dictionary contain...
[ "def", "save_to_mat_file", "(", "self", ",", "parameter_space", ",", "result_parsing_function", ",", "filename", ",", "runs", ")", ":", "# Make sure all values are lists", "for", "key", "in", "parameter_space", ":", "if", "not", "isinstance", "(", "parameter_space", ...
Return the results relative to the desired parameter space in the form of a .mat file. Args: parameter_space (dict): dictionary containing parameter/list-of-values pairs. result_parsing_function (function): user-defined function, taking a result d...
[ "Return", "the", "results", "relative", "to", "the", "desired", "parameter", "space", "in", "the", "form", "of", "a", ".", "mat", "file", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L385-L421
signetlabdei/sem
sem/manager.py
CampaignManager.save_to_npy_file
def save_to_npy_file(self, parameter_space, result_parsing_function, filename, runs): """ Save results to a numpy array file format. """ np.save(filename, self.get_results_as_numpy_array( parameter_space, result_parsing_functi...
python
def save_to_npy_file(self, parameter_space, result_parsing_function, filename, runs): """ Save results to a numpy array file format. """ np.save(filename, self.get_results_as_numpy_array( parameter_space, result_parsing_functi...
[ "def", "save_to_npy_file", "(", "self", ",", "parameter_space", ",", "result_parsing_function", ",", "filename", ",", "runs", ")", ":", "np", ".", "save", "(", "filename", ",", "self", ".", "get_results_as_numpy_array", "(", "parameter_space", ",", "result_parsing...
Save results to a numpy array file format.
[ "Save", "results", "to", "a", "numpy", "array", "file", "format", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L423-L430
signetlabdei/sem
sem/manager.py
CampaignManager.save_to_folders
def save_to_folders(self, parameter_space, folder_name, runs): """ Save results to a folder structure. """ self.space_to_folders(self.db.get_results(), {}, parameter_space, runs, folder_name)
python
def save_to_folders(self, parameter_space, folder_name, runs): """ Save results to a folder structure. """ self.space_to_folders(self.db.get_results(), {}, parameter_space, runs, folder_name)
[ "def", "save_to_folders", "(", "self", ",", "parameter_space", ",", "folder_name", ",", "runs", ")", ":", "self", ".", "space_to_folders", "(", "self", ".", "db", ".", "get_results", "(", ")", ",", "{", "}", ",", "parameter_space", ",", "runs", ",", "fol...
Save results to a folder structure.
[ "Save", "results", "to", "a", "folder", "structure", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L432-L437
signetlabdei/sem
sem/manager.py
CampaignManager.space_to_folders
def space_to_folders(self, current_result_list, current_query, param_space, runs, current_directory): """ Convert a parameter space specification to a directory tree with a nested structure. """ # Base case: we iterate over the runs and copy files in the ...
python
def space_to_folders(self, current_result_list, current_query, param_space, runs, current_directory): """ Convert a parameter space specification to a directory tree with a nested structure. """ # Base case: we iterate over the runs and copy files in the ...
[ "def", "space_to_folders", "(", "self", ",", "current_result_list", ",", "current_query", ",", "param_space", ",", "runs", ",", "current_directory", ")", ":", "# Base case: we iterate over the runs and copy files in the final", "# directory.", "if", "not", "param_space", ":...
Convert a parameter space specification to a directory tree with a nested structure.
[ "Convert", "a", "parameter", "space", "specification", "to", "a", "directory", "tree", "with", "a", "nested", "structure", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L439-L478
signetlabdei/sem
sem/manager.py
CampaignManager.get_results_as_xarray
def get_results_as_xarray(self, parameter_space, result_parsing_function, output_labels, runs): """ Return the results relative to the desired parameter space in the form of an xarray data structure. Args: parameter...
python
def get_results_as_xarray(self, parameter_space, result_parsing_function, output_labels, runs): """ Return the results relative to the desired parameter space in the form of an xarray data structure. Args: parameter...
[ "def", "get_results_as_xarray", "(", "self", ",", "parameter_space", ",", "result_parsing_function", ",", "output_labels", ",", "runs", ")", ":", "np_array", "=", "np", ".", "array", "(", "self", ".", "get_space", "(", "self", ".", "db", ".", "get_complete_res...
Return the results relative to the desired parameter space in the form of an xarray data structure. Args: parameter_space (dict): The space of parameters to export. result_parsing_function (function): user-defined function, taking a result dictionary as argument,...
[ "Return", "the", "results", "relative", "to", "the", "desired", "parameter", "space", "in", "the", "form", "of", "an", "xarray", "data", "structure", "." ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L480-L516
signetlabdei/sem
sem/manager.py
CampaignManager.get_space
def get_space(self, current_result_list, current_query, param_space, runs, result_parsing_function): """ Convert a parameter space specification to a nested array structure representing the space. In other words, if the parameter space is:: param_space = { ...
python
def get_space(self, current_result_list, current_query, param_space, runs, result_parsing_function): """ Convert a parameter space specification to a nested array structure representing the space. In other words, if the parameter space is:: param_space = { ...
[ "def", "get_space", "(", "self", ",", "current_result_list", ",", "current_query", ",", "param_space", ",", "runs", ",", "result_parsing_function", ")", ":", "if", "result_parsing_function", "is", "None", ":", "result_parsing_function", "=", "CampaignManager", ".", ...
Convert a parameter space specification to a nested array structure representing the space. In other words, if the parameter space is:: param_space = { 'a': [1, 2], 'b': [3, 4] } the function will return a structure like the following:: ...
[ "Convert", "a", "parameter", "space", "specification", "to", "a", "nested", "array", "structure", "representing", "the", "space", ".", "In", "other", "words", "if", "the", "parameter", "space", "is", "::" ]
train
https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L525-L592