repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Gate.connect_input | def connect_input(self, name, wire):
"""Connect the specified input to a wire."""
self._inputs[name] = wire
wire.sinks.append(self) | python | def connect_input(self, name, wire):
"""Connect the specified input to a wire."""
self._inputs[name] = wire
wire.sinks.append(self) | [
"def",
"connect_input",
"(",
"self",
",",
"name",
",",
"wire",
")",
":",
"self",
".",
"_inputs",
"[",
"name",
"]",
"=",
"wire",
"wire",
".",
"sinks",
".",
"append",
"(",
"self",
")"
] | Connect the specified input to a wire. | [
"Connect",
"the",
"specified",
"input",
"to",
"a",
"wire",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L80-L83 |
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Gate._write_config | def _write_config(self, memory):
"""Write the configuration for this gate to memory."""
memory.seek(0)
memory.write(struct.pack("<5I",
# sim_length
self._simulator.length,
# input_a_key
... | python | def _write_config(self, memory):
"""Write the configuration for this gate to memory."""
memory.seek(0)
memory.write(struct.pack("<5I",
# sim_length
self._simulator.length,
# input_a_key
... | [
"def",
"_write_config",
"(",
"self",
",",
"memory",
")",
":",
"memory",
".",
"seek",
"(",
"0",
")",
"memory",
".",
"write",
"(",
"struct",
".",
"pack",
"(",
"\"<5I\"",
",",
"# sim_length",
"self",
".",
"_simulator",
".",
"length",
",",
"# input_a_key",
... | Write the configuration for this gate to memory. | [
"Write",
"the",
"configuration",
"for",
"this",
"gate",
"to",
"memory",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L94-L111 |
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Probe.connect_input | def connect_input(self, wire):
"""Probe the specified wire."""
self._input = wire
wire.sinks.append(self) | python | def connect_input(self, wire):
"""Probe the specified wire."""
self._input = wire
wire.sinks.append(self) | [
"def",
"connect_input",
"(",
"self",
",",
"wire",
")",
":",
"self",
".",
"_input",
"=",
"wire",
"wire",
".",
"sinks",
".",
"append",
"(",
"self",
")"
] | Probe the specified wire. | [
"Probe",
"the",
"specified",
"wire",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L172-L175 |
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Probe._write_config | def _write_config(self, memory):
"""Write the configuration for this probe to memory."""
memory.seek(0)
memory.write(struct.pack("<II",
# sim_length
self._simulator.length,
# input_key
... | python | def _write_config(self, memory):
"""Write the configuration for this probe to memory."""
memory.seek(0)
memory.write(struct.pack("<II",
# sim_length
self._simulator.length,
# input_key
... | [
"def",
"_write_config",
"(",
"self",
",",
"memory",
")",
":",
"memory",
".",
"seek",
"(",
"0",
")",
"memory",
".",
"write",
"(",
"struct",
".",
"pack",
"(",
"\"<II\"",
",",
"# sim_length",
"self",
".",
"_simulator",
".",
"length",
",",
"# input_key",
"... | Write the configuration for this probe to memory. | [
"Write",
"the",
"configuration",
"for",
"this",
"probe",
"to",
"memory",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L187-L196 |
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Probe._read_results | def _read_results(self, memory):
"""Read back the probed results.
Returns
-------
str
A string of "0"s and "1"s, one for each millisecond of simulation.
"""
# Seek to the simulation data and read it all back
memory.seek(8)
bits = bitarray(endi... | python | def _read_results(self, memory):
"""Read back the probed results.
Returns
-------
str
A string of "0"s and "1"s, one for each millisecond of simulation.
"""
# Seek to the simulation data and read it all back
memory.seek(8)
bits = bitarray(endi... | [
"def",
"_read_results",
"(",
"self",
",",
"memory",
")",
":",
"# Seek to the simulation data and read it all back",
"memory",
".",
"seek",
"(",
"8",
")",
"bits",
"=",
"bitarray",
"(",
"endian",
"=",
"\"little\"",
")",
"bits",
".",
"frombytes",
"(",
"memory",
"... | Read back the probed results.
Returns
-------
str
A string of "0"s and "1"s, one for each millisecond of simulation. | [
"Read",
"back",
"the",
"probed",
"results",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L198-L210 |
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Stimulus._write_config | def _write_config(self, memory):
"""Write the configuration for this stimulus to memory."""
memory.seek(0)
memory.write(struct.pack("<II",
# sim_length
self._simulator.length,
# output_key
... | python | def _write_config(self, memory):
"""Write the configuration for this stimulus to memory."""
memory.seek(0)
memory.write(struct.pack("<II",
# sim_length
self._simulator.length,
# output_key
... | [
"def",
"_write_config",
"(",
"self",
",",
"memory",
")",
":",
"memory",
".",
"seek",
"(",
"0",
")",
"memory",
".",
"write",
"(",
"struct",
".",
"pack",
"(",
"\"<II\"",
",",
"# sim_length",
"self",
".",
"_simulator",
".",
"length",
",",
"# output_key",
... | Write the configuration for this stimulus to memory. | [
"Write",
"the",
"configuration",
"for",
"this",
"stimulus",
"to",
"memory",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L247-L259 |
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Simulator._new_wire | def _new_wire(self, source, sinks=None):
"""Create a new :py:class:`._Wire` with a unique routing key."""
# Assign sequential routing key to new nets.
wire = _Wire(source, sinks if sinks is not None else [], len(self._wires))
self._wires.append(wire)
return wire | python | def _new_wire(self, source, sinks=None):
"""Create a new :py:class:`._Wire` with a unique routing key."""
# Assign sequential routing key to new nets.
wire = _Wire(source, sinks if sinks is not None else [], len(self._wires))
self._wires.append(wire)
return wire | [
"def",
"_new_wire",
"(",
"self",
",",
"source",
",",
"sinks",
"=",
"None",
")",
":",
"# Assign sequential routing key to new nets.",
"wire",
"=",
"_Wire",
"(",
"source",
",",
"sinks",
"if",
"sinks",
"is",
"not",
"None",
"else",
"[",
"]",
",",
"len",
"(",
... | Create a new :py:class:`._Wire` with a unique routing key. | [
"Create",
"a",
"new",
":",
"py",
":",
"class",
":",
".",
"_Wire",
"with",
"a",
"unique",
"routing",
"key",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L295-L301 |
project-rig/rig | docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py | Simulator.run | def run(self):
"""Run the simulation."""
# Define the resource requirements of each component in the simulation.
vertices_resources = {
# Every component runs on exactly one core and consumes a certain
# amount of SDRAM to hold configuration data.
component: {... | python | def run(self):
"""Run the simulation."""
# Define the resource requirements of each component in the simulation.
vertices_resources = {
# Every component runs on exactly one core and consumes a certain
# amount of SDRAM to hold configuration data.
component: {... | [
"def",
"run",
"(",
"self",
")",
":",
"# Define the resource requirements of each component in the simulation.",
"vertices_resources",
"=",
"{",
"# Every component runs on exactly one core and consumes a certain",
"# amount of SDRAM to hold configuration data.",
"component",
":",
"{",
"... | Run the simulation. | [
"Run",
"the",
"simulation",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/docs/source/circuit_sim_tutorial/05_circuit_simulation/circuit_simulator.py#L303-L365 |
Metatab/metapack | metapack/jupyter/exec.py | execute_notebook | def execute_notebook(nb_path, pkg_dir, dataframes, write_notebook=False, env=None):
"""
Execute a notebook after adding the prolog and epilog. Can also add %mt_materialize magics to
write dataframes to files
:param nb_path: path to a notebook.
:param pkg_dir: Directory to which dataframes are mater... | python | def execute_notebook(nb_path, pkg_dir, dataframes, write_notebook=False, env=None):
"""
Execute a notebook after adding the prolog and epilog. Can also add %mt_materialize magics to
write dataframes to files
:param nb_path: path to a notebook.
:param pkg_dir: Directory to which dataframes are mater... | [
"def",
"execute_notebook",
"(",
"nb_path",
",",
"pkg_dir",
",",
"dataframes",
",",
"write_notebook",
"=",
"False",
",",
"env",
"=",
"None",
")",
":",
"import",
"nbformat",
"from",
"metapack",
".",
"jupyter",
".",
"preprocessors",
"import",
"AddEpilog",
",",
... | Execute a notebook after adding the prolog and epilog. Can also add %mt_materialize magics to
write dataframes to files
:param nb_path: path to a notebook.
:param pkg_dir: Directory to which dataframes are materialized
:param dataframes: List of names of dataframes to materialize
:return: a Noteboo... | [
"Execute",
"a",
"notebook",
"after",
"adding",
"the",
"prolog",
"and",
"epilog",
".",
"Can",
"also",
"add",
"%mt_materialize",
"magics",
"to",
"write",
"dataframes",
"to",
"files"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/exec.py#L11-L72 |
Metatab/metapack | metapack/jupyter/convert.py | convert_documentation | def convert_documentation(nb_path):
"""Run only the document conversion portion of the notebook conversion
The final document will not be completel
"""
with open(nb_path) as f:
nb = nbformat.reads(f.read(), as_version=4)
doc = ExtractInlineMetatabDoc(package_url="metapack+file:" + dirna... | python | def convert_documentation(nb_path):
"""Run only the document conversion portion of the notebook conversion
The final document will not be completel
"""
with open(nb_path) as f:
nb = nbformat.reads(f.read(), as_version=4)
doc = ExtractInlineMetatabDoc(package_url="metapack+file:" + dirna... | [
"def",
"convert_documentation",
"(",
"nb_path",
")",
":",
"with",
"open",
"(",
"nb_path",
")",
"as",
"f",
":",
"nb",
"=",
"nbformat",
".",
"reads",
"(",
"f",
".",
"read",
"(",
")",
",",
"as_version",
"=",
"4",
")",
"doc",
"=",
"ExtractInlineMetatabDoc"... | Run only the document conversion portion of the notebook conversion
The final document will not be completel | [
"Run",
"only",
"the",
"document",
"conversion",
"portion",
"of",
"the",
"notebook",
"conversion"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/convert.py#L23-L46 |
Metatab/metapack | metapack/jupyter/convert.py | doc_metadata | def doc_metadata(doc):
"""Create a metadata dict from a MetatabDoc, for Document conversion"""
r = doc['Root'].as_dict()
r.update(doc['Contacts'].as_dict())
r['author'] = r.get('author', r.get('creator', r.get('wrangler')))
return r | python | def doc_metadata(doc):
"""Create a metadata dict from a MetatabDoc, for Document conversion"""
r = doc['Root'].as_dict()
r.update(doc['Contacts'].as_dict())
r['author'] = r.get('author', r.get('creator', r.get('wrangler')))
return r | [
"def",
"doc_metadata",
"(",
"doc",
")",
":",
"r",
"=",
"doc",
"[",
"'Root'",
"]",
".",
"as_dict",
"(",
")",
"r",
".",
"update",
"(",
"doc",
"[",
"'Contacts'",
"]",
".",
"as_dict",
"(",
")",
")",
"r",
"[",
"'author'",
"]",
"=",
"r",
".",
"get",
... | Create a metadata dict from a MetatabDoc, for Document conversion | [
"Create",
"a",
"metadata",
"dict",
"from",
"a",
"MetatabDoc",
"for",
"Document",
"conversion"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/convert.py#L111-L118 |
Metatab/metapack | metapack/jupyter/convert.py | extract_notebook_metatab | def extract_notebook_metatab(nb_path: Path):
"""Extract the metatab lines from a notebook and return a Metapack doc """
from metatab.rowgenerators import TextRowGenerator
import nbformat
with nb_path.open() as f:
nb = nbformat.read(f, as_version=4)
lines = '\n'.join(['Declare: metatab-lat... | python | def extract_notebook_metatab(nb_path: Path):
"""Extract the metatab lines from a notebook and return a Metapack doc """
from metatab.rowgenerators import TextRowGenerator
import nbformat
with nb_path.open() as f:
nb = nbformat.read(f, as_version=4)
lines = '\n'.join(['Declare: metatab-lat... | [
"def",
"extract_notebook_metatab",
"(",
"nb_path",
":",
"Path",
")",
":",
"from",
"metatab",
".",
"rowgenerators",
"import",
"TextRowGenerator",
"import",
"nbformat",
"with",
"nb_path",
".",
"open",
"(",
")",
"as",
"f",
":",
"nb",
"=",
"nbformat",
".",
"read... | Extract the metatab lines from a notebook and return a Metapack doc | [
"Extract",
"the",
"metatab",
"lines",
"from",
"a",
"notebook",
"and",
"return",
"a",
"Metapack",
"doc"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/convert.py#L181-L199 |
Metatab/metapack | metapack/cli/wp.py | publish_wp | def publish_wp(site_name, output_file, resources, args):
"""Publish a notebook to a wordpress post, using Gutenberg blocks.
Here is what the metadata looks like, in a section of the notebook tagged 'frontmatter'
show_input: hide
github: https://github.com/sandiegodata/notebooks/blob/master/tutorial/A... | python | def publish_wp(site_name, output_file, resources, args):
"""Publish a notebook to a wordpress post, using Gutenberg blocks.
Here is what the metadata looks like, in a section of the notebook tagged 'frontmatter'
show_input: hide
github: https://github.com/sandiegodata/notebooks/blob/master/tutorial/A... | [
"def",
"publish_wp",
"(",
"site_name",
",",
"output_file",
",",
"resources",
",",
"args",
")",
":",
"from",
"wordpress_xmlrpc",
"import",
"Client",
",",
"WordPressPost",
"from",
"wordpress_xmlrpc",
".",
"methods",
".",
"media",
"import",
"UploadFile",
",",
"GetM... | Publish a notebook to a wordpress post, using Gutenberg blocks.
Here is what the metadata looks like, in a section of the notebook tagged 'frontmatter'
show_input: hide
github: https://github.com/sandiegodata/notebooks/blob/master/tutorial/American%20Community%20Survey.ipynb
identifier: 5c987397-a954-... | [
"Publish",
"a",
"notebook",
"to",
"a",
"wordpress",
"post",
"using",
"Gutenberg",
"blocks",
"."
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/wp.py#L143-L263 |
Metatab/metapack | metapack/package/core.py | PackageBuilder.add_single_resource | def add_single_resource(self, ref, **properties):
""" Add a single resource, without trying to enumerate it's contents
:param ref:
:return:
"""
t = self.doc.find_first('Root.Datafile', value=ref)
if t:
self.prt("Datafile exists for '{}', deleting".format(ref... | python | def add_single_resource(self, ref, **properties):
""" Add a single resource, without trying to enumerate it's contents
:param ref:
:return:
"""
t = self.doc.find_first('Root.Datafile', value=ref)
if t:
self.prt("Datafile exists for '{}', deleting".format(ref... | [
"def",
"add_single_resource",
"(",
"self",
",",
"ref",
",",
"*",
"*",
"properties",
")",
":",
"t",
"=",
"self",
".",
"doc",
".",
"find_first",
"(",
"'Root.Datafile'",
",",
"value",
"=",
"ref",
")",
"if",
"t",
":",
"self",
".",
"prt",
"(",
"\"Datafile... | Add a single resource, without trying to enumerate it's contents
:param ref:
:return: | [
"Add",
"a",
"single",
"resource",
"without",
"trying",
"to",
"enumerate",
"it",
"s",
"contents",
":",
"param",
"ref",
":",
":",
"return",
":"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L253-L296 |
Metatab/metapack | metapack/package/core.py | PackageBuilder.add_resource | def add_resource(self, ref, **properties):
"""Add one or more resources entities, from a url and property values,
possibly adding multiple entries for an excel spreadsheet or ZIP file"""
raise NotImplementedError("Still uses decompose_url")
du = Bunch(decompose_url(ref))
added... | python | def add_resource(self, ref, **properties):
"""Add one or more resources entities, from a url and property values,
possibly adding multiple entries for an excel spreadsheet or ZIP file"""
raise NotImplementedError("Still uses decompose_url")
du = Bunch(decompose_url(ref))
added... | [
"def",
"add_resource",
"(",
"self",
",",
"ref",
",",
"*",
"*",
"properties",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"Still uses decompose_url\"",
")",
"du",
"=",
"Bunch",
"(",
"decompose_url",
"(",
"ref",
")",
")",
"added",
"=",
"[",
"]",
"if",
... | Add one or more resources entities, from a url and property values,
possibly adding multiple entries for an excel spreadsheet or ZIP file | [
"Add",
"one",
"or",
"more",
"resources",
"entities",
"from",
"a",
"url",
"and",
"property",
"values",
"possibly",
"adding",
"multiple",
"entries",
"for",
"an",
"excel",
"spreadsheet",
"or",
"ZIP",
"file"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L298-L323 |
Metatab/metapack | metapack/package/core.py | PackageBuilder._clean_doc | def _clean_doc(self, doc=None):
"""Clean the doc before writing it, removing unnecessary properties and doing other operations."""
if doc is None:
doc = self.doc
resources = doc['Resources']
# We don't need these anymore because all of the data written into the package is ... | python | def _clean_doc(self, doc=None):
"""Clean the doc before writing it, removing unnecessary properties and doing other operations."""
if doc is None:
doc = self.doc
resources = doc['Resources']
# We don't need these anymore because all of the data written into the package is ... | [
"def",
"_clean_doc",
"(",
"self",
",",
"doc",
"=",
"None",
")",
":",
"if",
"doc",
"is",
"None",
":",
"doc",
"=",
"self",
".",
"doc",
"resources",
"=",
"doc",
"[",
"'Resources'",
"]",
"# We don't need these anymore because all of the data written into the package i... | Clean the doc before writing it, removing unnecessary properties and doing other operations. | [
"Clean",
"the",
"doc",
"before",
"writing",
"it",
"removing",
"unnecessary",
"properties",
"and",
"doing",
"other",
"operations",
"."
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L325-L370 |
Metatab/metapack | metapack/package/core.py | PackageBuilder._load_resources | def _load_resources(self, abs_path=False):
"""Copy all of the Datafile entries into the package"""
from metapack.doc import MetapackDoc
assert type(self.doc) == MetapackDoc
for r in self.datafiles:
# Special handling for SQL is probably a really bad idea. It should be hand... | python | def _load_resources(self, abs_path=False):
"""Copy all of the Datafile entries into the package"""
from metapack.doc import MetapackDoc
assert type(self.doc) == MetapackDoc
for r in self.datafiles:
# Special handling for SQL is probably a really bad idea. It should be hand... | [
"def",
"_load_resources",
"(",
"self",
",",
"abs_path",
"=",
"False",
")",
":",
"from",
"metapack",
".",
"doc",
"import",
"MetapackDoc",
"assert",
"type",
"(",
"self",
".",
"doc",
")",
"==",
"MetapackDoc",
"for",
"r",
"in",
"self",
".",
"datafiles",
":",... | Copy all of the Datafile entries into the package | [
"Copy",
"all",
"of",
"the",
"Datafile",
"entries",
"into",
"the",
"package"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L372-L427 |
Metatab/metapack | metapack/package/core.py | PackageBuilder._load_documentation_files | def _load_documentation_files(self):
"""Copy all of the Datafile """
for t in self.doc.find(['Root.Documentation', 'Root.Image', 'Root.Notebook']):
resource = self._get_ref_contents(t)
if not resource:
continue
if t.term_is('Root.Documentation'):
... | python | def _load_documentation_files(self):
"""Copy all of the Datafile """
for t in self.doc.find(['Root.Documentation', 'Root.Image', 'Root.Notebook']):
resource = self._get_ref_contents(t)
if not resource:
continue
if t.term_is('Root.Documentation'):
... | [
"def",
"_load_documentation_files",
"(",
"self",
")",
":",
"for",
"t",
"in",
"self",
".",
"doc",
".",
"find",
"(",
"[",
"'Root.Documentation'",
",",
"'Root.Image'",
",",
"'Root.Notebook'",
"]",
")",
":",
"resource",
"=",
"self",
".",
"_get_ref_contents",
"("... | Copy all of the Datafile | [
"Copy",
"all",
"of",
"the",
"Datafile"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L491-L528 |
Metatab/metapack | metapack/package/core.py | PackageBuilder._load_files | def _load_files(self):
"""Load other files"""
def copy_dir(path):
for (dr, _, files) in walk(path):
for fn in files:
if '__pycache__' in fn:
continue
relpath = dr.replace(self.source_dir, '').strip('/')
... | python | def _load_files(self):
"""Load other files"""
def copy_dir(path):
for (dr, _, files) in walk(path):
for fn in files:
if '__pycache__' in fn:
continue
relpath = dr.replace(self.source_dir, '').strip('/')
... | [
"def",
"_load_files",
"(",
"self",
")",
":",
"def",
"copy_dir",
"(",
"path",
")",
":",
"for",
"(",
"dr",
",",
"_",
",",
"files",
")",
"in",
"walk",
"(",
"path",
")",
":",
"for",
"fn",
"in",
"files",
":",
"if",
"'__pycache__'",
"in",
"fn",
":",
... | Load other files | [
"Load",
"other",
"files"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L534-L577 |
Metatab/metapack | metapack/package/core.py | PackageBuilder.create_nv_link | def create_nv_link(self):
"""After a save(), write a link to the saved file using a non-versioned name"""
from os.path import abspath, islink
from os import unlink, symlink
nv_name = self.doc.as_version(None)
from_path = abspath(self._last_write_path or self.package_path.path)... | python | def create_nv_link(self):
"""After a save(), write a link to the saved file using a non-versioned name"""
from os.path import abspath, islink
from os import unlink, symlink
nv_name = self.doc.as_version(None)
from_path = abspath(self._last_write_path or self.package_path.path)... | [
"def",
"create_nv_link",
"(",
"self",
")",
":",
"from",
"os",
".",
"path",
"import",
"abspath",
",",
"islink",
"from",
"os",
"import",
"unlink",
",",
"symlink",
"nv_name",
"=",
"self",
".",
"doc",
".",
"as_version",
"(",
"None",
")",
"from_path",
"=",
... | After a save(), write a link to the saved file using a non-versioned name | [
"After",
"a",
"save",
"()",
"write",
"a",
"link",
"to",
"the",
"saved",
"file",
"using",
"a",
"non",
"-",
"versioned",
"name"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/package/core.py#L587-L601 |
NicolasLM/spinach | spinach/brokers/memory.py | MemoryBroker.enqueue_jobs | def enqueue_jobs(self, jobs: Iterable[Job]):
"""Enqueue a batch of jobs."""
for job in jobs:
if job.should_start:
job.status = JobStatus.QUEUED
queue = self._get_queue(job.queue)
queue.put(job.serialize())
else:
with... | python | def enqueue_jobs(self, jobs: Iterable[Job]):
"""Enqueue a batch of jobs."""
for job in jobs:
if job.should_start:
job.status = JobStatus.QUEUED
queue = self._get_queue(job.queue)
queue.put(job.serialize())
else:
with... | [
"def",
"enqueue_jobs",
"(",
"self",
",",
"jobs",
":",
"Iterable",
"[",
"Job",
"]",
")",
":",
"for",
"job",
"in",
"jobs",
":",
"if",
"job",
".",
"should_start",
":",
"job",
".",
"status",
"=",
"JobStatus",
".",
"QUEUED",
"queue",
"=",
"self",
".",
"... | Enqueue a batch of jobs. | [
"Enqueue",
"a",
"batch",
"of",
"jobs",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/memory.py#L36-L48 |
NicolasLM/spinach | spinach/brokers/memory.py | MemoryBroker.register_periodic_tasks | def register_periodic_tasks(self, tasks: Iterable[Task]):
"""Register tasks that need to be scheduled periodically."""
for task in tasks:
self._scheduler.enter(
int(task.periodicity.total_seconds()),
0,
self._schedule_periodic_task,
... | python | def register_periodic_tasks(self, tasks: Iterable[Task]):
"""Register tasks that need to be scheduled periodically."""
for task in tasks:
self._scheduler.enter(
int(task.periodicity.total_seconds()),
0,
self._schedule_periodic_task,
... | [
"def",
"register_periodic_tasks",
"(",
"self",
",",
"tasks",
":",
"Iterable",
"[",
"Task",
"]",
")",
":",
"for",
"task",
"in",
"tasks",
":",
"self",
".",
"_scheduler",
".",
"enter",
"(",
"int",
"(",
"task",
".",
"periodicity",
".",
"total_seconds",
"(",
... | Register tasks that need to be scheduled periodically. | [
"Register",
"tasks",
"that",
"need",
"to",
"be",
"scheduled",
"periodically",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/memory.py#L67-L75 |
NicolasLM/spinach | spinach/brokers/memory.py | MemoryBroker.next_future_periodic_delta | def next_future_periodic_delta(self) -> Optional[float]:
"""Give the amount of seconds before the next periodic task is due."""
try:
next_event = self._scheduler.queue[0]
except IndexError:
return None
now = time.monotonic()
next_event_time = next_event[0... | python | def next_future_periodic_delta(self) -> Optional[float]:
"""Give the amount of seconds before the next periodic task is due."""
try:
next_event = self._scheduler.queue[0]
except IndexError:
return None
now = time.monotonic()
next_event_time = next_event[0... | [
"def",
"next_future_periodic_delta",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"try",
":",
"next_event",
"=",
"self",
".",
"_scheduler",
".",
"queue",
"[",
"0",
"]",
"except",
"IndexError",
":",
"return",
"None",
"now",
"=",
"time",
"."... | Give the amount of seconds before the next periodic task is due. | [
"Give",
"the",
"amount",
"of",
"seconds",
"before",
"the",
"next",
"periodic",
"task",
"is",
"due",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/memory.py#L89-L101 |
NicolasLM/spinach | spinach/brokers/memory.py | MemoryBroker.inspect_periodic_tasks | def inspect_periodic_tasks(self) -> List[Tuple[int, str]]:
"""Get the next periodic task schedule.
Used only for debugging and during tests.
"""
return [(int(e[0]), e[3][0].name) for e in self._scheduler.queue] | python | def inspect_periodic_tasks(self) -> List[Tuple[int, str]]:
"""Get the next periodic task schedule.
Used only for debugging and during tests.
"""
return [(int(e[0]), e[3][0].name) for e in self._scheduler.queue] | [
"def",
"inspect_periodic_tasks",
"(",
"self",
")",
"->",
"List",
"[",
"Tuple",
"[",
"int",
",",
"str",
"]",
"]",
":",
"return",
"[",
"(",
"int",
"(",
"e",
"[",
"0",
"]",
")",
",",
"e",
"[",
"3",
"]",
"[",
"0",
"]",
".",
"name",
")",
"for",
... | Get the next periodic task schedule.
Used only for debugging and during tests. | [
"Get",
"the",
"next",
"periodic",
"task",
"schedule",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/memory.py#L103-L108 |
NicolasLM/spinach | spinach/brokers/memory.py | MemoryBroker.get_jobs_from_queue | def get_jobs_from_queue(self, queue: str, max_jobs: int) -> List[Job]:
"""Get jobs from a queue."""
rv = list()
while len(rv) < max_jobs:
try:
job_json_string = self._get_queue(queue).get(block=False)
except Empty:
break
job = ... | python | def get_jobs_from_queue(self, queue: str, max_jobs: int) -> List[Job]:
"""Get jobs from a queue."""
rv = list()
while len(rv) < max_jobs:
try:
job_json_string = self._get_queue(queue).get(block=False)
except Empty:
break
job = ... | [
"def",
"get_jobs_from_queue",
"(",
"self",
",",
"queue",
":",
"str",
",",
"max_jobs",
":",
"int",
")",
"->",
"List",
"[",
"Job",
"]",
":",
"rv",
"=",
"list",
"(",
")",
"while",
"len",
"(",
"rv",
")",
"<",
"max_jobs",
":",
"try",
":",
"job_json_stri... | Get jobs from a queue. | [
"Get",
"jobs",
"from",
"a",
"queue",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/memory.py#L117-L130 |
Ryuno-Ki/webmention-tools | webmentiontools/urlinfo.py | UrlInfo.snippetWithLink | def snippetWithLink(self, url):
""" This method will try to return the first
<p> or <div> that contains an <a> tag linking to
the given URL.
"""
link = self.soup.find("a", attrs={'href': url})
if link:
for p in link.parents:
if p.name in ('p', ... | python | def snippetWithLink(self, url):
""" This method will try to return the first
<p> or <div> that contains an <a> tag linking to
the given URL.
"""
link = self.soup.find("a", attrs={'href': url})
if link:
for p in link.parents:
if p.name in ('p', ... | [
"def",
"snippetWithLink",
"(",
"self",
",",
"url",
")",
":",
"link",
"=",
"self",
".",
"soup",
".",
"find",
"(",
"\"a\"",
",",
"attrs",
"=",
"{",
"'href'",
":",
"url",
"}",
")",
"if",
"link",
":",
"for",
"p",
"in",
"link",
".",
"parents",
":",
... | This method will try to return the first
<p> or <div> that contains an <a> tag linking to
the given URL. | [
"This",
"method",
"will",
"try",
"to",
"return",
"the",
"first",
"<p",
">",
"or",
"<div",
">",
"that",
"contains",
"an",
"<a",
">",
"tag",
"linking",
"to",
"the",
"given",
"URL",
"."
] | train | https://github.com/Ryuno-Ki/webmention-tools/blob/69851e34089d925cb856c936d2bcca7b09ecfdfd/webmentiontools/urlinfo.py#L90-L100 |
Metatab/metapack | metapack/support/pylib.py | row_generator | def row_generator(resource, doc, env, *args, **kwargs):
""" An example row generator function.
Reference this function in a Metatab file as the value of a Datafile:
Datafile: python:pylib#row_generator
The function must yield rows, with the first being headers, and subsequenct rows being data... | python | def row_generator(resource, doc, env, *args, **kwargs):
""" An example row generator function.
Reference this function in a Metatab file as the value of a Datafile:
Datafile: python:pylib#row_generator
The function must yield rows, with the first being headers, and subsequenct rows being data... | [
"def",
"row_generator",
"(",
"resource",
",",
"doc",
",",
"env",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"yield",
"'a b c'",
".",
"split",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"10",
")",
":",
"yield",
"[",
"i",
",",
"i",
"*",
... | An example row generator function.
Reference this function in a Metatab file as the value of a Datafile:
Datafile: python:pylib#row_generator
The function must yield rows, with the first being headers, and subsequenct rows being data.
:param resource: The Datafile term being processed
:p... | [
"An",
"example",
"row",
"generator",
"function",
"."
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/support/pylib.py#L4-L37 |
Metatab/metapack | metapack/support/pylib.py | example_transform | def example_transform(v, row, row_n, i_s, i_d, header_s, header_d,scratch, errors, accumulator):
""" An example column transform.
This is an example of a column transform with all of the arguments listed. An real transform
can omit any ( or all ) of these, and can supply them in any order; the calling code... | python | def example_transform(v, row, row_n, i_s, i_d, header_s, header_d,scratch, errors, accumulator):
""" An example column transform.
This is an example of a column transform with all of the arguments listed. An real transform
can omit any ( or all ) of these, and can supply them in any order; the calling code... | [
"def",
"example_transform",
"(",
"v",
",",
"row",
",",
"row_n",
",",
"i_s",
",",
"i_d",
",",
"header_s",
",",
"header_d",
",",
"scratch",
",",
"errors",
",",
"accumulator",
")",
":",
"return",
"str",
"(",
"v",
")",
"+",
"'-foo'"
] | An example column transform.
This is an example of a column transform with all of the arguments listed. An real transform
can omit any ( or all ) of these, and can supply them in any order; the calling code will inspect the
signature.
When the function is listed as a transform for a column, it is call... | [
"An",
"example",
"column",
"transform",
"."
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/support/pylib.py#L40-L62 |
Metatab/metapack | metapack/index.py | search_index_file | def search_index_file():
"""Return the default local index file, from the download cache"""
from metapack import Downloader
from os import environ
return environ.get('METAPACK_SEARCH_INDEX',
Downloader.get_instance().cache.getsyspath('index.json')) | python | def search_index_file():
"""Return the default local index file, from the download cache"""
from metapack import Downloader
from os import environ
return environ.get('METAPACK_SEARCH_INDEX',
Downloader.get_instance().cache.getsyspath('index.json')) | [
"def",
"search_index_file",
"(",
")",
":",
"from",
"metapack",
"import",
"Downloader",
"from",
"os",
"import",
"environ",
"return",
"environ",
".",
"get",
"(",
"'METAPACK_SEARCH_INDEX'",
",",
"Downloader",
".",
"get_instance",
"(",
")",
".",
"cache",
".",
"get... | Return the default local index file, from the download cache | [
"Return",
"the",
"default",
"local",
"index",
"file",
"from",
"the",
"download",
"cache"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/index.py#L15-L21 |
Metatab/metapack | metapack/index.py | SearchIndex.write | def write(self):
"""Safely write the index data to the index file """
index_file = self.path
new_index_file = index_file + '.new'
bak_index_file = index_file + '.bak'
if not self._db:
return
with open(new_index_file, 'w') as f:
json.dump(self._db... | python | def write(self):
"""Safely write the index data to the index file """
index_file = self.path
new_index_file = index_file + '.new'
bak_index_file = index_file + '.bak'
if not self._db:
return
with open(new_index_file, 'w') as f:
json.dump(self._db... | [
"def",
"write",
"(",
"self",
")",
":",
"index_file",
"=",
"self",
".",
"path",
"new_index_file",
"=",
"index_file",
"+",
"'.new'",
"bak_index_file",
"=",
"index_file",
"+",
"'.bak'",
"if",
"not",
"self",
".",
"_db",
":",
"return",
"with",
"open",
"(",
"n... | Safely write the index data to the index file | [
"Safely",
"write",
"the",
"index",
"data",
"to",
"the",
"index",
"file"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/index.py#L55-L70 |
Metatab/metapack | metapack/index.py | SearchIndex.update | def update(self,o):
"""Update from another index or index dict"""
self.open()
try:
self._db.update(o._db)
except AttributeError:
self._db.update(o) | python | def update(self,o):
"""Update from another index or index dict"""
self.open()
try:
self._db.update(o._db)
except AttributeError:
self._db.update(o) | [
"def",
"update",
"(",
"self",
",",
"o",
")",
":",
"self",
".",
"open",
"(",
")",
"try",
":",
"self",
".",
"_db",
".",
"update",
"(",
"o",
".",
"_db",
")",
"except",
"AttributeError",
":",
"self",
".",
"_db",
".",
"update",
"(",
"o",
")"
] | Update from another index or index dict | [
"Update",
"from",
"another",
"index",
"or",
"index",
"dict"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/index.py#L140-L148 |
ungarj/tilematrix | tilematrix/tmx/main.py | bounds | def bounds(ctx, tile):
"""Print Tile bounds."""
click.echo(
'%s %s %s %s' % TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tile(*tile).bounds(pixelbuffer=ctx.obj['pixelbuffer'])
) | python | def bounds(ctx, tile):
"""Print Tile bounds."""
click.echo(
'%s %s %s %s' % TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tile(*tile).bounds(pixelbuffer=ctx.obj['pixelbuffer'])
) | [
"def",
"bounds",
"(",
"ctx",
",",
"tile",
")",
":",
"click",
".",
"echo",
"(",
"'%s %s %s %s'",
"%",
"TilePyramid",
"(",
"ctx",
".",
"obj",
"[",
"'grid'",
"]",
",",
"tile_size",
"=",
"ctx",
".",
"obj",
"[",
"'tile_size'",
"]",
",",
"metatiling",
"=",... | Print Tile bounds. | [
"Print",
"Tile",
"bounds",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/tmx/main.py#L40-L48 |
ungarj/tilematrix | tilematrix/tmx/main.py | bbox | def bbox(ctx, tile):
"""Print Tile bounding box as geometry."""
geom = TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tile(*tile).bbox(pixelbuffer=ctx.obj['pixelbuffer'])
if ctx.obj['output_format'] in ['WKT', 'Tile']:
cli... | python | def bbox(ctx, tile):
"""Print Tile bounding box as geometry."""
geom = TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tile(*tile).bbox(pixelbuffer=ctx.obj['pixelbuffer'])
if ctx.obj['output_format'] in ['WKT', 'Tile']:
cli... | [
"def",
"bbox",
"(",
"ctx",
",",
"tile",
")",
":",
"geom",
"=",
"TilePyramid",
"(",
"ctx",
".",
"obj",
"[",
"'grid'",
"]",
",",
"tile_size",
"=",
"ctx",
".",
"obj",
"[",
"'tile_size'",
"]",
",",
"metatiling",
"=",
"ctx",
".",
"obj",
"[",
"'metatilin... | Print Tile bounding box as geometry. | [
"Print",
"Tile",
"bounding",
"box",
"as",
"geometry",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/tmx/main.py#L54-L64 |
ungarj/tilematrix | tilematrix/tmx/main.py | tile | def tile(ctx, point, zoom):
"""Print Tile containing POINT.."""
tile = TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tile_from_xy(*point, zoom=zoom)
if ctx.obj['output_format'] == 'Tile':
click.echo('%s %s %s' % tile.id)
... | python | def tile(ctx, point, zoom):
"""Print Tile containing POINT.."""
tile = TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tile_from_xy(*point, zoom=zoom)
if ctx.obj['output_format'] == 'Tile':
click.echo('%s %s %s' % tile.id)
... | [
"def",
"tile",
"(",
"ctx",
",",
"point",
",",
"zoom",
")",
":",
"tile",
"=",
"TilePyramid",
"(",
"ctx",
".",
"obj",
"[",
"'grid'",
"]",
",",
"tile_size",
"=",
"ctx",
".",
"obj",
"[",
"'tile_size'",
"]",
",",
"metatiling",
"=",
"ctx",
".",
"obj",
... | Print Tile containing POINT.. | [
"Print",
"Tile",
"containing",
"POINT",
".."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/tmx/main.py#L71-L96 |
ungarj/tilematrix | tilematrix/tmx/main.py | tiles | def tiles(ctx, bounds, zoom):
"""Print Tiles from bounds."""
tiles = TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tiles_from_bounds(bounds, zoom=zoom)
if ctx.obj['output_format'] == 'Tile':
for tile in tiles:
... | python | def tiles(ctx, bounds, zoom):
"""Print Tiles from bounds."""
tiles = TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
).tiles_from_bounds(bounds, zoom=zoom)
if ctx.obj['output_format'] == 'Tile':
for tile in tiles:
... | [
"def",
"tiles",
"(",
"ctx",
",",
"bounds",
",",
"zoom",
")",
":",
"tiles",
"=",
"TilePyramid",
"(",
"ctx",
".",
"obj",
"[",
"'grid'",
"]",
",",
"tile_size",
"=",
"ctx",
".",
"obj",
"[",
"'tile_size'",
"]",
",",
"metatiling",
"=",
"ctx",
".",
"obj",... | Print Tiles from bounds. | [
"Print",
"Tiles",
"from",
"bounds",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/tmx/main.py#L103-L145 |
ungarj/tilematrix | tilematrix/tmx/main.py | snap_bbox | def snap_bbox(ctx, bounds, zoom):
"""Snap bbox to tile grid."""
click.echo(box(*tilematrix.snap_bounds(
bounds=bounds,
tile_pyramid=TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
),
zoom=zoom,
... | python | def snap_bbox(ctx, bounds, zoom):
"""Snap bbox to tile grid."""
click.echo(box(*tilematrix.snap_bounds(
bounds=bounds,
tile_pyramid=TilePyramid(
ctx.obj['grid'],
tile_size=ctx.obj['tile_size'],
metatiling=ctx.obj['metatiling']
),
zoom=zoom,
... | [
"def",
"snap_bbox",
"(",
"ctx",
",",
"bounds",
",",
"zoom",
")",
":",
"click",
".",
"echo",
"(",
"box",
"(",
"*",
"tilematrix",
".",
"snap_bounds",
"(",
"bounds",
"=",
"bounds",
",",
"tile_pyramid",
"=",
"TilePyramid",
"(",
"ctx",
".",
"obj",
"[",
"'... | Snap bbox to tile grid. | [
"Snap",
"bbox",
"to",
"tile",
"grid",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/tmx/main.py#L170-L181 |
project-rig/rig | rig/place_and_route/place/rand.py | place | def place(vertices_resources, nets, machine, constraints,
random=default_random):
"""A random placer.
This algorithm performs uniform-random placement of vertices (completely
ignoring connectivty) and thus in the general case is likely to produce
very poor quality placements. It exists primar... | python | def place(vertices_resources, nets, machine, constraints,
random=default_random):
"""A random placer.
This algorithm performs uniform-random placement of vertices (completely
ignoring connectivty) and thus in the general case is likely to produce
very poor quality placements. It exists primar... | [
"def",
"place",
"(",
"vertices_resources",
",",
"nets",
",",
"machine",
",",
"constraints",
",",
"random",
"=",
"default_random",
")",
":",
"# Within the algorithm we modify the resource availability values in the",
"# machine to account for the effects of the current placement. As... | A random placer.
This algorithm performs uniform-random placement of vertices (completely
ignoring connectivty) and thus in the general case is likely to produce
very poor quality placements. It exists primarily as a baseline comparison
for placement quality and is probably of little value to most user... | [
"A",
"random",
"placer",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/rand.py#L19-L106 |
project-rig/rig | rig/place_and_route/place/sa/algorithm.py | _initial_placement | def _initial_placement(movable_vertices, vertices_resources, machine, random):
"""For internal use. Produces a random, sequential initial placement,
updating the resource availabilities of every core in the supplied machine.
Parameters
----------
movable_vertices : {vertex, ...}
A set of th... | python | def _initial_placement(movable_vertices, vertices_resources, machine, random):
"""For internal use. Produces a random, sequential initial placement,
updating the resource availabilities of every core in the supplied machine.
Parameters
----------
movable_vertices : {vertex, ...}
A set of th... | [
"def",
"_initial_placement",
"(",
"movable_vertices",
",",
"vertices_resources",
",",
"machine",
",",
"random",
")",
":",
"# Initially fill chips in the system in a random order",
"locations",
"=",
"list",
"(",
"machine",
")",
"random",
".",
"shuffle",
"(",
"locations",... | For internal use. Produces a random, sequential initial placement,
updating the resource availabilities of every core in the supplied machine.
Parameters
----------
movable_vertices : {vertex, ...}
A set of the vertices to be given a random initial placement.
vertices_resources : {vertex: {... | [
"For",
"internal",
"use",
".",
"Produces",
"a",
"random",
"sequential",
"initial",
"placement",
"updating",
"the",
"resource",
"availabilities",
"of",
"every",
"core",
"in",
"the",
"supplied",
"machine",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/sa/algorithm.py#L39-L117 |
project-rig/rig | rig/place_and_route/place/sa/algorithm.py | place | def place(vertices_resources, nets, machine, constraints,
effort=1.0, random=default_random, on_temperature_change=None,
kernel=default_kernel, kernel_kwargs={}):
"""A flat Simulated Annealing based placement algorithm.
This placement algorithm uses simulated annealing directly on the suppl... | python | def place(vertices_resources, nets, machine, constraints,
effort=1.0, random=default_random, on_temperature_change=None,
kernel=default_kernel, kernel_kwargs={}):
"""A flat Simulated Annealing based placement algorithm.
This placement algorithm uses simulated annealing directly on the suppl... | [
"def",
"place",
"(",
"vertices_resources",
",",
"nets",
",",
"machine",
",",
"constraints",
",",
"effort",
"=",
"1.0",
",",
"random",
"=",
"default_random",
",",
"on_temperature_change",
"=",
"None",
",",
"kernel",
"=",
"default_kernel",
",",
"kernel_kwargs",
... | A flat Simulated Annealing based placement algorithm.
This placement algorithm uses simulated annealing directly on the supplied
problem graph with the objective of reducing wire lengths (and thus,
indirectly, the potential for congestion). Though computationally
expensive, this placer produces relativ... | [
"A",
"flat",
"Simulated",
"Annealing",
"based",
"placement",
"algorithm",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/sa/algorithm.py#L120-L386 |
Metatab/metapack | metapack/html.py | make_citation_dict | def make_citation_dict(td):
"""
Update a citation dictionary by editing the Author field
:param td: A BixTex format citation dict or a term
:return:
"""
from datetime import datetime
if isinstance(td, dict):
d = td
name = d['name_link']
else:
d = td.as_dict()
... | python | def make_citation_dict(td):
"""
Update a citation dictionary by editing the Author field
:param td: A BixTex format citation dict or a term
:return:
"""
from datetime import datetime
if isinstance(td, dict):
d = td
name = d['name_link']
else:
d = td.as_dict()
... | [
"def",
"make_citation_dict",
"(",
"td",
")",
":",
"from",
"datetime",
"import",
"datetime",
"if",
"isinstance",
"(",
"td",
",",
"dict",
")",
":",
"d",
"=",
"td",
"name",
"=",
"d",
"[",
"'name_link'",
"]",
"else",
":",
"d",
"=",
"td",
".",
"as_dict",
... | Update a citation dictionary by editing the Author field
:param td: A BixTex format citation dict or a term
:return: | [
"Update",
"a",
"citation",
"dictionary",
"by",
"editing",
"the",
"Author",
"field",
":",
"param",
"td",
":",
"A",
"BixTex",
"format",
"citation",
"dict",
"or",
"a",
"term",
":",
"return",
":"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/html.py#L174-L242 |
Metatab/metapack | metapack/html.py | make_metatab_citation_dict | def make_metatab_citation_dict(t):
"""
Return a dict with BibText key/values for metatab data
:param t:
:return:
"""
try:
if parse_app_url(t.url).proto == 'metatab':
try:
url = parse_app_url(str(t.resolved_url)).resource_url
doc = t.row_gene... | python | def make_metatab_citation_dict(t):
"""
Return a dict with BibText key/values for metatab data
:param t:
:return:
"""
try:
if parse_app_url(t.url).proto == 'metatab':
try:
url = parse_app_url(str(t.resolved_url)).resource_url
doc = t.row_gene... | [
"def",
"make_metatab_citation_dict",
"(",
"t",
")",
":",
"try",
":",
"if",
"parse_app_url",
"(",
"t",
".",
"url",
")",
".",
"proto",
"==",
"'metatab'",
":",
"try",
":",
"url",
"=",
"parse_app_url",
"(",
"str",
"(",
"t",
".",
"resolved_url",
")",
")",
... | Return a dict with BibText key/values for metatab data
:param t:
:return: | [
"Return",
"a",
"dict",
"with",
"BibText",
"key",
"/",
"values",
"for",
"metatab",
"data",
":",
"param",
"t",
":",
":",
"return",
":"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/html.py#L245-L307 |
Metatab/metapack | metapack/html.py | _bibliography | def _bibliography(doc, terms, converters=[], format='html'):
"""
Render citations, from a document or a doct of dicts
If the input is a dict, each key is the name of the citation, and the value is a BibTex
formatted dict
:param doc: A MetatabDoc, or a dict of BibTex dicts
:return:
"""
... | python | def _bibliography(doc, terms, converters=[], format='html'):
"""
Render citations, from a document or a doct of dicts
If the input is a dict, each key is the name of the citation, and the value is a BibTex
formatted dict
:param doc: A MetatabDoc, or a dict of BibTex dicts
:return:
"""
... | [
"def",
"_bibliography",
"(",
"doc",
",",
"terms",
",",
"converters",
"=",
"[",
"]",
",",
"format",
"=",
"'html'",
")",
":",
"output_backend",
"=",
"'latex'",
"if",
"format",
"==",
"'latex'",
"else",
"MetatabHtmlBackend",
"def",
"mk_cite",
"(",
"v",
")",
... | Render citations, from a document or a doct of dicts
If the input is a dict, each key is the name of the citation, and the value is a BibTex
formatted dict
:param doc: A MetatabDoc, or a dict of BibTex dicts
:return: | [
"Render",
"citations",
"from",
"a",
"document",
"or",
"a",
"doct",
"of",
"dicts"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/html.py#L310-L349 |
Metatab/metapack | metapack/html.py | display_context | def display_context(doc):
"""Create a Jinja context for display"""
from rowgenerators.exceptions import DownloadError
context = {s.name.lower(): s.as_dict() for s in doc if s.name.lower() != 'schema'}
#import json
#print(json.dumps(context, indent=4))
mandatory_sections = ['documentation', 'c... | python | def display_context(doc):
"""Create a Jinja context for display"""
from rowgenerators.exceptions import DownloadError
context = {s.name.lower(): s.as_dict() for s in doc if s.name.lower() != 'schema'}
#import json
#print(json.dumps(context, indent=4))
mandatory_sections = ['documentation', 'c... | [
"def",
"display_context",
"(",
"doc",
")",
":",
"from",
"rowgenerators",
".",
"exceptions",
"import",
"DownloadError",
"context",
"=",
"{",
"s",
".",
"name",
".",
"lower",
"(",
")",
":",
"s",
".",
"as_dict",
"(",
")",
"for",
"s",
"in",
"doc",
"if",
"... | Create a Jinja context for display | [
"Create",
"a",
"Jinja",
"context",
"for",
"display"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/html.py#L477-L619 |
Metatab/metapack | metapack/html.py | markdown | def markdown(doc, title=True, template='short_documentation.md'):
"""Markdown, specifically for the Notes field in a CKAN dataset"""
from jinja2 import Environment, PackageLoader, select_autoescape
env = Environment(
loader=PackageLoader('metapack', 'support/templates')
#autoescape=select_a... | python | def markdown(doc, title=True, template='short_documentation.md'):
"""Markdown, specifically for the Notes field in a CKAN dataset"""
from jinja2 import Environment, PackageLoader, select_autoescape
env = Environment(
loader=PackageLoader('metapack', 'support/templates')
#autoescape=select_a... | [
"def",
"markdown",
"(",
"doc",
",",
"title",
"=",
"True",
",",
"template",
"=",
"'short_documentation.md'",
")",
":",
"from",
"jinja2",
"import",
"Environment",
",",
"PackageLoader",
",",
"select_autoescape",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"Pac... | Markdown, specifically for the Notes field in a CKAN dataset | [
"Markdown",
"specifically",
"for",
"the",
"Notes",
"field",
"in",
"a",
"CKAN",
"dataset"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/html.py#L621-L632 |
project-rig/rig | rig/place_and_route/place/breadth_first.py | breadth_first_vertex_order | def breadth_first_vertex_order(vertices_resources, nets):
"""A generator which iterates over a set of vertices in a breadth-first
order in terms of connectivity.
For use as a vertex ordering for the sequential placer.
"""
# Special case: no vertices, just stop immediately
if len(vertices_resour... | python | def breadth_first_vertex_order(vertices_resources, nets):
"""A generator which iterates over a set of vertices in a breadth-first
order in terms of connectivity.
For use as a vertex ordering for the sequential placer.
"""
# Special case: no vertices, just stop immediately
if len(vertices_resour... | [
"def",
"breadth_first_vertex_order",
"(",
"vertices_resources",
",",
"nets",
")",
":",
"# Special case: no vertices, just stop immediately",
"if",
"len",
"(",
"vertices_resources",
")",
"==",
"0",
":",
"return",
"# Enumerate the set of nets attached to each vertex",
"vertex_nei... | A generator which iterates over a set of vertices in a breadth-first
order in terms of connectivity.
For use as a vertex ordering for the sequential placer. | [
"A",
"generator",
"which",
"iterates",
"over",
"a",
"set",
"of",
"vertices",
"in",
"a",
"breadth",
"-",
"first",
"order",
"in",
"terms",
"of",
"connectivity",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/breadth_first.py#L8-L39 |
project-rig/rig | rig/place_and_route/place/breadth_first.py | place | def place(vertices_resources, nets, machine, constraints, chip_order=None):
"""Places vertices in breadth-first order onto chips in the machine.
This is a thin wrapper around the :py:func:`sequential
<rig.place_and_route.place.sequential.place>` placement algorithm which
uses the :py:func:`breadth_firs... | python | def place(vertices_resources, nets, machine, constraints, chip_order=None):
"""Places vertices in breadth-first order onto chips in the machine.
This is a thin wrapper around the :py:func:`sequential
<rig.place_and_route.place.sequential.place>` placement algorithm which
uses the :py:func:`breadth_firs... | [
"def",
"place",
"(",
"vertices_resources",
",",
"nets",
",",
"machine",
",",
"constraints",
",",
"chip_order",
"=",
"None",
")",
":",
"return",
"sequential_place",
"(",
"vertices_resources",
",",
"nets",
",",
"machine",
",",
"constraints",
",",
"breadth_first_ve... | Places vertices in breadth-first order onto chips in the machine.
This is a thin wrapper around the :py:func:`sequential
<rig.place_and_route.place.sequential.place>` placement algorithm which
uses the :py:func:`breadth_first_vertex_order` vertex ordering.
Parameters
----------
chip_order : No... | [
"Places",
"vertices",
"in",
"breadth",
"-",
"first",
"order",
"onto",
"chips",
"in",
"the",
"machine",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/place_and_route/place/breadth_first.py#L42-L61 |
TC01/python-xkcd | xkcd.py | getRandomComic | def getRandomComic():
""" Produces a :class:`Comic` object for a random xkcd comic. Uses the
Python standard library random number generator in order to select
a comic.
Returns the resulting comic object."""
random.seed()
numComics = getLatestComicNum()
number = random.randint(1, numComics)
return Comic(num... | python | def getRandomComic():
""" Produces a :class:`Comic` object for a random xkcd comic. Uses the
Python standard library random number generator in order to select
a comic.
Returns the resulting comic object."""
random.seed()
numComics = getLatestComicNum()
number = random.randint(1, numComics)
return Comic(num... | [
"def",
"getRandomComic",
"(",
")",
":",
"random",
".",
"seed",
"(",
")",
"numComics",
"=",
"getLatestComicNum",
"(",
")",
"number",
"=",
"random",
".",
"randint",
"(",
"1",
",",
"numComics",
")",
"return",
"Comic",
"(",
"number",
")"
] | Produces a :class:`Comic` object for a random xkcd comic. Uses the
Python standard library random number generator in order to select
a comic.
Returns the resulting comic object. | [
"Produces",
"a",
":",
"class",
":",
"Comic",
"object",
"for",
"a",
"random",
"xkcd",
"comic",
".",
"Uses",
"the",
"Python",
"standard",
"library",
"random",
"number",
"generator",
"in",
"order",
"to",
"select",
"a",
"comic",
"."
] | train | https://github.com/TC01/python-xkcd/blob/6998d4073507eea228185e02ad1d9071c77fa955/xkcd.py#L339-L348 |
TC01/python-xkcd | xkcd.py | getComic | def getComic(number, silent=True):
""" Produces a :class:`Comic` object with index equal to the provided argument.
Prints an error in the event of a failure (i.e. the number is less than zero
or greater than the latest comic number) and returns an empty Comic object.
Arguments:
an integer or string that repr... | python | def getComic(number, silent=True):
""" Produces a :class:`Comic` object with index equal to the provided argument.
Prints an error in the event of a failure (i.e. the number is less than zero
or greater than the latest comic number) and returns an empty Comic object.
Arguments:
an integer or string that repr... | [
"def",
"getComic",
"(",
"number",
",",
"silent",
"=",
"True",
")",
":",
"numComics",
"=",
"getLatestComicNum",
"(",
")",
"if",
"type",
"(",
"number",
")",
"is",
"str",
"and",
"number",
".",
"isdigit",
"(",
")",
":",
"number",
"=",
"int",
"(",
"number... | Produces a :class:`Comic` object with index equal to the provided argument.
Prints an error in the event of a failure (i.e. the number is less than zero
or greater than the latest comic number) and returns an empty Comic object.
Arguments:
an integer or string that represents a number, "number", that is the i... | [
"Produces",
"a",
":",
"class",
":",
"Comic",
"object",
"with",
"index",
"equal",
"to",
"the",
"provided",
"argument",
".",
"Prints",
"an",
"error",
"in",
"the",
"event",
"of",
"a",
"failure",
"(",
"i",
".",
"e",
".",
"the",
"number",
"is",
"less",
"t... | train | https://github.com/TC01/python-xkcd/blob/6998d4073507eea228185e02ad1d9071c77fa955/xkcd.py#L350-L371 |
TC01/python-xkcd | xkcd.py | getWhatIfArchive | def getWhatIfArchive():
""" Parses the xkcd What If archive. getWhatIfArchive passes the HTML text of
the archive page into a :class:`WhatIfArchiveParser` and then calls
the parser's :func:`WhatIfArchiveParser.getWhatIfs` method and returns the dictionary produced.
This function returns a dictionary mapping art... | python | def getWhatIfArchive():
""" Parses the xkcd What If archive. getWhatIfArchive passes the HTML text of
the archive page into a :class:`WhatIfArchiveParser` and then calls
the parser's :func:`WhatIfArchiveParser.getWhatIfs` method and returns the dictionary produced.
This function returns a dictionary mapping art... | [
"def",
"getWhatIfArchive",
"(",
")",
":",
"archive",
"=",
"urllib",
".",
"urlopen",
"(",
"archiveUrl",
")",
"text",
"=",
"archive",
".",
"read",
"(",
")",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">=",
"3",
":",
"text",
"=",
"text",
".",
"d... | Parses the xkcd What If archive. getWhatIfArchive passes the HTML text of
the archive page into a :class:`WhatIfArchiveParser` and then calls
the parser's :func:`WhatIfArchiveParser.getWhatIfs` method and returns the dictionary produced.
This function returns a dictionary mapping article numbers to :class:`WhatI... | [
"Parses",
"the",
"xkcd",
"What",
"If",
"archive",
".",
"getWhatIfArchive",
"passes",
"the",
"HTML",
"text",
"of",
"the",
"archive",
"page",
"into",
"a",
":",
"class",
":",
"WhatIfArchiveParser",
"and",
"then",
"calls",
"the",
"parser",
"s",
":",
"func",
":... | train | https://github.com/TC01/python-xkcd/blob/6998d4073507eea228185e02ad1d9071c77fa955/xkcd.py#L375-L391 |
TC01/python-xkcd | xkcd.py | getRandomWhatIf | def getRandomWhatIf():
""" Returns a randomly generated :class:`WhatIf` object, using the Python standard library
random number generator to select the object. The object is returned
from the dictionary produced by :func:`getWhatIfArchive`; like the other What If
routines, this function is called first in order ... | python | def getRandomWhatIf():
""" Returns a randomly generated :class:`WhatIf` object, using the Python standard library
random number generator to select the object. The object is returned
from the dictionary produced by :func:`getWhatIfArchive`; like the other What If
routines, this function is called first in order ... | [
"def",
"getRandomWhatIf",
"(",
")",
":",
"random",
".",
"seed",
"(",
")",
"archive",
"=",
"getWhatIfArchive",
"(",
")",
"latest",
"=",
"getLatestWhatIfNum",
"(",
"archive",
")",
"number",
"=",
"random",
".",
"randint",
"(",
"1",
",",
"latest",
")",
"retu... | Returns a randomly generated :class:`WhatIf` object, using the Python standard library
random number generator to select the object. The object is returned
from the dictionary produced by :func:`getWhatIfArchive`; like the other What If
routines, this function is called first in order to get a list of all previou... | [
"Returns",
"a",
"randomly",
"generated",
":",
"class",
":",
"WhatIf",
"object",
"using",
"the",
"Python",
"standard",
"library",
"random",
"number",
"generator",
"to",
"select",
"the",
"object",
".",
"The",
"object",
"is",
"returned",
"from",
"the",
"dictionar... | train | https://github.com/TC01/python-xkcd/blob/6998d4073507eea228185e02ad1d9071c77fa955/xkcd.py#L425-L436 |
TC01/python-xkcd | xkcd.py | getWhatIf | def getWhatIf(number):
""" Returns a :class:`WhatIf` object corresponding to the What If article of
index passed to the function. If the index is less than zero or
greater than the maximum number of articles published thus far,
None is returned instead.
Like all the routines for handling What If articles, :fu... | python | def getWhatIf(number):
""" Returns a :class:`WhatIf` object corresponding to the What If article of
index passed to the function. If the index is less than zero or
greater than the maximum number of articles published thus far,
None is returned instead.
Like all the routines for handling What If articles, :fu... | [
"def",
"getWhatIf",
"(",
"number",
")",
":",
"archive",
"=",
"getWhatIfArchive",
"(",
")",
"latest",
"=",
"getLatestWhatIfNum",
"(",
"archive",
")",
"if",
"type",
"(",
"number",
")",
"is",
"str",
"and",
"number",
".",
"isdigit",
"(",
")",
":",
"number",
... | Returns a :class:`WhatIf` object corresponding to the What If article of
index passed to the function. If the index is less than zero or
greater than the maximum number of articles published thus far,
None is returned instead.
Like all the routines for handling What If articles, :func:`getWhatIfArchive`
is c... | [
"Returns",
"a",
":",
"class",
":",
"WhatIf",
"object",
"corresponding",
"to",
"the",
"What",
"If",
"article",
"of",
"index",
"passed",
"to",
"the",
"function",
".",
"If",
"the",
"index",
"is",
"less",
"than",
"zero",
"or",
"greater",
"than",
"the",
"maxi... | train | https://github.com/TC01/python-xkcd/blob/6998d4073507eea228185e02ad1d9071c77fa955/xkcd.py#L438-L460 |
TC01/python-xkcd | xkcd.py | convertToAscii | def convertToAscii(string, error="?"):
""" Utility function that converts a unicode string to ASCII. This
exists so the :class:`Comic` class can be compatible with Python 2
libraries that expect ASCII strings, such as Twisted (as of this writing,
anyway). It is unlikely something you will need directly, and its
... | python | def convertToAscii(string, error="?"):
""" Utility function that converts a unicode string to ASCII. This
exists so the :class:`Comic` class can be compatible with Python 2
libraries that expect ASCII strings, such as Twisted (as of this writing,
anyway). It is unlikely something you will need directly, and its
... | [
"def",
"convertToAscii",
"(",
"string",
",",
"error",
"=",
"\"?\"",
")",
":",
"running",
"=",
"True",
"asciiString",
"=",
"string",
"while",
"running",
":",
"try",
":",
"asciiString",
"=",
"asciiString",
".",
"encode",
"(",
"'ascii'",
")",
"except",
"Unico... | Utility function that converts a unicode string to ASCII. This
exists so the :class:`Comic` class can be compatible with Python 2
libraries that expect ASCII strings, such as Twisted (as of this writing,
anyway). It is unlikely something you will need directly, and its
use is discouraged.
Arguments:
stri... | [
"Utility",
"function",
"that",
"converts",
"a",
"unicode",
"string",
"to",
"ASCII",
".",
"This",
"exists",
"so",
"the",
":",
"class",
":",
"Comic",
"class",
"can",
"be",
"compatible",
"with",
"Python",
"2",
"libraries",
"that",
"expect",
"ASCII",
"strings",
... | train | https://github.com/TC01/python-xkcd/blob/6998d4073507eea228185e02ad1d9071c77fa955/xkcd.py#L464-L491 |
TC01/python-xkcd | xkcd.py | Comic.download | def download(self, output="", outputFile="", silent=True):
""" Downloads the image of the comic onto your computer.
Arguments:
output: the output directory where comics will be downloaded to. The
default argument for 'output is the empty string; if the empty
string is passed, it defaults to a "Downloa... | python | def download(self, output="", outputFile="", silent=True):
""" Downloads the image of the comic onto your computer.
Arguments:
output: the output directory where comics will be downloaded to. The
default argument for 'output is the empty string; if the empty
string is passed, it defaults to a "Downloa... | [
"def",
"download",
"(",
"self",
",",
"output",
"=",
"\"\"",
",",
"outputFile",
"=",
"\"\"",
",",
"silent",
"=",
"True",
")",
":",
"image",
"=",
"urllib",
".",
"urlopen",
"(",
"self",
".",
"imageLink",
")",
".",
"read",
"(",
")",
"#Process optional inpu... | Downloads the image of the comic onto your computer.
Arguments:
output: the output directory where comics will be downloaded to. The
default argument for 'output is the empty string; if the empty
string is passed, it defaults to a "Downloads" directory in your home folder
(this directory will be cre... | [
"Downloads",
"the",
"image",
"of",
"the",
"comic",
"onto",
"your",
"computer",
"."
] | train | https://github.com/TC01/python-xkcd/blob/6998d4073507eea228185e02ad1d9071c77fa955/xkcd.py#L277-L317 |
project-rig/rig | setup.py | replace_local_hyperlinks | def replace_local_hyperlinks(
text, base_url="https://github.com/project-rig/rig/blob/master/"):
"""Replace local hyperlinks in RST with absolute addresses using the given
base URL.
This is used to make links in the long description function correctly
outside of the repository (e.g. when publis... | python | def replace_local_hyperlinks(
text, base_url="https://github.com/project-rig/rig/blob/master/"):
"""Replace local hyperlinks in RST with absolute addresses using the given
base URL.
This is used to make links in the long description function correctly
outside of the repository (e.g. when publis... | [
"def",
"replace_local_hyperlinks",
"(",
"text",
",",
"base_url",
"=",
"\"https://github.com/project-rig/rig/blob/master/\"",
")",
":",
"def",
"get_new_url",
"(",
"url",
")",
":",
"return",
"base_url",
"+",
"url",
"[",
"2",
":",
"]",
"# Deal with anonymous URLS",
"fo... | Replace local hyperlinks in RST with absolute addresses using the given
base URL.
This is used to make links in the long description function correctly
outside of the repository (e.g. when published on PyPi).
NOTE: This may need adjusting if further syntax is used. | [
"Replace",
"local",
"hyperlinks",
"in",
"RST",
"with",
"absolute",
"addresses",
"using",
"the",
"given",
"base",
"URL",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/setup.py#L13-L55 |
Metatab/metapack | metapack/cli/index.py | dump_index | def dump_index(args, idx):
"""Create a metatab file for the index"""
import csv
import sys
from metatab import MetatabDoc
doc = MetatabDoc()
pack_section = doc.new_section('Packages', ['Identifier', 'Name', 'Nvname', 'Version', 'Format'])
r = doc['Root']
r.new_term('Root.Title', 'Pa... | python | def dump_index(args, idx):
"""Create a metatab file for the index"""
import csv
import sys
from metatab import MetatabDoc
doc = MetatabDoc()
pack_section = doc.new_section('Packages', ['Identifier', 'Name', 'Nvname', 'Version', 'Format'])
r = doc['Root']
r.new_term('Root.Title', 'Pa... | [
"def",
"dump_index",
"(",
"args",
",",
"idx",
")",
":",
"import",
"csv",
"import",
"sys",
"from",
"metatab",
"import",
"MetatabDoc",
"doc",
"=",
"MetatabDoc",
"(",
")",
"pack_section",
"=",
"doc",
".",
"new_section",
"(",
"'Packages'",
",",
"[",
"'Identifi... | Create a metatab file for the index | [
"Create",
"a",
"metatab",
"file",
"for",
"the",
"index"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/index.py#L223-L248 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._setup | def _setup(self):
"""Setup the layer two agent."""
agent_config = CONF.get("AGENT", {})
self._worker_count = agent_config.get('worker_count')
self._phys_net_map = agent_config.get(
'physical_network_vswitch_mappings', [])
self._local_network_vswitch = agent_config.get... | python | def _setup(self):
"""Setup the layer two agent."""
agent_config = CONF.get("AGENT", {})
self._worker_count = agent_config.get('worker_count')
self._phys_net_map = agent_config.get(
'physical_network_vswitch_mappings', [])
self._local_network_vswitch = agent_config.get... | [
"def",
"_setup",
"(",
"self",
")",
":",
"agent_config",
"=",
"CONF",
".",
"get",
"(",
"\"AGENT\"",
",",
"{",
"}",
")",
"self",
".",
"_worker_count",
"=",
"agent_config",
".",
"get",
"(",
"'worker_count'",
")",
"self",
".",
"_phys_net_map",
"=",
"agent_co... | Setup the layer two agent. | [
"Setup",
"the",
"layer",
"two",
"agent",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L78-L95 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._setup_rpc | def _setup_rpc(self):
"""Setup the RPC client for the current agent."""
self._plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
self._state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
self._client = n_rpc.get_client(self.target)
self._consumers.extend([
[topics... | python | def _setup_rpc(self):
"""Setup the RPC client for the current agent."""
self._plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
self._state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
self._client = n_rpc.get_client(self.target)
self._consumers.extend([
[topics... | [
"def",
"_setup_rpc",
"(",
"self",
")",
":",
"self",
".",
"_plugin_rpc",
"=",
"agent_rpc",
".",
"PluginApi",
"(",
"topics",
".",
"PLUGIN",
")",
"self",
".",
"_state_rpc",
"=",
"agent_rpc",
".",
"PluginReportStateAPI",
"(",
"topics",
".",
"PLUGIN",
")",
"sel... | Setup the RPC client for the current agent. | [
"Setup",
"the",
"RPC",
"client",
"for",
"the",
"current",
"agent",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L101-L123 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._process_added_port_event | def _process_added_port_event(self, port_name):
"""Callback for added ports."""
LOG.info("Hyper-V VM vNIC added: %s", port_name)
self._added_ports.add(port_name) | python | def _process_added_port_event(self, port_name):
"""Callback for added ports."""
LOG.info("Hyper-V VM vNIC added: %s", port_name)
self._added_ports.add(port_name) | [
"def",
"_process_added_port_event",
"(",
"self",
",",
"port_name",
")",
":",
"LOG",
".",
"info",
"(",
"\"Hyper-V VM vNIC added: %s\"",
",",
"port_name",
")",
"self",
".",
"_added_ports",
".",
"add",
"(",
"port_name",
")"
] | Callback for added ports. | [
"Callback",
"for",
"added",
"ports",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L125-L128 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._load_physical_network_mappings | def _load_physical_network_mappings(self, phys_net_vswitch_mappings):
"""Load all the information regarding the physical network."""
for mapping in phys_net_vswitch_mappings:
parts = mapping.split(':')
if len(parts) != 2:
LOG.debug('Invalid physical network mappin... | python | def _load_physical_network_mappings(self, phys_net_vswitch_mappings):
"""Load all the information regarding the physical network."""
for mapping in phys_net_vswitch_mappings:
parts = mapping.split(':')
if len(parts) != 2:
LOG.debug('Invalid physical network mappin... | [
"def",
"_load_physical_network_mappings",
"(",
"self",
",",
"phys_net_vswitch_mappings",
")",
":",
"for",
"mapping",
"in",
"phys_net_vswitch_mappings",
":",
"parts",
"=",
"mapping",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"parts",
")",
"!=",
"2",
":",... | Load all the information regarding the physical network. | [
"Load",
"all",
"the",
"information",
"regarding",
"the",
"physical",
"network",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L134-L144 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._get_vswitch_name | def _get_vswitch_name(self, network_type, physical_network):
"""Get the vswitch name for the received network information."""
if network_type != constants.TYPE_LOCAL:
vswitch_name = self._get_vswitch_for_physical_network(
physical_network)
else:
vswitch_na... | python | def _get_vswitch_name(self, network_type, physical_network):
"""Get the vswitch name for the received network information."""
if network_type != constants.TYPE_LOCAL:
vswitch_name = self._get_vswitch_for_physical_network(
physical_network)
else:
vswitch_na... | [
"def",
"_get_vswitch_name",
"(",
"self",
",",
"network_type",
",",
"physical_network",
")",
":",
"if",
"network_type",
"!=",
"constants",
".",
"TYPE_LOCAL",
":",
"vswitch_name",
"=",
"self",
".",
"_get_vswitch_for_physical_network",
"(",
"physical_network",
")",
"el... | Get the vswitch name for the received network information. | [
"Get",
"the",
"vswitch",
"name",
"for",
"the",
"received",
"network",
"information",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L189-L205 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._get_vswitch_for_physical_network | def _get_vswitch_for_physical_network(self, phys_network_name):
"""Get the vswitch name for the received network name."""
for pattern in self._physical_network_mappings:
if phys_network_name is None:
phys_network_name = ''
if re.match(pattern, phys_network_name):
... | python | def _get_vswitch_for_physical_network(self, phys_network_name):
"""Get the vswitch name for the received network name."""
for pattern in self._physical_network_mappings:
if phys_network_name is None:
phys_network_name = ''
if re.match(pattern, phys_network_name):
... | [
"def",
"_get_vswitch_for_physical_network",
"(",
"self",
",",
"phys_network_name",
")",
":",
"for",
"pattern",
"in",
"self",
".",
"_physical_network_mappings",
":",
"if",
"phys_network_name",
"is",
"None",
":",
"phys_network_name",
"=",
"''",
"if",
"re",
".",
"mat... | Get the vswitch name for the received network name. | [
"Get",
"the",
"vswitch",
"name",
"for",
"the",
"received",
"network",
"name",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L207-L213 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._get_network_vswitch_map_by_port_id | def _get_network_vswitch_map_by_port_id(self, port_id):
"""Get the vswitch name for the received port id."""
for network_id, vswitch in six.iteritems(self._network_vswitch_map):
if port_id in vswitch['ports']:
return (network_id, vswitch)
# If the port was not found,... | python | def _get_network_vswitch_map_by_port_id(self, port_id):
"""Get the vswitch name for the received port id."""
for network_id, vswitch in six.iteritems(self._network_vswitch_map):
if port_id in vswitch['ports']:
return (network_id, vswitch)
# If the port was not found,... | [
"def",
"_get_network_vswitch_map_by_port_id",
"(",
"self",
",",
"port_id",
")",
":",
"for",
"network_id",
",",
"vswitch",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_network_vswitch_map",
")",
":",
"if",
"port_id",
"in",
"vswitch",
"[",
"'ports'",
"]",
... | Get the vswitch name for the received port id. | [
"Get",
"the",
"vswitch",
"name",
"for",
"the",
"received",
"port",
"id",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L215-L222 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._update_port_status_cache | def _update_port_status_cache(self, device, device_bound=True):
"""Update the ports status cache."""
with self._cache_lock:
if device_bound:
self._bound_ports.add(device)
self._unbound_ports.discard(device)
else:
self._bound_ports.d... | python | def _update_port_status_cache(self, device, device_bound=True):
"""Update the ports status cache."""
with self._cache_lock:
if device_bound:
self._bound_ports.add(device)
self._unbound_ports.discard(device)
else:
self._bound_ports.d... | [
"def",
"_update_port_status_cache",
"(",
"self",
",",
"device",
",",
"device_bound",
"=",
"True",
")",
":",
"with",
"self",
".",
"_cache_lock",
":",
"if",
"device_bound",
":",
"self",
".",
"_bound_ports",
".",
"add",
"(",
"device",
")",
"self",
".",
"_unbo... | Update the ports status cache. | [
"Update",
"the",
"ports",
"status",
"cache",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L224-L232 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._create_event_listeners | def _create_event_listeners(self):
"""Create and bind the event listeners."""
LOG.debug("Create the event listeners.")
for event_type, callback in self._event_callback_pairs:
LOG.debug("Create listener for %r event", event_type)
listener = self._utils.get_vnic_event_liste... | python | def _create_event_listeners(self):
"""Create and bind the event listeners."""
LOG.debug("Create the event listeners.")
for event_type, callback in self._event_callback_pairs:
LOG.debug("Create listener for %r event", event_type)
listener = self._utils.get_vnic_event_liste... | [
"def",
"_create_event_listeners",
"(",
"self",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Create the event listeners.\"",
")",
"for",
"event_type",
",",
"callback",
"in",
"self",
".",
"_event_callback_pairs",
":",
"LOG",
".",
"debug",
"(",
"\"Create listener for %r even... | Create and bind the event listeners. | [
"Create",
"and",
"bind",
"the",
"event",
"listeners",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L234-L240 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._port_bound | def _port_bound(self, port_id, network_id, network_type, physical_network,
segmentation_id, port_security_enabled, set_port_sriov):
"""Bind the port to the recived network."""
LOG.debug("Binding port %s", port_id)
if network_id not in self._network_vswitch_map:
s... | python | def _port_bound(self, port_id, network_id, network_type, physical_network,
segmentation_id, port_security_enabled, set_port_sriov):
"""Bind the port to the recived network."""
LOG.debug("Binding port %s", port_id)
if network_id not in self._network_vswitch_map:
s... | [
"def",
"_port_bound",
"(",
"self",
",",
"port_id",
",",
"network_id",
",",
"network_type",
",",
"physical_network",
",",
"segmentation_id",
",",
"port_security_enabled",
",",
"set_port_sriov",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Binding port %s\"",
",",
"port_i... | Bind the port to the recived network. | [
"Bind",
"the",
"port",
"to",
"the",
"recived",
"network",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L251-L272 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent.process_added_port | def process_added_port(self, device_details):
"""Process the new ports.
Wraps _process_added_port, and treats the sucessful and exception
cases.
"""
device = device_details['device']
port_id = device_details['port_id']
reprocess = True
try:
se... | python | def process_added_port(self, device_details):
"""Process the new ports.
Wraps _process_added_port, and treats the sucessful and exception
cases.
"""
device = device_details['device']
port_id = device_details['port_id']
reprocess = True
try:
se... | [
"def",
"process_added_port",
"(",
"self",
",",
"device_details",
")",
":",
"device",
"=",
"device_details",
"[",
"'device'",
"]",
"port_id",
"=",
"device_details",
"[",
"'port_id'",
"]",
"reprocess",
"=",
"True",
"try",
":",
"self",
".",
"_process_added_port",
... | Process the new ports.
Wraps _process_added_port, and treats the sucessful and exception
cases. | [
"Process",
"the",
"new",
"ports",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L304-L350 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._treat_devices_added | def _treat_devices_added(self):
"""Process the new devices."""
try:
devices_details_list = self._plugin_rpc.get_devices_details_list(
self._context, self._added_ports, self._agent_id)
except Exception as exc:
LOG.debug("Unable to get ports details for "
... | python | def _treat_devices_added(self):
"""Process the new devices."""
try:
devices_details_list = self._plugin_rpc.get_devices_details_list(
self._context, self._added_ports, self._agent_id)
except Exception as exc:
LOG.debug("Unable to get ports details for "
... | [
"def",
"_treat_devices_added",
"(",
"self",
")",
":",
"try",
":",
"devices_details_list",
"=",
"self",
".",
"_plugin_rpc",
".",
"get_devices_details_list",
"(",
"self",
".",
"_context",
",",
"self",
".",
"_added_ports",
",",
"self",
".",
"_agent_id",
")",
"exc... | Process the new devices. | [
"Process",
"the",
"new",
"devices",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L352-L378 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._process_removed_port | def _process_removed_port(self, device):
"""Process the removed ports."""
LOG.debug("Trying to remove the port %r", device)
self._update_port_status_cache(device, device_bound=False)
self._port_unbound(device, vnic_deleted=True)
LOG.debug("The port was successfully removed.")
... | python | def _process_removed_port(self, device):
"""Process the removed ports."""
LOG.debug("Trying to remove the port %r", device)
self._update_port_status_cache(device, device_bound=False)
self._port_unbound(device, vnic_deleted=True)
LOG.debug("The port was successfully removed.")
... | [
"def",
"_process_removed_port",
"(",
"self",
",",
"device",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Trying to remove the port %r\"",
",",
"device",
")",
"self",
".",
"_update_port_status_cache",
"(",
"device",
",",
"device_bound",
"=",
"False",
")",
"self",
".",
... | Process the removed ports. | [
"Process",
"the",
"removed",
"ports",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L380-L387 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._treat_devices_removed | def _treat_devices_removed(self):
"""Process the removed devices."""
for device in self._removed_ports.copy():
eventlet.spawn_n(self._process_removed_port, device) | python | def _treat_devices_removed(self):
"""Process the removed devices."""
for device in self._removed_ports.copy():
eventlet.spawn_n(self._process_removed_port, device) | [
"def",
"_treat_devices_removed",
"(",
"self",
")",
":",
"for",
"device",
"in",
"self",
".",
"_removed_ports",
".",
"copy",
"(",
")",
":",
"eventlet",
".",
"spawn_n",
"(",
"self",
".",
"_process_removed_port",
",",
"device",
")"
] | Process the removed devices. | [
"Process",
"the",
"removed",
"devices",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L389-L392 |
openstack/networking-hyperv | networking_hyperv/neutron/agent/layer2.py | Layer2Agent._work | def _work(self):
"""Process the information regarding the available ports."""
if self._refresh_cache:
# Inconsistent cache might cause exceptions. For example,
# if a port has been removed, it will be known in the next
# loop. Using the old switch port can cause excep... | python | def _work(self):
"""Process the information regarding the available ports."""
if self._refresh_cache:
# Inconsistent cache might cause exceptions. For example,
# if a port has been removed, it will be known in the next
# loop. Using the old switch port can cause excep... | [
"def",
"_work",
"(",
"self",
")",
":",
"if",
"self",
".",
"_refresh_cache",
":",
"# Inconsistent cache might cause exceptions. For example,",
"# if a port has been removed, it will be known in the next",
"# loop. Using the old switch port can cause exceptions.",
"LOG",
".",
"debug",
... | Process the information regarding the available ports. | [
"Process",
"the",
"information",
"regarding",
"the",
"available",
"ports",
"."
] | train | https://github.com/openstack/networking-hyperv/blob/7a89306ab0586c95b99debb44d898f70834508b9/networking_hyperv/neutron/agent/layer2.py#L412-L432 |
Metatab/metapack | metapack/cli/build.py | build | def build(subparsers):
"""
Build source packages.
The mp build program runs all of the resources listed in a Metatab file and
produces one or more Metapack packages with those resources localized. It
will always try to produce a Filesystem package, and may optionally produce
Excel, Zip and CSV ... | python | def build(subparsers):
"""
Build source packages.
The mp build program runs all of the resources listed in a Metatab file and
produces one or more Metapack packages with those resources localized. It
will always try to produce a Filesystem package, and may optionally produce
Excel, Zip and CSV ... | [
"def",
"build",
"(",
"subparsers",
")",
":",
"parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"'build'",
",",
"help",
"=",
"'Build derived packages'",
",",
"description",
"=",
"build",
".",
"__doc__",
",",
"formatter_class",
"=",
"argparse",
".",
"RawDescr... | Build source packages.
The mp build program runs all of the resources listed in a Metatab file and
produces one or more Metapack packages with those resources localized. It
will always try to produce a Filesystem package, and may optionally produce
Excel, Zip and CSV packages.
Typical usage is to ... | [
"Build",
"source",
"packages",
"."
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/build.py#L34-L126 |
Metatab/metapack | metapack/cli/build.py | metatab_derived_handler | def metatab_derived_handler(m):
"""Create local Zip, Excel and Filesystem packages
:param m:
:param skip_if_exists:
:return:
"""
from metapack.exc import PackageError
from metapack.util import get_materialized_data_cache
from shutil import rmtree
create_list = []
url = None
... | python | def metatab_derived_handler(m):
"""Create local Zip, Excel and Filesystem packages
:param m:
:param skip_if_exists:
:return:
"""
from metapack.exc import PackageError
from metapack.util import get_materialized_data_cache
from shutil import rmtree
create_list = []
url = None
... | [
"def",
"metatab_derived_handler",
"(",
"m",
")",
":",
"from",
"metapack",
".",
"exc",
"import",
"PackageError",
"from",
"metapack",
".",
"util",
"import",
"get_materialized_data_cache",
"from",
"shutil",
"import",
"rmtree",
"create_list",
"=",
"[",
"]",
"url",
"... | Create local Zip, Excel and Filesystem packages
:param m:
:param skip_if_exists:
:return: | [
"Create",
"local",
"Zip",
"Excel",
"and",
"Filesystem",
"packages"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/cli/build.py#L161-L234 |
Metatab/metapack | metapack/jupyter/__init__.py | init | def init():
"""Initialize features that are normally initialized in the CLI"""
from metapack.appurl import SearchUrl
import metapack as mp
from os import environ
SearchUrl.initialize() # This makes the 'index:" urls work
mp.Downloader.context.update(environ) | python | def init():
"""Initialize features that are normally initialized in the CLI"""
from metapack.appurl import SearchUrl
import metapack as mp
from os import environ
SearchUrl.initialize() # This makes the 'index:" urls work
mp.Downloader.context.update(environ) | [
"def",
"init",
"(",
")",
":",
"from",
"metapack",
".",
"appurl",
"import",
"SearchUrl",
"import",
"metapack",
"as",
"mp",
"from",
"os",
"import",
"environ",
"SearchUrl",
".",
"initialize",
"(",
")",
"# This makes the 'index:\" urls work",
"mp",
".",
"Downloader"... | Initialize features that are normally initialized in the CLI | [
"Initialize",
"features",
"that",
"are",
"normally",
"initialized",
"in",
"the",
"CLI"
] | train | https://github.com/Metatab/metapack/blob/8365f221fbeaa3c0be9091f2eaf3447fd8e2e8d6/metapack/jupyter/__init__.py#L10-L18 |
project-rig/rig | rig/machine_control/struct_file.py | read_struct_file | def read_struct_file(struct_data):
"""Interpret a struct file defining the location of variables in memory.
Parameters
----------
struct_data : :py:class:`bytes`
String of :py:class:`bytes` containing data to interpret as the struct
definition.
Returns
-------
{struct_name:... | python | def read_struct_file(struct_data):
"""Interpret a struct file defining the location of variables in memory.
Parameters
----------
struct_data : :py:class:`bytes`
String of :py:class:`bytes` containing data to interpret as the struct
definition.
Returns
-------
{struct_name:... | [
"def",
"read_struct_file",
"(",
"struct_data",
")",
":",
"# Holders for all structs",
"structs",
"=",
"dict",
"(",
")",
"# Holders for the current struct",
"name",
"=",
"None",
"# Iterate over every line in the file",
"for",
"i",
",",
"l",
"in",
"enumerate",
"(",
"str... | Interpret a struct file defining the location of variables in memory.
Parameters
----------
struct_data : :py:class:`bytes`
String of :py:class:`bytes` containing data to interpret as the struct
definition.
Returns
-------
{struct_name: :py:class:`~.Struct`}
A dictionar... | [
"Interpret",
"a",
"struct",
"file",
"defining",
"the",
"location",
"of",
"variables",
"in",
"memory",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/struct_file.py#L9-L91 |
project-rig/rig | rig/machine_control/struct_file.py | num | def num(value):
"""Convert a value from one of several bases to an int."""
if re_hex_num.match(value):
return int(value, base=16)
else:
return int(value) | python | def num(value):
"""Convert a value from one of several bases to an int."""
if re_hex_num.match(value):
return int(value, base=16)
else:
return int(value) | [
"def",
"num",
"(",
"value",
")",
":",
"if",
"re_hex_num",
".",
"match",
"(",
"value",
")",
":",
"return",
"int",
"(",
"value",
",",
"base",
"=",
"16",
")",
"else",
":",
"return",
"int",
"(",
"value",
")"
] | Convert a value from one of several bases to an int. | [
"Convert",
"a",
"value",
"from",
"one",
"of",
"several",
"bases",
"to",
"an",
"int",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/struct_file.py#L101-L106 |
project-rig/rig | rig/machine_control/struct_file.py | Struct.update_default_values | def update_default_values(self, **updates):
"""Replace the default values of specified fields.
Parameters
----------
Parameters are taken as keyword-arguments of `field=new_value`.
Raises
------
KeyError
If a field doesn't exist in the struct.
... | python | def update_default_values(self, **updates):
"""Replace the default values of specified fields.
Parameters
----------
Parameters are taken as keyword-arguments of `field=new_value`.
Raises
------
KeyError
If a field doesn't exist in the struct.
... | [
"def",
"update_default_values",
"(",
"self",
",",
"*",
"*",
"updates",
")",
":",
"for",
"(",
"field",
",",
"value",
")",
"in",
"six",
".",
"iteritems",
"(",
"updates",
")",
":",
"fname",
"=",
"six",
".",
"b",
"(",
"field",
")",
"self",
"[",
"fname"... | Replace the default values of specified fields.
Parameters
----------
Parameters are taken as keyword-arguments of `field=new_value`.
Raises
------
KeyError
If a field doesn't exist in the struct. | [
"Replace",
"the",
"default",
"values",
"of",
"specified",
"fields",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/struct_file.py#L132-L146 |
project-rig/rig | rig/machine_control/struct_file.py | Struct.pack | def pack(self):
"""Pack the struct (and its default values) into a string of bytes.
Returns
-------
:py:class:`bytes`
Byte-string representation of struct containing default values.
"""
# Generate a buffer big enough to hold the packed values
data = b... | python | def pack(self):
"""Pack the struct (and its default values) into a string of bytes.
Returns
-------
:py:class:`bytes`
Byte-string representation of struct containing default values.
"""
# Generate a buffer big enough to hold the packed values
data = b... | [
"def",
"pack",
"(",
"self",
")",
":",
"# Generate a buffer big enough to hold the packed values",
"data",
"=",
"bytearray",
"(",
"b\"\\x00\"",
"*",
"self",
".",
"size",
")",
"# Iterate over the fields, pack each value in little-endian format and",
"# insert into the buffered data... | Pack the struct (and its default values) into a string of bytes.
Returns
-------
:py:class:`bytes`
Byte-string representation of struct containing default values. | [
"Pack",
"the",
"struct",
"(",
"and",
"its",
"default",
"values",
")",
"into",
"a",
"string",
"of",
"bytes",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/struct_file.py#L159-L176 |
NicolasLM/spinach | spinach/brokers/base.py | Broker.next_future_job_delta | def next_future_job_delta(self) -> Optional[float]:
"""Give the amount of seconds before the next future job is due."""
job = self._get_next_future_job()
if not job:
return None
return (job.at - datetime.now(timezone.utc)).total_seconds() | python | def next_future_job_delta(self) -> Optional[float]:
"""Give the amount of seconds before the next future job is due."""
job = self._get_next_future_job()
if not job:
return None
return (job.at - datetime.now(timezone.utc)).total_seconds() | [
"def",
"next_future_job_delta",
"(",
"self",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"job",
"=",
"self",
".",
"_get_next_future_job",
"(",
")",
"if",
"not",
"job",
":",
"return",
"None",
"return",
"(",
"job",
".",
"at",
"-",
"datetime",
".",
"no... | Give the amount of seconds before the next future job is due. | [
"Give",
"the",
"amount",
"of",
"seconds",
"before",
"the",
"next",
"future",
"job",
"is",
"due",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/brokers/base.py#L102-L107 |
project-rig/rig | rig/machine_control/utils.py | sdram_alloc_for_vertices | def sdram_alloc_for_vertices(controller, placements, allocations,
core_as_tag=True, sdram_resource=SDRAM,
cores_resource=Cores, clear=False):
"""Allocate and return a file-like view of a region of SDRAM for each
vertex which uses SDRAM as a resource.
... | python | def sdram_alloc_for_vertices(controller, placements, allocations,
core_as_tag=True, sdram_resource=SDRAM,
cores_resource=Cores, clear=False):
"""Allocate and return a file-like view of a region of SDRAM for each
vertex which uses SDRAM as a resource.
... | [
"def",
"sdram_alloc_for_vertices",
"(",
"controller",
",",
"placements",
",",
"allocations",
",",
"core_as_tag",
"=",
"True",
",",
"sdram_resource",
"=",
"SDRAM",
",",
"cores_resource",
"=",
"Cores",
",",
"clear",
"=",
"False",
")",
":",
"# For each vertex we perf... | Allocate and return a file-like view of a region of SDRAM for each
vertex which uses SDRAM as a resource.
The tag assigned to each region of assigned SDRAM is the index of the
first core that each vertex is assigned. For example::
placements = {vertex: (0, 5)}
allocations = {vertex: {Core... | [
"Allocate",
"and",
"return",
"a",
"file",
"-",
"like",
"view",
"of",
"a",
"region",
"of",
"SDRAM",
"for",
"each",
"vertex",
"which",
"uses",
"SDRAM",
"as",
"a",
"resource",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/machine_control/utils.py#L6-L94 |
NicolasLM/spinach | spinach/job.py | advance_job_status | def advance_job_status(namespace: str, job: Job, duration: float,
err: Optional[Exception]):
"""Advance the status of a job depending on its execution.
This function is called after a job has been executed. It calculates its
next status and calls the appropriate signals.
"""
... | python | def advance_job_status(namespace: str, job: Job, duration: float,
err: Optional[Exception]):
"""Advance the status of a job depending on its execution.
This function is called after a job has been executed. It calculates its
next status and calls the appropriate signals.
"""
... | [
"def",
"advance_job_status",
"(",
"namespace",
":",
"str",
",",
"job",
":",
"Job",
",",
"duration",
":",
"float",
",",
"err",
":",
"Optional",
"[",
"Exception",
"]",
")",
":",
"duration",
"=",
"human_duration",
"(",
"duration",
")",
"if",
"not",
"err",
... | Advance the status of a job depending on its execution.
This function is called after a job has been executed. It calculates its
next status and calls the appropriate signals. | [
"Advance",
"the",
"status",
"of",
"a",
"job",
"depending",
"on",
"its",
"execution",
"."
] | train | https://github.com/NicolasLM/spinach/blob/0122f916643101eab5cdc1f3da662b9446e372aa/spinach/job.py#L152-L197 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tile | def tile(self, zoom, row, col):
"""
Return Tile object of this TilePyramid.
- zoom: zoom level
- row: tile matrix row
- col: tile matrix column
"""
return Tile(self, zoom, row, col) | python | def tile(self, zoom, row, col):
"""
Return Tile object of this TilePyramid.
- zoom: zoom level
- row: tile matrix row
- col: tile matrix column
"""
return Tile(self, zoom, row, col) | [
"def",
"tile",
"(",
"self",
",",
"zoom",
",",
"row",
",",
"col",
")",
":",
"return",
"Tile",
"(",
"self",
",",
"zoom",
",",
"row",
",",
"col",
")"
] | Return Tile object of this TilePyramid.
- zoom: zoom level
- row: tile matrix row
- col: tile matrix column | [
"Return",
"Tile",
"object",
"of",
"this",
"TilePyramid",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L62-L70 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.matrix_width | def matrix_width(self, zoom):
"""
Tile matrix width (number of columns) at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
width = int(math.ceil(self.grid.shape.width * 2**(zoom) / self.metatiling))
return 1 if width < 1 else width | python | def matrix_width(self, zoom):
"""
Tile matrix width (number of columns) at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
width = int(math.ceil(self.grid.shape.width * 2**(zoom) / self.metatiling))
return 1 if width < 1 else width | [
"def",
"matrix_width",
"(",
"self",
",",
"zoom",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"width",
"=",
"int",
"(",
"math",
".",
"ceil",
"(",
"self",
".",
"grid",
".",
"shape",
".",
"width",
"*",
"2",
"**",
"(",
"zoom",
")",
"/",
"self",
".",... | Tile matrix width (number of columns) at zoom level.
- zoom: zoom level | [
"Tile",
"matrix",
"width",
"(",
"number",
"of",
"columns",
")",
"at",
"zoom",
"level",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L72-L80 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.matrix_height | def matrix_height(self, zoom):
"""
Tile matrix height (number of rows) at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
height = int(math.ceil(self.grid.shape.height * 2**(zoom) / self.metatiling))
return 1 if height < 1 else height | python | def matrix_height(self, zoom):
"""
Tile matrix height (number of rows) at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
height = int(math.ceil(self.grid.shape.height * 2**(zoom) / self.metatiling))
return 1 if height < 1 else height | [
"def",
"matrix_height",
"(",
"self",
",",
"zoom",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"height",
"=",
"int",
"(",
"math",
".",
"ceil",
"(",
"self",
".",
"grid",
".",
"shape",
".",
"height",
"*",
"2",
"**",
"(",
"zoom",
")",
"/",
"self",
"... | Tile matrix height (number of rows) at zoom level.
- zoom: zoom level | [
"Tile",
"matrix",
"height",
"(",
"number",
"of",
"rows",
")",
"at",
"zoom",
"level",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L82-L90 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tile_x_size | def tile_x_size(self, zoom):
"""
Width of a tile in SRID units at zoom level.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_x_size is deprecated"))
validate_zoom(zoom)
return round(self.x_size / self.matrix_width(zoom), ROUND) | python | def tile_x_size(self, zoom):
"""
Width of a tile in SRID units at zoom level.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_x_size is deprecated"))
validate_zoom(zoom)
return round(self.x_size / self.matrix_width(zoom), ROUND) | [
"def",
"tile_x_size",
"(",
"self",
",",
"zoom",
")",
":",
"warnings",
".",
"warn",
"(",
"DeprecationWarning",
"(",
"\"tile_x_size is deprecated\"",
")",
")",
"validate_zoom",
"(",
"zoom",
")",
"return",
"round",
"(",
"self",
".",
"x_size",
"/",
"self",
".",
... | Width of a tile in SRID units at zoom level.
- zoom: zoom level | [
"Width",
"of",
"a",
"tile",
"in",
"SRID",
"units",
"at",
"zoom",
"level",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L92-L100 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tile_y_size | def tile_y_size(self, zoom):
"""
Height of a tile in SRID units at zoom level.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_y_size is deprecated"))
validate_zoom(zoom)
return round(self.y_size / self.matrix_height(zoom), ROUND) | python | def tile_y_size(self, zoom):
"""
Height of a tile in SRID units at zoom level.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_y_size is deprecated"))
validate_zoom(zoom)
return round(self.y_size / self.matrix_height(zoom), ROUND) | [
"def",
"tile_y_size",
"(",
"self",
",",
"zoom",
")",
":",
"warnings",
".",
"warn",
"(",
"DeprecationWarning",
"(",
"\"tile_y_size is deprecated\"",
")",
")",
"validate_zoom",
"(",
"zoom",
")",
"return",
"round",
"(",
"self",
".",
"y_size",
"/",
"self",
".",
... | Height of a tile in SRID units at zoom level.
- zoom: zoom level | [
"Height",
"of",
"a",
"tile",
"in",
"SRID",
"units",
"at",
"zoom",
"level",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L102-L110 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tile_width | def tile_width(self, zoom):
"""
Tile width in pixel.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_width is deprecated"))
validate_zoom(zoom)
matrix_pixel = 2**(zoom) * self.tile_size * self.grid.shape.width
tile_pixel = self.tile_size * s... | python | def tile_width(self, zoom):
"""
Tile width in pixel.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_width is deprecated"))
validate_zoom(zoom)
matrix_pixel = 2**(zoom) * self.tile_size * self.grid.shape.width
tile_pixel = self.tile_size * s... | [
"def",
"tile_width",
"(",
"self",
",",
"zoom",
")",
":",
"warnings",
".",
"warn",
"(",
"DeprecationWarning",
"(",
"\"tile_width is deprecated\"",
")",
")",
"validate_zoom",
"(",
"zoom",
")",
"matrix_pixel",
"=",
"2",
"**",
"(",
"zoom",
")",
"*",
"self",
".... | Tile width in pixel.
- zoom: zoom level | [
"Tile",
"width",
"in",
"pixel",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L112-L122 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tile_height | def tile_height(self, zoom):
"""
Tile height in pixel.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_height is deprecated"))
validate_zoom(zoom)
matrix_pixel = 2**(zoom) * self.tile_size * self.grid.shape.height
tile_pixel = self.tile_size... | python | def tile_height(self, zoom):
"""
Tile height in pixel.
- zoom: zoom level
"""
warnings.warn(DeprecationWarning("tile_height is deprecated"))
validate_zoom(zoom)
matrix_pixel = 2**(zoom) * self.tile_size * self.grid.shape.height
tile_pixel = self.tile_size... | [
"def",
"tile_height",
"(",
"self",
",",
"zoom",
")",
":",
"warnings",
".",
"warn",
"(",
"DeprecationWarning",
"(",
"\"tile_height is deprecated\"",
")",
")",
"validate_zoom",
"(",
"zoom",
")",
"matrix_pixel",
"=",
"2",
"**",
"(",
"zoom",
")",
"*",
"self",
... | Tile height in pixel.
- zoom: zoom level | [
"Tile",
"height",
"in",
"pixel",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L124-L134 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.pixel_x_size | def pixel_x_size(self, zoom):
"""
Width of a pixel in SRID units at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
return round(
(self.grid.right - self.grid.left) /
(self.grid.shape.width * 2**zoom * self.tile_size),
ROUND
... | python | def pixel_x_size(self, zoom):
"""
Width of a pixel in SRID units at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
return round(
(self.grid.right - self.grid.left) /
(self.grid.shape.width * 2**zoom * self.tile_size),
ROUND
... | [
"def",
"pixel_x_size",
"(",
"self",
",",
"zoom",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"return",
"round",
"(",
"(",
"self",
".",
"grid",
".",
"right",
"-",
"self",
".",
"grid",
".",
"left",
")",
"/",
"(",
"self",
".",
"grid",
".",
"shape",
... | Width of a pixel in SRID units at zoom level.
- zoom: zoom level | [
"Width",
"of",
"a",
"pixel",
"in",
"SRID",
"units",
"at",
"zoom",
"level",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L136-L147 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.pixel_y_size | def pixel_y_size(self, zoom):
"""
Height of a pixel in SRID units at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
return round(
(self.grid.top - self.grid.bottom) /
(self.grid.shape.height * 2**zoom * self.tile_size),
ROUND
... | python | def pixel_y_size(self, zoom):
"""
Height of a pixel in SRID units at zoom level.
- zoom: zoom level
"""
validate_zoom(zoom)
return round(
(self.grid.top - self.grid.bottom) /
(self.grid.shape.height * 2**zoom * self.tile_size),
ROUND
... | [
"def",
"pixel_y_size",
"(",
"self",
",",
"zoom",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"return",
"round",
"(",
"(",
"self",
".",
"grid",
".",
"top",
"-",
"self",
".",
"grid",
".",
"bottom",
")",
"/",
"(",
"self",
".",
"grid",
".",
"shape",
... | Height of a pixel in SRID units at zoom level.
- zoom: zoom level | [
"Height",
"of",
"a",
"pixel",
"in",
"SRID",
"units",
"at",
"zoom",
"level",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L149-L160 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tiles_from_bounds | def tiles_from_bounds(self, bounds, zoom):
"""
Return all tiles intersecting with bounds.
Bounds values will be cleaned if they cross the antimeridian or are
outside of the Northern or Southern tile pyramid bounds.
- bounds: tuple of (left, bottom, right, top) bounding values i... | python | def tiles_from_bounds(self, bounds, zoom):
"""
Return all tiles intersecting with bounds.
Bounds values will be cleaned if they cross the antimeridian or are
outside of the Northern or Southern tile pyramid bounds.
- bounds: tuple of (left, bottom, right, top) bounding values i... | [
"def",
"tiles_from_bounds",
"(",
"self",
",",
"bounds",
",",
"zoom",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"if",
"not",
"isinstance",
"(",
"bounds",
",",
"tuple",
")",
"or",
"len",
"(",
"bounds",
")",
"!=",
"4",
":",
"raise",
"ValueError",
"(",
... | Return all tiles intersecting with bounds.
Bounds values will be cleaned if they cross the antimeridian or are
outside of the Northern or Southern tile pyramid bounds.
- bounds: tuple of (left, bottom, right, top) bounding values in tile
pyramid CRS
- zoom: zoom level | [
"Return",
"all",
"tiles",
"intersecting",
"with",
"bounds",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L173-L194 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tiles_from_bbox | def tiles_from_bbox(self, geometry, zoom):
"""
All metatiles intersecting with given bounding box.
- geometry: shapely geometry
- zoom: zoom level
"""
validate_zoom(zoom)
return self.tiles_from_bounds(geometry.bounds, zoom) | python | def tiles_from_bbox(self, geometry, zoom):
"""
All metatiles intersecting with given bounding box.
- geometry: shapely geometry
- zoom: zoom level
"""
validate_zoom(zoom)
return self.tiles_from_bounds(geometry.bounds, zoom) | [
"def",
"tiles_from_bbox",
"(",
"self",
",",
"geometry",
",",
"zoom",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"return",
"self",
".",
"tiles_from_bounds",
"(",
"geometry",
".",
"bounds",
",",
"zoom",
")"
] | All metatiles intersecting with given bounding box.
- geometry: shapely geometry
- zoom: zoom level | [
"All",
"metatiles",
"intersecting",
"with",
"given",
"bounding",
"box",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L196-L204 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tiles_from_geom | def tiles_from_geom(self, geometry, zoom):
"""
Return all tiles intersecting with input geometry.
- geometry: shapely geometry
- zoom: zoom level
"""
validate_zoom(zoom)
if geometry.is_empty:
return
if not geometry.is_valid:
raise ... | python | def tiles_from_geom(self, geometry, zoom):
"""
Return all tiles intersecting with input geometry.
- geometry: shapely geometry
- zoom: zoom level
"""
validate_zoom(zoom)
if geometry.is_empty:
return
if not geometry.is_valid:
raise ... | [
"def",
"tiles_from_geom",
"(",
"self",
",",
"geometry",
",",
"zoom",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"if",
"geometry",
".",
"is_empty",
":",
"return",
"if",
"not",
"geometry",
".",
"is_valid",
":",
"raise",
"ValueError",
"(",
"\"no valid geometr... | Return all tiles intersecting with input geometry.
- geometry: shapely geometry
- zoom: zoom level | [
"Return",
"all",
"tiles",
"intersecting",
"with",
"input",
"geometry",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L206-L230 |
ungarj/tilematrix | tilematrix/_tilepyramid.py | TilePyramid.tile_from_xy | def tile_from_xy(self, x, y, zoom, on_edge_use="rb"):
"""
Return tile covering a point defined by x and y values.
- x: x coordinate
- y: y coordinate
- zoom: zoom level
- on_edge_use: determine which Tile to pick if Point hits a grid edge
- rb: right bottom (... | python | def tile_from_xy(self, x, y, zoom, on_edge_use="rb"):
"""
Return tile covering a point defined by x and y values.
- x: x coordinate
- y: y coordinate
- zoom: zoom level
- on_edge_use: determine which Tile to pick if Point hits a grid edge
- rb: right bottom (... | [
"def",
"tile_from_xy",
"(",
"self",
",",
"x",
",",
"y",
",",
"zoom",
",",
"on_edge_use",
"=",
"\"rb\"",
")",
":",
"validate_zoom",
"(",
"zoom",
")",
"if",
"x",
"<",
"self",
".",
"left",
"or",
"x",
">",
"self",
".",
"right",
"or",
"y",
"<",
"self"... | Return tile covering a point defined by x and y values.
- x: x coordinate
- y: y coordinate
- zoom: zoom level
- on_edge_use: determine which Tile to pick if Point hits a grid edge
- rb: right bottom (default)
- rt: right top
- lt: left top
... | [
"Return",
"tile",
"covering",
"a",
"point",
"defined",
"by",
"x",
"and",
"y",
"values",
"."
] | train | https://github.com/ungarj/tilematrix/blob/6f8cd3b85f61434a7ce5d7b635c3ad8f18ccb268/tilematrix/_tilepyramid.py#L232-L250 |
happyleavesaoc/python-voobly | utils/update_metadata.py | get_ladder_metadata | def get_ladder_metadata(session, url):
"""Get ladder metadata."""
parsed = make_scrape_request(session, url)
tag = parsed.find('a', href=re.compile(LADDER_ID_REGEX))
return {
'id': int(tag['href'].split('/')[-1]),
'slug': url.split('/')[-1],
'url': url
} | python | def get_ladder_metadata(session, url):
"""Get ladder metadata."""
parsed = make_scrape_request(session, url)
tag = parsed.find('a', href=re.compile(LADDER_ID_REGEX))
return {
'id': int(tag['href'].split('/')[-1]),
'slug': url.split('/')[-1],
'url': url
} | [
"def",
"get_ladder_metadata",
"(",
"session",
",",
"url",
")",
":",
"parsed",
"=",
"make_scrape_request",
"(",
"session",
",",
"url",
")",
"tag",
"=",
"parsed",
".",
"find",
"(",
"'a'",
",",
"href",
"=",
"re",
".",
"compile",
"(",
"LADDER_ID_REGEX",
")",... | Get ladder metadata. | [
"Get",
"ladder",
"metadata",
"."
] | train | https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/utils/update_metadata.py#L14-L22 |
happyleavesaoc/python-voobly | utils/update_metadata.py | get_ladders_metadata | def get_ladders_metadata(session, parsed):
"""Get metadata for all ladders."""
ladders = {}
for ladder in parsed.find_all('a', href=re.compile(LADDER_URL_REGEX)):
ladders[ladder.text] = get_ladder_metadata(session, ladder['href'])
return ladders | python | def get_ladders_metadata(session, parsed):
"""Get metadata for all ladders."""
ladders = {}
for ladder in parsed.find_all('a', href=re.compile(LADDER_URL_REGEX)):
ladders[ladder.text] = get_ladder_metadata(session, ladder['href'])
return ladders | [
"def",
"get_ladders_metadata",
"(",
"session",
",",
"parsed",
")",
":",
"ladders",
"=",
"{",
"}",
"for",
"ladder",
"in",
"parsed",
".",
"find_all",
"(",
"'a'",
",",
"href",
"=",
"re",
".",
"compile",
"(",
"LADDER_URL_REGEX",
")",
")",
":",
"ladders",
"... | Get metadata for all ladders. | [
"Get",
"metadata",
"for",
"all",
"ladders",
"."
] | train | https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/utils/update_metadata.py#L25-L30 |
happyleavesaoc/python-voobly | utils/update_metadata.py | get_metadata | def get_metadata(session, games):
"""Get metadata for games (only ladder data right now)."""
for data in games.values():
parsed = make_scrape_request(session, data['url'])
return {
'ladders': get_ladders_metadata(session, parsed)
} | python | def get_metadata(session, games):
"""Get metadata for games (only ladder data right now)."""
for data in games.values():
parsed = make_scrape_request(session, data['url'])
return {
'ladders': get_ladders_metadata(session, parsed)
} | [
"def",
"get_metadata",
"(",
"session",
",",
"games",
")",
":",
"for",
"data",
"in",
"games",
".",
"values",
"(",
")",
":",
"parsed",
"=",
"make_scrape_request",
"(",
"session",
",",
"data",
"[",
"'url'",
"]",
")",
"return",
"{",
"'ladders'",
":",
"get_... | Get metadata for games (only ladder data right now). | [
"Get",
"metadata",
"for",
"games",
"(",
"only",
"ladder",
"data",
"right",
"now",
")",
"."
] | train | https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/utils/update_metadata.py#L33-L39 |
happyleavesaoc/python-voobly | utils/update_metadata.py | update_metadata | def update_metadata(session, path=DATA_PATH):
"""Update metadata files (only ladders right now)."""
with open(os.path.join(path, 'games.json')) as handle:
games = json.loads(handle.read())
for key, data in get_metadata(session, games).items():
with open(os.path.join(path, '{}.json'.for... | python | def update_metadata(session, path=DATA_PATH):
"""Update metadata files (only ladders right now)."""
with open(os.path.join(path, 'games.json')) as handle:
games = json.loads(handle.read())
for key, data in get_metadata(session, games).items():
with open(os.path.join(path, '{}.json'.for... | [
"def",
"update_metadata",
"(",
"session",
",",
"path",
"=",
"DATA_PATH",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"'games.json'",
")",
")",
"as",
"handle",
":",
"games",
"=",
"json",
".",
"loads",
"(",
"handle"... | Update metadata files (only ladders right now). | [
"Update",
"metadata",
"files",
"(",
"only",
"ladders",
"right",
"now",
")",
"."
] | train | https://github.com/happyleavesaoc/python-voobly/blob/83b4ab7d630a00459c2a64e55e3ac85c7be38194/utils/update_metadata.py#L42-L49 |
project-rig/rig | rig/scripts/rig_counters.py | sample_counters | def sample_counters(mc, system_info):
"""Sample every router counter in the machine."""
return {
(x, y): mc.get_router_diagnostics(x, y) for (x, y) in system_info
} | python | def sample_counters(mc, system_info):
"""Sample every router counter in the machine."""
return {
(x, y): mc.get_router_diagnostics(x, y) for (x, y) in system_info
} | [
"def",
"sample_counters",
"(",
"mc",
",",
"system_info",
")",
":",
"return",
"{",
"(",
"x",
",",
"y",
")",
":",
"mc",
".",
"get_router_diagnostics",
"(",
"x",
",",
"y",
")",
"for",
"(",
"x",
",",
"y",
")",
"in",
"system_info",
"}"
] | Sample every router counter in the machine. | [
"Sample",
"every",
"router",
"counter",
"in",
"the",
"machine",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/scripts/rig_counters.py#L24-L28 |
project-rig/rig | rig/scripts/rig_counters.py | deltas | def deltas(last, now):
"""Return the change in counter values (accounting for wrap-around)."""
return {
xy: RouterDiagnostics(*((n - l) & 0xFFFFFFFF
for l, n in zip(last[xy], now[xy])))
for xy in last
} | python | def deltas(last, now):
"""Return the change in counter values (accounting for wrap-around)."""
return {
xy: RouterDiagnostics(*((n - l) & 0xFFFFFFFF
for l, n in zip(last[xy], now[xy])))
for xy in last
} | [
"def",
"deltas",
"(",
"last",
",",
"now",
")",
":",
"return",
"{",
"xy",
":",
"RouterDiagnostics",
"(",
"*",
"(",
"(",
"n",
"-",
"l",
")",
"&",
"0xFFFFFFFF",
"for",
"l",
",",
"n",
"in",
"zip",
"(",
"last",
"[",
"xy",
"]",
",",
"now",
"[",
"xy... | Return the change in counter values (accounting for wrap-around). | [
"Return",
"the",
"change",
"in",
"counter",
"values",
"(",
"accounting",
"for",
"wrap",
"-",
"around",
")",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/scripts/rig_counters.py#L31-L37 |
project-rig/rig | rig/scripts/rig_counters.py | monitor_counters | def monitor_counters(mc, output, counters, detailed, f):
"""Monitor the counters on a specified machine, taking a snap-shot every
time the generator 'f' yields."""
# Print CSV header
output.write("time,{}{}\n".format("x,y," if detailed else "",
",".join(counters)))
... | python | def monitor_counters(mc, output, counters, detailed, f):
"""Monitor the counters on a specified machine, taking a snap-shot every
time the generator 'f' yields."""
# Print CSV header
output.write("time,{}{}\n".format("x,y," if detailed else "",
",".join(counters)))
... | [
"def",
"monitor_counters",
"(",
"mc",
",",
"output",
",",
"counters",
",",
"detailed",
",",
"f",
")",
":",
"# Print CSV header",
"output",
".",
"write",
"(",
"\"time,{}{}\\n\"",
".",
"format",
"(",
"\"x,y,\"",
"if",
"detailed",
"else",
"\"\"",
",",
"\",\"",
... | Monitor the counters on a specified machine, taking a snap-shot every
time the generator 'f' yields. | [
"Monitor",
"the",
"counters",
"on",
"a",
"specified",
"machine",
"taking",
"a",
"snap",
"-",
"shot",
"every",
"time",
"the",
"generator",
"f",
"yields",
"."
] | train | https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/scripts/rig_counters.py#L40-L75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.