repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
rwl/pylon | pylon/ac_pf.py | FastDecoupledPF._q_iteration | def _q_iteration(self, Q, Bpp_solver, Vm, Va, pq):
""" Performs a Q iteration, updates Vm.
"""
dVm = -Bpp_solver.solve(Q)
# Update voltage.
Vm[pq] = Vm[pq] + dVm
V = Vm * exp(1j * Va)
return V, Vm, Va | python | def _q_iteration(self, Q, Bpp_solver, Vm, Va, pq):
""" Performs a Q iteration, updates Vm.
"""
dVm = -Bpp_solver.solve(Q)
# Update voltage.
Vm[pq] = Vm[pq] + dVm
V = Vm * exp(1j * Va)
return V, Vm, Va | [
"def",
"_q_iteration",
"(",
"self",
",",
"Q",
",",
"Bpp_solver",
",",
"Vm",
",",
"Va",
",",
"pq",
")",
":",
"dVm",
"=",
"-",
"Bpp_solver",
".",
"solve",
"(",
"Q",
")",
"# Update voltage.",
"Vm",
"[",
"pq",
"]",
"=",
"Vm",
"[",
"pq",
"]",
"+",
"... | Performs a Q iteration, updates Vm. | [
"Performs",
"a",
"Q",
"iteration",
"updates",
"Vm",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ac_pf.py#L494-L503 | train |
melizalab/libtfr | examples/tfr_tm.py | fmsin | def fmsin(N, fnormin=0.05, fnormax=0.45, period=None, t0=None, fnorm0=0.25, pm1=1):
"""
Signal with sinusoidal frequency modulation.
generates a frequency modulation with a sinusoidal frequency.
This sinusoidal modulation is designed such that the instantaneous
frequency at time T0 is equal to FNOR... | python | def fmsin(N, fnormin=0.05, fnormax=0.45, period=None, t0=None, fnorm0=0.25, pm1=1):
"""
Signal with sinusoidal frequency modulation.
generates a frequency modulation with a sinusoidal frequency.
This sinusoidal modulation is designed such that the instantaneous
frequency at time T0 is equal to FNOR... | [
"def",
"fmsin",
"(",
"N",
",",
"fnormin",
"=",
"0.05",
",",
"fnormax",
"=",
"0.45",
",",
"period",
"=",
"None",
",",
"t0",
"=",
"None",
",",
"fnorm0",
"=",
"0.25",
",",
"pm1",
"=",
"1",
")",
":",
"if",
"period",
"==",
"None",
":",
"period",
"="... | Signal with sinusoidal frequency modulation.
generates a frequency modulation with a sinusoidal frequency.
This sinusoidal modulation is designed such that the instantaneous
frequency at time T0 is equal to FNORM0, and the ambiguity between
increasing or decreasing frequency is solved by PM1.
N ... | [
"Signal",
"with",
"sinusoidal",
"frequency",
"modulation",
"."
] | 9f7e7705793d258a0b205f185b20e3bbcda473da | https://github.com/melizalab/libtfr/blob/9f7e7705793d258a0b205f185b20e3bbcda473da/examples/tfr_tm.py#L14-L56 | train |
rwl/pylon | pylon/io/rdf.py | RDFReader._parse_rdf | def _parse_rdf(self, file):
""" Returns a case from the given file.
"""
store = Graph()
store.parse(file)
print len(store) | python | def _parse_rdf(self, file):
""" Returns a case from the given file.
"""
store = Graph()
store.parse(file)
print len(store) | [
"def",
"_parse_rdf",
"(",
"self",
",",
"file",
")",
":",
"store",
"=",
"Graph",
"(",
")",
"store",
".",
"parse",
"(",
"file",
")",
"print",
"len",
"(",
"store",
")"
] | Returns a case from the given file. | [
"Returns",
"a",
"case",
"from",
"the",
"given",
"file",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/rdf.py#L72-L78 | train |
finklabs/metrics | metrics/plugins.py | load_plugins | def load_plugins(group='metrics.plugin.10'):
"""Load and installed metrics plugins.
"""
# on using entrypoints:
# http://stackoverflow.com/questions/774824/explain-python-entry-points
file_processors = []
build_processors = []
for ep in pkg_resources.iter_entry_points(group, name=None):
... | python | def load_plugins(group='metrics.plugin.10'):
"""Load and installed metrics plugins.
"""
# on using entrypoints:
# http://stackoverflow.com/questions/774824/explain-python-entry-points
file_processors = []
build_processors = []
for ep in pkg_resources.iter_entry_points(group, name=None):
... | [
"def",
"load_plugins",
"(",
"group",
"=",
"'metrics.plugin.10'",
")",
":",
"# on using entrypoints:",
"# http://stackoverflow.com/questions/774824/explain-python-entry-points",
"file_processors",
"=",
"[",
"]",
"build_processors",
"=",
"[",
"]",
"for",
"ep",
"in",
"pkg_reso... | Load and installed metrics plugins. | [
"Load",
"and",
"installed",
"metrics",
"plugins",
"."
] | fd9974af498831664b9ae8e8f3834e1ec2e8a699 | https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/plugins.py#L11-L25 | train |
rwl/pylon | pylon/main.py | read_case | def read_case(input, format=None):
""" Returns a case object from the given input file object. The data
format may be optionally specified.
"""
# Map of data file types to readers.
format_map = {"matpower": MATPOWERReader,
"psse": PSSEReader, "pickle": PickleReader}
# Read case data.
... | python | def read_case(input, format=None):
""" Returns a case object from the given input file object. The data
format may be optionally specified.
"""
# Map of data file types to readers.
format_map = {"matpower": MATPOWERReader,
"psse": PSSEReader, "pickle": PickleReader}
# Read case data.
... | [
"def",
"read_case",
"(",
"input",
",",
"format",
"=",
"None",
")",
":",
"# Map of data file types to readers.",
"format_map",
"=",
"{",
"\"matpower\"",
":",
"MATPOWERReader",
",",
"\"psse\"",
":",
"PSSEReader",
",",
"\"pickle\"",
":",
"PickleReader",
"}",
"# Read ... | Returns a case object from the given input file object. The data
format may be optionally specified. | [
"Returns",
"a",
"case",
"object",
"from",
"the",
"given",
"input",
"file",
"object",
".",
"The",
"data",
"format",
"may",
"be",
"optionally",
"specified",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/main.py#L48-L74 | train |
rwl/pylon | pylon/main.py | detect_data_file | def detect_data_file(input, file_name=""):
""" Detects the format of a network data file according to the
file extension and the header.
"""
_, ext = os.path.splitext(file_name)
if ext == ".m":
line = input.readline() # first line
if line.startswith("function"):
type... | python | def detect_data_file(input, file_name=""):
""" Detects the format of a network data file according to the
file extension and the header.
"""
_, ext = os.path.splitext(file_name)
if ext == ".m":
line = input.readline() # first line
if line.startswith("function"):
type... | [
"def",
"detect_data_file",
"(",
"input",
",",
"file_name",
"=",
"\"\"",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"file_name",
")",
"if",
"ext",
"==",
"\".m\"",
":",
"line",
"=",
"input",
".",
"readline",
"(",
")",
"#... | Detects the format of a network data file according to the
file extension and the header. | [
"Detects",
"the",
"format",
"of",
"a",
"network",
"data",
"file",
"according",
"to",
"the",
"file",
"extension",
"and",
"the",
"header",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/main.py#L80-L109 | train |
rwl/pylon | pylon/io/dot.py | DotWriter.write | def write(self, file_or_filename, prog=None, format='xdot'):
""" Writes the case data in Graphviz DOT language.
The format 'raw' is used to dump the Dot representation of the Case
object, without further processing. The output can be processed by any
of graphviz tools, defined in 'prog'... | python | def write(self, file_or_filename, prog=None, format='xdot'):
""" Writes the case data in Graphviz DOT language.
The format 'raw' is used to dump the Dot representation of the Case
object, without further processing. The output can be processed by any
of graphviz tools, defined in 'prog'... | [
"def",
"write",
"(",
"self",
",",
"file_or_filename",
",",
"prog",
"=",
"None",
",",
"format",
"=",
"'xdot'",
")",
":",
"if",
"prog",
"is",
"None",
":",
"file",
"=",
"super",
"(",
"DotWriter",
",",
"self",
")",
".",
"write",
"(",
"file_or_filename",
... | Writes the case data in Graphviz DOT language.
The format 'raw' is used to dump the Dot representation of the Case
object, without further processing. The output can be processed by any
of graphviz tools, defined in 'prog'. | [
"Writes",
"the",
"case",
"data",
"in",
"Graphviz",
"DOT",
"language",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/dot.py#L71-L100 | train |
rwl/pylon | pylon/io/dot.py | DotWriter.write_bus_data | def write_bus_data(self, file, padding=" "):
""" Writes bus data to file.
"""
for bus in self.case.buses:
attrs = ['%s="%s"' % (k, v) for k, v in self.bus_attr.iteritems()]
# attrs.insert(0, 'label="%s"' % bus.name)
attr_str = ", ".join(attrs)
f... | python | def write_bus_data(self, file, padding=" "):
""" Writes bus data to file.
"""
for bus in self.case.buses:
attrs = ['%s="%s"' % (k, v) for k, v in self.bus_attr.iteritems()]
# attrs.insert(0, 'label="%s"' % bus.name)
attr_str = ", ".join(attrs)
f... | [
"def",
"write_bus_data",
"(",
"self",
",",
"file",
",",
"padding",
"=",
"\" \"",
")",
":",
"for",
"bus",
"in",
"self",
".",
"case",
".",
"buses",
":",
"attrs",
"=",
"[",
"'%s=\"%s\"'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
... | Writes bus data to file. | [
"Writes",
"bus",
"data",
"to",
"file",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/dot.py#L114-L122 | train |
rwl/pylon | pylon/io/dot.py | DotWriter.write_branch_data | def write_branch_data(self, file, padding=" "):
""" Writes branch data in Graphviz DOT language.
"""
attrs = ['%s="%s"' % (k,v) for k,v in self.branch_attr.iteritems()]
attr_str = ", ".join(attrs)
for br in self.case.branches:
file.write("%s%s -> %s [%s];\n" % \
... | python | def write_branch_data(self, file, padding=" "):
""" Writes branch data in Graphviz DOT language.
"""
attrs = ['%s="%s"' % (k,v) for k,v in self.branch_attr.iteritems()]
attr_str = ", ".join(attrs)
for br in self.case.branches:
file.write("%s%s -> %s [%s];\n" % \
... | [
"def",
"write_branch_data",
"(",
"self",
",",
"file",
",",
"padding",
"=",
"\" \"",
")",
":",
"attrs",
"=",
"[",
"'%s=\"%s\"'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"branch_attr",
".",
"iteritems",
"(",
")",
"]"... | Writes branch data in Graphviz DOT language. | [
"Writes",
"branch",
"data",
"in",
"Graphviz",
"DOT",
"language",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/dot.py#L125-L133 | train |
rwl/pylon | pylon/io/dot.py | DotWriter.write_generator_data | def write_generator_data(self, file, padding=" "):
""" Write generator data in Graphviz DOT language.
"""
attrs = ['%s="%s"' % (k, v) for k, v in self.gen_attr.iteritems()]
attr_str = ", ".join(attrs)
edge_attrs = ['%s="%s"' % (k,v) for k,v in {}.iteritems()]
edge_att... | python | def write_generator_data(self, file, padding=" "):
""" Write generator data in Graphviz DOT language.
"""
attrs = ['%s="%s"' % (k, v) for k, v in self.gen_attr.iteritems()]
attr_str = ", ".join(attrs)
edge_attrs = ['%s="%s"' % (k,v) for k,v in {}.iteritems()]
edge_att... | [
"def",
"write_generator_data",
"(",
"self",
",",
"file",
",",
"padding",
"=",
"\" \"",
")",
":",
"attrs",
"=",
"[",
"'%s=\"%s\"'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"gen_attr",
".",
"iteritems",
"(",
")",
"]"... | Write generator data in Graphviz DOT language. | [
"Write",
"generator",
"data",
"in",
"Graphviz",
"DOT",
"language",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/dot.py#L136-L151 | train |
rwl/pylon | pylon/io/dot.py | DotWriter.create | def create(self, dotdata, prog="dot", format="xdot"):
""" Creates and returns a representation of the graph using the
Graphviz layout program given by 'prog', according to the given format.
Writes the graph to a temporary dot file and processes it with the
program given by 'prog' (which... | python | def create(self, dotdata, prog="dot", format="xdot"):
""" Creates and returns a representation of the graph using the
Graphviz layout program given by 'prog', according to the given format.
Writes the graph to a temporary dot file and processes it with the
program given by 'prog' (which... | [
"def",
"create",
"(",
"self",
",",
"dotdata",
",",
"prog",
"=",
"\"dot\"",
",",
"format",
"=",
"\"xdot\"",
")",
":",
"import",
"os",
",",
"tempfile",
"from",
"dot2tex",
".",
"dotparsing",
"import",
"find_graphviz",
"# Map Graphviz executable names to their paths."... | Creates and returns a representation of the graph using the
Graphviz layout program given by 'prog', according to the given format.
Writes the graph to a temporary dot file and processes it with the
program given by 'prog' (which defaults to 'dot'), reading the output
and returning it a... | [
"Creates",
"and",
"returns",
"a",
"representation",
"of",
"the",
"graph",
"using",
"the",
"Graphviz",
"layout",
"program",
"given",
"by",
"prog",
"according",
"to",
"the",
"given",
"format",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/dot.py#L157-L235 | train |
finklabs/metrics | metrics/outputformat_xml.py | format | def format(file_metrics, build_metrics):
"""compute output in XML format."""
def indent(elem, level=0):
i = "\n" + level*" "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
... | python | def format(file_metrics, build_metrics):
"""compute output in XML format."""
def indent(elem, level=0):
i = "\n" + level*" "
if len(elem):
if not elem.text or not elem.text.strip():
elem.text = i + " "
if not elem.tail or not elem.tail.strip():
... | [
"def",
"format",
"(",
"file_metrics",
",",
"build_metrics",
")",
":",
"def",
"indent",
"(",
"elem",
",",
"level",
"=",
"0",
")",
":",
"i",
"=",
"\"\\n\"",
"+",
"level",
"*",
"\" \"",
"if",
"len",
"(",
"elem",
")",
":",
"if",
"not",
"elem",
".",
... | compute output in XML format. | [
"compute",
"output",
"in",
"XML",
"format",
"."
] | fd9974af498831664b9ae8e8f3834e1ec2e8a699 | https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/outputformat_xml.py#L16-L59 | train |
brunobord/tdaemon | tdaemon.py | ask | def ask(message='Are you sure? [y/N]'):
"""Asks the user his opinion."""
agree = False
answer = raw_input(message).lower()
if answer.startswith('y'):
agree = True
return agree | python | def ask(message='Are you sure? [y/N]'):
"""Asks the user his opinion."""
agree = False
answer = raw_input(message).lower()
if answer.startswith('y'):
agree = True
return agree | [
"def",
"ask",
"(",
"message",
"=",
"'Are you sure? [y/N]'",
")",
":",
"agree",
"=",
"False",
"answer",
"=",
"raw_input",
"(",
"message",
")",
".",
"lower",
"(",
")",
"if",
"answer",
".",
"startswith",
"(",
"'y'",
")",
":",
"agree",
"=",
"True",
"return... | Asks the user his opinion. | [
"Asks",
"the",
"user",
"his",
"opinion",
"."
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L45-L51 | train |
brunobord/tdaemon | tdaemon.py | main | def main(prog_args=None):
"""
What do you expect?
"""
if prog_args is None:
prog_args = sys.argv
parser = optparse.OptionParser()
parser.usage = """Usage: %[prog] [options] [<path>]"""
parser.add_option("-t", "--test-program", dest="test_program",
default="nose", help="speci... | python | def main(prog_args=None):
"""
What do you expect?
"""
if prog_args is None:
prog_args = sys.argv
parser = optparse.OptionParser()
parser.usage = """Usage: %[prog] [options] [<path>]"""
parser.add_option("-t", "--test-program", dest="test_program",
default="nose", help="speci... | [
"def",
"main",
"(",
"prog_args",
"=",
"None",
")",
":",
"if",
"prog_args",
"is",
"None",
":",
"prog_args",
"=",
"sys",
".",
"argv",
"parser",
"=",
"optparse",
".",
"OptionParser",
"(",
")",
"parser",
".",
"usage",
"=",
"\"\"\"Usage: %[prog] [options] [<path>... | What do you expect? | [
"What",
"do",
"you",
"expect?"
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L235-L288 | train |
brunobord/tdaemon | tdaemon.py | Watcher.check_configuration | def check_configuration(self, file_path, test_program, custom_args):
"""Checks if configuration is ok."""
# checking filepath
if not os.path.isdir(file_path):
raise InvalidFilePath("INVALID CONFIGURATION: file path %s is not a directory" %
os.path.abspath(file_path)
... | python | def check_configuration(self, file_path, test_program, custom_args):
"""Checks if configuration is ok."""
# checking filepath
if not os.path.isdir(file_path):
raise InvalidFilePath("INVALID CONFIGURATION: file path %s is not a directory" %
os.path.abspath(file_path)
... | [
"def",
"check_configuration",
"(",
"self",
",",
"file_path",
",",
"test_program",
",",
"custom_args",
")",
":",
"# checking filepath",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"file_path",
")",
":",
"raise",
"InvalidFilePath",
"(",
"\"INVALID CONFIGURA... | Checks if configuration is ok. | [
"Checks",
"if",
"configuration",
"is",
"ok",
"."
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L88-L101 | train |
brunobord/tdaemon | tdaemon.py | Watcher.check_dependencies | def check_dependencies(self):
"Checks if the test program is available in the python environnement"
if self.test_program == 'nose':
try:
import nose
except ImportError:
sys.exit('Nosetests is not available on your system. Please install it and try ... | python | def check_dependencies(self):
"Checks if the test program is available in the python environnement"
if self.test_program == 'nose':
try:
import nose
except ImportError:
sys.exit('Nosetests is not available on your system. Please install it and try ... | [
"def",
"check_dependencies",
"(",
"self",
")",
":",
"if",
"self",
".",
"test_program",
"==",
"'nose'",
":",
"try",
":",
"import",
"nose",
"except",
"ImportError",
":",
"sys",
".",
"exit",
"(",
"'Nosetests is not available on your system. Please install it and try to r... | Checks if the test program is available in the python environnement | [
"Checks",
"if",
"the",
"test",
"program",
"is",
"available",
"in",
"the",
"python",
"environnement"
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L103-L129 | train |
brunobord/tdaemon | tdaemon.py | Watcher.get_cmd | def get_cmd(self):
"""Returns the full command to be executed at runtime"""
cmd = None
if self.test_program in ('nose', 'nosetests'):
cmd = "nosetests %s" % self.file_path
elif self.test_program == 'django':
executable = "%s/manage.py" % self.file_path
... | python | def get_cmd(self):
"""Returns the full command to be executed at runtime"""
cmd = None
if self.test_program in ('nose', 'nosetests'):
cmd = "nosetests %s" % self.file_path
elif self.test_program == 'django':
executable = "%s/manage.py" % self.file_path
... | [
"def",
"get_cmd",
"(",
"self",
")",
":",
"cmd",
"=",
"None",
"if",
"self",
".",
"test_program",
"in",
"(",
"'nose'",
",",
"'nosetests'",
")",
":",
"cmd",
"=",
"\"nosetests %s\"",
"%",
"self",
".",
"file_path",
"elif",
"self",
".",
"test_program",
"==",
... | Returns the full command to be executed at runtime | [
"Returns",
"the",
"full",
"command",
"to",
"be",
"executed",
"at",
"runtime"
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L132-L164 | train |
brunobord/tdaemon | tdaemon.py | Watcher.include | def include(self, path):
"""Returns `True` if the file is not ignored"""
for extension in IGNORE_EXTENSIONS:
if path.endswith(extension):
return False
parts = path.split(os.path.sep)
for part in parts:
if part in self.ignore_dirs:
r... | python | def include(self, path):
"""Returns `True` if the file is not ignored"""
for extension in IGNORE_EXTENSIONS:
if path.endswith(extension):
return False
parts = path.split(os.path.sep)
for part in parts:
if part in self.ignore_dirs:
r... | [
"def",
"include",
"(",
"self",
",",
"path",
")",
":",
"for",
"extension",
"in",
"IGNORE_EXTENSIONS",
":",
"if",
"path",
".",
"endswith",
"(",
"extension",
")",
":",
"return",
"False",
"parts",
"=",
"path",
".",
"split",
"(",
"os",
".",
"path",
".",
"... | Returns `True` if the file is not ignored | [
"Returns",
"True",
"if",
"the",
"file",
"is",
"not",
"ignored"
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L167-L176 | train |
brunobord/tdaemon | tdaemon.py | Watcher.diff_list | def diff_list(self, list1, list2):
"""Extracts differences between lists. For debug purposes"""
for key in list1:
if key in list2 and list2[key] != list1[key]:
print key
elif key not in list2:
print key | python | def diff_list(self, list1, list2):
"""Extracts differences between lists. For debug purposes"""
for key in list1:
if key in list2 and list2[key] != list1[key]:
print key
elif key not in list2:
print key | [
"def",
"diff_list",
"(",
"self",
",",
"list1",
",",
"list2",
")",
":",
"for",
"key",
"in",
"list1",
":",
"if",
"key",
"in",
"list2",
"and",
"list2",
"[",
"key",
"]",
"!=",
"list1",
"[",
"key",
"]",
":",
"print",
"key",
"elif",
"key",
"not",
"in",... | Extracts differences between lists. For debug purposes | [
"Extracts",
"differences",
"between",
"lists",
".",
"For",
"debug",
"purposes"
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L205-L211 | train |
brunobord/tdaemon | tdaemon.py | Watcher.run | def run(self, cmd):
"""Runs the appropriate command"""
print datetime.datetime.now()
output = subprocess.Popen(cmd, shell=True)
output = output.communicate()[0]
print output | python | def run(self, cmd):
"""Runs the appropriate command"""
print datetime.datetime.now()
output = subprocess.Popen(cmd, shell=True)
output = output.communicate()[0]
print output | [
"def",
"run",
"(",
"self",
",",
"cmd",
")",
":",
"print",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"output",
"=",
"subprocess",
".",
"Popen",
"(",
"cmd",
",",
"shell",
"=",
"True",
")",
"output",
"=",
"output",
".",
"communicate",
"(",
")... | Runs the appropriate command | [
"Runs",
"the",
"appropriate",
"command"
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L213-L218 | train |
brunobord/tdaemon | tdaemon.py | Watcher.loop | def loop(self):
"""Main loop daemon."""
while True:
sleep(1)
new_file_list = self.walk(self.file_path, {})
if new_file_list != self.file_list:
if self.debug:
self.diff_list(new_file_list, self.file_list)
self.run_tes... | python | def loop(self):
"""Main loop daemon."""
while True:
sleep(1)
new_file_list = self.walk(self.file_path, {})
if new_file_list != self.file_list:
if self.debug:
self.diff_list(new_file_list, self.file_list)
self.run_tes... | [
"def",
"loop",
"(",
"self",
")",
":",
"while",
"True",
":",
"sleep",
"(",
"1",
")",
"new_file_list",
"=",
"self",
".",
"walk",
"(",
"self",
".",
"file_path",
",",
"{",
"}",
")",
"if",
"new_file_list",
"!=",
"self",
".",
"file_list",
":",
"if",
"sel... | Main loop daemon. | [
"Main",
"loop",
"daemon",
"."
] | 733b5bddb4b12bc3db326a192ce5606f28768307 | https://github.com/brunobord/tdaemon/blob/733b5bddb4b12bc3db326a192ce5606f28768307/tdaemon.py#L224-L233 | train |
finklabs/metrics | metrics/outputformat_json.py | format | def format(file_metrics, build_metrics):
"""compute output in JSON format."""
metrics = {'files': file_metrics}
if build_metrics:
metrics['build'] = build_metrics
body = json.dumps(metrics, sort_keys=True, indent=4) + '\n'
return body | python | def format(file_metrics, build_metrics):
"""compute output in JSON format."""
metrics = {'files': file_metrics}
if build_metrics:
metrics['build'] = build_metrics
body = json.dumps(metrics, sort_keys=True, indent=4) + '\n'
return body | [
"def",
"format",
"(",
"file_metrics",
",",
"build_metrics",
")",
":",
"metrics",
"=",
"{",
"'files'",
":",
"file_metrics",
"}",
"if",
"build_metrics",
":",
"metrics",
"[",
"'build'",
"]",
"=",
"build_metrics",
"body",
"=",
"json",
".",
"dumps",
"(",
"metri... | compute output in JSON format. | [
"compute",
"output",
"in",
"JSON",
"format",
"."
] | fd9974af498831664b9ae8e8f3834e1ec2e8a699 | https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/outputformat_json.py#L9-L15 | train |
rwl/pylon | contrib/cvxopf.py | split_linear_constraints | def split_linear_constraints(A, l, u):
""" Returns the linear equality and inequality constraints.
"""
ieq = []
igt = []
ilt = []
ibx = []
for i in range(len(l)):
if abs(u[i] - l[i]) <= EPS:
ieq.append(i)
elif (u[i] > 1e10) and (l[i] > -1e10):
igt.appe... | python | def split_linear_constraints(A, l, u):
""" Returns the linear equality and inequality constraints.
"""
ieq = []
igt = []
ilt = []
ibx = []
for i in range(len(l)):
if abs(u[i] - l[i]) <= EPS:
ieq.append(i)
elif (u[i] > 1e10) and (l[i] > -1e10):
igt.appe... | [
"def",
"split_linear_constraints",
"(",
"A",
",",
"l",
",",
"u",
")",
":",
"ieq",
"=",
"[",
"]",
"igt",
"=",
"[",
"]",
"ilt",
"=",
"[",
"]",
"ibx",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"l",
")",
")",
":",
"if",
"abs",
... | Returns the linear equality and inequality constraints. | [
"Returns",
"the",
"linear",
"equality",
"and",
"inequality",
"constraints",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L472-L496 | train |
rwl/pylon | contrib/cvxopf.py | dSbus_dV | def dSbus_dV(Y, V):
""" Computes the partial derivative of power injection w.r.t. voltage.
References:
Ray Zimmerman, "dSbus_dV.m", MATPOWER, version 3.2,
PSERC (Cornell), http://www.pserc.cornell.edu/matpower/
"""
I = Y * V
diagV = spdiag(V)
diagIbus = spdiag(I)
... | python | def dSbus_dV(Y, V):
""" Computes the partial derivative of power injection w.r.t. voltage.
References:
Ray Zimmerman, "dSbus_dV.m", MATPOWER, version 3.2,
PSERC (Cornell), http://www.pserc.cornell.edu/matpower/
"""
I = Y * V
diagV = spdiag(V)
diagIbus = spdiag(I)
... | [
"def",
"dSbus_dV",
"(",
"Y",
",",
"V",
")",
":",
"I",
"=",
"Y",
"*",
"V",
"diagV",
"=",
"spdiag",
"(",
"V",
")",
"diagIbus",
"=",
"spdiag",
"(",
"I",
")",
"diagVnorm",
"=",
"spdiag",
"(",
"div",
"(",
"V",
",",
"abs",
"(",
"V",
")",
")",
")"... | Computes the partial derivative of power injection w.r.t. voltage.
References:
Ray Zimmerman, "dSbus_dV.m", MATPOWER, version 3.2,
PSERC (Cornell), http://www.pserc.cornell.edu/matpower/ | [
"Computes",
"the",
"partial",
"derivative",
"of",
"power",
"injection",
"w",
".",
"r",
".",
"t",
".",
"voltage",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L502-L518 | train |
rwl/pylon | contrib/cvxopf.py | dIbr_dV | def dIbr_dV(Yf, Yt, V):
""" Computes partial derivatives of branch currents w.r.t. voltage.
Ray Zimmerman, "dIbr_dV.m", MATPOWER, version 4.0b1,
PSERC (Cornell), http://www.pserc.cornell.edu/matpower/
"""
# nb = len(V)
Vnorm = div(V, abs(V))
diagV = spdiag(V)
diagVnorm = spd... | python | def dIbr_dV(Yf, Yt, V):
""" Computes partial derivatives of branch currents w.r.t. voltage.
Ray Zimmerman, "dIbr_dV.m", MATPOWER, version 4.0b1,
PSERC (Cornell), http://www.pserc.cornell.edu/matpower/
"""
# nb = len(V)
Vnorm = div(V, abs(V))
diagV = spdiag(V)
diagVnorm = spd... | [
"def",
"dIbr_dV",
"(",
"Yf",
",",
"Yt",
",",
"V",
")",
":",
"# nb = len(V)",
"Vnorm",
"=",
"div",
"(",
"V",
",",
"abs",
"(",
"V",
")",
")",
"diagV",
"=",
"spdiag",
"(",
"V",
")",
"diagVnorm",
"=",
"spdiag",
"(",
"Vnorm",
")",
"dIf_dVa",
"=... | Computes partial derivatives of branch currents w.r.t. voltage.
Ray Zimmerman, "dIbr_dV.m", MATPOWER, version 4.0b1,
PSERC (Cornell), http://www.pserc.cornell.edu/matpower/ | [
"Computes",
"partial",
"derivatives",
"of",
"branch",
"currents",
"w",
".",
"r",
".",
"t",
".",
"voltage",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L524-L544 | train |
rwl/pylon | contrib/cvxopf.py | dSbr_dV | def dSbr_dV(Yf, Yt, V, buses, branches):
""" Computes the branch power flow vector and the partial derivative of
branch power flow w.r.t voltage.
"""
nl = len(branches)
nb = len(V)
f = matrix([l.from_bus._i for l in branches])
t = matrix([l.to_bus._i for l in branches])
# Compute c... | python | def dSbr_dV(Yf, Yt, V, buses, branches):
""" Computes the branch power flow vector and the partial derivative of
branch power flow w.r.t voltage.
"""
nl = len(branches)
nb = len(V)
f = matrix([l.from_bus._i for l in branches])
t = matrix([l.to_bus._i for l in branches])
# Compute c... | [
"def",
"dSbr_dV",
"(",
"Yf",
",",
"Yt",
",",
"V",
",",
"buses",
",",
"branches",
")",
":",
"nl",
"=",
"len",
"(",
"branches",
")",
"nb",
"=",
"len",
"(",
"V",
")",
"f",
"=",
"matrix",
"(",
"[",
"l",
".",
"from_bus",
".",
"_i",
"for",
"l",
"... | Computes the branch power flow vector and the partial derivative of
branch power flow w.r.t voltage. | [
"Computes",
"the",
"branch",
"power",
"flow",
"vector",
"and",
"the",
"partial",
"derivative",
"of",
"branch",
"power",
"flow",
"w",
".",
"r",
".",
"t",
"voltage",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L550-L593 | train |
rwl/pylon | contrib/cvxopf.py | dAbr_dV | def dAbr_dV(dSf_dVa, dSf_dVm, dSt_dVa, dSt_dVm, Sf, St):
""" Partial derivatives of squared flow magnitudes w.r.t voltage.
Computes partial derivatives of apparent power w.r.t active and
reactive power flows. Partial derivative must equal 1 for lines
with zero flow to avoid division by zer... | python | def dAbr_dV(dSf_dVa, dSf_dVm, dSt_dVa, dSt_dVm, Sf, St):
""" Partial derivatives of squared flow magnitudes w.r.t voltage.
Computes partial derivatives of apparent power w.r.t active and
reactive power flows. Partial derivative must equal 1 for lines
with zero flow to avoid division by zer... | [
"def",
"dAbr_dV",
"(",
"dSf_dVa",
",",
"dSf_dVm",
",",
"dSt_dVa",
",",
"dSt_dVm",
",",
"Sf",
",",
"St",
")",
":",
"dAf_dPf",
"=",
"spdiag",
"(",
"2",
"*",
"Sf",
".",
"real",
"(",
")",
")",
"dAf_dQf",
"=",
"spdiag",
"(",
"2",
"*",
"Sf",
".",
"im... | Partial derivatives of squared flow magnitudes w.r.t voltage.
Computes partial derivatives of apparent power w.r.t active and
reactive power flows. Partial derivative must equal 1 for lines
with zero flow to avoid division by zero errors (1 comes from
L'Hopital). | [
"Partial",
"derivatives",
"of",
"squared",
"flow",
"magnitudes",
"w",
".",
"r",
".",
"t",
"voltage",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L599-L621 | train |
rwl/pylon | contrib/cvxopf.py | d2Sbus_dV2 | def d2Sbus_dV2(Ybus, V, lam):
""" Computes 2nd derivatives of power injection w.r.t. voltage.
"""
n = len(V)
Ibus = Ybus * V
diaglam = spdiag(lam)
diagV = spdiag(V)
A = spmatrix(mul(lam, V), range(n), range(n))
B = Ybus * diagV
C = A * conj(B)
D = Ybus.H * diagV
E = conj(dia... | python | def d2Sbus_dV2(Ybus, V, lam):
""" Computes 2nd derivatives of power injection w.r.t. voltage.
"""
n = len(V)
Ibus = Ybus * V
diaglam = spdiag(lam)
diagV = spdiag(V)
A = spmatrix(mul(lam, V), range(n), range(n))
B = Ybus * diagV
C = A * conj(B)
D = Ybus.H * diagV
E = conj(dia... | [
"def",
"d2Sbus_dV2",
"(",
"Ybus",
",",
"V",
",",
"lam",
")",
":",
"n",
"=",
"len",
"(",
"V",
")",
"Ibus",
"=",
"Ybus",
"*",
"V",
"diaglam",
"=",
"spdiag",
"(",
"lam",
")",
"diagV",
"=",
"spdiag",
"(",
"V",
")",
"A",
"=",
"spmatrix",
"(",
"mul... | Computes 2nd derivatives of power injection w.r.t. voltage. | [
"Computes",
"2nd",
"derivatives",
"of",
"power",
"injection",
"w",
".",
"r",
".",
"t",
".",
"voltage",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L627-L648 | train |
rwl/pylon | contrib/cvxopf.py | d2Ibr_dV2 | def d2Ibr_dV2(Ybr, V, lam):
""" Computes 2nd derivatives of complex branch current w.r.t. voltage.
"""
nb = len(V)
diaginvVm = spdiag(div(matrix(1.0, (nb, 1)), abs(V)))
Haa = spdiag(mul(-(Ybr.T * lam), V))
Hva = -1j * Haa * diaginvVm
Hav = Hva
Hvv = spmatrix([], [], [], (nb, nb))
r... | python | def d2Ibr_dV2(Ybr, V, lam):
""" Computes 2nd derivatives of complex branch current w.r.t. voltage.
"""
nb = len(V)
diaginvVm = spdiag(div(matrix(1.0, (nb, 1)), abs(V)))
Haa = spdiag(mul(-(Ybr.T * lam), V))
Hva = -1j * Haa * diaginvVm
Hav = Hva
Hvv = spmatrix([], [], [], (nb, nb))
r... | [
"def",
"d2Ibr_dV2",
"(",
"Ybr",
",",
"V",
",",
"lam",
")",
":",
"nb",
"=",
"len",
"(",
"V",
")",
"diaginvVm",
"=",
"spdiag",
"(",
"div",
"(",
"matrix",
"(",
"1.0",
",",
"(",
"nb",
",",
"1",
")",
")",
",",
"abs",
"(",
"V",
")",
")",
")",
"... | Computes 2nd derivatives of complex branch current w.r.t. voltage. | [
"Computes",
"2nd",
"derivatives",
"of",
"complex",
"branch",
"current",
"w",
".",
"r",
".",
"t",
".",
"voltage",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L654-L665 | train |
rwl/pylon | contrib/cvxopf.py | d2Sbr_dV2 | def d2Sbr_dV2(Cbr, Ybr, V, lam):
""" Computes 2nd derivatives of complex power flow w.r.t. voltage.
"""
nb = len(V)
diaglam = spdiag(lam)
diagV = spdiag(V)
A = Ybr.H * diaglam * Cbr
B = conj(diagV) * A * diagV
D = spdiag(mul((A*V), conj(V)))
E = spdiag(mul((A.T * conj(V)), V))
... | python | def d2Sbr_dV2(Cbr, Ybr, V, lam):
""" Computes 2nd derivatives of complex power flow w.r.t. voltage.
"""
nb = len(V)
diaglam = spdiag(lam)
diagV = spdiag(V)
A = Ybr.H * diaglam * Cbr
B = conj(diagV) * A * diagV
D = spdiag(mul((A*V), conj(V)))
E = spdiag(mul((A.T * conj(V)), V))
... | [
"def",
"d2Sbr_dV2",
"(",
"Cbr",
",",
"Ybr",
",",
"V",
",",
"lam",
")",
":",
"nb",
"=",
"len",
"(",
"V",
")",
"diaglam",
"=",
"spdiag",
"(",
"lam",
")",
"diagV",
"=",
"spdiag",
"(",
"V",
")",
"A",
"=",
"Ybr",
".",
"H",
"*",
"diaglam",
"*",
"... | Computes 2nd derivatives of complex power flow w.r.t. voltage. | [
"Computes",
"2nd",
"derivatives",
"of",
"complex",
"power",
"flow",
"w",
".",
"r",
".",
"t",
".",
"voltage",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L671-L691 | train |
rwl/pylon | contrib/cvxopf.py | tocvx | def tocvx(B):
""" Converts a sparse SciPy matrix into a sparse CVXOPT matrix.
"""
Bcoo = B.tocoo()
return spmatrix(Bcoo.data, Bcoo.row.tolist(), Bcoo.col.tolist()) | python | def tocvx(B):
""" Converts a sparse SciPy matrix into a sparse CVXOPT matrix.
"""
Bcoo = B.tocoo()
return spmatrix(Bcoo.data, Bcoo.row.tolist(), Bcoo.col.tolist()) | [
"def",
"tocvx",
"(",
"B",
")",
":",
"Bcoo",
"=",
"B",
".",
"tocoo",
"(",
")",
"return",
"spmatrix",
"(",
"Bcoo",
".",
"data",
",",
"Bcoo",
".",
"row",
".",
"tolist",
"(",
")",
",",
"Bcoo",
".",
"col",
".",
"tolist",
"(",
")",
")"
] | Converts a sparse SciPy matrix into a sparse CVXOPT matrix. | [
"Converts",
"a",
"sparse",
"SciPy",
"matrix",
"into",
"a",
"sparse",
"CVXOPT",
"matrix",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/cvxopf.py#L741-L745 | train |
rwl/pylon | pyreto/discrete/experiment.py | MarketExperiment.doInteractions | def doInteractions(self, number=1):
""" Directly maps the agents and the tasks.
"""
t0 = time.time()
for _ in range(number):
self._oneInteraction()
elapsed = time.time() - t0
logger.info("%d interactions executed in %.3fs." % (number, elapsed))
retu... | python | def doInteractions(self, number=1):
""" Directly maps the agents and the tasks.
"""
t0 = time.time()
for _ in range(number):
self._oneInteraction()
elapsed = time.time() - t0
logger.info("%d interactions executed in %.3fs." % (number, elapsed))
retu... | [
"def",
"doInteractions",
"(",
"self",
",",
"number",
"=",
"1",
")",
":",
"t0",
"=",
"time",
".",
"time",
"(",
")",
"for",
"_",
"in",
"range",
"(",
"number",
")",
":",
"self",
".",
"_oneInteraction",
"(",
")",
"elapsed",
"=",
"time",
".",
"time",
... | Directly maps the agents and the tasks. | [
"Directly",
"maps",
"the",
"agents",
"and",
"the",
"tasks",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/discrete/experiment.py#L72-L83 | train |
rwl/pylon | pylon/dyn.py | DynamicCase.exciter | def exciter(self, Xexc, Pexc, Vexc):
""" Exciter model.
Based on Exciter.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information.
"""
exciters = self.exciters
F = ... | python | def exciter(self, Xexc, Pexc, Vexc):
""" Exciter model.
Based on Exciter.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information.
"""
exciters = self.exciters
F = ... | [
"def",
"exciter",
"(",
"self",
",",
"Xexc",
",",
"Pexc",
",",
"Vexc",
")",
":",
"exciters",
"=",
"self",
".",
"exciters",
"F",
"=",
"zeros",
"(",
"Xexc",
".",
"shape",
")",
"typ1",
"=",
"[",
"e",
".",
"generator",
".",
"_i",
"for",
"e",
"in",
"... | Exciter model.
Based on Exciter.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information. | [
"Exciter",
"model",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dyn.py#L409-L464 | train |
rwl/pylon | pylon/dyn.py | DynamicCase.governor | def governor(self, Xgov, Pgov, Vgov):
""" Governor model.
Based on Governor.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information.
"""
governors = self.governors
... | python | def governor(self, Xgov, Pgov, Vgov):
""" Governor model.
Based on Governor.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information.
"""
governors = self.governors
... | [
"def",
"governor",
"(",
"self",
",",
"Xgov",
",",
"Pgov",
",",
"Vgov",
")",
":",
"governors",
"=",
"self",
".",
"governors",
"omegas",
"=",
"2",
"*",
"pi",
"*",
"self",
".",
"freq",
"F",
"=",
"zeros",
"(",
"Xgov",
".",
"shape",
")",
"typ1",
"=",
... | Governor model.
Based on Governor.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information. | [
"Governor",
"model",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dyn.py#L467-L530 | train |
rwl/pylon | pylon/dyn.py | DynamicCase.generator | def generator(self, Xgen, Xexc, Xgov, Vgen):
""" Generator model.
Based on Generator.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information.
"""
generators = self.dyn_gene... | python | def generator(self, Xgen, Xexc, Xgov, Vgen):
""" Generator model.
Based on Generator.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information.
"""
generators = self.dyn_gene... | [
"def",
"generator",
"(",
"self",
",",
"Xgen",
",",
"Xexc",
",",
"Xgov",
",",
"Vgen",
")",
":",
"generators",
"=",
"self",
".",
"dyn_generators",
"omegas",
"=",
"2",
"*",
"pi",
"*",
"self",
".",
"freq",
"F",
"=",
"zeros",
"(",
"Xgen",
".",
"shape",
... | Generator model.
Based on Generator.m from MatDyn by Stijn Cole, developed at Katholieke
Universiteit Leuven. See U{http://www.esat.kuleuven.be/electa/teaching/
matdyn/} for more information. | [
"Generator",
"model",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dyn.py#L533-L595 | train |
rwl/pylon | pylon/io/rst.py | ReSTWriter._write_data | def _write_data(self, file):
""" Writes case data to file in ReStructuredText format.
"""
self.write_case_data(file)
file.write("Bus Data\n")
file.write("-" * 8 + "\n")
self.write_bus_data(file)
file.write("\n")
file.write("Branch Data\n")
file.w... | python | def _write_data(self, file):
""" Writes case data to file in ReStructuredText format.
"""
self.write_case_data(file)
file.write("Bus Data\n")
file.write("-" * 8 + "\n")
self.write_bus_data(file)
file.write("\n")
file.write("Branch Data\n")
file.w... | [
"def",
"_write_data",
"(",
"self",
",",
"file",
")",
":",
"self",
".",
"write_case_data",
"(",
"file",
")",
"file",
".",
"write",
"(",
"\"Bus Data\\n\"",
")",
"file",
".",
"write",
"(",
"\"-\"",
"*",
"8",
"+",
"\"\\n\"",
")",
"self",
".",
"write_bus_da... | Writes case data to file in ReStructuredText format. | [
"Writes",
"case",
"data",
"to",
"file",
"in",
"ReStructuredText",
"format",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/rst.py#L40-L58 | train |
rwl/pylon | pylon/io/rst.py | ReSTWriter.write_bus_data | def write_bus_data(self, file):
""" Writes bus data to a ReST table.
"""
report = CaseReport(self.case)
buses = self.case.buses
col_width = 8
col_width_2 = col_width * 2 + 1
col1_width = 6
sep = "=" * 6 + " " + ("=" * col_width + " ") * 6 + "\n"
... | python | def write_bus_data(self, file):
""" Writes bus data to a ReST table.
"""
report = CaseReport(self.case)
buses = self.case.buses
col_width = 8
col_width_2 = col_width * 2 + 1
col1_width = 6
sep = "=" * 6 + " " + ("=" * col_width + " ") * 6 + "\n"
... | [
"def",
"write_bus_data",
"(",
"self",
",",
"file",
")",
":",
"report",
"=",
"CaseReport",
"(",
"self",
".",
"case",
")",
"buses",
"=",
"self",
".",
"case",
".",
"buses",
"col_width",
"=",
"8",
"col_width_2",
"=",
"col_width",
"*",
"2",
"+",
"1",
"col... | Writes bus data to a ReST table. | [
"Writes",
"bus",
"data",
"to",
"a",
"ReST",
"table",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/rst.py#L87-L146 | train |
rwl/pylon | pylon/io/rst.py | ReSTWriter.write_how_many | def write_how_many(self, file):
""" Writes component numbers to a table.
"""
report = CaseReport(self.case)
# Map component labels to attribute names
components = [("Bus", "n_buses"), ("Generator", "n_generators"),
("Committed Generator", "n_online_generators"),
... | python | def write_how_many(self, file):
""" Writes component numbers to a table.
"""
report = CaseReport(self.case)
# Map component labels to attribute names
components = [("Bus", "n_buses"), ("Generator", "n_generators"),
("Committed Generator", "n_online_generators"),
... | [
"def",
"write_how_many",
"(",
"self",
",",
"file",
")",
":",
"report",
"=",
"CaseReport",
"(",
"self",
".",
"case",
")",
"# Map component labels to attribute names",
"components",
"=",
"[",
"(",
"\"Bus\"",
",",
"\"n_buses\"",
")",
",",
"(",
"\"Generator\"",
",... | Writes component numbers to a table. | [
"Writes",
"component",
"numbers",
"to",
"a",
"table",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/rst.py#L312-L355 | train |
rwl/pylon | pylon/io/rst.py | ReSTWriter.write_min_max | def write_min_max(self, file):
""" Writes minimum and maximum values to a table.
"""
report = CaseReport(self.case)
col1_header = "Attribute"
col1_width = 19
col2_header = "Minimum"
col3_header = "Maximum"
col_width = 22
sep = "="*col1_width +... | python | def write_min_max(self, file):
""" Writes minimum and maximum values to a table.
"""
report = CaseReport(self.case)
col1_header = "Attribute"
col1_width = 19
col2_header = "Minimum"
col3_header = "Maximum"
col_width = 22
sep = "="*col1_width +... | [
"def",
"write_min_max",
"(",
"self",
",",
"file",
")",
":",
"report",
"=",
"CaseReport",
"(",
"self",
".",
"case",
")",
"col1_header",
"=",
"\"Attribute\"",
"col1_width",
"=",
"19",
"col2_header",
"=",
"\"Minimum\"",
"col3_header",
"=",
"\"Maximum\"",
"col_wid... | Writes minimum and maximum values to a table. | [
"Writes",
"minimum",
"and",
"maximum",
"values",
"to",
"a",
"table",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/rst.py#L438-L478 | train |
rwl/pylon | pylon/io/parsing_util.py | make_unique_name | def make_unique_name(base, existing=[], format="%s_%s"):
""" Return a name, unique within a context, based on the specified name.
@param base: the desired base name of the generated unique name.
@param existing: a sequence of the existing names to avoid returning.
@param format: a formatting specificat... | python | def make_unique_name(base, existing=[], format="%s_%s"):
""" Return a name, unique within a context, based on the specified name.
@param base: the desired base name of the generated unique name.
@param existing: a sequence of the existing names to avoid returning.
@param format: a formatting specificat... | [
"def",
"make_unique_name",
"(",
"base",
",",
"existing",
"=",
"[",
"]",
",",
"format",
"=",
"\"%s_%s\"",
")",
":",
"count",
"=",
"2",
"name",
"=",
"base",
"while",
"name",
"in",
"existing",
":",
"name",
"=",
"format",
"%",
"(",
"base",
",",
"count",
... | Return a name, unique within a context, based on the specified name.
@param base: the desired base name of the generated unique name.
@param existing: a sequence of the existing names to avoid returning.
@param format: a formatting specification for how the name is made unique. | [
"Return",
"a",
"name",
"unique",
"within",
"a",
"context",
"based",
"on",
"the",
"specified",
"name",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/parsing_util.py#L167-L180 | train |
pymoca/pymoca | setup.py | call_antlr4 | def call_antlr4(arg):
"calls antlr4 on grammar file"
# pylint: disable=unused-argument, unused-variable
antlr_path = os.path.join(ROOT_DIR, "java", "antlr-4.7-complete.jar")
classpath = os.pathsep.join([".", "{:s}".format(antlr_path), "$CLASSPATH"])
generated = os.path.join(ROOT_DIR, 'src', 'pymoca'... | python | def call_antlr4(arg):
"calls antlr4 on grammar file"
# pylint: disable=unused-argument, unused-variable
antlr_path = os.path.join(ROOT_DIR, "java", "antlr-4.7-complete.jar")
classpath = os.pathsep.join([".", "{:s}".format(antlr_path), "$CLASSPATH"])
generated = os.path.join(ROOT_DIR, 'src', 'pymoca'... | [
"def",
"call_antlr4",
"(",
"arg",
")",
":",
"# pylint: disable=unused-argument, unused-variable",
"antlr_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"ROOT_DIR",
",",
"\"java\"",
",",
"\"antlr-4.7-complete.jar\"",
")",
"classpath",
"=",
"os",
".",
"pathsep",
"... | calls antlr4 on grammar file | [
"calls",
"antlr4",
"on",
"grammar",
"file"
] | 14b5eb7425e96689de6cc5c10f400895d586a978 | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/setup.py#L74-L86 | train |
pymoca/pymoca | setup.py | setup_package | def setup_package():
"""
Setup the package.
"""
with open('requirements.txt', 'r') as req_file:
install_reqs = req_file.read().split('\n')
cmdclass_ = {'antlr': AntlrBuildCommand}
cmdclass_.update(versioneer.get_cmdclass())
setup(
version=versioneer.get_version(),
n... | python | def setup_package():
"""
Setup the package.
"""
with open('requirements.txt', 'r') as req_file:
install_reqs = req_file.read().split('\n')
cmdclass_ = {'antlr': AntlrBuildCommand}
cmdclass_.update(versioneer.get_cmdclass())
setup(
version=versioneer.get_version(),
n... | [
"def",
"setup_package",
"(",
")",
":",
"with",
"open",
"(",
"'requirements.txt'",
",",
"'r'",
")",
"as",
"req_file",
":",
"install_reqs",
"=",
"req_file",
".",
"read",
"(",
")",
".",
"split",
"(",
"'\\n'",
")",
"cmdclass_",
"=",
"{",
"'antlr'",
":",
"A... | Setup the package. | [
"Setup",
"the",
"package",
"."
] | 14b5eb7425e96689de6cc5c10f400895d586a978 | https://github.com/pymoca/pymoca/blob/14b5eb7425e96689de6cc5c10f400895d586a978/setup.py#L89-L121 | train |
rwl/pylon | contrib/pylontk.py | CaseProperties.body | def body(self, frame):
""" Creates the dialog body. Returns the widget that should have
initial focus.
"""
master = Frame(self)
master.pack(padx=5, pady=0, expand=1, fill=BOTH)
title = Label(master, text="Buses")
title.pack(side=TOP)
bus_lb = self.bu... | python | def body(self, frame):
""" Creates the dialog body. Returns the widget that should have
initial focus.
"""
master = Frame(self)
master.pack(padx=5, pady=0, expand=1, fill=BOTH)
title = Label(master, text="Buses")
title.pack(side=TOP)
bus_lb = self.bu... | [
"def",
"body",
"(",
"self",
",",
"frame",
")",
":",
"master",
"=",
"Frame",
"(",
"self",
")",
"master",
".",
"pack",
"(",
"padx",
"=",
"5",
",",
"pady",
"=",
"0",
",",
"expand",
"=",
"1",
",",
"fill",
"=",
"BOTH",
")",
"title",
"=",
"Label",
... | Creates the dialog body. Returns the widget that should have
initial focus. | [
"Creates",
"the",
"dialog",
"body",
".",
"Returns",
"the",
"widget",
"that",
"should",
"have",
"initial",
"focus",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/pylontk.py#L538-L558 | train |
rwl/pylon | pylon/opf.py | OPF.solve | def solve(self, solver_klass=None):
""" Solves an optimal power flow and returns a results dictionary.
"""
# Start the clock.
t0 = time()
# Build an OPF model with variables and constraints.
om = self._construct_opf_model(self.case)
if om is None:
ret... | python | def solve(self, solver_klass=None):
""" Solves an optimal power flow and returns a results dictionary.
"""
# Start the clock.
t0 = time()
# Build an OPF model with variables and constraints.
om = self._construct_opf_model(self.case)
if om is None:
ret... | [
"def",
"solve",
"(",
"self",
",",
"solver_klass",
"=",
"None",
")",
":",
"# Start the clock.",
"t0",
"=",
"time",
"(",
")",
"# Build an OPF model with variables and constraints.",
"om",
"=",
"self",
".",
"_construct_opf_model",
"(",
"self",
".",
"case",
")",
"if... | Solves an optimal power flow and returns a results dictionary. | [
"Solves",
"an",
"optimal",
"power",
"flow",
"and",
"returns",
"a",
"results",
"dictionary",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L79-L110 | train |
rwl/pylon | pylon/opf.py | OPF._construct_opf_model | def _construct_opf_model(self, case):
""" Returns an OPF model.
"""
# Zero the case result attributes.
self.case.reset()
base_mva = case.base_mva
# Check for one reference bus.
oneref, refs = self._ref_check(case)
if not oneref: #return {"status": "error... | python | def _construct_opf_model(self, case):
""" Returns an OPF model.
"""
# Zero the case result attributes.
self.case.reset()
base_mva = case.base_mva
# Check for one reference bus.
oneref, refs = self._ref_check(case)
if not oneref: #return {"status": "error... | [
"def",
"_construct_opf_model",
"(",
"self",
",",
"case",
")",
":",
"# Zero the case result attributes.",
"self",
".",
"case",
".",
"reset",
"(",
")",
"base_mva",
"=",
"case",
".",
"base_mva",
"# Check for one reference bus.",
"oneref",
",",
"refs",
"=",
"self",
... | Returns an OPF model. | [
"Returns",
"an",
"OPF",
"model",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L116-L190 | train |
rwl/pylon | pylon/opf.py | OPF._ref_check | def _ref_check(self, case):
""" Checks that there is only one reference bus.
"""
refs = [bus._i for bus in case.buses if bus.type == REFERENCE]
if len(refs) == 1:
return True, refs
else:
logger.error("OPF requires a single reference bus.")
ret... | python | def _ref_check(self, case):
""" Checks that there is only one reference bus.
"""
refs = [bus._i for bus in case.buses if bus.type == REFERENCE]
if len(refs) == 1:
return True, refs
else:
logger.error("OPF requires a single reference bus.")
ret... | [
"def",
"_ref_check",
"(",
"self",
",",
"case",
")",
":",
"refs",
"=",
"[",
"bus",
".",
"_i",
"for",
"bus",
"in",
"case",
".",
"buses",
"if",
"bus",
".",
"type",
"==",
"REFERENCE",
"]",
"if",
"len",
"(",
"refs",
")",
"==",
"1",
":",
"return",
"T... | Checks that there is only one reference bus. | [
"Checks",
"that",
"there",
"is",
"only",
"one",
"reference",
"bus",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L193-L202 | train |
rwl/pylon | pylon/opf.py | OPF._remove_isolated | def _remove_isolated(self, case):
""" Returns non-isolated case components.
"""
# case.deactivate_isolated()
buses = case.connected_buses
branches = case.online_branches
gens = case.online_generators
return buses, branches, gens | python | def _remove_isolated(self, case):
""" Returns non-isolated case components.
"""
# case.deactivate_isolated()
buses = case.connected_buses
branches = case.online_branches
gens = case.online_generators
return buses, branches, gens | [
"def",
"_remove_isolated",
"(",
"self",
",",
"case",
")",
":",
"# case.deactivate_isolated()",
"buses",
"=",
"case",
".",
"connected_buses",
"branches",
"=",
"case",
".",
"online_branches",
"gens",
"=",
"case",
".",
"online_generators",
"return",
"buses",
"... | Returns non-isolated case components. | [
"Returns",
"non",
"-",
"isolated",
"case",
"components",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L205-L213 | train |
rwl/pylon | pylon/opf.py | OPF._pwl1_to_poly | def _pwl1_to_poly(self, generators):
""" Converts single-block piecewise-linear costs into linear
polynomial.
"""
for g in generators:
if (g.pcost_model == PW_LINEAR) and (len(g.p_cost) == 2):
g.pwl_to_poly()
return generators | python | def _pwl1_to_poly(self, generators):
""" Converts single-block piecewise-linear costs into linear
polynomial.
"""
for g in generators:
if (g.pcost_model == PW_LINEAR) and (len(g.p_cost) == 2):
g.pwl_to_poly()
return generators | [
"def",
"_pwl1_to_poly",
"(",
"self",
",",
"generators",
")",
":",
"for",
"g",
"in",
"generators",
":",
"if",
"(",
"g",
".",
"pcost_model",
"==",
"PW_LINEAR",
")",
"and",
"(",
"len",
"(",
"g",
".",
"p_cost",
")",
"==",
"2",
")",
":",
"g",
".",
"pw... | Converts single-block piecewise-linear costs into linear
polynomial. | [
"Converts",
"single",
"-",
"block",
"piecewise",
"-",
"linear",
"costs",
"into",
"linear",
"polynomial",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L216-L224 | train |
rwl/pylon | pylon/opf.py | OPF._get_voltage_angle_var | def _get_voltage_angle_var(self, refs, buses):
""" Returns the voltage angle variable set.
"""
Va = array([b.v_angle * (pi / 180.0) for b in buses])
Vau = Inf * ones(len(buses))
Val = -Vau
Vau[refs] = Va[refs]
Val[refs] = Va[refs]
return Variable("Va", l... | python | def _get_voltage_angle_var(self, refs, buses):
""" Returns the voltage angle variable set.
"""
Va = array([b.v_angle * (pi / 180.0) for b in buses])
Vau = Inf * ones(len(buses))
Val = -Vau
Vau[refs] = Va[refs]
Val[refs] = Va[refs]
return Variable("Va", l... | [
"def",
"_get_voltage_angle_var",
"(",
"self",
",",
"refs",
",",
"buses",
")",
":",
"Va",
"=",
"array",
"(",
"[",
"b",
".",
"v_angle",
"*",
"(",
"pi",
"/",
"180.0",
")",
"for",
"b",
"in",
"buses",
"]",
")",
"Vau",
"=",
"Inf",
"*",
"ones",
"(",
"... | Returns the voltage angle variable set. | [
"Returns",
"the",
"voltage",
"angle",
"variable",
"set",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L230-L240 | train |
rwl/pylon | pylon/opf.py | OPF._get_voltage_magnitude_var | def _get_voltage_magnitude_var(self, buses, generators):
""" Returns the voltage magnitude variable set.
"""
Vm = array([b.v_magnitude for b in buses])
# For buses with generators initialise Vm from gen data.
for g in generators:
Vm[g.bus._i] = g.v_magnitude
... | python | def _get_voltage_magnitude_var(self, buses, generators):
""" Returns the voltage magnitude variable set.
"""
Vm = array([b.v_magnitude for b in buses])
# For buses with generators initialise Vm from gen data.
for g in generators:
Vm[g.bus._i] = g.v_magnitude
... | [
"def",
"_get_voltage_magnitude_var",
"(",
"self",
",",
"buses",
",",
"generators",
")",
":",
"Vm",
"=",
"array",
"(",
"[",
"b",
".",
"v_magnitude",
"for",
"b",
"in",
"buses",
"]",
")",
"# For buses with generators initialise Vm from gen data.",
"for",
"g",
"in",... | Returns the voltage magnitude variable set. | [
"Returns",
"the",
"voltage",
"magnitude",
"variable",
"set",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L243-L255 | train |
rwl/pylon | pylon/opf.py | OPF._get_pgen_var | def _get_pgen_var(self, generators, base_mva):
""" Returns the generator active power set-point variable.
"""
Pg = array([g.p / base_mva for g in generators])
Pmin = array([g.p_min / base_mva for g in generators])
Pmax = array([g.p_max / base_mva for g in generators])
r... | python | def _get_pgen_var(self, generators, base_mva):
""" Returns the generator active power set-point variable.
"""
Pg = array([g.p / base_mva for g in generators])
Pmin = array([g.p_min / base_mva for g in generators])
Pmax = array([g.p_max / base_mva for g in generators])
r... | [
"def",
"_get_pgen_var",
"(",
"self",
",",
"generators",
",",
"base_mva",
")",
":",
"Pg",
"=",
"array",
"(",
"[",
"g",
".",
"p",
"/",
"base_mva",
"for",
"g",
"in",
"generators",
"]",
")",
"Pmin",
"=",
"array",
"(",
"[",
"g",
".",
"p_min",
"/",
"ba... | Returns the generator active power set-point variable. | [
"Returns",
"the",
"generator",
"active",
"power",
"set",
"-",
"point",
"variable",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L258-L266 | train |
rwl/pylon | pylon/opf.py | OPF._get_qgen_var | def _get_qgen_var(self, generators, base_mva):
""" Returns the generator reactive power variable set.
"""
Qg = array([g.q / base_mva for g in generators])
Qmin = array([g.q_min / base_mva for g in generators])
Qmax = array([g.q_max / base_mva for g in generators])
retur... | python | def _get_qgen_var(self, generators, base_mva):
""" Returns the generator reactive power variable set.
"""
Qg = array([g.q / base_mva for g in generators])
Qmin = array([g.q_min / base_mva for g in generators])
Qmax = array([g.q_max / base_mva for g in generators])
retur... | [
"def",
"_get_qgen_var",
"(",
"self",
",",
"generators",
",",
"base_mva",
")",
":",
"Qg",
"=",
"array",
"(",
"[",
"g",
".",
"q",
"/",
"base_mva",
"for",
"g",
"in",
"generators",
"]",
")",
"Qmin",
"=",
"array",
"(",
"[",
"g",
".",
"q_min",
"/",
"ba... | Returns the generator reactive power variable set. | [
"Returns",
"the",
"generator",
"reactive",
"power",
"variable",
"set",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L269-L277 | train |
rwl/pylon | pylon/opf.py | OPF._nln_constraints | def _nln_constraints(self, nb, nl):
""" Returns non-linear constraints for OPF.
"""
Pmis = NonLinearConstraint("Pmis", nb)
Qmis = NonLinearConstraint("Qmis", nb)
Sf = NonLinearConstraint("Sf", nl)
St = NonLinearConstraint("St", nl)
return Pmis, Qmis, Sf, St | python | def _nln_constraints(self, nb, nl):
""" Returns non-linear constraints for OPF.
"""
Pmis = NonLinearConstraint("Pmis", nb)
Qmis = NonLinearConstraint("Qmis", nb)
Sf = NonLinearConstraint("Sf", nl)
St = NonLinearConstraint("St", nl)
return Pmis, Qmis, Sf, St | [
"def",
"_nln_constraints",
"(",
"self",
",",
"nb",
",",
"nl",
")",
":",
"Pmis",
"=",
"NonLinearConstraint",
"(",
"\"Pmis\"",
",",
"nb",
")",
"Qmis",
"=",
"NonLinearConstraint",
"(",
"\"Qmis\"",
",",
"nb",
")",
"Sf",
"=",
"NonLinearConstraint",
"(",
"\"Sf\"... | Returns non-linear constraints for OPF. | [
"Returns",
"non",
"-",
"linear",
"constraints",
"for",
"OPF",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L283-L291 | train |
rwl/pylon | pylon/opf.py | OPF._const_pf_constraints | def _const_pf_constraints(self, gn, base_mva):
""" Returns a linear constraint enforcing constant power factor for
dispatchable loads.
The power factor is derived from the original value of Pmin and either
Qmin (for inductive loads) or Qmax (for capacitive loads). If both Qmin
a... | python | def _const_pf_constraints(self, gn, base_mva):
""" Returns a linear constraint enforcing constant power factor for
dispatchable loads.
The power factor is derived from the original value of Pmin and either
Qmin (for inductive loads) or Qmax (for capacitive loads). If both Qmin
a... | [
"def",
"_const_pf_constraints",
"(",
"self",
",",
"gn",
",",
"base_mva",
")",
":",
"ivl",
"=",
"array",
"(",
"[",
"i",
"for",
"i",
",",
"g",
"in",
"enumerate",
"(",
"gn",
")",
"if",
"g",
".",
"is_load",
"and",
"(",
"g",
".",
"q_min",
"!=",
"0.0",... | Returns a linear constraint enforcing constant power factor for
dispatchable loads.
The power factor is derived from the original value of Pmin and either
Qmin (for inductive loads) or Qmax (for capacitive loads). If both Qmin
and Qmax are zero, this implies a unity power factor without... | [
"Returns",
"a",
"linear",
"constraint",
"enforcing",
"constant",
"power",
"factor",
"for",
"dispatchable",
"loads",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L330-L384 | train |
rwl/pylon | pylon/opf.py | OPF._voltage_angle_diff_limit | def _voltage_angle_diff_limit(self, buses, branches):
""" Returns the constraint on the branch voltage angle differences.
"""
nb = len(buses)
if not self.ignore_ang_lim:
iang = [i for i, b in enumerate(branches)
if (b.ang_min and (b.ang_min > -360.0))
... | python | def _voltage_angle_diff_limit(self, buses, branches):
""" Returns the constraint on the branch voltage angle differences.
"""
nb = len(buses)
if not self.ignore_ang_lim:
iang = [i for i, b in enumerate(branches)
if (b.ang_min and (b.ang_min > -360.0))
... | [
"def",
"_voltage_angle_diff_limit",
"(",
"self",
",",
"buses",
",",
"branches",
")",
":",
"nb",
"=",
"len",
"(",
"buses",
")",
"if",
"not",
"self",
".",
"ignore_ang_lim",
":",
"iang",
"=",
"[",
"i",
"for",
"i",
",",
"b",
"in",
"enumerate",
"(",
"bran... | Returns the constraint on the branch voltage angle differences. | [
"Returns",
"the",
"constraint",
"on",
"the",
"branch",
"voltage",
"angle",
"differences",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L387-L430 | train |
rwl/pylon | pylon/opf.py | OPFModel.add_var | def add_var(self, var):
""" Adds a variable to the model.
"""
if var.name in [v.name for v in self.vars]:
logger.error("Variable set named '%s' already exists." % var.name)
return
var.i1 = self.var_N
var.iN = self.var_N + var.N - 1
self.vars.appen... | python | def add_var(self, var):
""" Adds a variable to the model.
"""
if var.name in [v.name for v in self.vars]:
logger.error("Variable set named '%s' already exists." % var.name)
return
var.i1 = self.var_N
var.iN = self.var_N + var.N - 1
self.vars.appen... | [
"def",
"add_var",
"(",
"self",
",",
"var",
")",
":",
"if",
"var",
".",
"name",
"in",
"[",
"v",
".",
"name",
"for",
"v",
"in",
"self",
".",
"vars",
"]",
":",
"logger",
".",
"error",
"(",
"\"Variable set named '%s' already exists.\"",
"%",
"var",
".",
... | Adds a variable to the model. | [
"Adds",
"a",
"variable",
"to",
"the",
"model",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L731-L740 | train |
rwl/pylon | pylon/opf.py | OPFModel.get_var | def get_var(self, name):
""" Returns the variable set with the given name.
"""
for var in self.vars:
if var.name == name:
return var
else:
raise ValueError | python | def get_var(self, name):
""" Returns the variable set with the given name.
"""
for var in self.vars:
if var.name == name:
return var
else:
raise ValueError | [
"def",
"get_var",
"(",
"self",
",",
"name",
")",
":",
"for",
"var",
"in",
"self",
".",
"vars",
":",
"if",
"var",
".",
"name",
"==",
"name",
":",
"return",
"var",
"else",
":",
"raise",
"ValueError"
] | Returns the variable set with the given name. | [
"Returns",
"the",
"variable",
"set",
"with",
"the",
"given",
"name",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L750-L757 | train |
rwl/pylon | pylon/opf.py | OPFModel.linear_constraints | def linear_constraints(self):
""" Returns the linear constraints.
"""
if self.lin_N == 0:
return None, array([]), array([])
A = lil_matrix((self.lin_N, self.var_N), dtype=float64)
l = -Inf * ones(self.lin_N)
u = -l
for lin in self.lin_constraints:
... | python | def linear_constraints(self):
""" Returns the linear constraints.
"""
if self.lin_N == 0:
return None, array([]), array([])
A = lil_matrix((self.lin_N, self.var_N), dtype=float64)
l = -Inf * ones(self.lin_N)
u = -l
for lin in self.lin_constraints:
... | [
"def",
"linear_constraints",
"(",
"self",
")",
":",
"if",
"self",
".",
"lin_N",
"==",
"0",
":",
"return",
"None",
",",
"array",
"(",
"[",
"]",
")",
",",
"array",
"(",
"[",
"]",
")",
"A",
"=",
"lil_matrix",
"(",
"(",
"self",
".",
"lin_N",
",",
"... | Returns the linear constraints. | [
"Returns",
"the",
"linear",
"constraints",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L782-L818 | train |
rwl/pylon | pylon/opf.py | OPFModel.add_constraint | def add_constraint(self, con):
""" Adds a constraint to the model.
"""
if isinstance(con, LinearConstraint):
N, M = con.A.shape
if con.name in [c.name for c in self.lin_constraints]:
logger.error("Constraint set named '%s' already exists."
... | python | def add_constraint(self, con):
""" Adds a constraint to the model.
"""
if isinstance(con, LinearConstraint):
N, M = con.A.shape
if con.name in [c.name for c in self.lin_constraints]:
logger.error("Constraint set named '%s' already exists."
... | [
"def",
"add_constraint",
"(",
"self",
",",
"con",
")",
":",
"if",
"isinstance",
"(",
"con",
",",
"LinearConstraint",
")",
":",
"N",
",",
"M",
"=",
"con",
".",
"A",
".",
"shape",
"if",
"con",
".",
"name",
"in",
"[",
"c",
".",
"name",
"for",
"c",
... | Adds a constraint to the model. | [
"Adds",
"a",
"constraint",
"to",
"the",
"model",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/opf.py#L821-L854 | train |
rwl/pylon | pylon/ipopf.py | IPOPFSolver._solve | def _solve(self, x0, A, l, u, xmin, xmax):
""" Solves using the Interior Point OPTimizer.
"""
# Indexes of constrained lines.
il = [i for i,ln in enumerate(self._ln) if 0.0 < ln.rate_a < 1e10]
nl2 = len(il)
neqnln = 2 * self._nb # no. of non-linear equality constraints
... | python | def _solve(self, x0, A, l, u, xmin, xmax):
""" Solves using the Interior Point OPTimizer.
"""
# Indexes of constrained lines.
il = [i for i,ln in enumerate(self._ln) if 0.0 < ln.rate_a < 1e10]
nl2 = len(il)
neqnln = 2 * self._nb # no. of non-linear equality constraints
... | [
"def",
"_solve",
"(",
"self",
",",
"x0",
",",
"A",
",",
"l",
",",
"u",
",",
"xmin",
",",
"xmax",
")",
":",
"# Indexes of constrained lines.",
"il",
"=",
"[",
"i",
"for",
"i",
",",
"ln",
"in",
"enumerate",
"(",
"self",
".",
"_ln",
")",
"if",
"0.0"... | Solves using the Interior Point OPTimizer. | [
"Solves",
"using",
"the",
"Interior",
"Point",
"OPTimizer",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/ipopf.py#L44-L86 | train |
rwl/pylon | pyreto/continuous/experiment.py | MarketExperiment.doOutages | def doOutages(self):
""" Applies branch outtages.
"""
assert len(self.branchOutages) == len(self.market.case.branches)
weights = [[(False, r), (True, 1 - (r))] for r in self.branchOutages]
for i, ln in enumerate(self.market.case.branches):
ln.online = weighted_choic... | python | def doOutages(self):
""" Applies branch outtages.
"""
assert len(self.branchOutages) == len(self.market.case.branches)
weights = [[(False, r), (True, 1 - (r))] for r in self.branchOutages]
for i, ln in enumerate(self.market.case.branches):
ln.online = weighted_choic... | [
"def",
"doOutages",
"(",
"self",
")",
":",
"assert",
"len",
"(",
"self",
".",
"branchOutages",
")",
"==",
"len",
"(",
"self",
".",
"market",
".",
"case",
".",
"branches",
")",
"weights",
"=",
"[",
"[",
"(",
"False",
",",
"r",
")",
",",
"(",
"True... | Applies branch outtages. | [
"Applies",
"branch",
"outtages",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/experiment.py#L133-L143 | train |
rwl/pylon | pyreto/continuous/experiment.py | MarketExperiment.reset_case | def reset_case(self):
""" Returns the case to its original state.
"""
for bus in self.market.case.buses:
bus.p_demand = self.pdemand[bus]
for task in self.tasks:
for g in task.env.generators:
g.p = task.env._g0[g]["p"]
g.p_max = tas... | python | def reset_case(self):
""" Returns the case to its original state.
"""
for bus in self.market.case.buses:
bus.p_demand = self.pdemand[bus]
for task in self.tasks:
for g in task.env.generators:
g.p = task.env._g0[g]["p"]
g.p_max = tas... | [
"def",
"reset_case",
"(",
"self",
")",
":",
"for",
"bus",
"in",
"self",
".",
"market",
".",
"case",
".",
"buses",
":",
"bus",
".",
"p_demand",
"=",
"self",
".",
"pdemand",
"[",
"bus",
"]",
"for",
"task",
"in",
"self",
".",
"tasks",
":",
"for",
"g... | Returns the case to its original state. | [
"Returns",
"the",
"case",
"to",
"its",
"original",
"state",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/experiment.py#L146-L164 | train |
rwl/pylon | pyreto/continuous/experiment.py | MarketExperiment.doEpisodes | def doEpisodes(self, number=1):
""" Do the given numer of episodes, and return the rewards of each
step as a list.
"""
for episode in range(number):
print "Starting episode %d." % episode
# Initialise the profile cycle.
if len(self.profile.shape) ... | python | def doEpisodes(self, number=1):
""" Do the given numer of episodes, and return the rewards of each
step as a list.
"""
for episode in range(number):
print "Starting episode %d." % episode
# Initialise the profile cycle.
if len(self.profile.shape) ... | [
"def",
"doEpisodes",
"(",
"self",
",",
"number",
"=",
"1",
")",
":",
"for",
"episode",
"in",
"range",
"(",
"number",
")",
":",
"print",
"\"Starting episode %d.\"",
"%",
"episode",
"# Initialise the profile cycle.",
"if",
"len",
"(",
"self",
".",
"profile",
"... | Do the given numer of episodes, and return the rewards of each
step as a list. | [
"Do",
"the",
"given",
"numer",
"of",
"episodes",
"and",
"return",
"the",
"rewards",
"of",
"each",
"step",
"as",
"a",
"list",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/experiment.py#L170-L199 | train |
rwl/pylon | pyreto/continuous/experiment.py | MarketExperiment.reset | def reset(self):
""" Sets initial conditions for the experiment.
"""
self.stepid = 0
for task, agent in zip(self.tasks, self.agents):
task.reset()
agent.module.reset()
agent.history.reset() | python | def reset(self):
""" Sets initial conditions for the experiment.
"""
self.stepid = 0
for task, agent in zip(self.tasks, self.agents):
task.reset()
agent.module.reset()
agent.history.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"stepid",
"=",
"0",
"for",
"task",
",",
"agent",
"in",
"zip",
"(",
"self",
".",
"tasks",
",",
"self",
".",
"agents",
")",
":",
"task",
".",
"reset",
"(",
")",
"agent",
".",
"module",
".",
"res... | Sets initial conditions for the experiment. | [
"Sets",
"initial",
"conditions",
"for",
"the",
"experiment",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/continuous/experiment.py#L249-L258 | train |
rwl/pylon | pyreto/roth_erev.py | RothErev._updatePropensities | def _updatePropensities(self, lastState, lastAction, reward):
""" Update the propensities for all actions. The propensity for last
action chosen will be updated using the feedback value that resulted
from performing the action.
If j is the index of the last action chosen, r_j is the rew... | python | def _updatePropensities(self, lastState, lastAction, reward):
""" Update the propensities for all actions. The propensity for last
action chosen will be updated using the feedback value that resulted
from performing the action.
If j is the index of the last action chosen, r_j is the rew... | [
"def",
"_updatePropensities",
"(",
"self",
",",
"lastState",
",",
"lastAction",
",",
"reward",
")",
":",
"phi",
"=",
"self",
".",
"recency",
"for",
"action",
"in",
"range",
"(",
"self",
".",
"module",
".",
"numActions",
")",
":",
"carryOver",
"=",
"(",
... | Update the propensities for all actions. The propensity for last
action chosen will be updated using the feedback value that resulted
from performing the action.
If j is the index of the last action chosen, r_j is the reward received
for performing j, i is the current action being updat... | [
"Update",
"the",
"propensities",
"for",
"all",
"actions",
".",
"The",
"propensity",
"for",
"last",
"action",
"chosen",
"will",
"be",
"updated",
"using",
"the",
"feedback",
"value",
"that",
"resulted",
"from",
"performing",
"the",
"action",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/roth_erev.py#L136-L154 | train |
rwl/pylon | pyreto/roth_erev.py | ProportionalExplorer._forwardImplementation | def _forwardImplementation(self, inbuf, outbuf):
""" Proportional probability method.
"""
assert self.module
propensities = self.module.getActionValues(0)
summedProps = sum(propensities)
probabilities = propensities / summedProps
action = eventGenerator(probabi... | python | def _forwardImplementation(self, inbuf, outbuf):
""" Proportional probability method.
"""
assert self.module
propensities = self.module.getActionValues(0)
summedProps = sum(propensities)
probabilities = propensities / summedProps
action = eventGenerator(probabi... | [
"def",
"_forwardImplementation",
"(",
"self",
",",
"inbuf",
",",
"outbuf",
")",
":",
"assert",
"self",
".",
"module",
"propensities",
"=",
"self",
".",
"module",
".",
"getActionValues",
"(",
"0",
")",
"summedProps",
"=",
"sum",
"(",
"propensities",
")",
"p... | Proportional probability method. | [
"Proportional",
"probability",
"method",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/roth_erev.py#L254-L267 | train |
rwl/pylon | pylon/io/excel.py | ExcelWriter.write | def write(self, file_or_filename):
""" Writes case data to file in Excel format.
"""
self.book = Workbook()
self._write_data(None)
self.book.save(file_or_filename) | python | def write(self, file_or_filename):
""" Writes case data to file in Excel format.
"""
self.book = Workbook()
self._write_data(None)
self.book.save(file_or_filename) | [
"def",
"write",
"(",
"self",
",",
"file_or_filename",
")",
":",
"self",
".",
"book",
"=",
"Workbook",
"(",
")",
"self",
".",
"_write_data",
"(",
"None",
")",
"self",
".",
"book",
".",
"save",
"(",
"file_or_filename",
")"
] | Writes case data to file in Excel format. | [
"Writes",
"case",
"data",
"to",
"file",
"in",
"Excel",
"format",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L38-L43 | train |
rwl/pylon | pylon/io/excel.py | ExcelWriter.write_bus_data | def write_bus_data(self, file):
""" Writes bus data to an Excel spreadsheet.
"""
bus_sheet = self.book.add_sheet("Buses")
for i, bus in enumerate(self.case.buses):
for j, attr in enumerate(BUS_ATTRS):
bus_sheet.write(i, j, getattr(bus, attr)) | python | def write_bus_data(self, file):
""" Writes bus data to an Excel spreadsheet.
"""
bus_sheet = self.book.add_sheet("Buses")
for i, bus in enumerate(self.case.buses):
for j, attr in enumerate(BUS_ATTRS):
bus_sheet.write(i, j, getattr(bus, attr)) | [
"def",
"write_bus_data",
"(",
"self",
",",
"file",
")",
":",
"bus_sheet",
"=",
"self",
".",
"book",
".",
"add_sheet",
"(",
"\"Buses\"",
")",
"for",
"i",
",",
"bus",
"in",
"enumerate",
"(",
"self",
".",
"case",
".",
"buses",
")",
":",
"for",
"j",
",... | Writes bus data to an Excel spreadsheet. | [
"Writes",
"bus",
"data",
"to",
"an",
"Excel",
"spreadsheet",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L56-L63 | train |
rwl/pylon | pylon/io/excel.py | ExcelWriter.write_branch_data | def write_branch_data(self, file):
""" Writes branch data to an Excel spreadsheet.
"""
branch_sheet = self.book.add_sheet("Branches")
for i, branch in enumerate(self.case.branches):
for j, attr in enumerate(BRANCH_ATTRS):
branch_sheet.write(i, j, getattr(bran... | python | def write_branch_data(self, file):
""" Writes branch data to an Excel spreadsheet.
"""
branch_sheet = self.book.add_sheet("Branches")
for i, branch in enumerate(self.case.branches):
for j, attr in enumerate(BRANCH_ATTRS):
branch_sheet.write(i, j, getattr(bran... | [
"def",
"write_branch_data",
"(",
"self",
",",
"file",
")",
":",
"branch_sheet",
"=",
"self",
".",
"book",
".",
"add_sheet",
"(",
"\"Branches\"",
")",
"for",
"i",
",",
"branch",
"in",
"enumerate",
"(",
"self",
".",
"case",
".",
"branches",
")",
":",
"fo... | Writes branch data to an Excel spreadsheet. | [
"Writes",
"branch",
"data",
"to",
"an",
"Excel",
"spreadsheet",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L66-L73 | train |
rwl/pylon | pylon/io/excel.py | ExcelWriter.write_generator_data | def write_generator_data(self, file):
""" Write generator data to file.
"""
generator_sheet = self.book.add_sheet("Generators")
for j, generator in enumerate(self.case.generators):
i = generator.bus._i
for k, attr in enumerate(GENERATOR_ATTRS):
ge... | python | def write_generator_data(self, file):
""" Write generator data to file.
"""
generator_sheet = self.book.add_sheet("Generators")
for j, generator in enumerate(self.case.generators):
i = generator.bus._i
for k, attr in enumerate(GENERATOR_ATTRS):
ge... | [
"def",
"write_generator_data",
"(",
"self",
",",
"file",
")",
":",
"generator_sheet",
"=",
"self",
".",
"book",
".",
"add_sheet",
"(",
"\"Generators\"",
")",
"for",
"j",
",",
"generator",
"in",
"enumerate",
"(",
"self",
".",
"case",
".",
"generators",
")",... | Write generator data to file. | [
"Write",
"generator",
"data",
"to",
"file",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L76-L84 | train |
rwl/pylon | pylon/io/excel.py | CSVWriter.write | def write(self, file_or_filename):
""" Writes case data as CSV.
"""
if isinstance(file_or_filename, basestring):
file = open(file_or_filename, "wb")
else:
file = file_or_filename
self.writer = csv.writer(file)
super(CSVWriter, self).write(file) | python | def write(self, file_or_filename):
""" Writes case data as CSV.
"""
if isinstance(file_or_filename, basestring):
file = open(file_or_filename, "wb")
else:
file = file_or_filename
self.writer = csv.writer(file)
super(CSVWriter, self).write(file) | [
"def",
"write",
"(",
"self",
",",
"file_or_filename",
")",
":",
"if",
"isinstance",
"(",
"file_or_filename",
",",
"basestring",
")",
":",
"file",
"=",
"open",
"(",
"file_or_filename",
",",
"\"wb\"",
")",
"else",
":",
"file",
"=",
"file_or_filename",
"self",
... | Writes case data as CSV. | [
"Writes",
"case",
"data",
"as",
"CSV",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L112-L122 | train |
rwl/pylon | pylon/io/excel.py | CSVWriter.write_case_data | def write_case_data(self, file):
""" Writes the case data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(["Name", "base_mva"])
writer.writerow([self.case.name, self.case.base_mva]) | python | def write_case_data(self, file):
""" Writes the case data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(["Name", "base_mva"])
writer.writerow([self.case.name, self.case.base_mva]) | [
"def",
"write_case_data",
"(",
"self",
",",
"file",
")",
":",
"writer",
"=",
"self",
".",
"_get_writer",
"(",
"file",
")",
"writer",
".",
"writerow",
"(",
"[",
"\"Name\"",
",",
"\"base_mva\"",
"]",
")",
"writer",
".",
"writerow",
"(",
"[",
"self",
".",... | Writes the case data as CSV. | [
"Writes",
"the",
"case",
"data",
"as",
"CSV",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L125-L130 | train |
rwl/pylon | pylon/io/excel.py | CSVWriter.write_bus_data | def write_bus_data(self, file):
""" Writes bus data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(BUS_ATTRS)
for bus in self.case.buses:
writer.writerow([getattr(bus, attr) for attr in BUS_ATTRS]) | python | def write_bus_data(self, file):
""" Writes bus data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(BUS_ATTRS)
for bus in self.case.buses:
writer.writerow([getattr(bus, attr) for attr in BUS_ATTRS]) | [
"def",
"write_bus_data",
"(",
"self",
",",
"file",
")",
":",
"writer",
"=",
"self",
".",
"_get_writer",
"(",
"file",
")",
"writer",
".",
"writerow",
"(",
"BUS_ATTRS",
")",
"for",
"bus",
"in",
"self",
".",
"case",
".",
"buses",
":",
"writer",
".",
"wr... | Writes bus data as CSV. | [
"Writes",
"bus",
"data",
"as",
"CSV",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L133-L139 | train |
rwl/pylon | pylon/io/excel.py | CSVWriter.write_branch_data | def write_branch_data(self, file):
""" Writes branch data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(BRANCH_ATTRS)
for branch in self.case.branches:
writer.writerow([getattr(branch, a) for a in BRANCH_ATTRS]) | python | def write_branch_data(self, file):
""" Writes branch data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(BRANCH_ATTRS)
for branch in self.case.branches:
writer.writerow([getattr(branch, a) for a in BRANCH_ATTRS]) | [
"def",
"write_branch_data",
"(",
"self",
",",
"file",
")",
":",
"writer",
"=",
"self",
".",
"_get_writer",
"(",
"file",
")",
"writer",
".",
"writerow",
"(",
"BRANCH_ATTRS",
")",
"for",
"branch",
"in",
"self",
".",
"case",
".",
"branches",
":",
"writer",
... | Writes branch data as CSV. | [
"Writes",
"branch",
"data",
"as",
"CSV",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L142-L148 | train |
rwl/pylon | pylon/io/excel.py | CSVWriter.write_generator_data | def write_generator_data(self, file):
""" Write generator data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(["bus"] + GENERATOR_ATTRS)
for g in self.case.generators:
i = g.bus._i
writer.writerow([i] + [getattr(g,a) for a in GENERATOR_ATTRS]... | python | def write_generator_data(self, file):
""" Write generator data as CSV.
"""
writer = self._get_writer(file)
writer.writerow(["bus"] + GENERATOR_ATTRS)
for g in self.case.generators:
i = g.bus._i
writer.writerow([i] + [getattr(g,a) for a in GENERATOR_ATTRS]... | [
"def",
"write_generator_data",
"(",
"self",
",",
"file",
")",
":",
"writer",
"=",
"self",
".",
"_get_writer",
"(",
"file",
")",
"writer",
".",
"writerow",
"(",
"[",
"\"bus\"",
"]",
"+",
"GENERATOR_ATTRS",
")",
"for",
"g",
"in",
"self",
".",
"case",
"."... | Write generator data as CSV. | [
"Write",
"generator",
"data",
"as",
"CSV",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/excel.py#L151-L159 | train |
rwl/pylon | pyreto/smart_market.py | SmartMarket.run | def run(self):
""" Computes cleared offers and bids.
"""
# Start the clock.
t0 = time.time()
# Manage reactive power offers/bids.
haveQ = self._isReactiveMarket()
# Withhold offers/bids outwith optional price limits.
self._withholdOffbids()
# Co... | python | def run(self):
""" Computes cleared offers and bids.
"""
# Start the clock.
t0 = time.time()
# Manage reactive power offers/bids.
haveQ = self._isReactiveMarket()
# Withhold offers/bids outwith optional price limits.
self._withholdOffbids()
# Co... | [
"def",
"run",
"(",
"self",
")",
":",
"# Start the clock.",
"t0",
"=",
"time",
".",
"time",
"(",
")",
"# Manage reactive power offers/bids.",
"haveQ",
"=",
"self",
".",
"_isReactiveMarket",
"(",
")",
"# Withhold offers/bids outwith optional price limits.",
"self",
".",... | Computes cleared offers and bids. | [
"Computes",
"cleared",
"offers",
"and",
"bids",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/smart_market.py#L131-L166 | train |
rwl/pylon | pyreto/smart_market.py | SmartMarket._runOPF | def _runOPF(self):
""" Computes dispatch points and LMPs using OPF.
"""
if self.decommit:
solver = UDOPF(self.case, dc=(self.locationalAdjustment == "dc"))
elif self.locationalAdjustment == "dc":
solver = OPF(self.case, dc=True)
else:
solver = ... | python | def _runOPF(self):
""" Computes dispatch points and LMPs using OPF.
"""
if self.decommit:
solver = UDOPF(self.case, dc=(self.locationalAdjustment == "dc"))
elif self.locationalAdjustment == "dc":
solver = OPF(self.case, dc=True)
else:
solver = ... | [
"def",
"_runOPF",
"(",
"self",
")",
":",
"if",
"self",
".",
"decommit",
":",
"solver",
"=",
"UDOPF",
"(",
"self",
".",
"case",
",",
"dc",
"=",
"(",
"self",
".",
"locationalAdjustment",
"==",
"\"dc\"",
")",
")",
"elif",
"self",
".",
"locationalAdjustmen... | Computes dispatch points and LMPs using OPF. | [
"Computes",
"dispatch",
"points",
"and",
"LMPs",
"using",
"OPF",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/smart_market.py#L266-L281 | train |
rwl/pylon | contrib/public/services/simplejson/encoder.py | JSONEncoder.encode | def encode(self, o):
"""
Return a JSON string representation of a Python data structure.
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo":["bar", "baz"]}'
"""
# This doesn't pass the iterator directly to ''.join() because it
# sucks at reporting exceptio... | python | def encode(self, o):
"""
Return a JSON string representation of a Python data structure.
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo":["bar", "baz"]}'
"""
# This doesn't pass the iterator directly to ''.join() because it
# sucks at reporting exceptio... | [
"def",
"encode",
"(",
"self",
",",
"o",
")",
":",
"# This doesn't pass the iterator directly to ''.join() because it",
"# sucks at reporting exceptions. It's going to do this internally",
"# anyway because it uses PySequence_Fast or similar.",
"chunks",
"=",
"list",
"(",
"self",
"."... | Return a JSON string representation of a Python data structure.
>>> JSONEncoder().encode({"foo": ["bar", "baz"]})
'{"foo":["bar", "baz"]}' | [
"Return",
"a",
"JSON",
"string",
"representation",
"of",
"a",
"Python",
"data",
"structure",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/contrib/public/services/simplejson/encoder.py#L278-L289 | train |
finklabs/metrics | metrics/compute.py | compute_file_metrics | def compute_file_metrics(processors, language, key, token_list):
"""use processors to compute file metrics."""
# multiply iterator
tli = itertools.tee(token_list, len(processors))
metrics = OrderedDict()
# reset all processors
for p in processors:
p.reset()
# process all tokens
... | python | def compute_file_metrics(processors, language, key, token_list):
"""use processors to compute file metrics."""
# multiply iterator
tli = itertools.tee(token_list, len(processors))
metrics = OrderedDict()
# reset all processors
for p in processors:
p.reset()
# process all tokens
... | [
"def",
"compute_file_metrics",
"(",
"processors",
",",
"language",
",",
"key",
",",
"token_list",
")",
":",
"# multiply iterator",
"tli",
"=",
"itertools",
".",
"tee",
"(",
"token_list",
",",
"len",
"(",
"processors",
")",
")",
"metrics",
"=",
"OrderedDict",
... | use processors to compute file metrics. | [
"use",
"processors",
"to",
"compute",
"file",
"metrics",
"."
] | fd9974af498831664b9ae8e8f3834e1ec2e8a699 | https://github.com/finklabs/metrics/blob/fd9974af498831664b9ae8e8f3834e1ec2e8a699/metrics/compute.py#L8-L26 | train |
Liebeck/IWNLP-py | iwnlp/iwnlp_wrapper.py | IWNLPWrapper.load | def load(self, lemmatizer_path):
"""
This methods load the IWNLP.Lemmatizer json file and creates a dictionary
of lowercased forms which maps each form to its possible lemmas.
"""
self.lemmatizer = {}
with io.open(lemmatizer_path, encoding='utf-8') as data_file:
... | python | def load(self, lemmatizer_path):
"""
This methods load the IWNLP.Lemmatizer json file and creates a dictionary
of lowercased forms which maps each form to its possible lemmas.
"""
self.lemmatizer = {}
with io.open(lemmatizer_path, encoding='utf-8') as data_file:
... | [
"def",
"load",
"(",
"self",
",",
"lemmatizer_path",
")",
":",
"self",
".",
"lemmatizer",
"=",
"{",
"}",
"with",
"io",
".",
"open",
"(",
"lemmatizer_path",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"data_file",
":",
"raw",
"=",
"json",
".",
"load",
... | This methods load the IWNLP.Lemmatizer json file and creates a dictionary
of lowercased forms which maps each form to its possible lemmas. | [
"This",
"methods",
"load",
"the",
"IWNLP",
".",
"Lemmatizer",
"json",
"file",
"and",
"creates",
"a",
"dictionary",
"of",
"lowercased",
"forms",
"which",
"maps",
"each",
"form",
"to",
"its",
"possible",
"lemmas",
"."
] | fd4b81769317476eac0487396cce0faf482a1913 | https://github.com/Liebeck/IWNLP-py/blob/fd4b81769317476eac0487396cce0faf482a1913/iwnlp/iwnlp_wrapper.py#L14-L24 | train |
rwl/pylon | pylon/io/common.py | _CaseWriter.write | def write(self, file_or_filename):
""" Writes the case data to file.
"""
if isinstance(file_or_filename, basestring):
file = None
try:
file = open(file_or_filename, "wb")
except Exception, detail:
logger.error("Error opening %s.... | python | def write(self, file_or_filename):
""" Writes the case data to file.
"""
if isinstance(file_or_filename, basestring):
file = None
try:
file = open(file_or_filename, "wb")
except Exception, detail:
logger.error("Error opening %s.... | [
"def",
"write",
"(",
"self",
",",
"file_or_filename",
")",
":",
"if",
"isinstance",
"(",
"file_or_filename",
",",
"basestring",
")",
":",
"file",
"=",
"None",
"try",
":",
"file",
"=",
"open",
"(",
"file_or_filename",
",",
"\"wb\"",
")",
"except",
"Exceptio... | Writes the case data to file. | [
"Writes",
"the",
"case",
"data",
"to",
"file",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/common.py#L64-L81 | train |
rwl/pylon | pyreto/discrete/task.py | ProfitTask.performAction | def performAction(self, action):
""" The action vector is stripped and the only element is cast to
integer and given to the super class.
"""
self.t += 1
super(ProfitTask, self).performAction(int(action[0]))
self.samples += 1 | python | def performAction(self, action):
""" The action vector is stripped and the only element is cast to
integer and given to the super class.
"""
self.t += 1
super(ProfitTask, self).performAction(int(action[0]))
self.samples += 1 | [
"def",
"performAction",
"(",
"self",
",",
"action",
")",
":",
"self",
".",
"t",
"+=",
"1",
"super",
"(",
"ProfitTask",
",",
"self",
")",
".",
"performAction",
"(",
"int",
"(",
"action",
"[",
"0",
"]",
")",
")",
"self",
".",
"samples",
"+=",
"1"
] | The action vector is stripped and the only element is cast to
integer and given to the super class. | [
"The",
"action",
"vector",
"is",
"stripped",
"and",
"the",
"only",
"element",
"is",
"cast",
"to",
"integer",
"and",
"given",
"to",
"the",
"super",
"class",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/discrete/task.py#L120-L126 | train |
rwl/pylon | pyreto/discrete/task.py | ProfitTask.addReward | def addReward(self, r=None):
""" A filtered mapping towards performAction of the underlying
environment.
"""
r = self.getReward() if r is None else r
# by default, the cumulative reward is just the sum over the episode
if self.discount:
self.cumulativeRew... | python | def addReward(self, r=None):
""" A filtered mapping towards performAction of the underlying
environment.
"""
r = self.getReward() if r is None else r
# by default, the cumulative reward is just the sum over the episode
if self.discount:
self.cumulativeRew... | [
"def",
"addReward",
"(",
"self",
",",
"r",
"=",
"None",
")",
":",
"r",
"=",
"self",
".",
"getReward",
"(",
")",
"if",
"r",
"is",
"None",
"else",
"r",
"# by default, the cumulative reward is just the sum over the episode",
"if",
"self",
".",
"discount",
":",
... | A filtered mapping towards performAction of the underlying
environment. | [
"A",
"filtered",
"mapping",
"towards",
"performAction",
"of",
"the",
"underlying",
"environment",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/discrete/task.py#L156-L166 | train |
rwl/pylon | pylon/estimator.py | StateEstimator.getV0 | def getV0(self, v_mag_guess, buses, generators, type=CASE_GUESS):
""" Returns the initial voltage profile.
"""
if type == CASE_GUESS:
Va = array([b.v_angle * (pi / 180.0) for b in buses])
Vm = array([b.v_magnitude for b in buses])
V0 = Vm * exp(1j * Va)
... | python | def getV0(self, v_mag_guess, buses, generators, type=CASE_GUESS):
""" Returns the initial voltage profile.
"""
if type == CASE_GUESS:
Va = array([b.v_angle * (pi / 180.0) for b in buses])
Vm = array([b.v_magnitude for b in buses])
V0 = Vm * exp(1j * Va)
... | [
"def",
"getV0",
"(",
"self",
",",
"v_mag_guess",
",",
"buses",
",",
"generators",
",",
"type",
"=",
"CASE_GUESS",
")",
":",
"if",
"type",
"==",
"CASE_GUESS",
":",
"Va",
"=",
"array",
"(",
"[",
"b",
".",
"v_angle",
"*",
"(",
"pi",
"/",
"180.0",
")",... | Returns the initial voltage profile. | [
"Returns",
"the",
"initial",
"voltage",
"profile",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/estimator.py#L300-L321 | train |
rwl/pylon | pylon/estimator.py | StateEstimator.output_solution | def output_solution(self, fd, z, z_est, error_sqrsum):
""" Prints comparison of measurements and their estimations.
"""
col_width = 11
sep = ("=" * col_width + " ") * 4 + "\n"
fd.write("State Estimation\n")
fd.write("-" * 16 + "\n")
fd.write(sep)
fd.write... | python | def output_solution(self, fd, z, z_est, error_sqrsum):
""" Prints comparison of measurements and their estimations.
"""
col_width = 11
sep = ("=" * col_width + " ") * 4 + "\n"
fd.write("State Estimation\n")
fd.write("-" * 16 + "\n")
fd.write(sep)
fd.write... | [
"def",
"output_solution",
"(",
"self",
",",
"fd",
",",
"z",
",",
"z_est",
",",
"error_sqrsum",
")",
":",
"col_width",
"=",
"11",
"sep",
"=",
"(",
"\"=\"",
"*",
"col_width",
"+",
"\" \"",
")",
"*",
"4",
"+",
"\"\\n\"",
"fd",
".",
"write",
"(",
"\"St... | Prints comparison of measurements and their estimations. | [
"Prints",
"comparison",
"of",
"measurements",
"and",
"their",
"estimations",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/estimator.py#L324-L352 | train |
rwl/pylon | pyreto/auction.py | Auction.run | def run(self):
""" Clears a set of bids and offers.
"""
# Compute cleared offer/bid quantities from total dispatched quantity.
self._clearQuantities()
# Compute shift values to add to lam to get desired pricing.
# lao, fro, lab, frb = self._first_rejected_last_accepted()
... | python | def run(self):
""" Clears a set of bids and offers.
"""
# Compute cleared offer/bid quantities from total dispatched quantity.
self._clearQuantities()
# Compute shift values to add to lam to get desired pricing.
# lao, fro, lab, frb = self._first_rejected_last_accepted()
... | [
"def",
"run",
"(",
"self",
")",
":",
"# Compute cleared offer/bid quantities from total dispatched quantity.",
"self",
".",
"_clearQuantities",
"(",
")",
"# Compute shift values to add to lam to get desired pricing.",
"# lao, fro, lab, frb = self._first_rejected_last_accepted()",
... | Clears a set of bids and offers. | [
"Clears",
"a",
"set",
"of",
"bids",
"and",
"offers",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/auction.py#L85-L103 | train |
rwl/pylon | pyreto/auction.py | Auction._clearQuantity | def _clearQuantity(self, offbids, gen):
""" Computes the cleared bid quantity from total dispatched quantity.
"""
# Filter out offers/bids not applicable to the generator in question.
gOffbids = [offer for offer in offbids if offer.generator == gen]
# Offers/bids within valid pr... | python | def _clearQuantity(self, offbids, gen):
""" Computes the cleared bid quantity from total dispatched quantity.
"""
# Filter out offers/bids not applicable to the generator in question.
gOffbids = [offer for offer in offbids if offer.generator == gen]
# Offers/bids within valid pr... | [
"def",
"_clearQuantity",
"(",
"self",
",",
"offbids",
",",
"gen",
")",
":",
"# Filter out offers/bids not applicable to the generator in question.",
"gOffbids",
"=",
"[",
"offer",
"for",
"offer",
"in",
"offbids",
"if",
"offer",
".",
"generator",
"==",
"gen",
"]",
... | Computes the cleared bid quantity from total dispatched quantity. | [
"Computes",
"the",
"cleared",
"bid",
"quantity",
"from",
"total",
"dispatched",
"quantity",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/auction.py#L120-L158 | train |
rwl/pylon | pyreto/auction.py | Auction._clearPrices | def _clearPrices(self):
""" Clears prices according to auction type.
"""
for offbid in self.offers + self.bids:
if self.auctionType == DISCRIMINATIVE:
offbid.clearedPrice = offbid.price
elif self.auctionType == FIRST_PRICE:
offbid.clearedPr... | python | def _clearPrices(self):
""" Clears prices according to auction type.
"""
for offbid in self.offers + self.bids:
if self.auctionType == DISCRIMINATIVE:
offbid.clearedPrice = offbid.price
elif self.auctionType == FIRST_PRICE:
offbid.clearedPr... | [
"def",
"_clearPrices",
"(",
"self",
")",
":",
"for",
"offbid",
"in",
"self",
".",
"offers",
"+",
"self",
".",
"bids",
":",
"if",
"self",
".",
"auctionType",
"==",
"DISCRIMINATIVE",
":",
"offbid",
".",
"clearedPrice",
"=",
"offbid",
".",
"price",
"elif",
... | Clears prices according to auction type. | [
"Clears",
"prices",
"according",
"to",
"auction",
"type",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/auction.py#L219-L228 | train |
rwl/pylon | pyreto/auction.py | Auction._clipPrices | def _clipPrices(self):
""" Clip cleared prices according to guarantees and limits.
"""
# Guarantee that cleared offer prices are >= offers.
if self.guaranteeOfferPrice:
for offer in self.offers:
if offer.accepted and offer.clearedPrice < offer.price:
... | python | def _clipPrices(self):
""" Clip cleared prices according to guarantees and limits.
"""
# Guarantee that cleared offer prices are >= offers.
if self.guaranteeOfferPrice:
for offer in self.offers:
if offer.accepted and offer.clearedPrice < offer.price:
... | [
"def",
"_clipPrices",
"(",
"self",
")",
":",
"# Guarantee that cleared offer prices are >= offers.",
"if",
"self",
".",
"guaranteeOfferPrice",
":",
"for",
"offer",
"in",
"self",
".",
"offers",
":",
"if",
"offer",
".",
"accepted",
"and",
"offer",
".",
"clearedPrice... | Clip cleared prices according to guarantees and limits. | [
"Clip",
"cleared",
"prices",
"according",
"to",
"guarantees",
"and",
"limits",
"."
] | 916514255db1ae1661406f0283df756baf960d14 | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pyreto/auction.py#L265-L311 | train |
praekeltfoundation/seaworthy | seaworthy/client.py | wait_for_response | def wait_for_response(client, timeout, path='/', expected_status_code=None):
"""
Try make a GET request with an HTTP client against a certain path and
return once any response has been received, ignoring any errors.
:param ContainerHttpClient client:
The HTTP client to use to connect to the con... | python | def wait_for_response(client, timeout, path='/', expected_status_code=None):
"""
Try make a GET request with an HTTP client against a certain path and
return once any response has been received, ignoring any errors.
:param ContainerHttpClient client:
The HTTP client to use to connect to the con... | [
"def",
"wait_for_response",
"(",
"client",
",",
"timeout",
",",
"path",
"=",
"'/'",
",",
"expected_status_code",
"=",
"None",
")",
":",
"# We want time.monotonic on Pythons that have it, otherwise time.time will",
"# have to do.",
"get_time",
"=",
"getattr",
"(",
"time",
... | Try make a GET request with an HTTP client against a certain path and
return once any response has been received, ignoring any errors.
:param ContainerHttpClient client:
The HTTP client to use to connect to the container.
:param timeout:
Timeout value in seconds.
:param path:
HT... | [
"Try",
"make",
"a",
"GET",
"request",
"with",
"an",
"HTTP",
"client",
"against",
"a",
"certain",
"path",
"and",
"return",
"once",
"any",
"response",
"has",
"been",
"received",
"ignoring",
"any",
"errors",
"."
] | 6f10a19b45d4ea1dc3bd0553cc4d0438696c079c | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/client.py#L205-L248 | train |
praekeltfoundation/seaworthy | seaworthy/client.py | ContainerHttpClient.request | def request(self, method, path=None, url_kwargs=None, **kwargs):
"""
Make a request against a container.
:param method:
The HTTP method to use.
:param list path:
The HTTP path (either absolute or relative).
:param dict url_kwargs:
Parameters t... | python | def request(self, method, path=None, url_kwargs=None, **kwargs):
"""
Make a request against a container.
:param method:
The HTTP method to use.
:param list path:
The HTTP path (either absolute or relative).
:param dict url_kwargs:
Parameters t... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"path",
"=",
"None",
",",
"url_kwargs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_session",
".",
"request",
"(",
"method",
",",
"self",
".",
"_url",
"(",
"path",
",",... | Make a request against a container.
:param method:
The HTTP method to use.
:param list path:
The HTTP path (either absolute or relative).
:param dict url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param kwargs:
... | [
"Make",
"a",
"request",
"against",
"a",
"container",
"."
] | 6f10a19b45d4ea1dc3bd0553cc4d0438696c079c | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/client.py#L90-L104 | train |
praekeltfoundation/seaworthy | seaworthy/client.py | ContainerHttpClient.options | def options(self, path=None, url_kwargs=None, **kwargs):
"""
Sends an OPTIONS request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
... | python | def options(self, path=None, url_kwargs=None, **kwargs):
"""
Sends an OPTIONS request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
... | [
"def",
"options",
"(",
"self",
",",
"path",
"=",
"None",
",",
"url_kwargs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_session",
".",
"options",
"(",
"self",
".",
"_url",
"(",
"path",
",",
"url_kwargs",
")",
",",
"*",
... | Sends an OPTIONS request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Optional arguments that ``request`` takes.
:return: response obj... | [
"Sends",
"an",
"OPTIONS",
"request",
"."
] | 6f10a19b45d4ea1dc3bd0553cc4d0438696c079c | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/client.py#L120-L132 | train |
praekeltfoundation/seaworthy | seaworthy/client.py | ContainerHttpClient.head | def head(self, path=None, url_kwargs=None, **kwargs):
"""
Sends a HEAD request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Op... | python | def head(self, path=None, url_kwargs=None, **kwargs):
"""
Sends a HEAD request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Op... | [
"def",
"head",
"(",
"self",
",",
"path",
"=",
"None",
",",
"url_kwargs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_session",
".",
"head",
"(",
"self",
".",
"_url",
"(",
"path",
",",
"url_kwargs",
")",
",",
"*",
"*",... | Sends a HEAD request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Optional arguments that ``request`` takes.
:return: response object | [
"Sends",
"a",
"HEAD",
"request",
"."
] | 6f10a19b45d4ea1dc3bd0553cc4d0438696c079c | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/client.py#L134-L146 | train |
praekeltfoundation/seaworthy | seaworthy/client.py | ContainerHttpClient.post | def post(self, path=None, url_kwargs=None, **kwargs):
"""
Sends a POST request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Op... | python | def post(self, path=None, url_kwargs=None, **kwargs):
"""
Sends a POST request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Op... | [
"def",
"post",
"(",
"self",
",",
"path",
"=",
"None",
",",
"url_kwargs",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_session",
".",
"post",
"(",
"self",
".",
"_url",
"(",
"path",
",",
"url_kwargs",
")",
",",
"*",
"*",... | Sends a POST request.
:param path:
The HTTP path (either absolute or relative).
:param url_kwargs:
Parameters to override in the generated URL. See `~hyperlink.URL`.
:param **kwargs:
Optional arguments that ``request`` takes.
:return: response object | [
"Sends",
"a",
"POST",
"request",
"."
] | 6f10a19b45d4ea1dc3bd0553cc4d0438696c079c | https://github.com/praekeltfoundation/seaworthy/blob/6f10a19b45d4ea1dc3bd0553cc4d0438696c079c/seaworthy/client.py#L148-L160 | train |
ratt-ru/PyMORESANE | pymoresane/iuwt.py | iuwt_decomposition | def iuwt_decomposition(in1, scale_count, scale_adjust=0, mode='ser', core_count=2, store_smoothed=False,
store_on_gpu=False):
"""
This function serves as a handler for the different implementations of the IUWT decomposition. It allows the
different methods to be used almost interchang... | python | def iuwt_decomposition(in1, scale_count, scale_adjust=0, mode='ser', core_count=2, store_smoothed=False,
store_on_gpu=False):
"""
This function serves as a handler for the different implementations of the IUWT decomposition. It allows the
different methods to be used almost interchang... | [
"def",
"iuwt_decomposition",
"(",
"in1",
",",
"scale_count",
",",
"scale_adjust",
"=",
"0",
",",
"mode",
"=",
"'ser'",
",",
"core_count",
"=",
"2",
",",
"store_smoothed",
"=",
"False",
",",
"store_on_gpu",
"=",
"False",
")",
":",
"if",
"mode",
"==",
"'se... | This function serves as a handler for the different implementations of the IUWT decomposition. It allows the
different methods to be used almost interchangeably.
INPUTS:
in1 (no default): Array on which the decomposition is to be performed.
scale_count (no default): ... | [
"This",
"function",
"serves",
"as",
"a",
"handler",
"for",
"the",
"different",
"implementations",
"of",
"the",
"IUWT",
"decomposition",
".",
"It",
"allows",
"the",
"different",
"methods",
"to",
"be",
"used",
"almost",
"interchangeably",
"."
] | b024591ad0bbb69320d08841f28a2c27f62ae1af | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L17-L41 | train |
ratt-ru/PyMORESANE | pymoresane/iuwt.py | iuwt_recomposition | def iuwt_recomposition(in1, scale_adjust=0, mode='ser', core_count=1, store_on_gpu=False, smoothed_array=None):
"""
This function serves as a handler for the different implementations of the IUWT recomposition. It allows the
different methods to be used almost interchangeably.
INPUTS:
in1 ... | python | def iuwt_recomposition(in1, scale_adjust=0, mode='ser', core_count=1, store_on_gpu=False, smoothed_array=None):
"""
This function serves as a handler for the different implementations of the IUWT recomposition. It allows the
different methods to be used almost interchangeably.
INPUTS:
in1 ... | [
"def",
"iuwt_recomposition",
"(",
"in1",
",",
"scale_adjust",
"=",
"0",
",",
"mode",
"=",
"'ser'",
",",
"core_count",
"=",
"1",
",",
"store_on_gpu",
"=",
"False",
",",
"smoothed_array",
"=",
"None",
")",
":",
"if",
"mode",
"==",
"'ser'",
":",
"return",
... | This function serves as a handler for the different implementations of the IUWT recomposition. It allows the
different methods to be used almost interchangeably.
INPUTS:
in1 (no default): Array on which the decomposition is to be performed.
scale_adjust (no default): ... | [
"This",
"function",
"serves",
"as",
"a",
"handler",
"for",
"the",
"different",
"implementations",
"of",
"the",
"IUWT",
"recomposition",
".",
"It",
"allows",
"the",
"different",
"methods",
"to",
"be",
"used",
"almost",
"interchangeably",
"."
] | b024591ad0bbb69320d08841f28a2c27f62ae1af | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L43-L64 | train |
ratt-ru/PyMORESANE | pymoresane/iuwt.py | ser_iuwt_decomposition | def ser_iuwt_decomposition(in1, scale_count, scale_adjust, store_smoothed):
"""
This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is
the isotropic undecimated wavelet transform implemented for a single CPU core.
INPUTS:
in1 (no... | python | def ser_iuwt_decomposition(in1, scale_count, scale_adjust, store_smoothed):
"""
This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is
the isotropic undecimated wavelet transform implemented for a single CPU core.
INPUTS:
in1 (no... | [
"def",
"ser_iuwt_decomposition",
"(",
"in1",
",",
"scale_count",
",",
"scale_adjust",
",",
"store_smoothed",
")",
":",
"wavelet_filter",
"=",
"(",
"1.",
"/",
"16",
")",
"*",
"np",
".",
"array",
"(",
"[",
"1",
",",
"4",
",",
"6",
",",
"4",
",",
"1",
... | This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is
the isotropic undecimated wavelet transform implemented for a single CPU core.
INPUTS:
in1 (no default): Array on which the decomposition is to be performed.
scale_count ... | [
"This",
"function",
"calls",
"the",
"a",
"trous",
"algorithm",
"code",
"to",
"decompose",
"the",
"input",
"into",
"its",
"wavelet",
"coefficients",
".",
"This",
"is",
"the",
"isotropic",
"undecimated",
"wavelet",
"transform",
"implemented",
"for",
"a",
"single",... | b024591ad0bbb69320d08841f28a2c27f62ae1af | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L66-L111 | train |
ratt-ru/PyMORESANE | pymoresane/iuwt.py | ser_iuwt_recomposition | def ser_iuwt_recomposition(in1, scale_adjust, smoothed_array):
"""
This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for a single CPU core.
INPUTS:
in1 (no de... | python | def ser_iuwt_recomposition(in1, scale_adjust, smoothed_array):
"""
This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for a single CPU core.
INPUTS:
in1 (no de... | [
"def",
"ser_iuwt_recomposition",
"(",
"in1",
",",
"scale_adjust",
",",
"smoothed_array",
")",
":",
"wavelet_filter",
"=",
"(",
"1.",
"/",
"16",
")",
"*",
"np",
".",
"array",
"(",
"[",
"1",
",",
"4",
",",
"6",
",",
"4",
",",
"1",
"]",
")",
"# Filter... | This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for a single CPU core.
INPUTS:
in1 (no default): Array containing wavelet coefficients.
scale_adjust (no de... | [
"This",
"function",
"calls",
"the",
"a",
"trous",
"algorithm",
"code",
"to",
"recompose",
"the",
"input",
"into",
"a",
"single",
"array",
".",
"This",
"is",
"the",
"implementation",
"of",
"the",
"isotropic",
"undecimated",
"wavelet",
"transform",
"recomposition"... | b024591ad0bbb69320d08841f28a2c27f62ae1af | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L113-L149 | train |
ratt-ru/PyMORESANE | pymoresane/iuwt.py | mp_iuwt_recomposition | def mp_iuwt_recomposition(in1, scale_adjust, core_count, smoothed_array):
"""
This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for multiple CPU cores.
INPUTS:
in1 ... | python | def mp_iuwt_recomposition(in1, scale_adjust, core_count, smoothed_array):
"""
This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for multiple CPU cores.
INPUTS:
in1 ... | [
"def",
"mp_iuwt_recomposition",
"(",
"in1",
",",
"scale_adjust",
",",
"core_count",
",",
"smoothed_array",
")",
":",
"wavelet_filter",
"=",
"(",
"1.",
"/",
"16",
")",
"*",
"np",
".",
"array",
"(",
"[",
"1",
",",
"4",
",",
"6",
",",
"4",
",",
"1",
"... | This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for multiple CPU cores.
INPUTS:
in1 (no default): Array containing wavelet coefficients.
scale_adjust (no d... | [
"This",
"function",
"calls",
"the",
"a",
"trous",
"algorithm",
"code",
"to",
"recompose",
"the",
"input",
"into",
"a",
"single",
"array",
".",
"This",
"is",
"the",
"implementation",
"of",
"the",
"isotropic",
"undecimated",
"wavelet",
"transform",
"recomposition"... | b024591ad0bbb69320d08841f28a2c27f62ae1af | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L242-L279 | train |
ratt-ru/PyMORESANE | pymoresane/iuwt.py | gpu_iuwt_decomposition | def gpu_iuwt_decomposition(in1, scale_count, scale_adjust, store_smoothed, store_on_gpu):
"""
This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is
the isotropic undecimated wavelet transform implemented for a GPU.
INPUTS:
in1 (... | python | def gpu_iuwt_decomposition(in1, scale_count, scale_adjust, store_smoothed, store_on_gpu):
"""
This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is
the isotropic undecimated wavelet transform implemented for a GPU.
INPUTS:
in1 (... | [
"def",
"gpu_iuwt_decomposition",
"(",
"in1",
",",
"scale_count",
",",
"scale_adjust",
",",
"store_smoothed",
",",
"store_on_gpu",
")",
":",
"# The following simple kernel just allows for the construction of a 3D decomposition on the GPU.",
"ker",
"=",
"SourceModule",
"(",
"\"\"... | This function calls the a trous algorithm code to decompose the input into its wavelet coefficients. This is
the isotropic undecimated wavelet transform implemented for a GPU.
INPUTS:
in1 (no default): Array on which the decomposition is to be performed.
scale_count (no defaul... | [
"This",
"function",
"calls",
"the",
"a",
"trous",
"algorithm",
"code",
"to",
"decompose",
"the",
"input",
"into",
"its",
"wavelet",
"coefficients",
".",
"This",
"is",
"the",
"isotropic",
"undecimated",
"wavelet",
"transform",
"implemented",
"for",
"a",
"GPU",
... | b024591ad0bbb69320d08841f28a2c27f62ae1af | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L384-L499 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.