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 |
|---|---|---|---|---|---|---|---|---|---|---|
cuihantao/andes | andes/utils/misc.py | get_log_dir | def get_log_dir():
"""
Get a directory for logging
On Linux or macOS, '/tmp/andes' is the default. On Windows,
'%APPDATA%/andes' is the default.
Returns
-------
str
Path to the logging directory
"""
PATH = ''
if platform.system() in ('Linux', 'Darwin'):
PATH = t... | python | def get_log_dir():
"""
Get a directory for logging
On Linux or macOS, '/tmp/andes' is the default. On Windows,
'%APPDATA%/andes' is the default.
Returns
-------
str
Path to the logging directory
"""
PATH = ''
if platform.system() in ('Linux', 'Darwin'):
PATH = t... | [
"def",
"get_log_dir",
"(",
")",
":",
"PATH",
"=",
"''",
"if",
"platform",
".",
"system",
"(",
")",
"in",
"(",
"'Linux'",
",",
"'Darwin'",
")",
":",
"PATH",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"'andes-'",
")",
"elif",
"platform",
".",... | Get a directory for logging
On Linux or macOS, '/tmp/andes' is the default. On Windows,
'%APPDATA%/andes' is the default.
Returns
-------
str
Path to the logging directory | [
"Get",
"a",
"directory",
"for",
"logging"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/misc.py#L42-L64 |
cuihantao/andes | andes/variables/varout.py | VarOut.store | def store(self, t, step):
"""
Record the state/algeb values at time t to self.vars
"""
max_cache = int(self.system.tds.config.max_cache)
if len(self.vars) >= max_cache > 0:
self.dump()
self.vars = list()
self.t = list()
self.k = lis... | python | def store(self, t, step):
"""
Record the state/algeb values at time t to self.vars
"""
max_cache = int(self.system.tds.config.max_cache)
if len(self.vars) >= max_cache > 0:
self.dump()
self.vars = list()
self.t = list()
self.k = lis... | [
"def",
"store",
"(",
"self",
",",
"t",
",",
"step",
")",
":",
"max_cache",
"=",
"int",
"(",
"self",
".",
"system",
".",
"tds",
".",
"config",
".",
"max_cache",
")",
"if",
"len",
"(",
"self",
".",
"vars",
")",
">=",
"max_cache",
">",
"0",
":",
"... | Record the state/algeb values at time t to self.vars | [
"Record",
"the",
"state",
"/",
"algeb",
"values",
"at",
"time",
"t",
"to",
"self",
".",
"vars"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L37-L95 |
cuihantao/andes | andes/variables/varout.py | VarOut.show | def show(self):
"""
The representation of an Varout object
:return: the full result matrix (for use with PyCharm viewer)
:rtype: np.array
"""
out = []
for item in self.vars:
out.append(list(item))
return np.array(out) | python | def show(self):
"""
The representation of an Varout object
:return: the full result matrix (for use with PyCharm viewer)
:rtype: np.array
"""
out = []
for item in self.vars:
out.append(list(item))
return np.array(out) | [
"def",
"show",
"(",
"self",
")",
":",
"out",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"vars",
":",
"out",
".",
"append",
"(",
"list",
"(",
"item",
")",
")",
"return",
"np",
".",
"array",
"(",
"out",
")"
] | The representation of an Varout object
:return: the full result matrix (for use with PyCharm viewer)
:rtype: np.array | [
"The",
"representation",
"of",
"an",
"Varout",
"object"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L97-L109 |
cuihantao/andes | andes/variables/varout.py | VarOut.concat_t_vars | def concat_t_vars(self):
"""
Concatenate ``self.t`` with ``self.vars`` and output a single matrix
for data dump
:return matrix: concatenated matrix with ``self.t`` as the 0-th column
"""
logger.warning('This function is deprecated and replaced by `concat_t_vars_np`.')
... | python | def concat_t_vars(self):
"""
Concatenate ``self.t`` with ``self.vars`` and output a single matrix
for data dump
:return matrix: concatenated matrix with ``self.t`` as the 0-th column
"""
logger.warning('This function is deprecated and replaced by `concat_t_vars_np`.')
... | [
"def",
"concat_t_vars",
"(",
"self",
")",
":",
"logger",
".",
"warning",
"(",
"'This function is deprecated and replaced by `concat_t_vars_np`.'",
")",
"out",
"=",
"np",
".",
"array",
"(",
"[",
"]",
")",
"if",
"len",
"(",
"self",
".",
"t",
")",
"==",
"0",
... | Concatenate ``self.t`` with ``self.vars`` and output a single matrix
for data dump
:return matrix: concatenated matrix with ``self.t`` as the 0-th column | [
"Concatenate",
"self",
".",
"t",
"with",
"self",
".",
"vars",
"and",
"output",
"a",
"single",
"matrix",
"for",
"data",
"dump"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L111-L131 |
cuihantao/andes | andes/variables/varout.py | VarOut.concat_t_vars_np | def concat_t_vars_np(self, vars_idx=None):
"""
Concatenate `self.np_t` with `self.np_vars` and return a single matrix.
The first column corresponds to time, and the rest of the matrix is the variables.
Returns
-------
np.array : concatenated matrix
"""
s... | python | def concat_t_vars_np(self, vars_idx=None):
"""
Concatenate `self.np_t` with `self.np_vars` and return a single matrix.
The first column corresponds to time, and the rest of the matrix is the variables.
Returns
-------
np.array : concatenated matrix
"""
s... | [
"def",
"concat_t_vars_np",
"(",
"self",
",",
"vars_idx",
"=",
"None",
")",
":",
"selected_np_vars",
"=",
"self",
".",
"np_vars",
"if",
"vars_idx",
"is",
"not",
"None",
":",
"selected_np_vars",
"=",
"self",
".",
"np_vars",
"[",
":",
",",
"vars_idx",
"]",
... | Concatenate `self.np_t` with `self.np_vars` and return a single matrix.
The first column corresponds to time, and the rest of the matrix is the variables.
Returns
-------
np.array : concatenated matrix | [
"Concatenate",
"self",
".",
"np_t",
"with",
"self",
".",
"np_vars",
"and",
"return",
"a",
"single",
"matrix",
".",
"The",
"first",
"column",
"corresponds",
"to",
"time",
"and",
"the",
"rest",
"of",
"the",
"matrix",
"is",
"the",
"variables",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L133-L148 |
cuihantao/andes | andes/variables/varout.py | VarOut.get_xy | def get_xy(self, yidx, xidx=0):
"""
Return stored data for the given indices for plot
:param yidx: the indices of the y-axis variables(1-indexing)
:param xidx: the index of the x-axis variables
:return: None
"""
assert isinstance(xidx, int)
if isinstance(... | python | def get_xy(self, yidx, xidx=0):
"""
Return stored data for the given indices for plot
:param yidx: the indices of the y-axis variables(1-indexing)
:param xidx: the index of the x-axis variables
:return: None
"""
assert isinstance(xidx, int)
if isinstance(... | [
"def",
"get_xy",
"(",
"self",
",",
"yidx",
",",
"xidx",
"=",
"0",
")",
":",
"assert",
"isinstance",
"(",
"xidx",
",",
"int",
")",
"if",
"isinstance",
"(",
"yidx",
",",
"int",
")",
":",
"yidx",
"=",
"[",
"yidx",
"]",
"t_vars",
"=",
"self",
".",
... | Return stored data for the given indices for plot
:param yidx: the indices of the y-axis variables(1-indexing)
:param xidx: the index of the x-axis variables
:return: None | [
"Return",
"stored",
"data",
"for",
"the",
"given",
"indices",
"for",
"plot"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L150-L167 |
cuihantao/andes | andes/variables/varout.py | VarOut.dump_np_vars | def dump_np_vars(self, store_format='csv', delimiter=','):
"""
Dump the TDS simulation data to files by calling subroutines `write_lst` and
`write_np_dat`.
Parameters
-----------
store_format : str
dump format in `('csv', 'txt', 'hdf5')`
delimiter :... | python | def dump_np_vars(self, store_format='csv', delimiter=','):
"""
Dump the TDS simulation data to files by calling subroutines `write_lst` and
`write_np_dat`.
Parameters
-----------
store_format : str
dump format in `('csv', 'txt', 'hdf5')`
delimiter :... | [
"def",
"dump_np_vars",
"(",
"self",
",",
"store_format",
"=",
"'csv'",
",",
"delimiter",
"=",
"','",
")",
":",
"ret",
"=",
"False",
"if",
"self",
".",
"system",
".",
"files",
".",
"no_output",
"is",
"True",
":",
"logger",
".",
"debug",
"(",
"'no_output... | Dump the TDS simulation data to files by calling subroutines `write_lst` and
`write_np_dat`.
Parameters
-----------
store_format : str
dump format in `('csv', 'txt', 'hdf5')`
delimiter : str
delimiter for the `csv` and `txt` format
Returns
... | [
"Dump",
"the",
"TDS",
"simulation",
"data",
"to",
"files",
"by",
"calling",
"subroutines",
"write_lst",
"and",
"write_np_dat",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L169-L197 |
cuihantao/andes | andes/variables/varout.py | VarOut.dump | def dump(self):
"""
Dump the TDS results to the output `dat` file
:return: succeed flag
"""
logger.warn('This function is deprecated and replaced by `dump_np_vars`.')
ret = False
if self.system.files.no_output:
# return ``True`` because it did not f... | python | def dump(self):
"""
Dump the TDS results to the output `dat` file
:return: succeed flag
"""
logger.warn('This function is deprecated and replaced by `dump_np_vars`.')
ret = False
if self.system.files.no_output:
# return ``True`` because it did not f... | [
"def",
"dump",
"(",
"self",
")",
":",
"logger",
".",
"warn",
"(",
"'This function is deprecated and replaced by `dump_np_vars`.'",
")",
"ret",
"=",
"False",
"if",
"self",
".",
"system",
".",
"files",
".",
"no_output",
":",
"# return ``True`` because it did not fail",
... | Dump the TDS results to the output `dat` file
:return: succeed flag | [
"Dump",
"the",
"TDS",
"results",
"to",
"the",
"output",
"dat",
"file"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L199-L216 |
cuihantao/andes | andes/variables/varout.py | VarOut.write_np_dat | def write_np_dat(self, store_format='csv', delimiter=',', fmt='%.12g'):
"""
Write TDS data stored in `self.np_vars` to the output file
Parameters
----------
store_format : str
dump format in ('csv', 'txt', 'hdf5')
delimiter : str
delimiter for th... | python | def write_np_dat(self, store_format='csv', delimiter=',', fmt='%.12g'):
"""
Write TDS data stored in `self.np_vars` to the output file
Parameters
----------
store_format : str
dump format in ('csv', 'txt', 'hdf5')
delimiter : str
delimiter for th... | [
"def",
"write_np_dat",
"(",
"self",
",",
"store_format",
"=",
"'csv'",
",",
"delimiter",
"=",
"','",
",",
"fmt",
"=",
"'%.12g'",
")",
":",
"ret",
"=",
"False",
"system",
"=",
"self",
".",
"system",
"# compute the total number of columns, excluding time",
"if",
... | Write TDS data stored in `self.np_vars` to the output file
Parameters
----------
store_format : str
dump format in ('csv', 'txt', 'hdf5')
delimiter : str
delimiter for the `csv` and `txt` format
fmt : str
output formatting template
... | [
"Write",
"TDS",
"data",
"stored",
"in",
"self",
".",
"np_vars",
"to",
"the",
"output",
"file"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L218-L271 |
cuihantao/andes | andes/variables/varout.py | VarOut.write_dat | def write_dat(self):
"""
Write ``system.Varout.vars`` to a ``.dat`` file
:return:
"""
logger.warn('This function is deprecated and replaced by `write_np_dat`.')
ret = False
system = self.system
# compute the total number of columns, excluding time
... | python | def write_dat(self):
"""
Write ``system.Varout.vars`` to a ``.dat`` file
:return:
"""
logger.warn('This function is deprecated and replaced by `write_np_dat`.')
ret = False
system = self.system
# compute the total number of columns, excluding time
... | [
"def",
"write_dat",
"(",
"self",
")",
":",
"logger",
".",
"warn",
"(",
"'This function is deprecated and replaced by `write_np_dat`.'",
")",
"ret",
"=",
"False",
"system",
"=",
"self",
".",
"system",
"# compute the total number of columns, excluding time",
"if",
"not",
... | Write ``system.Varout.vars`` to a ``.dat`` file
:return: | [
"Write",
"system",
".",
"Varout",
".",
"vars",
"to",
"a",
".",
"dat",
"file",
":",
"return",
":"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L273-L315 |
cuihantao/andes | andes/variables/varout.py | VarOut.write_lst | def write_lst(self):
"""
Dump the variable name lst file
:return: succeed flag
"""
ret = False
out = ''
system = self.system
dae = self.system.dae
varname = self.system.varname
template = '{:>6g}, {:>25s}, {:>35s}\n'
# header lin... | python | def write_lst(self):
"""
Dump the variable name lst file
:return: succeed flag
"""
ret = False
out = ''
system = self.system
dae = self.system.dae
varname = self.system.varname
template = '{:>6g}, {:>25s}, {:>35s}\n'
# header lin... | [
"def",
"write_lst",
"(",
"self",
")",
":",
"ret",
"=",
"False",
"out",
"=",
"''",
"system",
"=",
"self",
".",
"system",
"dae",
"=",
"self",
".",
"system",
".",
"dae",
"varname",
"=",
"self",
".",
"system",
".",
"varname",
"template",
"=",
"'{:>6g}, {... | Dump the variable name lst file
:return: succeed flag | [
"Dump",
"the",
"variable",
"name",
"lst",
"file"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L317-L363 |
cuihantao/andes | andes/variables/varout.py | VarOut.vars_to_array | def vars_to_array(self):
"""
Convert `self.vars` to a numpy array
Returns
-------
numpy.array
"""
logger.warn('This function is deprecated. You can inspect `self.np_vars` directly as NumPy arrays '
'without conversion.')
if not self.v... | python | def vars_to_array(self):
"""
Convert `self.vars` to a numpy array
Returns
-------
numpy.array
"""
logger.warn('This function is deprecated. You can inspect `self.np_vars` directly as NumPy arrays '
'without conversion.')
if not self.v... | [
"def",
"vars_to_array",
"(",
"self",
")",
":",
"logger",
".",
"warn",
"(",
"'This function is deprecated. You can inspect `self.np_vars` directly as NumPy arrays '",
"'without conversion.'",
")",
"if",
"not",
"self",
".",
"vars",
":",
"return",
"None",
"vars_matrix",
"=",... | Convert `self.vars` to a numpy array
Returns
-------
numpy.array | [
"Convert",
"self",
".",
"vars",
"to",
"a",
"numpy",
"array"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/varout.py#L365-L384 |
cuihantao/andes | andes/main.py | config_logger | def config_logger(name='andes',
log_file='andes.log',
log_path='',
stream=True,
stream_level=logging.INFO
):
"""
Configure a logger for the andes package with options for a `FileHandler`
and a `StreamHandler`. This fun... | python | def config_logger(name='andes',
log_file='andes.log',
log_path='',
stream=True,
stream_level=logging.INFO
):
"""
Configure a logger for the andes package with options for a `FileHandler`
and a `StreamHandler`. This fun... | [
"def",
"config_logger",
"(",
"name",
"=",
"'andes'",
",",
"log_file",
"=",
"'andes.log'",
",",
"log_path",
"=",
"''",
",",
"stream",
"=",
"True",
",",
"stream_level",
"=",
"logging",
".",
"INFO",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",... | Configure a logger for the andes package with options for a `FileHandler`
and a `StreamHandler`. This function is called at the beginning of
``andes.main.main()``.
Parameters
----------
name : str, optional
Base logger name, ``'andes'`` by default. Changing this
parameter will affec... | [
"Configure",
"a",
"logger",
"for",
"the",
"andes",
"package",
"with",
"options",
"for",
"a",
"FileHandler",
"and",
"a",
"StreamHandler",
".",
"This",
"function",
"is",
"called",
"at",
"the",
"beginning",
"of",
"andes",
".",
"main",
".",
"main",
"()",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L47-L103 |
cuihantao/andes | andes/main.py | preamble | def preamble():
"""
Log the Andes command-line preamble at the `logging.INFO` level
Returns
-------
None
"""
from . import __version__ as version
logger.info('ANDES {ver} (Build {b}, Python {p} on {os})'
.format(ver=version[:5], b=version[-8:],
p=... | python | def preamble():
"""
Log the Andes command-line preamble at the `logging.INFO` level
Returns
-------
None
"""
from . import __version__ as version
logger.info('ANDES {ver} (Build {b}, Python {p} on {os})'
.format(ver=version[:5], b=version[-8:],
p=... | [
"def",
"preamble",
"(",
")",
":",
"from",
".",
"import",
"__version__",
"as",
"version",
"logger",
".",
"info",
"(",
"'ANDES {ver} (Build {b}, Python {p} on {os})'",
".",
"format",
"(",
"ver",
"=",
"version",
"[",
":",
"5",
"]",
",",
"b",
"=",
"version",
"... | Log the Andes command-line preamble at the `logging.INFO` level
Returns
-------
None | [
"Log",
"the",
"Andes",
"command",
"-",
"line",
"preamble",
"at",
"the",
"logging",
".",
"INFO",
"level"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L106-L126 |
cuihantao/andes | andes/main.py | cli_new | def cli_new():
"""
Construct a CLI argument parser and return the parsed arguments.
Returns
-------
Namespace
A namespace object containing the parsed command-line arguments
"""
parser = ArgumentParser()
parser.add_argument('filename', help='Case file name', nargs='*')
# ge... | python | def cli_new():
"""
Construct a CLI argument parser and return the parsed arguments.
Returns
-------
Namespace
A namespace object containing the parsed command-line arguments
"""
parser = ArgumentParser()
parser.add_argument('filename', help='Case file name', nargs='*')
# ge... | [
"def",
"cli_new",
"(",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'filename'",
",",
"help",
"=",
"'Case file name'",
",",
"nargs",
"=",
"'*'",
")",
"# general options",
"general_group",
"=",
"parser",
".",
"add_... | Construct a CLI argument parser and return the parsed arguments.
Returns
-------
Namespace
A namespace object containing the parsed command-line arguments | [
"Construct",
"a",
"CLI",
"argument",
"parser",
"and",
"return",
"the",
"parsed",
"arguments",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L129-L233 |
cuihantao/andes | andes/main.py | andeshelp | def andeshelp(group=None,
category=None,
model_list=None,
model_format=None,
model_var=None,
quick_help=None,
help_option=None,
help_config=None,
export='plain',
**kwargs):
"""
Print the... | python | def andeshelp(group=None,
category=None,
model_list=None,
model_format=None,
model_var=None,
quick_help=None,
help_option=None,
help_config=None,
export='plain',
**kwargs):
"""
Print the... | [
"def",
"andeshelp",
"(",
"group",
"=",
"None",
",",
"category",
"=",
"None",
",",
"model_list",
"=",
"None",
",",
"model_format",
"=",
"None",
",",
"model_var",
"=",
"None",
",",
"quick_help",
"=",
"None",
",",
"help_option",
"=",
"None",
",",
"help_conf... | Print the requested help and documentation to stdout.
Parameters
----------
group : None or str
Name of a group whose model names will be printed
category : None or str
Name of a category whose models will be printed
model_list : bool
If ``True``, print the full model list... | [
"Print",
"the",
"requested",
"help",
"and",
"documentation",
"to",
"stdout",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L236-L422 |
cuihantao/andes | andes/main.py | edit_conf | def edit_conf(edit_config=False, load_config=None, **kwargs):
"""
Edit the Andes config file which occurs first in the search path.
Parameters
----------
edit_config : bool
If ``True``, try to open up an editor and edit the config file.
Otherwise returns.
load_config : None or ... | python | def edit_conf(edit_config=False, load_config=None, **kwargs):
"""
Edit the Andes config file which occurs first in the search path.
Parameters
----------
edit_config : bool
If ``True``, try to open up an editor and edit the config file.
Otherwise returns.
load_config : None or ... | [
"def",
"edit_conf",
"(",
"edit_config",
"=",
"False",
",",
"load_config",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"False",
"# no `edit-config` supplied",
"if",
"edit_config",
"==",
"''",
":",
"return",
"ret",
"conf_path",
"=",
"misc",
"... | Edit the Andes config file which occurs first in the search path.
Parameters
----------
edit_config : bool
If ``True``, try to open up an editor and edit the config file.
Otherwise returns.
load_config : None or str, optional
Path to the config file, which will be placed to the... | [
"Edit",
"the",
"Andes",
"config",
"file",
"which",
"occurs",
"first",
"in",
"the",
"search",
"path",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L425-L480 |
cuihantao/andes | andes/main.py | remove_output | def remove_output(clean=False, **kwargs):
"""
Remove the outputs generated by Andes, including power flow reports
``_out.txt``, time-domain list ``_out.lst`` and data ``_out.dat``,
eigenvalue analysis report ``_eig.txt``.
Parameters
----------
clean : bool
If ``True``, execute the f... | python | def remove_output(clean=False, **kwargs):
"""
Remove the outputs generated by Andes, including power flow reports
``_out.txt``, time-domain list ``_out.lst`` and data ``_out.dat``,
eigenvalue analysis report ``_eig.txt``.
Parameters
----------
clean : bool
If ``True``, execute the f... | [
"def",
"remove_output",
"(",
"clean",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"clean",
":",
"return",
"False",
"found",
"=",
"False",
"cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
... | Remove the outputs generated by Andes, including power flow reports
``_out.txt``, time-domain list ``_out.lst`` and data ``_out.dat``,
eigenvalue analysis report ``_eig.txt``.
Parameters
----------
clean : bool
If ``True``, execute the function body. Returns otherwise.
kwargs : dict
... | [
"Remove",
"the",
"outputs",
"generated",
"by",
"Andes",
"including",
"power",
"flow",
"reports",
"_out",
".",
"txt",
"time",
"-",
"domain",
"list",
"_out",
".",
"lst",
"and",
"data",
"_out",
".",
"dat",
"eigenvalue",
"analysis",
"report",
"_eig",
".",
"txt... | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L483-L524 |
cuihantao/andes | andes/main.py | search | def search(search, **kwargs):
"""
Search for models whose names matches the given pattern. Print the
results to stdout.
.. deprecated :: 1.0.0
`search` will be moved to ``andeshelp`` in future versions.
Parameters
----------
search : str
Partial or full name of the model to... | python | def search(search, **kwargs):
"""
Search for models whose names matches the given pattern. Print the
results to stdout.
.. deprecated :: 1.0.0
`search` will be moved to ``andeshelp`` in future versions.
Parameters
----------
search : str
Partial or full name of the model to... | [
"def",
"search",
"(",
"search",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"models",
"import",
"all_models",
"out",
"=",
"[",
"]",
"if",
"not",
"search",
":",
"return",
"out",
"keys",
"=",
"sorted",
"(",
"list",
"(",
"all_models",
".",
"keys",
... | Search for models whose names matches the given pattern. Print the
results to stdout.
.. deprecated :: 1.0.0
`search` will be moved to ``andeshelp`` in future versions.
Parameters
----------
search : str
Partial or full name of the model to search for
kwargs : dict
Oth... | [
"Search",
"for",
"models",
"whose",
"names",
"matches",
"the",
"given",
"pattern",
".",
"Print",
"the",
"results",
"to",
"stdout",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L527-L573 |
cuihantao/andes | andes/main.py | save_config | def save_config(save_config='', **kwargs):
"""
Save the Andes config to a file at the path specified by ``save_config``.
The save action will not run if `save_config = ''`.
Parameters
----------
save_config : None or str, optional, ('' by default)
Path to the file to save the config fil... | python | def save_config(save_config='', **kwargs):
"""
Save the Andes config to a file at the path specified by ``save_config``.
The save action will not run if `save_config = ''`.
Parameters
----------
save_config : None or str, optional, ('' by default)
Path to the file to save the config fil... | [
"def",
"save_config",
"(",
"save_config",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"False",
"cf_path",
"=",
"save_config",
"# no ``--save-config ``",
"if",
"cf_path",
"==",
"''",
":",
"return",
"ret",
"if",
"cf_path",
"is",
"None",
":",
... | Save the Andes config to a file at the path specified by ``save_config``.
The save action will not run if `save_config = ''`.
Parameters
----------
save_config : None or str, optional, ('' by default)
Path to the file to save the config file. If the path is an emtpy
string, the save act... | [
"Save",
"the",
"Andes",
"config",
"to",
"a",
"file",
"at",
"the",
"path",
"specified",
"by",
"save_config",
".",
"The",
"save",
"action",
"will",
"not",
"run",
"if",
"save_config",
"=",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L576-L617 |
cuihantao/andes | andes/main.py | main | def main():
"""
The main function of the Andes command-line tool.
This function executes the following workflow:
* Parse the command line inputs
* Show the tool preamble
* Output the requested helps, edit/save configs or remove outputs. Exit
the main program if any of the above is ex... | python | def main():
"""
The main function of the Andes command-line tool.
This function executes the following workflow:
* Parse the command line inputs
* Show the tool preamble
* Output the requested helps, edit/save configs or remove outputs. Exit
the main program if any of the above is ex... | [
"def",
"main",
"(",
")",
":",
"t0",
",",
"s",
"=",
"elapsed",
"(",
")",
"# parser command line arguments",
"args",
"=",
"vars",
"(",
"cli_new",
"(",
")",
")",
"# configure stream handler verbose level",
"config_logger",
"(",
"log_path",
"=",
"misc",
".",
"get_... | The main function of the Andes command-line tool.
This function executes the following workflow:
* Parse the command line inputs
* Show the tool preamble
* Output the requested helps, edit/save configs or remove outputs. Exit
the main program if any of the above is executed
* Process th... | [
"The",
"main",
"function",
"of",
"the",
"Andes",
"command",
"-",
"line",
"tool",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L620-L727 |
cuihantao/andes | andes/main.py | run | def run(case, routine=None, profile=False, dump_raw=False, pid=-1, show_data=None, exit=False,
**kwargs):
"""
Entry function to run a single case study. This function executes the
following workflow:
* Turn on cProfile if requested
* Populate a ``PowerSystem`` object
* Parse the inpu... | python | def run(case, routine=None, profile=False, dump_raw=False, pid=-1, show_data=None, exit=False,
**kwargs):
"""
Entry function to run a single case study. This function executes the
following workflow:
* Turn on cProfile if requested
* Populate a ``PowerSystem`` object
* Parse the inpu... | [
"def",
"run",
"(",
"case",
",",
"routine",
"=",
"None",
",",
"profile",
"=",
"False",
",",
"dump_raw",
"=",
"False",
",",
"pid",
"=",
"-",
"1",
",",
"show_data",
"=",
"None",
",",
"exit",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"t0",
"... | Entry function to run a single case study. This function executes the
following workflow:
* Turn on cProfile if requested
* Populate a ``PowerSystem`` object
* Parse the input files using filters
* Dump the case file is requested
* Set up the system
* Run the specified routine(s)
... | [
"Entry",
"function",
"to",
"run",
"a",
"single",
"case",
"study",
".",
"This",
"function",
"executes",
"the",
"following",
"workflow",
":"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/main.py#L730-L841 |
cuihantao/andes | andes/variables/call.py | Call.setup | def setup(self):
"""
setup the call list after case file is parsed and jit models are loaded
"""
self.devices = self.system.devman.devices
self.ndevice = len(self.devices)
self.gcalls = [''] * self.ndevice
self.fcalls = [''] * self.ndevice
self.gycalls = ... | python | def setup(self):
"""
setup the call list after case file is parsed and jit models are loaded
"""
self.devices = self.system.devman.devices
self.ndevice = len(self.devices)
self.gcalls = [''] * self.ndevice
self.fcalls = [''] * self.ndevice
self.gycalls = ... | [
"def",
"setup",
"(",
"self",
")",
":",
"self",
".",
"devices",
"=",
"self",
".",
"system",
".",
"devman",
".",
"devices",
"self",
".",
"ndevice",
"=",
"len",
"(",
"self",
".",
"devices",
")",
"self",
".",
"gcalls",
"=",
"[",
"''",
"]",
"*",
"self... | setup the call list after case file is parsed and jit models are loaded | [
"setup",
"the",
"call",
"list",
"after",
"case",
"file",
"is",
"parsed",
"and",
"jit",
"models",
"are",
"loaded"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L36-L59 |
cuihantao/andes | andes/variables/call.py | Call.build_vec | def build_vec(self):
"""build call validity vector for each device"""
for item in all_calls:
self.__dict__[item] = []
for dev in self.devices:
for item in all_calls:
if self.system.__dict__[dev].n == 0:
val = False
else... | python | def build_vec(self):
"""build call validity vector for each device"""
for item in all_calls:
self.__dict__[item] = []
for dev in self.devices:
for item in all_calls:
if self.system.__dict__[dev].n == 0:
val = False
else... | [
"def",
"build_vec",
"(",
"self",
")",
":",
"for",
"item",
"in",
"all_calls",
":",
"self",
".",
"__dict__",
"[",
"item",
"]",
"=",
"[",
"]",
"for",
"dev",
"in",
"self",
".",
"devices",
":",
"for",
"item",
"in",
"all_calls",
":",
"if",
"self",
".",
... | build call validity vector for each device | [
"build",
"call",
"validity",
"vector",
"for",
"each",
"device"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L61-L72 |
cuihantao/andes | andes/variables/call.py | Call.build_strings | def build_strings(self):
"""build call string for each device"""
for idx, dev in enumerate(self.devices):
header = 'system.' + dev
self.gcalls[idx] = header + '.gcall(system.dae)\n'
self.fcalls[idx] = header + '.fcall(system.dae)\n'
self.gycalls[idx] = hea... | python | def build_strings(self):
"""build call string for each device"""
for idx, dev in enumerate(self.devices):
header = 'system.' + dev
self.gcalls[idx] = header + '.gcall(system.dae)\n'
self.fcalls[idx] = header + '.fcall(system.dae)\n'
self.gycalls[idx] = hea... | [
"def",
"build_strings",
"(",
"self",
")",
":",
"for",
"idx",
",",
"dev",
"in",
"enumerate",
"(",
"self",
".",
"devices",
")",
":",
"header",
"=",
"'system.'",
"+",
"dev",
"self",
".",
"gcalls",
"[",
"idx",
"]",
"=",
"header",
"+",
"'.gcall(system.dae)\... | build call string for each device | [
"build",
"call",
"string",
"for",
"each",
"device"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L74-L82 |
cuihantao/andes | andes/variables/call.py | Call._compile_newton | def _compile_newton(self):
"""Newton power flow execution
1. evaluate g and f;
1.1. handle islanded buses by Bus.gisland()
2. factorize when needed;
3. evaluate Gy and Fx.
3.1. take care of islanded buses by Bus.gyisland()
"... | python | def _compile_newton(self):
"""Newton power flow execution
1. evaluate g and f;
1.1. handle islanded buses by Bus.gisland()
2. factorize when needed;
3. evaluate Gy and Fx.
3.1. take care of islanded buses by Bus.gyisland()
"... | [
"def",
"_compile_newton",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"# evaluate algebraic equations g and differential equations f",
"string",
"+=",
"'system.dae.init_fg()\\n'",
"for",
"pflow",
",",
"gcall",
",",
"call",
"in",
"zip",
"(",
"self",
".",
"pflo... | Newton power flow execution
1. evaluate g and f;
1.1. handle islanded buses by Bus.gisland()
2. factorize when needed;
3. evaluate Gy and Fx.
3.1. take care of islanded buses by Bus.gyisland() | [
"Newton",
"power",
"flow",
"execution",
"1",
".",
"evaluate",
"g",
"and",
"f",
";",
"1",
".",
"1",
".",
"handle",
"islanded",
"buses",
"by",
"Bus",
".",
"gisland",
"()",
"2",
".",
"factorize",
"when",
"needed",
";",
"3",
".",
"evaluate",
"Gy",
"and",... | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L84-L134 |
cuihantao/andes | andes/variables/call.py | Call._compile_fdpf | def _compile_fdpf(self):
"""Fast Decoupled Power Flow execution: Implement g(y)
"""
string = '"""\n'
string += 'system.dae.init_g()\n'
for pflow, gcall, call in zip(self.pflow, self.gcall, self.gcalls):
if pflow and gcall:
string += call
string... | python | def _compile_fdpf(self):
"""Fast Decoupled Power Flow execution: Implement g(y)
"""
string = '"""\n'
string += 'system.dae.init_g()\n'
for pflow, gcall, call in zip(self.pflow, self.gcall, self.gcalls):
if pflow and gcall:
string += call
string... | [
"def",
"_compile_fdpf",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"string",
"+=",
"'system.dae.init_g()\\n'",
"for",
"pflow",
",",
"gcall",
",",
"call",
"in",
"zip",
"(",
"self",
".",
"pflow",
",",
"self",
".",
"gcall",
",",
"self",
".",
"gcal... | Fast Decoupled Power Flow execution: Implement g(y) | [
"Fast",
"Decoupled",
"Power",
"Flow",
"execution",
":",
"Implement",
"g",
"(",
"y",
")"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L136-L147 |
cuihantao/andes | andes/variables/call.py | Call._compile_pfload | def _compile_pfload(self):
"""Post power flow computation for load
S_gen + S_line + [S_shunt - S_load] = 0
"""
string = '"""\n'
string += 'system.dae.init_g()\n'
for gcall, pflow, shunt, stagen, call in zip(
self.gcall, self.pflow, self.shunt, ... | python | def _compile_pfload(self):
"""Post power flow computation for load
S_gen + S_line + [S_shunt - S_load] = 0
"""
string = '"""\n'
string += 'system.dae.init_g()\n'
for gcall, pflow, shunt, stagen, call in zip(
self.gcall, self.pflow, self.shunt, ... | [
"def",
"_compile_pfload",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"string",
"+=",
"'system.dae.init_g()\\n'",
"for",
"gcall",
",",
"pflow",
",",
"shunt",
",",
"stagen",
",",
"call",
"in",
"zip",
"(",
"self",
".",
"gcall",
",",
"self",
".",
"... | Post power flow computation for load
S_gen + S_line + [S_shunt - S_load] = 0 | [
"Post",
"power",
"flow",
"computation",
"for",
"load",
"S_gen",
"+",
"S_line",
"+",
"[",
"S_shunt",
"-",
"S_load",
"]",
"=",
"0"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L149-L162 |
cuihantao/andes | andes/variables/call.py | Call._compile_pfgen | def _compile_pfgen(self):
"""Post power flow computation for PV and SW"""
string = '"""\n'
string += 'system.dae.init_g()\n'
for gcall, pflow, shunt, series, stagen, call in zip(
self.gcall, self.pflow, self.shunt, self.series, self.stagen,
self.gcalls):
... | python | def _compile_pfgen(self):
"""Post power flow computation for PV and SW"""
string = '"""\n'
string += 'system.dae.init_g()\n'
for gcall, pflow, shunt, series, stagen, call in zip(
self.gcall, self.pflow, self.shunt, self.series, self.stagen,
self.gcalls):
... | [
"def",
"_compile_pfgen",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"string",
"+=",
"'system.dae.init_g()\\n'",
"for",
"gcall",
",",
"pflow",
",",
"shunt",
",",
"series",
",",
"stagen",
",",
"call",
"in",
"zip",
"(",
"self",
".",
"gcall",
",",
... | Post power flow computation for PV and SW | [
"Post",
"power",
"flow",
"computation",
"for",
"PV",
"and",
"SW"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L164-L176 |
cuihantao/andes | andes/variables/call.py | Call._compile_bus_injection | def _compile_bus_injection(self):
"""Impose injections on buses"""
string = '"""\n'
for device, series in zip(self.devices, self.series):
if series:
string += 'system.' + device + '.gcall(system.dae)\n'
string += '\n'
string += 'system.dae.reset_small_... | python | def _compile_bus_injection(self):
"""Impose injections on buses"""
string = '"""\n'
for device, series in zip(self.devices, self.series):
if series:
string += 'system.' + device + '.gcall(system.dae)\n'
string += '\n'
string += 'system.dae.reset_small_... | [
"def",
"_compile_bus_injection",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"for",
"device",
",",
"series",
"in",
"zip",
"(",
"self",
".",
"devices",
",",
"self",
".",
"series",
")",
":",
"if",
"series",
":",
"string",
"+=",
"'system.'",
"+",
... | Impose injections on buses | [
"Impose",
"injections",
"on",
"buses"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L178-L188 |
cuihantao/andes | andes/variables/call.py | Call._compile_seriesflow | def _compile_seriesflow(self):
"""Post power flow computation of series device flow"""
string = '"""\n'
for device, pflow, series in zip(self.devices, self.pflow,
self.series):
if pflow and series:
string += 'system.' + device ... | python | def _compile_seriesflow(self):
"""Post power flow computation of series device flow"""
string = '"""\n'
for device, pflow, series in zip(self.devices, self.pflow,
self.series):
if pflow and series:
string += 'system.' + device ... | [
"def",
"_compile_seriesflow",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"for",
"device",
",",
"pflow",
",",
"series",
"in",
"zip",
"(",
"self",
".",
"devices",
",",
"self",
".",
"pflow",
",",
"self",
".",
"series",
")",
":",
"if",
"pflow",
... | Post power flow computation of series device flow | [
"Post",
"power",
"flow",
"computation",
"of",
"series",
"device",
"flow"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L190-L199 |
cuihantao/andes | andes/variables/call.py | Call._compile_int | def _compile_int(self):
"""Time Domain Simulation routine execution"""
string = '"""\n'
# evaluate the algebraic equations g
string += 'system.dae.init_fg(resetz=False)\n'
for gcall, call in zip(self.gcall, self.gcalls):
if gcall:
string += call
... | python | def _compile_int(self):
"""Time Domain Simulation routine execution"""
string = '"""\n'
# evaluate the algebraic equations g
string += 'system.dae.init_fg(resetz=False)\n'
for gcall, call in zip(self.gcall, self.gcalls):
if gcall:
string += call
... | [
"def",
"_compile_int",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"# evaluate the algebraic equations g",
"string",
"+=",
"'system.dae.init_fg(resetz=False)\\n'",
"for",
"gcall",
",",
"call",
"in",
"zip",
"(",
"self",
".",
"gcall",
",",
"self",
".",
"gca... | Time Domain Simulation routine execution | [
"Time",
"Domain",
"Simulation",
"routine",
"execution"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L201-L250 |
cuihantao/andes | andes/variables/call.py | Call._compile_int_f | def _compile_int_f(self):
"""Time Domain Simulation - update differential equations"""
string = '"""\n'
string += 'system.dae.init_f()\n'
# evaluate differential equations f
for fcall, call in zip(self.fcall, self.fcalls):
if fcall:
string += call
... | python | def _compile_int_f(self):
"""Time Domain Simulation - update differential equations"""
string = '"""\n'
string += 'system.dae.init_f()\n'
# evaluate differential equations f
for fcall, call in zip(self.fcall, self.fcalls):
if fcall:
string += call
... | [
"def",
"_compile_int_f",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"string",
"+=",
"'system.dae.init_f()\\n'",
"# evaluate differential equations f",
"for",
"fcall",
",",
"call",
"in",
"zip",
"(",
"self",
".",
"fcall",
",",
"self",
".",
"fcalls",
")",... | Time Domain Simulation - update differential equations | [
"Time",
"Domain",
"Simulation",
"-",
"update",
"differential",
"equations"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L252-L263 |
cuihantao/andes | andes/variables/call.py | Call._compile_int_g | def _compile_int_g(self):
"""Time Domain Simulation - update algebraic equations and Jacobian"""
string = '"""\n'
# evaluate the algebraic equations g
string += 'system.dae.init_g()\n'
for gcall, call in zip(self.gcall, self.gcalls):
if gcall:
string ... | python | def _compile_int_g(self):
"""Time Domain Simulation - update algebraic equations and Jacobian"""
string = '"""\n'
# evaluate the algebraic equations g
string += 'system.dae.init_g()\n'
for gcall, call in zip(self.gcall, self.gcalls):
if gcall:
string ... | [
"def",
"_compile_int_g",
"(",
"self",
")",
":",
"string",
"=",
"'\"\"\"\\n'",
"# evaluate the algebraic equations g",
"string",
"+=",
"'system.dae.init_g()\\n'",
"for",
"gcall",
",",
"call",
"in",
"zip",
"(",
"self",
".",
"gcall",
",",
"self",
".",
"gcalls",
")"... | Time Domain Simulation - update algebraic equations and Jacobian | [
"Time",
"Domain",
"Simulation",
"-",
"update",
"algebraic",
"equations",
"and",
"Jacobian"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/call.py#L265-L298 |
cuihantao/andes | andes/models/base.py | ModelBase._init | def _init(self):
"""
Convert model metadata to class attributes.
This function is called automatically after ``define()`` in new
versions.
:return: None
"""
assert self._name
assert self._group
# self.n = 0
self.u = []
self.name ... | python | def _init(self):
"""
Convert model metadata to class attributes.
This function is called automatically after ``define()`` in new
versions.
:return: None
"""
assert self._name
assert self._group
# self.n = 0
self.u = []
self.name ... | [
"def",
"_init",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_name",
"assert",
"self",
".",
"_group",
"# self.n = 0",
"self",
".",
"u",
"=",
"[",
"]",
"self",
".",
"name",
"=",
"[",
"]",
"self",
".",
"idx",
"=",
"[",
"]",
"self",
".",
"uid",
... | Convert model metadata to class attributes.
This function is called automatically after ``define()`` in new
versions.
:return: None | [
"Convert",
"model",
"metadata",
"to",
"class",
"attributes",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L194-L237 |
cuihantao/andes | andes/models/base.py | ModelBase.param_define | def param_define(self,
param,
default,
unit='',
descr='',
tomatrix=True,
nonzero=False,
mandatory=False,
power=False,
voltage=False... | python | def param_define(self,
param,
default,
unit='',
descr='',
tomatrix=True,
nonzero=False,
mandatory=False,
power=False,
voltage=False... | [
"def",
"param_define",
"(",
"self",
",",
"param",
",",
"default",
",",
"unit",
"=",
"''",
",",
"descr",
"=",
"''",
",",
"tomatrix",
"=",
"True",
",",
"nonzero",
"=",
"False",
",",
"mandatory",
"=",
"False",
",",
"power",
"=",
"False",
",",
"voltage",... | Define a parameter in the model
:param tomatrix: convert this parameter list to matrix
:param param: parameter name
:param default: parameter default value
:param unit: parameter unit
:param descr: description
:param nonzero: is non-zero
:param mandatory: is mand... | [
"Define",
"a",
"parameter",
"in",
"the",
"model"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L239-L337 |
cuihantao/andes | andes/models/base.py | ModelBase.var_define | def var_define(self, variable, ty, fname, descr='', uname=''):
"""
Define a variable in the model
:param fname: LaTex formatted variable name string
:param uname: unformatted variable name string, `variable` as default
:param variable: variable name
:param ty: type code ... | python | def var_define(self, variable, ty, fname, descr='', uname=''):
"""
Define a variable in the model
:param fname: LaTex formatted variable name string
:param uname: unformatted variable name string, `variable` as default
:param variable: variable name
:param ty: type code ... | [
"def",
"var_define",
"(",
"self",
",",
"variable",
",",
"ty",
",",
"fname",
",",
"descr",
"=",
"''",
",",
"uname",
"=",
"''",
")",
":",
"assert",
"ty",
"in",
"(",
"'x'",
",",
"'y'",
")",
"if",
"not",
"uname",
":",
"uname",
"=",
"variable",
"if",
... | Define a variable in the model
:param fname: LaTex formatted variable name string
:param uname: unformatted variable name string, `variable` as default
:param variable: variable name
:param ty: type code in ``('x', 'y')``
:param descr: variable description
:type variabl... | [
"Define",
"a",
"variable",
"in",
"the",
"model"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L339-L369 |
cuihantao/andes | andes/models/base.py | ModelBase.service_define | def service_define(self, service, ty):
"""
Add a service variable of type ``ty`` to this model
:param str service: variable name
:param type ty: variable type
:return: None
"""
assert service not in self._data
assert service not in self._algebs + self._s... | python | def service_define(self, service, ty):
"""
Add a service variable of type ``ty`` to this model
:param str service: variable name
:param type ty: variable type
:return: None
"""
assert service not in self._data
assert service not in self._algebs + self._s... | [
"def",
"service_define",
"(",
"self",
",",
"service",
",",
"ty",
")",
":",
"assert",
"service",
"not",
"in",
"self",
".",
"_data",
"assert",
"service",
"not",
"in",
"self",
".",
"_algebs",
"+",
"self",
".",
"_states",
"self",
".",
"_service",
".",
"app... | Add a service variable of type ``ty`` to this model
:param str service: variable name
:param type ty: variable type
:return: None | [
"Add",
"a",
"service",
"variable",
"of",
"type",
"ty",
"to",
"this",
"model"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L371-L384 |
cuihantao/andes | andes/models/base.py | ModelBase.get_uid | def get_uid(self, idx):
"""
Return the `uid` of the elements with the given `idx`
:param list, matrix idx: external indices
:type idx: list, matrix
:return: a matrix of uid
"""
assert idx is not None
if isinstance(idx, (int, float, str)):
ret... | python | def get_uid(self, idx):
"""
Return the `uid` of the elements with the given `idx`
:param list, matrix idx: external indices
:type idx: list, matrix
:return: a matrix of uid
"""
assert idx is not None
if isinstance(idx, (int, float, str)):
ret... | [
"def",
"get_uid",
"(",
"self",
",",
"idx",
")",
":",
"assert",
"idx",
"is",
"not",
"None",
"if",
"isinstance",
"(",
"idx",
",",
"(",
"int",
",",
"float",
",",
"str",
")",
")",
":",
"return",
"self",
".",
"uid",
"[",
"idx",
"]",
"ret",
"=",
"[",... | Return the `uid` of the elements with the given `idx`
:param list, matrix idx: external indices
:type idx: list, matrix
:return: a matrix of uid | [
"Return",
"the",
"uid",
"of",
"the",
"elements",
"with",
"the",
"given",
"idx"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L386-L406 |
cuihantao/andes | andes/models/base.py | ModelBase.get_field | def get_field(self, field, idx=None, astype=None):
"""
Return `self.field` for the elements labeled by `idx`
:param astype: type cast of the return value
:param field: field name of this model
:param idx: element indices, will be the whole list if not specified
:return: ... | python | def get_field(self, field, idx=None, astype=None):
"""
Return `self.field` for the elements labeled by `idx`
:param astype: type cast of the return value
:param field: field name of this model
:param idx: element indices, will be the whole list if not specified
:return: ... | [
"def",
"get_field",
"(",
"self",
",",
"field",
",",
"idx",
"=",
"None",
",",
"astype",
"=",
"None",
")",
":",
"assert",
"astype",
"in",
"(",
"None",
",",
"list",
",",
"matrix",
")",
"ret",
"=",
"None",
"if",
"idx",
"is",
"None",
":",
"idx",
"=",
... | Return `self.field` for the elements labeled by `idx`
:param astype: type cast of the return value
:param field: field name of this model
:param idx: element indices, will be the whole list if not specified
:return: field values | [
"Return",
"self",
".",
"field",
"for",
"the",
"elements",
"labeled",
"by",
"idx"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L417-L455 |
cuihantao/andes | andes/models/base.py | ModelBase._alloc | def _alloc(self):
"""
Allocate empty memory for dae variable indices.
Called in device setup phase.
:return: None
"""
nzeros = [0] * self.n
for var in self._states:
self.__dict__[var] = nzeros[:]
for var in self._algebs:
self.__dic... | python | def _alloc(self):
"""
Allocate empty memory for dae variable indices.
Called in device setup phase.
:return: None
"""
nzeros = [0] * self.n
for var in self._states:
self.__dict__[var] = nzeros[:]
for var in self._algebs:
self.__dic... | [
"def",
"_alloc",
"(",
"self",
")",
":",
"nzeros",
"=",
"[",
"0",
"]",
"*",
"self",
".",
"n",
"for",
"var",
"in",
"self",
".",
"_states",
":",
"self",
".",
"__dict__",
"[",
"var",
"]",
"=",
"nzeros",
"[",
":",
"]",
"for",
"var",
"in",
"self",
... | Allocate empty memory for dae variable indices.
Called in device setup phase.
:return: None | [
"Allocate",
"empty",
"memory",
"for",
"dae",
"variable",
"indices",
".",
"Called",
"in",
"device",
"setup",
"phase",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L457-L468 |
cuihantao/andes | andes/models/base.py | ModelBase.data_to_dict | def data_to_dict(self, sysbase=False):
"""
Return the loaded model parameters as one dictionary.
Each key of the dictionary is a parameter name, and the value is a
list of all the parameter values.
:param sysbase: use system base quantities
:type sysbase: bool
"... | python | def data_to_dict(self, sysbase=False):
"""
Return the loaded model parameters as one dictionary.
Each key of the dictionary is a parameter name, and the value is a
list of all the parameter values.
:param sysbase: use system base quantities
:type sysbase: bool
"... | [
"def",
"data_to_dict",
"(",
"self",
",",
"sysbase",
"=",
"False",
")",
":",
"assert",
"isinstance",
"(",
"sysbase",
",",
"bool",
")",
"ret",
"=",
"{",
"}",
"for",
"key",
"in",
"self",
".",
"data_keys",
":",
"if",
"(",
"not",
"sysbase",
")",
"and",
... | Return the loaded model parameters as one dictionary.
Each key of the dictionary is a parameter name, and the value is a
list of all the parameter values.
:param sysbase: use system base quantities
:type sysbase: bool | [
"Return",
"the",
"loaded",
"model",
"parameters",
"as",
"one",
"dictionary",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L470-L492 |
cuihantao/andes | andes/models/base.py | ModelBase.data_to_list | def data_to_list(self, sysbase=False):
"""
Return the loaded model data as a list of dictionaries.
Each dictionary contains the full parameters of an element.
:param sysbase: use system base quantities
:type sysbase: bool
"""
ret = list()
# for each elem... | python | def data_to_list(self, sysbase=False):
"""
Return the loaded model data as a list of dictionaries.
Each dictionary contains the full parameters of an element.
:param sysbase: use system base quantities
:type sysbase: bool
"""
ret = list()
# for each elem... | [
"def",
"data_to_list",
"(",
"self",
",",
"sysbase",
"=",
"False",
")",
":",
"ret",
"=",
"list",
"(",
")",
"# for each element",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"n",
")",
":",
"# read the parameter values and put in the temp dict ``e``",
"e",
"=",
... | Return the loaded model data as a list of dictionaries.
Each dictionary contains the full parameters of an element.
:param sysbase: use system base quantities
:type sysbase: bool | [
"Return",
"the",
"loaded",
"model",
"data",
"as",
"a",
"list",
"of",
"dictionaries",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L520-L543 |
cuihantao/andes | andes/models/base.py | ModelBase.data_from_dict | def data_from_dict(self, data):
"""
Populate model parameters from a dictionary of parameters
Parameters
----------
data : dict
List of parameter dictionaries
Returns
-------
None
"""
nvars = []
for key, val in data.i... | python | def data_from_dict(self, data):
"""
Populate model parameters from a dictionary of parameters
Parameters
----------
data : dict
List of parameter dictionaries
Returns
-------
None
"""
nvars = []
for key, val in data.i... | [
"def",
"data_from_dict",
"(",
"self",
",",
"data",
")",
":",
"nvars",
"=",
"[",
"]",
"for",
"key",
",",
"val",
"in",
"data",
".",
"items",
"(",
")",
":",
"self",
".",
"__dict__",
"[",
"key",
"]",
".",
"extend",
"(",
"val",
")",
"# assure the same p... | Populate model parameters from a dictionary of parameters
Parameters
----------
data : dict
List of parameter dictionaries
Returns
-------
None | [
"Populate",
"model",
"parameters",
"from",
"a",
"dictionary",
"of",
"parameters"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L561-L588 |
cuihantao/andes | andes/models/base.py | ModelBase.data_to_df | def data_to_df(self, sysbase=False):
"""
Return a pandas.DataFrame of device parameters.
:param sysbase: save per unit values in system base
"""
p_dict_comp = self.data_to_dict(sysbase=sysbase)
self._check_pd()
self.param_df = pd.DataFrame(data=p_dict_comp).set_... | python | def data_to_df(self, sysbase=False):
"""
Return a pandas.DataFrame of device parameters.
:param sysbase: save per unit values in system base
"""
p_dict_comp = self.data_to_dict(sysbase=sysbase)
self._check_pd()
self.param_df = pd.DataFrame(data=p_dict_comp).set_... | [
"def",
"data_to_df",
"(",
"self",
",",
"sysbase",
"=",
"False",
")",
":",
"p_dict_comp",
"=",
"self",
".",
"data_to_dict",
"(",
"sysbase",
"=",
"sysbase",
")",
"self",
".",
"_check_pd",
"(",
")",
"self",
".",
"param_df",
"=",
"pd",
".",
"DataFrame",
"(... | Return a pandas.DataFrame of device parameters.
:param sysbase: save per unit values in system base | [
"Return",
"a",
"pandas",
".",
"DataFrame",
"of",
"device",
"parameters",
".",
":",
"param",
"sysbase",
":",
"save",
"per",
"unit",
"values",
"in",
"system",
"base"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L590-L601 |
cuihantao/andes | andes/models/base.py | ModelBase.var_to_df | def var_to_df(self):
"""
Return the current var_to_df of variables
:return: pandas.DataFrame
"""
ret = {}
self._check_pd()
if self._flags['address'] is False:
return pd.DataFrame.from_dict(ret)
ret.update({'name': self.name})
ret.upd... | python | def var_to_df(self):
"""
Return the current var_to_df of variables
:return: pandas.DataFrame
"""
ret = {}
self._check_pd()
if self._flags['address'] is False:
return pd.DataFrame.from_dict(ret)
ret.update({'name': self.name})
ret.upd... | [
"def",
"var_to_df",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"}",
"self",
".",
"_check_pd",
"(",
")",
"if",
"self",
".",
"_flags",
"[",
"'address'",
"]",
"is",
"False",
":",
"return",
"pd",
".",
"DataFrame",
".",
"from_dict",
"(",
"ret",
")",
"ret",... | Return the current var_to_df of variables
:return: pandas.DataFrame | [
"Return",
"the",
"current",
"var_to_df",
"of",
"variables"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L603-L627 |
cuihantao/andes | andes/models/base.py | ModelBase.param_remove | def param_remove(self, param: 'str') -> None:
"""
Remove a param from this model
:param param: name of the parameter to be removed
:type param: str
"""
for attr in self._param_attr_dicts:
if param in self.__dict__[attr]:
self.__dict__[attr].po... | python | def param_remove(self, param: 'str') -> None:
"""
Remove a param from this model
:param param: name of the parameter to be removed
:type param: str
"""
for attr in self._param_attr_dicts:
if param in self.__dict__[attr]:
self.__dict__[attr].po... | [
"def",
"param_remove",
"(",
"self",
",",
"param",
":",
"'str'",
")",
"->",
"None",
":",
"for",
"attr",
"in",
"self",
".",
"_param_attr_dicts",
":",
"if",
"param",
"in",
"self",
".",
"__dict__",
"[",
"attr",
"]",
":",
"self",
".",
"__dict__",
"[",
"at... | Remove a param from this model
:param param: name of the parameter to be removed
:type param: str | [
"Remove",
"a",
"param",
"from",
"this",
"model"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L639-L652 |
cuihantao/andes | andes/models/base.py | ModelBase.param_alter | def param_alter(self,
param,
default=None,
unit=None,
descr=None,
tomatrix=None,
nonzero=None,
mandatory=None,
power=None,
voltage=None,
... | python | def param_alter(self,
param,
default=None,
unit=None,
descr=None,
tomatrix=None,
nonzero=None,
mandatory=None,
power=None,
voltage=None,
... | [
"def",
"param_alter",
"(",
"self",
",",
"param",
",",
"default",
"=",
"None",
",",
"unit",
"=",
"None",
",",
"descr",
"=",
"None",
",",
"tomatrix",
"=",
"None",
",",
"nonzero",
"=",
"None",
",",
"mandatory",
"=",
"None",
",",
"power",
"=",
"None",
... | Set attribute of an existing parameter.
To be used to alter an attribute inherited from parent models.
See .. self.param_define for argument descriptions. | [
"Set",
"attribute",
"of",
"an",
"existing",
"parameter",
".",
"To",
"be",
"used",
"to",
"alter",
"an",
"attribute",
"inherited",
"from",
"parent",
"models",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L654-L713 |
cuihantao/andes | andes/models/base.py | ModelBase.eq_add | def eq_add(self, expr, var, intf=False):
"""
Add an equation to this model.
An equation is associated with the addresses of a variable. The
number of equations must equal that of variables.
Stored to ``self._equations`` is a tuple of ``(expr, var, intf,
ty)`` where ``t... | python | def eq_add(self, expr, var, intf=False):
"""
Add an equation to this model.
An equation is associated with the addresses of a variable. The
number of equations must equal that of variables.
Stored to ``self._equations`` is a tuple of ``(expr, var, intf,
ty)`` where ``t... | [
"def",
"eq_add",
"(",
"self",
",",
"expr",
",",
"var",
",",
"intf",
"=",
"False",
")",
":",
"# determine the type of the equation, ('f', 'g') based on var",
"# We assume that all differential equations are only modifiable by",
"# the model itself",
"# Only interface to algebraic ... | Add an equation to this model.
An equation is associated with the addresses of a variable. The
number of equations must equal that of variables.
Stored to ``self._equations`` is a tuple of ``(expr, var, intf,
ty)`` where ``ty`` is in ('f', 'g')
:param str expr: equation expre... | [
"Add",
"an",
"equation",
"to",
"this",
"model",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L715-L764 |
cuihantao/andes | andes/models/base.py | ModelBase.read_data_ext | def read_data_ext(self, model: str, field: str, idx=None, astype=None):
"""
Return a field of a model or group at the given indices
:param str model: name of the group or model to retrieve
:param str field: name of the field
:param list, int, float str idx: idx of elements to ac... | python | def read_data_ext(self, model: str, field: str, idx=None, astype=None):
"""
Return a field of a model or group at the given indices
:param str model: name of the group or model to retrieve
:param str field: name of the field
:param list, int, float str idx: idx of elements to ac... | [
"def",
"read_data_ext",
"(",
"self",
",",
"model",
":",
"str",
",",
"field",
":",
"str",
",",
"idx",
"=",
"None",
",",
"astype",
"=",
"None",
")",
":",
"ret",
"=",
"list",
"(",
")",
"if",
"model",
"in",
"self",
".",
"system",
".",
"devman",
".",
... | Return a field of a model or group at the given indices
:param str model: name of the group or model to retrieve
:param str field: name of the field
:param list, int, float str idx: idx of elements to access
:param type astype: type cast
:return: | [
"Return",
"a",
"field",
"of",
"a",
"model",
"or",
"group",
"at",
"the",
"given",
"indices"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L766-L805 |
cuihantao/andes | andes/models/base.py | ModelBase.copy_data_ext | def copy_data_ext(self, model, field, dest=None, idx=None, astype=None):
"""
Retrieve the field of another model and store it as a field.
:param model: name of the source model being a model name or a group name
:param field: name of the field to retrieve
:param dest: name of th... | python | def copy_data_ext(self, model, field, dest=None, idx=None, astype=None):
"""
Retrieve the field of another model and store it as a field.
:param model: name of the source model being a model name or a group name
:param field: name of the field to retrieve
:param dest: name of th... | [
"def",
"copy_data_ext",
"(",
"self",
",",
"model",
",",
"field",
",",
"dest",
"=",
"None",
",",
"idx",
"=",
"None",
",",
"astype",
"=",
"None",
")",
":",
"# use default destination",
"if",
"not",
"dest",
":",
"dest",
"=",
"field",
"assert",
"dest",
"no... | Retrieve the field of another model and store it as a field.
:param model: name of the source model being a model name or a group name
:param field: name of the field to retrieve
:param dest: name of the destination field in ``self``
:param idx: idx of elements to access
:param ... | [
"Retrieve",
"the",
"field",
"of",
"another",
"model",
"and",
"store",
"it",
"as",
"a",
"field",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L807-L837 |
cuihantao/andes | andes/models/base.py | ModelBase.elem_add | def elem_add(self, idx=None, name=None, **kwargs):
"""
Add an element of this model
:param idx: element idx
:param name: element name
:param kwargs: keyword arguments of the parameters
:return: allocated idx
"""
idx = self.system.devman.register_element(... | python | def elem_add(self, idx=None, name=None, **kwargs):
"""
Add an element of this model
:param idx: element idx
:param name: element name
:param kwargs: keyword arguments of the parameters
:return: allocated idx
"""
idx = self.system.devman.register_element(... | [
"def",
"elem_add",
"(",
"self",
",",
"idx",
"=",
"None",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"idx",
"=",
"self",
".",
"system",
".",
"devman",
".",
"register_element",
"(",
"dev_name",
"=",
"self",
".",
"_name",
",",
"idx",... | Add an element of this model
:param idx: element idx
:param name: element name
:param kwargs: keyword arguments of the parameters
:return: allocated idx | [
"Add",
"an",
"element",
"of",
"this",
"model"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L839-L899 |
cuihantao/andes | andes/models/base.py | ModelBase.elem_remove | def elem_remove(self, idx=None):
"""
Remove elements labeled by idx from this model instance.
:param list,matrix idx: indices of elements to be removed
:return: None
"""
if idx is not None:
if idx in self.uid:
key = idx
item = ... | python | def elem_remove(self, idx=None):
"""
Remove elements labeled by idx from this model instance.
:param list,matrix idx: indices of elements to be removed
:return: None
"""
if idx is not None:
if idx in self.uid:
key = idx
item = ... | [
"def",
"elem_remove",
"(",
"self",
",",
"idx",
"=",
"None",
")",
":",
"if",
"idx",
"is",
"not",
"None",
":",
"if",
"idx",
"in",
"self",
".",
"uid",
":",
"key",
"=",
"idx",
"item",
"=",
"self",
".",
"uid",
"[",
"idx",
"]",
"else",
":",
"self",
... | Remove elements labeled by idx from this model instance.
:param list,matrix idx: indices of elements to be removed
:return: None | [
"Remove",
"elements",
"labeled",
"by",
"idx",
"from",
"this",
"model",
"instance",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L901-L966 |
cuihantao/andes | andes/models/base.py | ModelBase.data_to_sys_base | def data_to_sys_base(self):
"""
Converts parameters to system base. Stores a copy in ``self._store``.
Sets the flag ``self.flag['sysbase']`` to True.
:return: None
"""
if (not self.n) or self._flags['sysbase']:
return
Sb = self.system.mva
Vb =... | python | def data_to_sys_base(self):
"""
Converts parameters to system base. Stores a copy in ``self._store``.
Sets the flag ``self.flag['sysbase']`` to True.
:return: None
"""
if (not self.n) or self._flags['sysbase']:
return
Sb = self.system.mva
Vb =... | [
"def",
"data_to_sys_base",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"n",
")",
"or",
"self",
".",
"_flags",
"[",
"'sysbase'",
"]",
":",
"return",
"Sb",
"=",
"self",
".",
"system",
".",
"mva",
"Vb",
"=",
"matrix",
"(",
"[",
"]",
")",
... | Converts parameters to system base. Stores a copy in ``self._store``.
Sets the flag ``self.flag['sysbase']`` to True.
:return: None | [
"Converts",
"parameters",
"to",
"system",
"base",
".",
"Stores",
"a",
"copy",
"in",
"self",
".",
"_store",
".",
"Sets",
"the",
"flag",
"self",
".",
"flag",
"[",
"sysbase",
"]",
"to",
"True",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L968-L1039 |
cuihantao/andes | andes/models/base.py | ModelBase.data_to_elem_base | def data_to_elem_base(self):
"""
Convert parameter data to element base
Returns
-------
None
"""
if self._flags['sysbase'] is False:
return
for key, val in self._store.items():
self.__dict__[key] = val
self._flags['sysbas... | python | def data_to_elem_base(self):
"""
Convert parameter data to element base
Returns
-------
None
"""
if self._flags['sysbase'] is False:
return
for key, val in self._store.items():
self.__dict__[key] = val
self._flags['sysbas... | [
"def",
"data_to_elem_base",
"(",
"self",
")",
":",
"if",
"self",
".",
"_flags",
"[",
"'sysbase'",
"]",
"is",
"False",
":",
"return",
"for",
"key",
",",
"val",
"in",
"self",
".",
"_store",
".",
"items",
"(",
")",
":",
"self",
".",
"__dict__",
"[",
"... | Convert parameter data to element base
Returns
-------
None | [
"Convert",
"parameter",
"data",
"to",
"element",
"base"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1041-L1055 |
cuihantao/andes | andes/models/base.py | ModelBase._intf_network | def _intf_network(self):
"""
Retrieve the ac and dc network interface variable indices.
:Example:
``self._ac = {'bus1': (a1, v1)}`` gives
- indices: self.bus1
- system.Bus.a -> self.a1
- system.Bus.v -> self.v1
``self._dc = {'node... | python | def _intf_network(self):
"""
Retrieve the ac and dc network interface variable indices.
:Example:
``self._ac = {'bus1': (a1, v1)}`` gives
- indices: self.bus1
- system.Bus.a -> self.a1
- system.Bus.v -> self.v1
``self._dc = {'node... | [
"def",
"_intf_network",
"(",
"self",
")",
":",
"for",
"key",
",",
"val",
"in",
"self",
".",
"_ac",
".",
"items",
"(",
")",
":",
"self",
".",
"copy_data_ext",
"(",
"model",
"=",
"'Bus'",
",",
"field",
"=",
"'a'",
",",
"dest",
"=",
"val",
"[",
"0",... | Retrieve the ac and dc network interface variable indices.
:Example:
``self._ac = {'bus1': (a1, v1)}`` gives
- indices: self.bus1
- system.Bus.a -> self.a1
- system.Bus.v -> self.v1
``self._dc = {'node1': v1}`` gives
- indices: self... | [
"Retrieve",
"the",
"ac",
"and",
"dc",
"network",
"interface",
"variable",
"indices",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1070-L1099 |
cuihantao/andes | andes/models/base.py | ModelBase._intf_ctrl | def _intf_ctrl(self):
"""
Retrieve variable indices of controlled models.
Control interfaces are specified in ``self._ctrl``.
Each ``key:value`` pair has ``key`` being the variable names
for the reference idx and ``value`` being a tuple of
``(model name, field to read, d... | python | def _intf_ctrl(self):
"""
Retrieve variable indices of controlled models.
Control interfaces are specified in ``self._ctrl``.
Each ``key:value`` pair has ``key`` being the variable names
for the reference idx and ``value`` being a tuple of
``(model name, field to read, d... | [
"def",
"_intf_ctrl",
"(",
"self",
")",
":",
"for",
"key",
",",
"val",
"in",
"self",
".",
"_ctrl",
".",
"items",
"(",
")",
":",
"model",
",",
"field",
",",
"dest",
",",
"astype",
"=",
"val",
"self",
".",
"copy_data_ext",
"(",
"model",
",",
"field",
... | Retrieve variable indices of controlled models.
Control interfaces are specified in ``self._ctrl``.
Each ``key:value`` pair has ``key`` being the variable names
for the reference idx and ``value`` being a tuple of
``(model name, field to read, destination field, return type)``.
... | [
"Retrieve",
"variable",
"indices",
"of",
"controlled",
"models",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1101-L1122 |
cuihantao/andes | andes/models/base.py | ModelBase._addr | def _addr(self):
"""
Assign dae addresses for algebraic and state variables.
Addresses are stored in ``self.__dict__[var]``.
``dae.m`` and ``dae.n`` are updated accordingly.
Returns
-------
None
"""
group_by = self._config['address_group_by']
... | python | def _addr(self):
"""
Assign dae addresses for algebraic and state variables.
Addresses are stored in ``self.__dict__[var]``.
``dae.m`` and ``dae.n`` are updated accordingly.
Returns
-------
None
"""
group_by = self._config['address_group_by']
... | [
"def",
"_addr",
"(",
"self",
")",
":",
"group_by",
"=",
"self",
".",
"_config",
"[",
"'address_group_by'",
"]",
"assert",
"not",
"self",
".",
"_flags",
"[",
"'address'",
"]",
",",
"\"{} address already assigned\"",
".",
"format",
"(",
"self",
".",
"_name",
... | Assign dae addresses for algebraic and state variables.
Addresses are stored in ``self.__dict__[var]``.
``dae.m`` and ``dae.n`` are updated accordingly.
Returns
-------
None | [
"Assign",
"dae",
"addresses",
"for",
"algebraic",
"and",
"state",
"variables",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1124-L1164 |
cuihantao/andes | andes/models/base.py | ModelBase._varname | def _varname(self):
"""
Set up variable names in ``self.system.varname``.
Variable names follows the convention ``VariableName,Model Name``.
A maximum of 24 characters are allowed for each variable.
:return: None
"""
if not self._flags['address']:
se... | python | def _varname(self):
"""
Set up variable names in ``self.system.varname``.
Variable names follows the convention ``VariableName,Model Name``.
A maximum of 24 characters are allowed for each variable.
:return: None
"""
if not self._flags['address']:
se... | [
"def",
"_varname",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_flags",
"[",
"'address'",
"]",
":",
"self",
".",
"log",
"(",
"'Unable to assign Varname before allocating address'",
",",
"ERROR",
")",
"return",
"varname",
"=",
"self",
".",
"system",
"."... | Set up variable names in ``self.system.varname``.
Variable names follows the convention ``VariableName,Model Name``.
A maximum of 24 characters are allowed for each variable.
:return: None | [
"Set",
"up",
"variable",
"names",
"in",
"self",
".",
"system",
".",
"varname",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1166-L1200 |
cuihantao/andes | andes/models/base.py | ModelBase._param_to_matrix | def _param_to_matrix(self):
"""
Convert parameters defined in `self._params` to `cvxopt.matrix`
:return None
"""
for item in self._params:
self.__dict__[item] = matrix(self.__dict__[item], tc='d') | python | def _param_to_matrix(self):
"""
Convert parameters defined in `self._params` to `cvxopt.matrix`
:return None
"""
for item in self._params:
self.__dict__[item] = matrix(self.__dict__[item], tc='d') | [
"def",
"_param_to_matrix",
"(",
"self",
")",
":",
"for",
"item",
"in",
"self",
".",
"_params",
":",
"self",
".",
"__dict__",
"[",
"item",
"]",
"=",
"matrix",
"(",
"self",
".",
"__dict__",
"[",
"item",
"]",
",",
"tc",
"=",
"'d'",
")"
] | Convert parameters defined in `self._params` to `cvxopt.matrix`
:return None | [
"Convert",
"parameters",
"defined",
"in",
"self",
".",
"_params",
"to",
"cvxopt",
".",
"matrix"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1202-L1209 |
cuihantao/andes | andes/models/base.py | ModelBase._param_to_list | def _param_to_list(self):
"""
Convert parameters defined in `self._param` to list
:return None
"""
for item in self._params:
self.__dict__[item] = list(self.__dict__[item]) | python | def _param_to_list(self):
"""
Convert parameters defined in `self._param` to list
:return None
"""
for item in self._params:
self.__dict__[item] = list(self.__dict__[item]) | [
"def",
"_param_to_list",
"(",
"self",
")",
":",
"for",
"item",
"in",
"self",
".",
"_params",
":",
"self",
".",
"__dict__",
"[",
"item",
"]",
"=",
"list",
"(",
"self",
".",
"__dict__",
"[",
"item",
"]",
")"
] | Convert parameters defined in `self._param` to list
:return None | [
"Convert",
"parameters",
"defined",
"in",
"self",
".",
"_param",
"to",
"list"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1211-L1218 |
cuihantao/andes | andes/models/base.py | ModelBase.log | def log(self, msg, level=INFO):
"""Record a line of log in logger
:param str msg: content of the messag
:param level: logging level
:return: None
"""
logger.log(level, '<{}> - '.format(self._name) + msg) | python | def log(self, msg, level=INFO):
"""Record a line of log in logger
:param str msg: content of the messag
:param level: logging level
:return: None
"""
logger.log(level, '<{}> - '.format(self._name) + msg) | [
"def",
"log",
"(",
"self",
",",
"msg",
",",
"level",
"=",
"INFO",
")",
":",
"logger",
".",
"log",
"(",
"level",
",",
"'<{}> - '",
".",
"format",
"(",
"self",
".",
"_name",
")",
"+",
"msg",
")"
] | Record a line of log in logger
:param str msg: content of the messag
:param level: logging level
:return: None | [
"Record",
"a",
"line",
"of",
"log",
"in",
"logger"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1220-L1229 |
cuihantao/andes | andes/models/base.py | ModelBase.init_limit | def init_limit(self, key, lower=None, upper=None, limit=False):
""" check if data is within limits. reset if violates"""
above = agtb(self.__dict__[key], upper)
for idx, item in enumerate(above):
if item == 0.:
continue
maxval = upper[idx]
self... | python | def init_limit(self, key, lower=None, upper=None, limit=False):
""" check if data is within limits. reset if violates"""
above = agtb(self.__dict__[key], upper)
for idx, item in enumerate(above):
if item == 0.:
continue
maxval = upper[idx]
self... | [
"def",
"init_limit",
"(",
"self",
",",
"key",
",",
"lower",
"=",
"None",
",",
"upper",
"=",
"None",
",",
"limit",
"=",
"False",
")",
":",
"above",
"=",
"agtb",
"(",
"self",
".",
"__dict__",
"[",
"key",
"]",
",",
"upper",
")",
"for",
"idx",
",",
... | check if data is within limits. reset if violates | [
"check",
"if",
"data",
"is",
"within",
"limits",
".",
"reset",
"if",
"violates"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1231-L1253 |
cuihantao/andes | andes/models/base.py | ModelBase.doc | def doc(self, export='plain'):
"""
Build help document into a Texttable table
:param ('plain', 'latex') export: export format
:param save: save to file ``help_model.extension`` or not
:param writemode: file write mode
:return: None
"""
title = '<{}.{}>'.... | python | def doc(self, export='plain'):
"""
Build help document into a Texttable table
:param ('plain', 'latex') export: export format
:param save: save to file ``help_model.extension`` or not
:param writemode: file write mode
:return: None
"""
title = '<{}.{}>'.... | [
"def",
"doc",
"(",
"self",
",",
"export",
"=",
"'plain'",
")",
":",
"title",
"=",
"'<{}.{}>'",
".",
"format",
"(",
"self",
".",
"_group",
",",
"self",
".",
"_name",
")",
"table",
"=",
"Tab",
"(",
"export",
"=",
"export",
",",
"title",
"=",
"title",... | Build help document into a Texttable table
:param ('plain', 'latex') export: export format
:param save: save to file ``help_model.extension`` or not
:param writemode: file write mode
:return: None | [
"Build",
"help",
"document",
"into",
"a",
"Texttable",
"table"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1276-L1322 |
cuihantao/andes | andes/models/base.py | ModelBase.check_limit | def check_limit(self, varname, vmin=None, vmax=None):
"""
Check if the variable values are within the limits.
Return False if fails.
"""
retval = True
assert varname in self.__dict__
if varname in self._algebs:
val = self.system.dae.y[self.__dict__[... | python | def check_limit(self, varname, vmin=None, vmax=None):
"""
Check if the variable values are within the limits.
Return False if fails.
"""
retval = True
assert varname in self.__dict__
if varname in self._algebs:
val = self.system.dae.y[self.__dict__[... | [
"def",
"check_limit",
"(",
"self",
",",
"varname",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
")",
":",
"retval",
"=",
"True",
"assert",
"varname",
"in",
"self",
".",
"__dict__",
"if",
"varname",
"in",
"self",
".",
"_algebs",
":",
"val",
"="... | Check if the variable values are within the limits.
Return False if fails. | [
"Check",
"if",
"the",
"variable",
"values",
"are",
"within",
"the",
"limits",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1324-L1364 |
cuihantao/andes | andes/models/base.py | ModelBase.on_bus | def on_bus(self, bus_idx):
"""
Return the indices of elements on the given buses for shunt-connected
elements
:param bus_idx: idx of the buses to which the elements are connected
:return: idx of elements connected to bus_idx
"""
assert hasattr(self, 'bus')
... | python | def on_bus(self, bus_idx):
"""
Return the indices of elements on the given buses for shunt-connected
elements
:param bus_idx: idx of the buses to which the elements are connected
:return: idx of elements connected to bus_idx
"""
assert hasattr(self, 'bus')
... | [
"def",
"on_bus",
"(",
"self",
",",
"bus_idx",
")",
":",
"assert",
"hasattr",
"(",
"self",
",",
"'bus'",
")",
"ret",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"bus_idx",
",",
"(",
"int",
",",
"float",
",",
"str",
")",
")",
":",
"bus_idx",
"=",
"[",
... | Return the indices of elements on the given buses for shunt-connected
elements
:param bus_idx: idx of the buses to which the elements are connected
:return: idx of elements connected to bus_idx | [
"Return",
"the",
"indices",
"of",
"elements",
"on",
"the",
"given",
"buses",
"for",
"shunt",
"-",
"connected",
"elements"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1366-L1396 |
cuihantao/andes | andes/models/base.py | ModelBase.link_bus | def link_bus(self, bus_idx):
"""
Return the indices of elements linking the given buses
:param bus_idx:
:return:
"""
ret = []
if not self._config['is_series']:
self.log(
'link_bus function is not valid for non-series model <{}>'.
... | python | def link_bus(self, bus_idx):
"""
Return the indices of elements linking the given buses
:param bus_idx:
:return:
"""
ret = []
if not self._config['is_series']:
self.log(
'link_bus function is not valid for non-series model <{}>'.
... | [
"def",
"link_bus",
"(",
"self",
",",
"bus_idx",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"_config",
"[",
"'is_series'",
"]",
":",
"self",
".",
"log",
"(",
"'link_bus function is not valid for non-series model <{}>'",
".",
"format",
"(",
"sel... | Return the indices of elements linking the given buses
:param bus_idx:
:return: | [
"Return",
"the",
"indices",
"of",
"elements",
"linking",
"the",
"given",
"buses"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1398-L1441 |
cuihantao/andes | andes/models/base.py | ModelBase.elem_find | def elem_find(self, field, value):
"""
Return the indices of elements whose field first satisfies the given values
``value`` should be unique in self.field.
This function does not check the uniqueness.
:param field: name of the supplied field
:param value: value of fiel... | python | def elem_find(self, field, value):
"""
Return the indices of elements whose field first satisfies the given values
``value`` should be unique in self.field.
This function does not check the uniqueness.
:param field: name of the supplied field
:param value: value of fiel... | [
"def",
"elem_find",
"(",
"self",
",",
"field",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
",",
"str",
")",
")",
":",
"value",
"=",
"[",
"value",
"]",
"f",
"=",
"list",
"(",
"self",
".",
"__dict__",
... | Return the indices of elements whose field first satisfies the given values
``value`` should be unique in self.field.
This function does not check the uniqueness.
:param field: name of the supplied field
:param value: value of field of the elemtn to find
:return: idx of the ele... | [
"Return",
"the",
"indices",
"of",
"elements",
"whose",
"field",
"first",
"satisfies",
"the",
"given",
"values"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1443-L1460 |
cuihantao/andes | andes/models/base.py | ModelBase._check_Vn | def _check_Vn(self):
"""Check data consistency of Vn and Vdcn if connected to Bus or Node
:return None
"""
if hasattr(self, 'bus') and hasattr(self, 'Vn'):
bus_Vn = self.read_data_ext('Bus', field='Vn', idx=self.bus)
for name, bus, Vn, Vn0 in zip(self.name, self.... | python | def _check_Vn(self):
"""Check data consistency of Vn and Vdcn if connected to Bus or Node
:return None
"""
if hasattr(self, 'bus') and hasattr(self, 'Vn'):
bus_Vn = self.read_data_ext('Bus', field='Vn', idx=self.bus)
for name, bus, Vn, Vn0 in zip(self.name, self.... | [
"def",
"_check_Vn",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'bus'",
")",
"and",
"hasattr",
"(",
"self",
",",
"'Vn'",
")",
":",
"bus_Vn",
"=",
"self",
".",
"read_data_ext",
"(",
"'Bus'",
",",
"field",
"=",
"'Vn'",
",",
"idx",
"=",... | Check data consistency of Vn and Vdcn if connected to Bus or Node
:return None | [
"Check",
"data",
"consistency",
"of",
"Vn",
"and",
"Vdcn",
"if",
"connected",
"to",
"Bus",
"or",
"Node"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1462-L1483 |
cuihantao/andes | andes/models/base.py | ModelBase.link_to | def link_to(self, model, idx, self_idx):
"""
Register (self.name, self.idx) in `model._from`
Returns
-------
"""
if model in self.system.loaded_groups:
# access group instance
grp = self.system.__dict__[model]
# doing it one by one
... | python | def link_to(self, model, idx, self_idx):
"""
Register (self.name, self.idx) in `model._from`
Returns
-------
"""
if model in self.system.loaded_groups:
# access group instance
grp = self.system.__dict__[model]
# doing it one by one
... | [
"def",
"link_to",
"(",
"self",
",",
"model",
",",
"idx",
",",
"self_idx",
")",
":",
"if",
"model",
"in",
"self",
".",
"system",
".",
"loaded_groups",
":",
"# access group instance",
"grp",
"=",
"self",
".",
"system",
".",
"__dict__",
"[",
"model",
"]",
... | Register (self.name, self.idx) in `model._from`
Returns
------- | [
"Register",
"(",
"self",
".",
"name",
"self",
".",
"idx",
")",
"in",
"model",
".",
"_from"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1494-L1530 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.reset | def reset(self):
"""
Reset all internal storage to initial status
Returns
-------
None
"""
self.solved = False
self.niter = 0
self.iter_mis = []
self.F = None
self.system.dae.factorize = True | python | def reset(self):
"""
Reset all internal storage to initial status
Returns
-------
None
"""
self.solved = False
self.niter = 0
self.iter_mis = []
self.F = None
self.system.dae.factorize = True | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"solved",
"=",
"False",
"self",
".",
"niter",
"=",
"0",
"self",
".",
"iter_mis",
"=",
"[",
"]",
"self",
".",
"F",
"=",
"None",
"self",
".",
"system",
".",
"dae",
".",
"factorize",
"=",
"True"
] | Reset all internal storage to initial status
Returns
-------
None | [
"Reset",
"all",
"internal",
"storage",
"to",
"initial",
"status"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L27-L39 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.pre | def pre(self):
"""
Initialize system for power flow study
Returns
-------
None
"""
logger.info('-> Power flow study: {} method, {} start'.format(
self.config.method.upper(), 'flat' if self.config.flatstart else 'non-flat')
)
t, s = el... | python | def pre(self):
"""
Initialize system for power flow study
Returns
-------
None
"""
logger.info('-> Power flow study: {} method, {} start'.format(
self.config.method.upper(), 'flat' if self.config.flatstart else 'non-flat')
)
t, s = el... | [
"def",
"pre",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'-> Power flow study: {} method, {} start'",
".",
"format",
"(",
"self",
".",
"config",
".",
"method",
".",
"upper",
"(",
")",
",",
"'flat'",
"if",
"self",
".",
"config",
".",
"flatstart",
... | Initialize system for power flow study
Returns
-------
None | [
"Initialize",
"system",
"for",
"power",
"flow",
"study"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L41-L69 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.run | def run(self, **kwargs):
"""
call the power flow solution routine
Returns
-------
bool
True for success, False for fail
"""
ret = None
# initialization Y matrix and inital guess
self.pre()
t, _ = elapsed()
# call solu... | python | def run(self, **kwargs):
"""
call the power flow solution routine
Returns
-------
bool
True for success, False for fail
"""
ret = None
# initialization Y matrix and inital guess
self.pre()
t, _ = elapsed()
# call solu... | [
"def",
"run",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"None",
"# initialization Y matrix and inital guess",
"self",
".",
"pre",
"(",
")",
"t",
",",
"_",
"=",
"elapsed",
"(",
")",
"# call solution methods",
"if",
"self",
".",
"config",
... | call the power flow solution routine
Returns
-------
bool
True for success, False for fail | [
"call",
"the",
"power",
"flow",
"solution",
"routine"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L71-L102 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.newton | def newton(self):
"""
Newton power flow routine
Returns
-------
(bool, int)
success flag, number of iterations
"""
dae = self.system.dae
while True:
inc = self.calc_inc()
dae.x += inc[:dae.n]
dae.y += inc[d... | python | def newton(self):
"""
Newton power flow routine
Returns
-------
(bool, int)
success flag, number of iterations
"""
dae = self.system.dae
while True:
inc = self.calc_inc()
dae.x += inc[:dae.n]
dae.y += inc[d... | [
"def",
"newton",
"(",
"self",
")",
":",
"dae",
"=",
"self",
".",
"system",
".",
"dae",
"while",
"True",
":",
"inc",
"=",
"self",
".",
"calc_inc",
"(",
")",
"dae",
".",
"x",
"+=",
"inc",
"[",
":",
"dae",
".",
"n",
"]",
"dae",
".",
"y",
"+=",
... | Newton power flow routine
Returns
-------
(bool, int)
success flag, number of iterations | [
"Newton",
"power",
"flow",
"routine"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L104-L137 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.dcpf | def dcpf(self):
"""
Calculate linearized power flow
Returns
-------
(bool, int)
success flag, number of iterations
"""
dae = self.system.dae
self.system.Bus.init0(dae)
self.system.dae.init_g()
Va0 = self.system.Bus.angle
... | python | def dcpf(self):
"""
Calculate linearized power flow
Returns
-------
(bool, int)
success flag, number of iterations
"""
dae = self.system.dae
self.system.Bus.init0(dae)
self.system.dae.init_g()
Va0 = self.system.Bus.angle
... | [
"def",
"dcpf",
"(",
"self",
")",
":",
"dae",
"=",
"self",
".",
"system",
".",
"dae",
"self",
".",
"system",
".",
"Bus",
".",
"init0",
"(",
"dae",
")",
"self",
".",
"system",
".",
"dae",
".",
"init_g",
"(",
")",
"Va0",
"=",
"self",
".",
"system"... | Calculate linearized power flow
Returns
-------
(bool, int)
success flag, number of iterations | [
"Calculate",
"linearized",
"power",
"flow"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L139-L179 |
cuihantao/andes | andes/routines/pflow.py | PFLOW._iter_info | def _iter_info(self, niter, level=logging.INFO):
"""
Log iteration number and mismatch
Parameters
----------
level
logging level
Returns
-------
None
"""
max_mis = self.iter_mis[niter - 1]
msg = ' Iter {:<d}. max misma... | python | def _iter_info(self, niter, level=logging.INFO):
"""
Log iteration number and mismatch
Parameters
----------
level
logging level
Returns
-------
None
"""
max_mis = self.iter_mis[niter - 1]
msg = ' Iter {:<d}. max misma... | [
"def",
"_iter_info",
"(",
"self",
",",
"niter",
",",
"level",
"=",
"logging",
".",
"INFO",
")",
":",
"max_mis",
"=",
"self",
".",
"iter_mis",
"[",
"niter",
"-",
"1",
"]",
"msg",
"=",
"' Iter {:<d}. max mismatch = {:8.7f}'",
".",
"format",
"(",
"niter",
... | Log iteration number and mismatch
Parameters
----------
level
logging level
Returns
-------
None | [
"Log",
"iteration",
"number",
"and",
"mismatch"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L181-L195 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.calc_inc | def calc_inc(self):
"""
Calculate the Newton incrementals for each step
Returns
-------
matrix
The solution to ``x = -A\\b``
"""
system = self.system
self.newton_call()
A = sparse([[system.dae.Fx, system.dae.Gx],
[... | python | def calc_inc(self):
"""
Calculate the Newton incrementals for each step
Returns
-------
matrix
The solution to ``x = -A\\b``
"""
system = self.system
self.newton_call()
A = sparse([[system.dae.Fx, system.dae.Gx],
[... | [
"def",
"calc_inc",
"(",
"self",
")",
":",
"system",
"=",
"self",
".",
"system",
"self",
".",
"newton_call",
"(",
")",
"A",
"=",
"sparse",
"(",
"[",
"[",
"system",
".",
"dae",
".",
"Fx",
",",
"system",
".",
"dae",
".",
"Gx",
"]",
",",
"[",
"syst... | Calculate the Newton incrementals for each step
Returns
-------
matrix
The solution to ``x = -A\\b`` | [
"Calculate",
"the",
"Newton",
"incrementals",
"for",
"each",
"step"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L197-L228 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.newton_call | def newton_call(self):
"""
Function calls for Newton power flow
Returns
-------
None
"""
# system = self.system
# exec(system.call.newton)
system = self.system
dae = self.system.dae
system.dae.init_fg()
system.dae.reset_... | python | def newton_call(self):
"""
Function calls for Newton power flow
Returns
-------
None
"""
# system = self.system
# exec(system.call.newton)
system = self.system
dae = self.system.dae
system.dae.init_fg()
system.dae.reset_... | [
"def",
"newton_call",
"(",
"self",
")",
":",
"# system = self.system",
"# exec(system.call.newton)",
"system",
"=",
"self",
".",
"system",
"dae",
"=",
"self",
".",
"system",
".",
"dae",
"system",
".",
"dae",
".",
"init_fg",
"(",
")",
"system",
".",
"dae",
... | Function calls for Newton power flow
Returns
-------
None | [
"Function",
"calls",
"for",
"Newton",
"power",
"flow"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L230-L288 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.post | def post(self):
"""
Post processing for solved systems.
Store load, generation data on buses.
Store reactive power generation on PVs and slack generators.
Calculate series flows and area flows.
Returns
-------
None
"""
if not self.solved:... | python | def post(self):
"""
Post processing for solved systems.
Store load, generation data on buses.
Store reactive power generation on PVs and slack generators.
Calculate series flows and area flows.
Returns
-------
None
"""
if not self.solved:... | [
"def",
"post",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"solved",
":",
"return",
"system",
"=",
"self",
".",
"system",
"exec",
"(",
"system",
".",
"call",
".",
"pfload",
")",
"system",
".",
"Bus",
".",
"Pl",
"=",
"system",
".",
"dae",
"."... | Post processing for solved systems.
Store load, generation data on buses.
Store reactive power generation on PVs and slack generators.
Calculate series flows and area flows.
Returns
-------
None | [
"Post",
"processing",
"for",
"solved",
"systems",
"."
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L290-L323 |
cuihantao/andes | andes/routines/pflow.py | PFLOW.fdpf | def fdpf(self):
"""
Fast Decoupled Power Flow
Returns
-------
bool, int
Success flag, number of iterations
"""
system = self.system
# general settings
self.niter = 1
iter_max = self.config.maxit
self.solved = True
... | python | def fdpf(self):
"""
Fast Decoupled Power Flow
Returns
-------
bool, int
Success flag, number of iterations
"""
system = self.system
# general settings
self.niter = 1
iter_max = self.config.maxit
self.solved = True
... | [
"def",
"fdpf",
"(",
"self",
")",
":",
"system",
"=",
"self",
".",
"system",
"# general settings",
"self",
".",
"niter",
"=",
"1",
"iter_max",
"=",
"self",
".",
"config",
".",
"maxit",
"self",
".",
"solved",
"=",
"True",
"tol",
"=",
"self",
".",
"conf... | Fast Decoupled Power Flow
Returns
-------
bool, int
Success flag, number of iterations | [
"Fast",
"Decoupled",
"Power",
"Flow"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/routines/pflow.py#L325-L407 |
cuihantao/andes | andes/models/pv.py | PV.init0 | def init0(self, dae):
"""
Set initial voltage and reactive power for PQ.
Overwrites Bus.voltage values
"""
dae.y[self.v] = self.v0
dae.y[self.q] = mul(self.u, self.qg) | python | def init0(self, dae):
"""
Set initial voltage and reactive power for PQ.
Overwrites Bus.voltage values
"""
dae.y[self.v] = self.v0
dae.y[self.q] = mul(self.u, self.qg) | [
"def",
"init0",
"(",
"self",
",",
"dae",
")",
":",
"dae",
".",
"y",
"[",
"self",
".",
"v",
"]",
"=",
"self",
".",
"v0",
"dae",
".",
"y",
"[",
"self",
".",
"q",
"]",
"=",
"mul",
"(",
"self",
".",
"u",
",",
"self",
".",
"qg",
")"
] | Set initial voltage and reactive power for PQ.
Overwrites Bus.voltage values | [
"Set",
"initial",
"voltage",
"and",
"reactive",
"power",
"for",
"PQ",
".",
"Overwrites",
"Bus",
".",
"voltage",
"values"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pv.py#L99-L105 |
cuihantao/andes | andes/models/pv.py | PV.disable_gen | def disable_gen(self, idx):
"""
Disable a PV element for TDS
Parameters
----------
idx
Returns
-------
"""
self.u[self.uid[idx]] = 0
self.system.dae.factorize = True | python | def disable_gen(self, idx):
"""
Disable a PV element for TDS
Parameters
----------
idx
Returns
-------
"""
self.u[self.uid[idx]] = 0
self.system.dae.factorize = True | [
"def",
"disable_gen",
"(",
"self",
",",
"idx",
")",
":",
"self",
".",
"u",
"[",
"self",
".",
"uid",
"[",
"idx",
"]",
"]",
"=",
"0",
"self",
".",
"system",
".",
"dae",
".",
"factorize",
"=",
"True"
] | Disable a PV element for TDS
Parameters
----------
idx
Returns
------- | [
"Disable",
"a",
"PV",
"element",
"for",
"TDS"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pv.py#L172-L185 |
cuihantao/andes | andes/models/pq.py | PQ.init0 | def init0(self, dae):
"""Set initial p and q for power flow"""
self.p0 = matrix(self.p, (self.n, 1), 'd')
self.q0 = matrix(self.q, (self.n, 1), 'd') | python | def init0(self, dae):
"""Set initial p and q for power flow"""
self.p0 = matrix(self.p, (self.n, 1), 'd')
self.q0 = matrix(self.q, (self.n, 1), 'd') | [
"def",
"init0",
"(",
"self",
",",
"dae",
")",
":",
"self",
".",
"p0",
"=",
"matrix",
"(",
"self",
".",
"p",
",",
"(",
"self",
".",
"n",
",",
"1",
")",
",",
"'d'",
")",
"self",
".",
"q0",
"=",
"matrix",
"(",
"self",
".",
"q",
",",
"(",
"se... | Set initial p and q for power flow | [
"Set",
"initial",
"p",
"and",
"q",
"for",
"power",
"flow"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pq.py#L62-L65 |
cuihantao/andes | andes/models/pq.py | PQ.init1 | def init1(self, dae):
"""Set initial voltage for time domain simulation"""
self.v0 = matrix(dae.y[self.v]) | python | def init1(self, dae):
"""Set initial voltage for time domain simulation"""
self.v0 = matrix(dae.y[self.v]) | [
"def",
"init1",
"(",
"self",
",",
"dae",
")",
":",
"self",
".",
"v0",
"=",
"matrix",
"(",
"dae",
".",
"y",
"[",
"self",
".",
"v",
"]",
")"
] | Set initial voltage for time domain simulation | [
"Set",
"initial",
"voltage",
"for",
"time",
"domain",
"simulation"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/pq.py#L67-L69 |
DiamondLightSource/python-workflows | workflows/contrib/status_monitor.py | Monitor.update_status | def update_status(self, header, message):
"""Process incoming status message. Acquire lock for status dictionary before updating."""
with self._lock:
if self.message_box:
self.message_box.erase()
self.message_box.move(0, 0)
for n, field in enum... | python | def update_status(self, header, message):
"""Process incoming status message. Acquire lock for status dictionary before updating."""
with self._lock:
if self.message_box:
self.message_box.erase()
self.message_box.move(0, 0)
for n, field in enum... | [
"def",
"update_status",
"(",
"self",
",",
"header",
",",
"message",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"self",
".",
"message_box",
":",
"self",
".",
"message_box",
".",
"erase",
"(",
")",
"self",
".",
"message_box",
".",
"move",
"(",
... | Process incoming status message. Acquire lock for status dictionary before updating. | [
"Process",
"incoming",
"status",
"message",
".",
"Acquire",
"lock",
"for",
"status",
"dictionary",
"before",
"updating",
"."
] | train | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L46-L73 |
DiamondLightSource/python-workflows | workflows/contrib/status_monitor.py | Monitor._redraw_screen | def _redraw_screen(self, stdscr):
"""Redraw screen. This could be to initialize, or to redraw after resizing."""
with self._lock:
stdscr.clear()
stdscr.addstr(
0, 0, "workflows service monitor -- quit with Ctrl+C", curses.A_BOLD
)
stdscr.re... | python | def _redraw_screen(self, stdscr):
"""Redraw screen. This could be to initialize, or to redraw after resizing."""
with self._lock:
stdscr.clear()
stdscr.addstr(
0, 0, "workflows service monitor -- quit with Ctrl+C", curses.A_BOLD
)
stdscr.re... | [
"def",
"_redraw_screen",
"(",
"self",
",",
"stdscr",
")",
":",
"with",
"self",
".",
"_lock",
":",
"stdscr",
".",
"clear",
"(",
")",
"stdscr",
".",
"addstr",
"(",
"0",
",",
"0",
",",
"\"workflows service monitor -- quit with Ctrl+C\"",
",",
"curses",
".",
"... | Redraw screen. This could be to initialize, or to redraw after resizing. | [
"Redraw",
"screen",
".",
"This",
"could",
"be",
"to",
"initialize",
"or",
"to",
"redraw",
"after",
"resizing",
"."
] | train | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L96-L108 |
DiamondLightSource/python-workflows | workflows/contrib/status_monitor.py | Monitor._erase_card | def _erase_card(self, number):
"""Destroy cards with this or higher number."""
with self._lock:
if number < (len(self.cards) - 1):
self._erase_card(number + 1)
if number > (len(self.cards) - 1):
return
max_cards_horiz = int(curses.COLS ... | python | def _erase_card(self, number):
"""Destroy cards with this or higher number."""
with self._lock:
if number < (len(self.cards) - 1):
self._erase_card(number + 1)
if number > (len(self.cards) - 1):
return
max_cards_horiz = int(curses.COLS ... | [
"def",
"_erase_card",
"(",
"self",
",",
"number",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"number",
"<",
"(",
"len",
"(",
"self",
".",
"cards",
")",
"-",
"1",
")",
":",
"self",
".",
"_erase_card",
"(",
"number",
"+",
"1",
")",
"if",
... | Destroy cards with this or higher number. | [
"Destroy",
"cards",
"with",
"this",
"or",
"higher",
"number",
"."
] | train | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L128-L144 |
DiamondLightSource/python-workflows | workflows/contrib/status_monitor.py | Monitor._run | def _run(self, stdscr):
"""Start the actual service monitor"""
with self._lock:
curses.use_default_colors()
curses.curs_set(False)
curses.init_pair(1, curses.COLOR_RED, -1)
curses.init_pair(2, curses.COLOR_BLACK, -1)
curses.init_pair(3, curses.... | python | def _run(self, stdscr):
"""Start the actual service monitor"""
with self._lock:
curses.use_default_colors()
curses.curs_set(False)
curses.init_pair(1, curses.COLOR_RED, -1)
curses.init_pair(2, curses.COLOR_BLACK, -1)
curses.init_pair(3, curses.... | [
"def",
"_run",
"(",
"self",
",",
"stdscr",
")",
":",
"with",
"self",
".",
"_lock",
":",
"curses",
".",
"use_default_colors",
"(",
")",
"curses",
".",
"curs_set",
"(",
"False",
")",
"curses",
".",
"init_pair",
"(",
"1",
",",
"curses",
".",
"COLOR_RED",
... | Start the actual service monitor | [
"Start",
"the",
"actual",
"service",
"monitor"
] | train | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/status_monitor.py#L146-L217 |
cuihantao/andes | andes/models/vsc.py | VSC.switch | def switch(self, idx, control):
"""Switch a single control of <idx>"""
old = None
new = None
if control == 'Q':
if self.PQ[idx] == 1:
old = 'PQ'
new = 'PV'
elif self.vQ[idx] == 1:
old = 'vQ'
new = 'vV... | python | def switch(self, idx, control):
"""Switch a single control of <idx>"""
old = None
new = None
if control == 'Q':
if self.PQ[idx] == 1:
old = 'PQ'
new = 'PV'
elif self.vQ[idx] == 1:
old = 'vQ'
new = 'vV... | [
"def",
"switch",
"(",
"self",
",",
"idx",
",",
"control",
")",
":",
"old",
"=",
"None",
"new",
"=",
"None",
"if",
"control",
"==",
"'Q'",
":",
"if",
"self",
".",
"PQ",
"[",
"idx",
"]",
"==",
"1",
":",
"old",
"=",
"'PQ'",
"new",
"=",
"'PV'",
"... | Switch a single control of <idx> | [
"Switch",
"a",
"single",
"control",
"of",
"<idx",
">"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/vsc.py#L279-L313 |
cuihantao/andes | andes/models/vsc.py | VSC.disable | def disable(self, idx):
"""Disable an element and reset the outputs"""
if idx not in self.uid.keys():
self.log('Element index {0} does not exist.'.format(idx))
return
self.u[self.uid[idx]] = 0 | python | def disable(self, idx):
"""Disable an element and reset the outputs"""
if idx not in self.uid.keys():
self.log('Element index {0} does not exist.'.format(idx))
return
self.u[self.uid[idx]] = 0 | [
"def",
"disable",
"(",
"self",
",",
"idx",
")",
":",
"if",
"idx",
"not",
"in",
"self",
".",
"uid",
".",
"keys",
"(",
")",
":",
"self",
".",
"log",
"(",
"'Element index {0} does not exist.'",
".",
"format",
"(",
"idx",
")",
")",
"return",
"self",
".",... | Disable an element and reset the outputs | [
"Disable",
"an",
"element",
"and",
"reset",
"the",
"outputs"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/vsc.py#L437-L442 |
cuihantao/andes | andes/config/base.py | ConfigBase.get_alt | def get_alt(self, option):
"""
Return the alternative values of an option
Parameters
----------
option: str
option name
Returns
-------
str
a string of alternative options
"""
assert hasattr(self, option)
... | python | def get_alt(self, option):
"""
Return the alternative values of an option
Parameters
----------
option: str
option name
Returns
-------
str
a string of alternative options
"""
assert hasattr(self, option)
... | [
"def",
"get_alt",
"(",
"self",
",",
"option",
")",
":",
"assert",
"hasattr",
"(",
"self",
",",
"option",
")",
"alt",
"=",
"option",
"+",
"'_alt'",
"if",
"not",
"hasattr",
"(",
"self",
",",
"alt",
")",
":",
"return",
"''",
"return",
"', '",
".",
"jo... | Return the alternative values of an option
Parameters
----------
option: str
option name
Returns
-------
str
a string of alternative options | [
"Return",
"the",
"alternative",
"values",
"of",
"an",
"option"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L36-L56 |
cuihantao/andes | andes/config/base.py | ConfigBase.doc | def doc(self, export='plain'):
"""
Dump help document for setting classes
"""
rows = []
title = '<{:s}> config options'.format(self.__class__.__name__)
table = Tab(export=export, title=title)
for opt in sorted(self.config_descr):
if hasattr(self, opt)... | python | def doc(self, export='plain'):
"""
Dump help document for setting classes
"""
rows = []
title = '<{:s}> config options'.format(self.__class__.__name__)
table = Tab(export=export, title=title)
for opt in sorted(self.config_descr):
if hasattr(self, opt)... | [
"def",
"doc",
"(",
"self",
",",
"export",
"=",
"'plain'",
")",
":",
"rows",
"=",
"[",
"]",
"title",
"=",
"'<{:s}> config options'",
".",
"format",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"table",
"=",
"Tab",
"(",
"export",
"=",
"export",
... | Dump help document for setting classes | [
"Dump",
"help",
"document",
"for",
"setting",
"classes"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L58-L80 |
cuihantao/andes | andes/config/base.py | ConfigBase.dump_conf | def dump_conf(self, conf=None):
"""
Dump settings to an rc config file
Parameters
----------
conf
configparser.ConfigParser() object
Returns
-------
None
"""
if conf is None:
conf = configparser.ConfigParser()
... | python | def dump_conf(self, conf=None):
"""
Dump settings to an rc config file
Parameters
----------
conf
configparser.ConfigParser() object
Returns
-------
None
"""
if conf is None:
conf = configparser.ConfigParser()
... | [
"def",
"dump_conf",
"(",
"self",
",",
"conf",
"=",
"None",
")",
":",
"if",
"conf",
"is",
"None",
":",
"conf",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"tab",
"=",
"self",
".",
"__class__",
".",
"__name__",
"conf",
"[",
"tab",
"]",
"=",
"... | Dump settings to an rc config file
Parameters
----------
conf
configparser.ConfigParser() object
Returns
-------
None | [
"Dump",
"settings",
"to",
"an",
"rc",
"config",
"file"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L82-L107 |
cuihantao/andes | andes/config/base.py | ConfigBase.load_config | def load_config(self, conf):
"""
Load configurations from an rc file
Parameters
----------
rc: str
path to the rc file
Returns
-------
None
"""
section = self.__class__.__name__
if section not in conf.sections():
... | python | def load_config(self, conf):
"""
Load configurations from an rc file
Parameters
----------
rc: str
path to the rc file
Returns
-------
None
"""
section = self.__class__.__name__
if section not in conf.sections():
... | [
"def",
"load_config",
"(",
"self",
",",
"conf",
")",
":",
"section",
"=",
"self",
".",
"__class__",
".",
"__name__",
"if",
"section",
"not",
"in",
"conf",
".",
"sections",
"(",
")",
":",
"logger",
".",
"debug",
"(",
"'Config section {} not in rc file'",
".... | Load configurations from an rc file
Parameters
----------
rc: str
path to the rc file
Returns
-------
None | [
"Load",
"configurations",
"from",
"an",
"rc",
"file"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/config/base.py#L109-L146 |
DiamondLightSource/python-workflows | workflows/frontend/utilization.py | UtilizationStatistics.update_status | def update_status(self, new_status):
"""Record a status change with a current timestamp."""
timestamp = time.time()
self.status_history[-1]["end"] = timestamp
self.status_history.append(
{"start": timestamp, "end": None, "status": new_status}
) | python | def update_status(self, new_status):
"""Record a status change with a current timestamp."""
timestamp = time.time()
self.status_history[-1]["end"] = timestamp
self.status_history.append(
{"start": timestamp, "end": None, "status": new_status}
) | [
"def",
"update_status",
"(",
"self",
",",
"new_status",
")",
":",
"timestamp",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"status_history",
"[",
"-",
"1",
"]",
"[",
"\"end\"",
"]",
"=",
"timestamp",
"self",
".",
"status_history",
".",
"append",
"... | Record a status change with a current timestamp. | [
"Record",
"a",
"status",
"change",
"with",
"a",
"current",
"timestamp",
"."
] | train | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/utilization.py#L20-L26 |
DiamondLightSource/python-workflows | workflows/frontend/utilization.py | UtilizationStatistics.report | def report(self):
"""Return a dictionary of different status codes and the percentage of time
spent in each throughout the last summation_period seconds.
Truncate the aggregated history appropriately."""
timestamp = time.time()
cutoff = timestamp - self.period
truncate = ... | python | def report(self):
"""Return a dictionary of different status codes and the percentage of time
spent in each throughout the last summation_period seconds.
Truncate the aggregated history appropriately."""
timestamp = time.time()
cutoff = timestamp - self.period
truncate = ... | [
"def",
"report",
"(",
"self",
")",
":",
"timestamp",
"=",
"time",
".",
"time",
"(",
")",
"cutoff",
"=",
"timestamp",
"-",
"self",
".",
"period",
"truncate",
"=",
"0",
"summary",
"=",
"{",
"}",
"for",
"event",
"in",
"self",
".",
"status_history",
"[",... | Return a dictionary of different status codes and the percentage of time
spent in each throughout the last summation_period seconds.
Truncate the aggregated history appropriately. | [
"Return",
"a",
"dictionary",
"of",
"different",
"status",
"codes",
"and",
"the",
"percentage",
"of",
"time",
"spent",
"in",
"each",
"throughout",
"the",
"last",
"summation_period",
"seconds",
".",
"Truncate",
"the",
"aggregated",
"history",
"appropriately",
"."
] | train | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/utilization.py#L28-L54 |
DiamondLightSource/python-workflows | workflows/util/__init__.py | generate_unique_host_id | def generate_unique_host_id():
"""Generate a unique ID, that is somewhat guaranteed to be unique among all
instances running at the same time."""
host = ".".join(reversed(socket.gethostname().split(".")))
pid = os.getpid()
return "%s.%d" % (host, pid) | python | def generate_unique_host_id():
"""Generate a unique ID, that is somewhat guaranteed to be unique among all
instances running at the same time."""
host = ".".join(reversed(socket.gethostname().split(".")))
pid = os.getpid()
return "%s.%d" % (host, pid) | [
"def",
"generate_unique_host_id",
"(",
")",
":",
"host",
"=",
"\".\"",
".",
"join",
"(",
"reversed",
"(",
"socket",
".",
"gethostname",
"(",
")",
".",
"split",
"(",
"\".\"",
")",
")",
")",
"pid",
"=",
"os",
".",
"getpid",
"(",
")",
"return",
"\"%s.%d... | Generate a unique ID, that is somewhat guaranteed to be unique among all
instances running at the same time. | [
"Generate",
"a",
"unique",
"ID",
"that",
"is",
"somewhat",
"guaranteed",
"to",
"be",
"unique",
"among",
"all",
"instances",
"running",
"at",
"the",
"same",
"time",
"."
] | train | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/util/__init__.py#L7-L12 |
cuihantao/andes | andes/models/governor.py | GovernorBase.data_to_sys_base | def data_to_sys_base(self):
"""Custom system base conversion function"""
if not self.n or self._flags['sysbase'] is True:
return
self.copy_data_ext(model='Synchronous', field='Sn', dest='Sn', idx=self.gen)
super(GovernorBase, self).data_to_sys_base()
self._store['R']... | python | def data_to_sys_base(self):
"""Custom system base conversion function"""
if not self.n or self._flags['sysbase'] is True:
return
self.copy_data_ext(model='Synchronous', field='Sn', dest='Sn', idx=self.gen)
super(GovernorBase, self).data_to_sys_base()
self._store['R']... | [
"def",
"data_to_sys_base",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"n",
"or",
"self",
".",
"_flags",
"[",
"'sysbase'",
"]",
"is",
"True",
":",
"return",
"self",
".",
"copy_data_ext",
"(",
"model",
"=",
"'Synchronous'",
",",
"field",
"=",
"'Sn'... | Custom system base conversion function | [
"Custom",
"system",
"base",
"conversion",
"function"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/governor.py#L52-L61 |
cuihantao/andes | andes/models/governor.py | GovernorBase.data_to_elem_base | def data_to_elem_base(self):
"""Custom system base unconversion function"""
if not self.n or self._flags['sysbase'] is False:
return
self.R = mul(self.R, self.Sn) / self.system.mva
super(GovernorBase, self).data_to_elem_base() | python | def data_to_elem_base(self):
"""Custom system base unconversion function"""
if not self.n or self._flags['sysbase'] is False:
return
self.R = mul(self.R, self.Sn) / self.system.mva
super(GovernorBase, self).data_to_elem_base() | [
"def",
"data_to_elem_base",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"n",
"or",
"self",
".",
"_flags",
"[",
"'sysbase'",
"]",
"is",
"False",
":",
"return",
"self",
".",
"R",
"=",
"mul",
"(",
"self",
".",
"R",
",",
"self",
".",
"Sn",
")",
... | Custom system base unconversion function | [
"Custom",
"system",
"base",
"unconversion",
"function"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/governor.py#L63-L68 |
cuihantao/andes | andes/variables/fileman.py | add_suffix | def add_suffix(fullname, suffix):
""" Add suffix to a full file name"""
name, ext = os.path.splitext(fullname)
return name + '_' + suffix + ext | python | def add_suffix(fullname, suffix):
""" Add suffix to a full file name"""
name, ext = os.path.splitext(fullname)
return name + '_' + suffix + ext | [
"def",
"add_suffix",
"(",
"fullname",
",",
"suffix",
")",
":",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"fullname",
")",
"return",
"name",
"+",
"'_'",
"+",
"suffix",
"+",
"ext"
] | Add suffix to a full file name | [
"Add",
"suffix",
"to",
"a",
"full",
"file",
"name"
] | train | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/fileman.py#L121-L124 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.