repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
redhat-openstack/python-tripleo-helper | tripleohelper/undercloud.py | Undercloud.openstack_undercloud_install | def openstack_undercloud_install(self):
"""Deploy an undercloud on the host.
"""
instack_undercloud_ver, _ = self.run('repoquery --whatprovides /usr/share/instack-undercloud/puppet-stack-config/puppet-stack-config.pp')
if instack_undercloud_ver.rstrip('\n') == 'instack-undercloud-0:2.2.0... | python | def openstack_undercloud_install(self):
"""Deploy an undercloud on the host.
"""
instack_undercloud_ver, _ = self.run('repoquery --whatprovides /usr/share/instack-undercloud/puppet-stack-config/puppet-stack-config.pp')
if instack_undercloud_ver.rstrip('\n') == 'instack-undercloud-0:2.2.0... | [
"def",
"openstack_undercloud_install",
"(",
"self",
")",
":",
"instack_undercloud_ver",
",",
"_",
"=",
"self",
".",
"run",
"(",
"'repoquery --whatprovides /usr/share/instack-undercloud/puppet-stack-config/puppet-stack-config.pp'",
")",
"if",
"instack_undercloud_ver",
".",
"rstr... | Deploy an undercloud on the host. | [
"Deploy",
"an",
"undercloud",
"on",
"the",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L56-L70 | train | Deploy an undercloud on the host. |
redhat-openstack/python-tripleo-helper | tripleohelper/undercloud.py | Undercloud.load_instackenv | def load_instackenv(self):
"""Load the instackenv.json file and wait till the ironic nodes are ready.
TODO(Gonéri): should be splitted, write_instackenv() to generate the
instackenv.json and instackenv_import() for the rest.
"""
self.add_environment_file(user='stack', filename='s... | python | def load_instackenv(self):
"""Load the instackenv.json file and wait till the ironic nodes are ready.
TODO(Gonéri): should be splitted, write_instackenv() to generate the
instackenv.json and instackenv_import() for the rest.
"""
self.add_environment_file(user='stack', filename='s... | [
"def",
"load_instackenv",
"(",
"self",
")",
":",
"self",
".",
"add_environment_file",
"(",
"user",
"=",
"'stack'",
",",
"filename",
"=",
"'stackrc'",
")",
"self",
".",
"run",
"(",
"'openstack baremetal import --json instackenv.json'",
",",
"user",
"=",
"'stack'",
... | Load the instackenv.json file and wait till the ironic nodes are ready.
TODO(Gonéri): should be splitted, write_instackenv() to generate the
instackenv.json and instackenv_import() for the rest. | [
"Load",
"the",
"instackenv",
".",
"json",
"file",
"and",
"wait",
"till",
"the",
"ironic",
"nodes",
"are",
"ready",
".",
"TODO",
"(",
"Gonéri",
")",
":",
"should",
"be",
"splitted",
"write_instackenv",
"()",
"to",
"generate",
"the",
"instackenv",
".",
"json... | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L99-L121 | train | Load the instackenv. json file and wait till the ironic nodes are ready. |
redhat-openstack/python-tripleo-helper | tripleohelper/undercloud.py | Undercloud.create_flavor | def create_flavor(self, name):
"""Create a new baremetal flavor.
:param name: the name of the flavor
"""
self.add_environment_file(user='stack', filename='stackrc')
self.run('openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal', user='stack', success_statu... | python | def create_flavor(self, name):
"""Create a new baremetal flavor.
:param name: the name of the flavor
"""
self.add_environment_file(user='stack', filename='stackrc')
self.run('openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal', user='stack', success_statu... | [
"def",
"create_flavor",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"add_environment_file",
"(",
"user",
"=",
"'stack'",
",",
"filename",
"=",
"'stackrc'",
")",
"self",
".",
"run",
"(",
"'openstack flavor create --id auto --ram 4096 --disk 40 --vcpus 1 baremetal'... | Create a new baremetal flavor.
:param name: the name of the flavor | [
"Create",
"a",
"new",
"baremetal",
"flavor",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L188-L196 | train | Create a new baremetal flavor. |
redhat-openstack/python-tripleo-helper | tripleohelper/undercloud.py | Undercloud.list_nodes | def list_nodes(self):
"""List the Ironic nodes UUID."""
self.add_environment_file(user='stack', filename='stackrc')
ret, _ = self.run("ironic node-list --fields uuid|awk '/-.*-/ {print $2}'", user='stack')
# NOTE(Gonéri): the good new is, the order of the nodes is preserved and follow th... | python | def list_nodes(self):
"""List the Ironic nodes UUID."""
self.add_environment_file(user='stack', filename='stackrc')
ret, _ = self.run("ironic node-list --fields uuid|awk '/-.*-/ {print $2}'", user='stack')
# NOTE(Gonéri): the good new is, the order of the nodes is preserved and follow th... | [
"def",
"list_nodes",
"(",
"self",
")",
":",
"self",
".",
"add_environment_file",
"(",
"user",
"=",
"'stack'",
",",
"filename",
"=",
"'stackrc'",
")",
"ret",
",",
"_",
"=",
"self",
".",
"run",
"(",
"\"ironic node-list --fields uuid|awk '/-.*-/ {print $2}'\"",
","... | List the Ironic nodes UUID. | [
"List",
"the",
"Ironic",
"nodes",
"UUID",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L198-L204 | train | List the Ironic nodes UUID. |
redhat-openstack/python-tripleo-helper | tripleohelper/undercloud.py | Undercloud.set_flavor | def set_flavor(self, node, flavor):
"""Set a flavor to a given ironic node.
:param uuid: the ironic node UUID
:param flavor: the flavor name
"""
command = (
'ironic node-update {uuid} add '
'properties/capabilities=profile:{flavor},boot_option:local').for... | python | def set_flavor(self, node, flavor):
"""Set a flavor to a given ironic node.
:param uuid: the ironic node UUID
:param flavor: the flavor name
"""
command = (
'ironic node-update {uuid} add '
'properties/capabilities=profile:{flavor},boot_option:local').for... | [
"def",
"set_flavor",
"(",
"self",
",",
"node",
",",
"flavor",
")",
":",
"command",
"=",
"(",
"'ironic node-update {uuid} add '",
"'properties/capabilities=profile:{flavor},boot_option:local'",
")",
".",
"format",
"(",
"uuid",
"=",
"node",
".",
"uuid",
",",
"flavor",... | Set a flavor to a given ironic node.
:param uuid: the ironic node UUID
:param flavor: the flavor name | [
"Set",
"a",
"flavor",
"to",
"a",
"given",
"ironic",
"node",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L206-L219 | train | Set a flavor to a given ironic node |
JawboneHealth/jhhalchemy | jhhalchemy/model/__init__.py | Base.read_by | def read_by(cls, removed=False, **kwargs):
"""
filter_by query helper that handles soft delete logic. If your query conditions require expressions, use read.
:param removed: whether to include soft-deleted rows
:param kwargs: where clause mappings to pass to filter_by
:return: r... | python | def read_by(cls, removed=False, **kwargs):
"""
filter_by query helper that handles soft delete logic. If your query conditions require expressions, use read.
:param removed: whether to include soft-deleted rows
:param kwargs: where clause mappings to pass to filter_by
:return: r... | [
"def",
"read_by",
"(",
"cls",
",",
"removed",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"removed",
":",
"kwargs",
"[",
"'time_removed'",
"]",
"=",
"0",
"return",
"cls",
".",
"query",
".",
"filter_by",
"(",
"*",
"*",
"kwargs",
")... | filter_by query helper that handles soft delete logic. If your query conditions require expressions, use read.
:param removed: whether to include soft-deleted rows
:param kwargs: where clause mappings to pass to filter_by
:return: row object generator | [
"filter_by",
"query",
"helper",
"that",
"handles",
"soft",
"delete",
"logic",
".",
"If",
"your",
"query",
"conditions",
"require",
"expressions",
"use",
"read",
"."
] | ca0011d644e404561a142c9d7f0a8a569f1f4f27 | https://github.com/JawboneHealth/jhhalchemy/blob/ca0011d644e404561a142c9d7f0a8a569f1f4f27/jhhalchemy/model/__init__.py#L45-L55 | train | filter_by query helper that handles soft - deleted logic |
JawboneHealth/jhhalchemy | jhhalchemy/model/__init__.py | Base.read | def read(cls, *criteria, **kwargs):
"""
filter query helper that handles soft delete logic. If your query conditions do not require expressions,
consider using read_by.
:param criteria: where clause conditions
:param kwargs: set removed=True if you want soft-deleted rows
... | python | def read(cls, *criteria, **kwargs):
"""
filter query helper that handles soft delete logic. If your query conditions do not require expressions,
consider using read_by.
:param criteria: where clause conditions
:param kwargs: set removed=True if you want soft-deleted rows
... | [
"def",
"read",
"(",
"cls",
",",
"*",
"criteria",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
".",
"get",
"(",
"'removed'",
",",
"False",
")",
":",
"return",
"cls",
".",
"query",
".",
"filter",
"(",
"cls",
".",
"time_removed",
"==",
... | filter query helper that handles soft delete logic. If your query conditions do not require expressions,
consider using read_by.
:param criteria: where clause conditions
:param kwargs: set removed=True if you want soft-deleted rows
:return: row object generator | [
"filter",
"query",
"helper",
"that",
"handles",
"soft",
"delete",
"logic",
".",
"If",
"your",
"query",
"conditions",
"do",
"not",
"require",
"expressions",
"consider",
"using",
"read_by",
"."
] | ca0011d644e404561a142c9d7f0a8a569f1f4f27 | https://github.com/JawboneHealth/jhhalchemy/blob/ca0011d644e404561a142c9d7f0a8a569f1f4f27/jhhalchemy/model/__init__.py#L58-L69 | train | filter query helper that handles soft - deleted logic. |
JawboneHealth/jhhalchemy | jhhalchemy/model/__init__.py | Base.delete | def delete(self, session, commit=True, soft=True):
"""
Delete a row from the DB.
:param session: flask_sqlalchemy session object
:param commit: whether to issue the commit
:param soft: whether this is a soft delete (i.e., update time_removed)
"""
if soft:
... | python | def delete(self, session, commit=True, soft=True):
"""
Delete a row from the DB.
:param session: flask_sqlalchemy session object
:param commit: whether to issue the commit
:param soft: whether this is a soft delete (i.e., update time_removed)
"""
if soft:
... | [
"def",
"delete",
"(",
"self",
",",
"session",
",",
"commit",
"=",
"True",
",",
"soft",
"=",
"True",
")",
":",
"if",
"soft",
":",
"self",
".",
"time_removed",
"=",
"sqlalchemy",
".",
"func",
".",
"unix_timestamp",
"(",
")",
"else",
":",
"session",
"."... | Delete a row from the DB.
:param session: flask_sqlalchemy session object
:param commit: whether to issue the commit
:param soft: whether this is a soft delete (i.e., update time_removed) | [
"Delete",
"a",
"row",
"from",
"the",
"DB",
"."
] | ca0011d644e404561a142c9d7f0a8a569f1f4f27 | https://github.com/JawboneHealth/jhhalchemy/blob/ca0011d644e404561a142c9d7f0a8a569f1f4f27/jhhalchemy/model/__init__.py#L71-L85 | train | Delete a row from the DB. |
gebn/wood | wood/entities.py | Entity.walk_paths | def walk_paths(self,
base: Optional[pathlib.PurePath] = pathlib.PurePath()) \
-> Iterator[pathlib.PurePath]:
"""
Recursively traverse all paths inside this entity, including the entity
itself.
:param base: The base path to prepend to the entity name.
... | python | def walk_paths(self,
base: Optional[pathlib.PurePath] = pathlib.PurePath()) \
-> Iterator[pathlib.PurePath]:
"""
Recursively traverse all paths inside this entity, including the entity
itself.
:param base: The base path to prepend to the entity name.
... | [
"def",
"walk_paths",
"(",
"self",
",",
"base",
":",
"Optional",
"[",
"pathlib",
".",
"PurePath",
"]",
"=",
"pathlib",
".",
"PurePath",
"(",
")",
")",
"->",
"Iterator",
"[",
"pathlib",
".",
"PurePath",
"]",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Recursively traverse all paths inside this entity, including the entity
itself.
:param base: The base path to prepend to the entity name.
:return: An iterator of paths. | [
"Recursively",
"traverse",
"all",
"paths",
"inside",
"this",
"entity",
"including",
"the",
"entity",
"itself",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/entities.py#L27-L37 | train | Recursively walks all paths inside this entity including the entity s base path. |
gebn/wood | wood/entities.py | Entity._walk_paths | def _walk_paths(self, base: pathlib.PurePath) \
-> Iterator[pathlib.PurePath]:
"""
Internal helper for walking paths. This is required to exclude the name
of the root entity from the walk.
:param base: The base path to prepend to the entity name.
:return: An iterator... | python | def _walk_paths(self, base: pathlib.PurePath) \
-> Iterator[pathlib.PurePath]:
"""
Internal helper for walking paths. This is required to exclude the name
of the root entity from the walk.
:param base: The base path to prepend to the entity name.
:return: An iterator... | [
"def",
"_walk_paths",
"(",
"self",
",",
"base",
":",
"pathlib",
".",
"PurePath",
")",
"->",
"Iterator",
"[",
"pathlib",
".",
"PurePath",
"]",
":",
"return",
"self",
".",
"walk_paths",
"(",
"base",
")"
] | Internal helper for walking paths. This is required to exclude the name
of the root entity from the walk.
:param base: The base path to prepend to the entity name.
:return: An iterator of paths. | [
"Internal",
"helper",
"for",
"walking",
"paths",
".",
"This",
"is",
"required",
"to",
"exclude",
"the",
"name",
"of",
"the",
"root",
"entity",
"from",
"the",
"walk",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/entities.py#L39-L48 | train | Internal helper for walking the paths. |
gebn/wood | wood/entities.py | Entity.from_path | def from_path(cls, path: pathlib.Path) -> 'Entity':
"""
Create an entity from a local path.
:param path: The path to the entity, either a file or directory.
:return: An entity instance representing the path.
"""
if path.is_file():
return File.from_path(path)
... | python | def from_path(cls, path: pathlib.Path) -> 'Entity':
"""
Create an entity from a local path.
:param path: The path to the entity, either a file or directory.
:return: An entity instance representing the path.
"""
if path.is_file():
return File.from_path(path)
... | [
"def",
"from_path",
"(",
"cls",
",",
"path",
":",
"pathlib",
".",
"Path",
")",
"->",
"'Entity'",
":",
"if",
"path",
".",
"is_file",
"(",
")",
":",
"return",
"File",
".",
"from_path",
"(",
"path",
")",
"return",
"Directory",
".",
"from_path",
"(",
"pa... | Create an entity from a local path.
:param path: The path to the entity, either a file or directory.
:return: An entity instance representing the path. | [
"Create",
"an",
"entity",
"from",
"a",
"local",
"path",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/entities.py#L61-L70 | train | Create an entity from a local path. |
gebn/wood | wood/entities.py | File._md5 | def _md5(path: pathlib.PurePath):
"""
Calculate the MD5 checksum of a file.
:param path: The path of the file whose checksum to calculate.
:return: The lowercase hex representation of the file's MD5
checksum, exactly 32 chars long.
"""
hash_ = hashlib... | python | def _md5(path: pathlib.PurePath):
"""
Calculate the MD5 checksum of a file.
:param path: The path of the file whose checksum to calculate.
:return: The lowercase hex representation of the file's MD5
checksum, exactly 32 chars long.
"""
hash_ = hashlib... | [
"def",
"_md5",
"(",
"path",
":",
"pathlib",
".",
"PurePath",
")",
":",
"hash_",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"for",
"chunk",
"in",
"iter",
"(",
"lambda",
":",
"f",
".",
"re... | Calculate the MD5 checksum of a file.
:param path: The path of the file whose checksum to calculate.
:return: The lowercase hex representation of the file's MD5
checksum, exactly 32 chars long. | [
"Calculate",
"the",
"MD5",
"checksum",
"of",
"a",
"file",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/entities.py#L119-L131 | train | Calculate the MD5 checksum of a file. |
gebn/wood | wood/entities.py | File.from_path | def from_path(cls, path: pathlib.Path) -> 'File':
"""
Create a file entity from a file path.
:param path: The path of the file.
:return: A file entity instance representing the file.
:raises ValueError: If the path does not point to a file.
"""
if not path.is_fil... | python | def from_path(cls, path: pathlib.Path) -> 'File':
"""
Create a file entity from a file path.
:param path: The path of the file.
:return: A file entity instance representing the file.
:raises ValueError: If the path does not point to a file.
"""
if not path.is_fil... | [
"def",
"from_path",
"(",
"cls",
",",
"path",
":",
"pathlib",
".",
"Path",
")",
"->",
"'File'",
":",
"if",
"not",
"path",
".",
"is_file",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Path does not point to a file'",
")",
"return",
"File",
"(",
"path",
"."... | Create a file entity from a file path.
:param path: The path of the file.
:return: A file entity instance representing the file.
:raises ValueError: If the path does not point to a file. | [
"Create",
"a",
"file",
"entity",
"from",
"a",
"file",
"path",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/entities.py#L134-L144 | train | Create a file entity from a file path. |
gebn/wood | wood/entities.py | Directory.from_path | def from_path(cls, path: pathlib.Path) -> 'Directory':
"""
Create a directory entity from a directory path.
:param path: The path of the directory.
:return: A directory entity instance representing the directory.
:raises ValueError: If the path does not point to a directory.
... | python | def from_path(cls, path: pathlib.Path) -> 'Directory':
"""
Create a directory entity from a directory path.
:param path: The path of the directory.
:return: A directory entity instance representing the directory.
:raises ValueError: If the path does not point to a directory.
... | [
"def",
"from_path",
"(",
"cls",
",",
"path",
":",
"pathlib",
".",
"Path",
")",
"->",
"'Directory'",
":",
"if",
"not",
"path",
".",
"is_dir",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Path does not point to a directory'",
")",
"return",
"Directory",
"(",
... | Create a directory entity from a directory path.
:param path: The path of the directory.
:return: A directory entity instance representing the directory.
:raises ValueError: If the path does not point to a directory. | [
"Create",
"a",
"directory",
"entity",
"from",
"a",
"directory",
"path",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/entities.py#L186-L197 | train | Create a directory entity from a directory path. |
pgxcentre/geneparse | geneparse/readers/vcf.py | VCFReader.iter_genotypes | def iter_genotypes(self):
"""Iterates on available markers.
Returns:
Genotypes instances.
"""
for v in self.get_vcf():
alleles = {v.REF} | set(v.ALT)
if self.quality_field:
variant = ImputedVariant(v.ID, v.CHROM, v.POS, alleles,
... | python | def iter_genotypes(self):
"""Iterates on available markers.
Returns:
Genotypes instances.
"""
for v in self.get_vcf():
alleles = {v.REF} | set(v.ALT)
if self.quality_field:
variant = ImputedVariant(v.ID, v.CHROM, v.POS, alleles,
... | [
"def",
"iter_genotypes",
"(",
"self",
")",
":",
"for",
"v",
"in",
"self",
".",
"get_vcf",
"(",
")",
":",
"alleles",
"=",
"{",
"v",
".",
"REF",
"}",
"|",
"set",
"(",
"v",
".",
"ALT",
")",
"if",
"self",
".",
"quality_field",
":",
"variant",
"=",
... | Iterates on available markers.
Returns:
Genotypes instances. | [
"Iterates",
"on",
"available",
"markers",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/vcf.py#L58-L76 | train | Iterates on available markers. |
pgxcentre/geneparse | geneparse/readers/vcf.py | VCFReader.iter_variants | def iter_variants(self):
"""Iterate over marker information."""
for v in self.get_vcf():
yield Variant(v.ID, v.CHROM, v.POS, {v.REF} | set(v.ALT)) | python | def iter_variants(self):
"""Iterate over marker information."""
for v in self.get_vcf():
yield Variant(v.ID, v.CHROM, v.POS, {v.REF} | set(v.ALT)) | [
"def",
"iter_variants",
"(",
"self",
")",
":",
"for",
"v",
"in",
"self",
".",
"get_vcf",
"(",
")",
":",
"yield",
"Variant",
"(",
"v",
".",
"ID",
",",
"v",
".",
"CHROM",
",",
"v",
".",
"POS",
",",
"{",
"v",
".",
"REF",
"}",
"|",
"set",
"(",
... | Iterate over marker information. | [
"Iterate",
"over",
"marker",
"information",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/vcf.py#L102-L105 | train | Iterate over the variants in the marker information. |
pgxcentre/geneparse | geneparse/readers/vcf.py | VCFReader.get_variants_in_region | def get_variants_in_region(self, chrom, start, end):
"""Iterate over variants in a region."""
region = self.get_vcf()(
"{}:{}-{}".format(chrom, start, end)
)
for v in region:
for coded_allele, g in self._make_genotypes(v.ALT, v.genotypes):
variant ... | python | def get_variants_in_region(self, chrom, start, end):
"""Iterate over variants in a region."""
region = self.get_vcf()(
"{}:{}-{}".format(chrom, start, end)
)
for v in region:
for coded_allele, g in self._make_genotypes(v.ALT, v.genotypes):
variant ... | [
"def",
"get_variants_in_region",
"(",
"self",
",",
"chrom",
",",
"start",
",",
"end",
")",
":",
"region",
"=",
"self",
".",
"get_vcf",
"(",
")",
"(",
"\"{}:{}-{}\"",
".",
"format",
"(",
"chrom",
",",
"start",
",",
"end",
")",
")",
"for",
"v",
"in",
... | Iterate over variants in a region. | [
"Iterate",
"over",
"variants",
"in",
"a",
"region",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/vcf.py#L130-L141 | train | Iterate over variants in a region. |
rhayes777/PyAutoFit | autofit/optimize/grid_search.py | GridSearchResult.best_result | def best_result(self):
"""
The best result of the grid search. That is, the result output by the non linear search that had the highest
maximum figure of merit.
Returns
-------
best_result: Result
"""
best_result = None
for result in self.results:... | python | def best_result(self):
"""
The best result of the grid search. That is, the result output by the non linear search that had the highest
maximum figure of merit.
Returns
-------
best_result: Result
"""
best_result = None
for result in self.results:... | [
"def",
"best_result",
"(",
"self",
")",
":",
"best_result",
"=",
"None",
"for",
"result",
"in",
"self",
".",
"results",
":",
"if",
"best_result",
"is",
"None",
"or",
"result",
".",
"figure_of_merit",
">",
"best_result",
".",
"figure_of_merit",
":",
"best_res... | The best result of the grid search. That is, the result output by the non linear search that had the highest
maximum figure of merit.
Returns
-------
best_result: Result | [
"The",
"best",
"result",
"of",
"the",
"grid",
"search",
".",
"That",
"is",
"the",
"result",
"output",
"by",
"the",
"non",
"linear",
"search",
"that",
"had",
"the",
"highest",
"maximum",
"figure",
"of",
"merit",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/grid_search.py#L36-L49 | train | Returns the result that has the highest figure of merit. |
rhayes777/PyAutoFit | autofit/optimize/grid_search.py | GridSearchResult.figure_of_merit_array | def figure_of_merit_array(self):
"""
Returns
-------
figure_of_merit_array: np.ndarray
An array of figures of merit. This array has the same dimensionality as the grid search, with the value in
each entry being the figure of merit taken from the optimization perfo... | python | def figure_of_merit_array(self):
"""
Returns
-------
figure_of_merit_array: np.ndarray
An array of figures of merit. This array has the same dimensionality as the grid search, with the value in
each entry being the figure of merit taken from the optimization perfo... | [
"def",
"figure_of_merit_array",
"(",
"self",
")",
":",
"return",
"np",
".",
"reshape",
"(",
"np",
".",
"array",
"(",
"[",
"result",
".",
"figure_of_merit",
"for",
"result",
"in",
"self",
".",
"results",
"]",
")",
",",
"tuple",
"(",
"self",
".",
"side_l... | Returns
-------
figure_of_merit_array: np.ndarray
An array of figures of merit. This array has the same dimensionality as the grid search, with the value in
each entry being the figure of merit taken from the optimization performed at that point. | [
"Returns",
"-------",
"figure_of_merit_array",
":",
"np",
".",
"ndarray",
"An",
"array",
"of",
"figures",
"of",
"merit",
".",
"This",
"array",
"has",
"the",
"same",
"dimensionality",
"as",
"the",
"grid",
"search",
"with",
"the",
"value",
"in",
"each",
"entry... | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/grid_search.py#L72-L81 | train | Returns the figure of merit array. |
rhayes777/PyAutoFit | autofit/optimize/grid_search.py | GridSearch.make_lists | def make_lists(self, grid_priors):
"""
Produces a list of lists of floats, where each list of floats represents the values in each dimension for one
step of the grid search.
Parameters
----------
grid_priors: [p.Prior]
A list of priors that are to be searched... | python | def make_lists(self, grid_priors):
"""
Produces a list of lists of floats, where each list of floats represents the values in each dimension for one
step of the grid search.
Parameters
----------
grid_priors: [p.Prior]
A list of priors that are to be searched... | [
"def",
"make_lists",
"(",
"self",
",",
"grid_priors",
")",
":",
"return",
"optimizer",
".",
"make_lists",
"(",
"len",
"(",
"grid_priors",
")",
",",
"step_size",
"=",
"self",
".",
"hyper_step_size",
",",
"centre_steps",
"=",
"False",
")"
] | Produces a list of lists of floats, where each list of floats represents the values in each dimension for one
step of the grid search.
Parameters
----------
grid_priors: [p.Prior]
A list of priors that are to be searched using the grid search.
Returns
------... | [
"Produces",
"a",
"list",
"of",
"lists",
"of",
"floats",
"where",
"each",
"list",
"of",
"floats",
"represents",
"the",
"values",
"in",
"each",
"dimension",
"for",
"one",
"step",
"of",
"the",
"grid",
"search",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/grid_search.py#L147-L161 | train | Generates a list of lists of floats where each list of floats represents the values in each dimension for one
step of the grid search. |
rhayes777/PyAutoFit | autofit/optimize/grid_search.py | GridSearch.fit | def fit(self, analysis, grid_priors):
"""
Fit an analysis with a set of grid priors. The grid priors are priors associated with the model mapper
of this instance that are replaced by uniform priors for each step of the grid search.
Parameters
----------
analysis: non_lin... | python | def fit(self, analysis, grid_priors):
"""
Fit an analysis with a set of grid priors. The grid priors are priors associated with the model mapper
of this instance that are replaced by uniform priors for each step of the grid search.
Parameters
----------
analysis: non_lin... | [
"def",
"fit",
"(",
"self",
",",
"analysis",
",",
"grid_priors",
")",
":",
"grid_priors",
"=",
"list",
"(",
"set",
"(",
"grid_priors",
")",
")",
"results",
"=",
"[",
"]",
"lists",
"=",
"self",
".",
"make_lists",
"(",
"grid_priors",
")",
"results_list",
... | Fit an analysis with a set of grid priors. The grid priors are priors associated with the model mapper
of this instance that are replaced by uniform priors for each step of the grid search.
Parameters
----------
analysis: non_linear.Analysis
An analysis used to determine the... | [
"Fit",
"an",
"analysis",
"with",
"a",
"set",
"of",
"grid",
"priors",
".",
"The",
"grid",
"priors",
"are",
"priors",
"associated",
"with",
"the",
"model",
"mapper",
"of",
"this",
"instance",
"that",
"are",
"replaced",
"by",
"uniform",
"priors",
"for",
"each... | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/grid_search.py#L181-L229 | train | Fit an analysis with a set of priors. |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/resolveSharedConnections.py | portTryReduce | def portTryReduce(root: LNode, port: LPort):
"""
Check if majority of children is connected to same port
if it is the case reduce children and connect this port instead children
:note: use reduceUselessAssignments, extractSplits, flattenTrees before this function
to maximize it's effect
"""... | python | def portTryReduce(root: LNode, port: LPort):
"""
Check if majority of children is connected to same port
if it is the case reduce children and connect this port instead children
:note: use reduceUselessAssignments, extractSplits, flattenTrees before this function
to maximize it's effect
"""... | [
"def",
"portTryReduce",
"(",
"root",
":",
"LNode",
",",
"port",
":",
"LPort",
")",
":",
"if",
"not",
"port",
".",
"children",
":",
"return",
"for",
"p",
"in",
"port",
".",
"children",
":",
"portTryReduce",
"(",
"root",
",",
"p",
")",
"target_nodes",
... | Check if majority of children is connected to same port
if it is the case reduce children and connect this port instead children
:note: use reduceUselessAssignments, extractSplits, flattenTrees before this function
to maximize it's effect | [
"Check",
"if",
"majority",
"of",
"children",
"is",
"connected",
"to",
"same",
"port",
"if",
"it",
"is",
"the",
"case",
"reduce",
"children",
"and",
"connect",
"this",
"port",
"instead",
"children"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/resolveSharedConnections.py#L6-L84 | train | This function tries to reduce the children of a port and returns a new tree that is reduced to the same tree. |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/resolveSharedConnections.py | resolveSharedConnections | def resolveSharedConnections(root: LNode):
"""
Walk all ports on all nodes and group subinterface connections
to only parent interface connection if it is possible
"""
for ch in root.children:
resolveSharedConnections(ch)
for ch in root.children:
for p in ch.iterPorts():
... | python | def resolveSharedConnections(root: LNode):
"""
Walk all ports on all nodes and group subinterface connections
to only parent interface connection if it is possible
"""
for ch in root.children:
resolveSharedConnections(ch)
for ch in root.children:
for p in ch.iterPorts():
... | [
"def",
"resolveSharedConnections",
"(",
"root",
":",
"LNode",
")",
":",
"for",
"ch",
"in",
"root",
".",
"children",
":",
"resolveSharedConnections",
"(",
"ch",
")",
"for",
"ch",
"in",
"root",
".",
"children",
":",
"for",
"p",
"in",
"ch",
".",
"iterPorts"... | Walk all ports on all nodes and group subinterface connections
to only parent interface connection if it is possible | [
"Walk",
"all",
"ports",
"on",
"all",
"nodes",
"and",
"group",
"subinterface",
"connections",
"to",
"only",
"parent",
"interface",
"connection",
"if",
"it",
"is",
"possible"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/resolveSharedConnections.py#L87-L97 | train | Walk all ports on all nodes and group subinterfaces to only parent interface connection |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/resolveSharedConnections.py | countDirectlyConnected | def countDirectlyConnected(port: LPort, result: dict) -> int:
"""
Count how many ports are directly connected to other nodes
:return: cumulative sum of port counts
"""
inEdges = port.incomingEdges
outEdges = port.outgoingEdges
if port.children:
ch_cnt = 0
# try:
# ... | python | def countDirectlyConnected(port: LPort, result: dict) -> int:
"""
Count how many ports are directly connected to other nodes
:return: cumulative sum of port counts
"""
inEdges = port.incomingEdges
outEdges = port.outgoingEdges
if port.children:
ch_cnt = 0
# try:
# ... | [
"def",
"countDirectlyConnected",
"(",
"port",
":",
"LPort",
",",
"result",
":",
"dict",
")",
"->",
"int",
":",
"inEdges",
"=",
"port",
".",
"incomingEdges",
"outEdges",
"=",
"port",
".",
"outgoingEdges",
"if",
"port",
".",
"children",
":",
"ch_cnt",
"=",
... | Count how many ports are directly connected to other nodes
:return: cumulative sum of port counts | [
"Count",
"how",
"many",
"ports",
"are",
"directly",
"connected",
"to",
"other",
"nodes"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/resolveSharedConnections.py#L110-L176 | train | Count how many ports are directly connected to other nodes. |
redhat-openstack/python-tripleo-helper | tripleohelper/ovb_baremetal.py | Baremetal.deploy | def deploy(self, image_name, ip, flavor='m1.small'):
"""Create the node.
This method should only be called by the BaremetalFactory.
"""
body_value = {
"port": {
"admin_state_up": True,
"name": self.name + '_provision',
"network... | python | def deploy(self, image_name, ip, flavor='m1.small'):
"""Create the node.
This method should only be called by the BaremetalFactory.
"""
body_value = {
"port": {
"admin_state_up": True,
"name": self.name + '_provision',
"network... | [
"def",
"deploy",
"(",
"self",
",",
"image_name",
",",
"ip",
",",
"flavor",
"=",
"'m1.small'",
")",
":",
"body_value",
"=",
"{",
"\"port\"",
":",
"{",
"\"admin_state_up\"",
":",
"True",
",",
"\"name\"",
":",
"self",
".",
"name",
"+",
"'_provision'",
",",
... | Create the node.
This method should only be called by the BaremetalFactory. | [
"Create",
"the",
"node",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_baremetal.py#L47-L88 | train | Deploy the node. |
redhat-openstack/python-tripleo-helper | tripleohelper/ovb_baremetal.py | Baremetal.pxe_netboot | def pxe_netboot(self, filename):
"""Specify which file ipxe should load during the netboot."""
new_port = {
'extra_dhcp_opts': [
{'opt_name': 'bootfile-name', 'opt_value': 'http://192.0.2.240:8088/' + filename, 'ip_version': 4, },
{'opt_name': 'tftp-server', '... | python | def pxe_netboot(self, filename):
"""Specify which file ipxe should load during the netboot."""
new_port = {
'extra_dhcp_opts': [
{'opt_name': 'bootfile-name', 'opt_value': 'http://192.0.2.240:8088/' + filename, 'ip_version': 4, },
{'opt_name': 'tftp-server', '... | [
"def",
"pxe_netboot",
"(",
"self",
",",
"filename",
")",
":",
"new_port",
"=",
"{",
"'extra_dhcp_opts'",
":",
"[",
"{",
"'opt_name'",
":",
"'bootfile-name'",
",",
"'opt_value'",
":",
"'http://192.0.2.240:8088/'",
"+",
"filename",
",",
"'ip_version'",
":",
"4",
... | Specify which file ipxe should load during the netboot. | [
"Specify",
"which",
"file",
"ipxe",
"should",
"load",
"during",
"the",
"netboot",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_baremetal.py#L94-L103 | train | Specify which file ipxe should load during the netboot. |
redhat-openstack/python-tripleo-helper | tripleohelper/ovb_baremetal.py | BaremetalFactory.initialize | def initialize(self, size=2):
"""Populate the node poll.
:param size: the number of node to create.
"""
# The IP should be in this range, this is the default DHCP range used by the introspection.
# inspection_iprange = 192.0.2.100,192.0.2.120
for i in range(0, size):
... | python | def initialize(self, size=2):
"""Populate the node poll.
:param size: the number of node to create.
"""
# The IP should be in this range, this is the default DHCP range used by the introspection.
# inspection_iprange = 192.0.2.100,192.0.2.120
for i in range(0, size):
... | [
"def",
"initialize",
"(",
"self",
",",
"size",
"=",
"2",
")",
":",
"# The IP should be in this range, this is the default DHCP range used by the introspection.",
"# inspection_iprange = 192.0.2.100,192.0.2.120",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"size",
")",
":",
... | Populate the node poll.
:param size: the number of node to create. | [
"Populate",
"the",
"node",
"poll",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_baremetal.py#L141-L181 | train | Populate the baremetal poll. |
redhat-openstack/python-tripleo-helper | tripleohelper/ovb_baremetal.py | BaremetalFactory.create_bmc | def create_bmc(self, os_username, os_password, os_project_id, os_auth_url):
"""Deploy the BMC machine.
This machine hosts the ipmi servers, each ipmi server is associated to a baremetal
node and has its own IP.
"""
bmc = ovb_bmc.OvbBmc(
nova_api=self.nova_api,
... | python | def create_bmc(self, os_username, os_password, os_project_id, os_auth_url):
"""Deploy the BMC machine.
This machine hosts the ipmi servers, each ipmi server is associated to a baremetal
node and has its own IP.
"""
bmc = ovb_bmc.OvbBmc(
nova_api=self.nova_api,
... | [
"def",
"create_bmc",
"(",
"self",
",",
"os_username",
",",
"os_password",
",",
"os_project_id",
",",
"os_auth_url",
")",
":",
"bmc",
"=",
"ovb_bmc",
".",
"OvbBmc",
"(",
"nova_api",
"=",
"self",
".",
"nova_api",
",",
"neutron",
"=",
"self",
".",
"neutron",
... | Deploy the BMC machine.
This machine hosts the ipmi servers, each ipmi server is associated to a baremetal
node and has its own IP. | [
"Deploy",
"the",
"BMC",
"machine",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_baremetal.py#L213-L231 | train | Create the BMC machine. |
unt-libraries/pyuntl | pyuntl/untldoc.py | untlxml2py | def untlxml2py(untl_filename):
"""Parse a UNTL XML file object into a pyuntl element tree.
You can also pass this a string as file input like so:
import StringIO
untlxml2py(StringIO.StringIO(untl_string))
"""
# Create a stack to hold parents.
parent_stack = []
# Use iterparse to open th... | python | def untlxml2py(untl_filename):
"""Parse a UNTL XML file object into a pyuntl element tree.
You can also pass this a string as file input like so:
import StringIO
untlxml2py(StringIO.StringIO(untl_string))
"""
# Create a stack to hold parents.
parent_stack = []
# Use iterparse to open th... | [
"def",
"untlxml2py",
"(",
"untl_filename",
")",
":",
"# Create a stack to hold parents.",
"parent_stack",
"=",
"[",
"]",
"# Use iterparse to open the file and loop through elements.",
"for",
"event",
",",
"element",
"in",
"iterparse",
"(",
"untl_filename",
",",
"events",
... | Parse a UNTL XML file object into a pyuntl element tree.
You can also pass this a string as file input like so:
import StringIO
untlxml2py(StringIO.StringIO(untl_string)) | [
"Parse",
"a",
"UNTL",
"XML",
"file",
"object",
"into",
"a",
"pyuntl",
"element",
"tree",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L45-L87 | train | Parse a UNTL XML file into a pyuntl element tree. |
unt-libraries/pyuntl | pyuntl/untldoc.py | untldict2py | def untldict2py(untl_dict):
"""Convert a UNTL dictionary into a Python object."""
# Create the root element.
untl_root = PYUNTL_DISPATCH['metadata']()
untl_py_list = []
for element_name, element_list in untl_dict.items():
# Loop through the element dictionaries in the element list.
f... | python | def untldict2py(untl_dict):
"""Convert a UNTL dictionary into a Python object."""
# Create the root element.
untl_root = PYUNTL_DISPATCH['metadata']()
untl_py_list = []
for element_name, element_list in untl_dict.items():
# Loop through the element dictionaries in the element list.
f... | [
"def",
"untldict2py",
"(",
"untl_dict",
")",
":",
"# Create the root element.",
"untl_root",
"=",
"PYUNTL_DISPATCH",
"[",
"'metadata'",
"]",
"(",
")",
"untl_py_list",
"=",
"[",
"]",
"for",
"element_name",
",",
"element_list",
"in",
"untl_dict",
".",
"items",
"("... | Convert a UNTL dictionary into a Python object. | [
"Convert",
"a",
"UNTL",
"dictionary",
"into",
"a",
"Python",
"object",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L121-L172 | train | Convert a UNTL dictionary into a Python object. |
unt-libraries/pyuntl | pyuntl/untldoc.py | post2pydict | def post2pydict(post, ignore_list):
"""Convert the UNTL posted data to a Python dictionary."""
root_element = PYUNTL_DISPATCH['metadata']()
untl_form_dict = {}
# Turn the posted data into usable data
# (otherwise the value lists get messed up).
form_post = dict(post.copy())
# Loop through al... | python | def post2pydict(post, ignore_list):
"""Convert the UNTL posted data to a Python dictionary."""
root_element = PYUNTL_DISPATCH['metadata']()
untl_form_dict = {}
# Turn the posted data into usable data
# (otherwise the value lists get messed up).
form_post = dict(post.copy())
# Loop through al... | [
"def",
"post2pydict",
"(",
"post",
",",
"ignore_list",
")",
":",
"root_element",
"=",
"PYUNTL_DISPATCH",
"[",
"'metadata'",
"]",
"(",
")",
"untl_form_dict",
"=",
"{",
"}",
"# Turn the posted data into usable data",
"# (otherwise the value lists get messed up).",
"form_pos... | Convert the UNTL posted data to a Python dictionary. | [
"Convert",
"the",
"UNTL",
"posted",
"data",
"to",
"a",
"Python",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L175-L251 | train | Convert the UNTL posted data to a Python dictionary. |
unt-libraries/pyuntl | pyuntl/untldoc.py | untlpy2dcpy | def untlpy2dcpy(untl_elements, **kwargs):
"""Convert the UNTL elements structure into a DC structure.
kwargs can be passed to the function for certain effects:
ark: Takes an ark string and creates an identifier element out of it.
domain_name: Takes a domain string and creates an ark URL from it
(a... | python | def untlpy2dcpy(untl_elements, **kwargs):
"""Convert the UNTL elements structure into a DC structure.
kwargs can be passed to the function for certain effects:
ark: Takes an ark string and creates an identifier element out of it.
domain_name: Takes a domain string and creates an ark URL from it
(a... | [
"def",
"untlpy2dcpy",
"(",
"untl_elements",
",",
"*",
"*",
"kwargs",
")",
":",
"sDate",
"=",
"None",
"eDate",
"=",
"None",
"ark",
"=",
"kwargs",
".",
"get",
"(",
"'ark'",
",",
"None",
")",
"domain_name",
"=",
"kwargs",
".",
"get",
"(",
"'domain_name'",... | Convert the UNTL elements structure into a DC structure.
kwargs can be passed to the function for certain effects:
ark: Takes an ark string and creates an identifier element out of it.
domain_name: Takes a domain string and creates an ark URL from it
(ark and domain_name must be passed together to wor... | [
"Convert",
"the",
"UNTL",
"elements",
"structure",
"into",
"a",
"DC",
"structure",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L254-L372 | train | Convert the UNTL elements structure into a DC structure. |
unt-libraries/pyuntl | pyuntl/untldoc.py | untlpy2highwirepy | def untlpy2highwirepy(untl_elements, **kwargs):
"""Convert a UNTL Python object to a highwire Python object."""
highwire_list = []
title = None
publisher = None
creation = None
escape = kwargs.get('escape', False)
for element in untl_elements.children:
# If the UNTL element should be... | python | def untlpy2highwirepy(untl_elements, **kwargs):
"""Convert a UNTL Python object to a highwire Python object."""
highwire_list = []
title = None
publisher = None
creation = None
escape = kwargs.get('escape', False)
for element in untl_elements.children:
# If the UNTL element should be... | [
"def",
"untlpy2highwirepy",
"(",
"untl_elements",
",",
"*",
"*",
"kwargs",
")",
":",
"highwire_list",
"=",
"[",
"]",
"title",
"=",
"None",
"publisher",
"=",
"None",
"creation",
"=",
"None",
"escape",
"=",
"kwargs",
".",
"get",
"(",
"'escape'",
",",
"Fals... | Convert a UNTL Python object to a highwire Python object. | [
"Convert",
"a",
"UNTL",
"Python",
"object",
"to",
"a",
"highwire",
"Python",
"object",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L375-L417 | train | Convert a UNTL Python object to a highwire Python object. |
unt-libraries/pyuntl | pyuntl/untldoc.py | untlpydict2dcformatteddict | def untlpydict2dcformatteddict(untl_dict, **kwargs):
"""Convert a UNTL data dictionary to a formatted DC data dictionary."""
ark = kwargs.get('ark', None)
domain_name = kwargs.get('domain_name', None)
scheme = kwargs.get('scheme', 'http')
resolve_values = kwargs.get('resolve_values', None)
resol... | python | def untlpydict2dcformatteddict(untl_dict, **kwargs):
"""Convert a UNTL data dictionary to a formatted DC data dictionary."""
ark = kwargs.get('ark', None)
domain_name = kwargs.get('domain_name', None)
scheme = kwargs.get('scheme', 'http')
resolve_values = kwargs.get('resolve_values', None)
resol... | [
"def",
"untlpydict2dcformatteddict",
"(",
"untl_dict",
",",
"*",
"*",
"kwargs",
")",
":",
"ark",
"=",
"kwargs",
".",
"get",
"(",
"'ark'",
",",
"None",
")",
"domain_name",
"=",
"kwargs",
".",
"get",
"(",
"'domain_name'",
",",
"None",
")",
"scheme",
"=",
... | Convert a UNTL data dictionary to a formatted DC data dictionary. | [
"Convert",
"a",
"UNTL",
"data",
"dictionary",
"to",
"a",
"formatted",
"DC",
"data",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L420-L441 | train | Convert a UNTL data dictionary to a formatted DC data dictionary. |
unt-libraries/pyuntl | pyuntl/untldoc.py | formatted_dc_dict | def formatted_dc_dict(dc_dict):
"""Change the formatting of the DC data dictionary.
Change the passed in DC data dictionary into a dictionary
with a list of values for each element.
i.e. {'publisher': ['someone', 'someone else'], 'title': ['a title'],}
"""
for key, element_list in dc_dict.items... | python | def formatted_dc_dict(dc_dict):
"""Change the formatting of the DC data dictionary.
Change the passed in DC data dictionary into a dictionary
with a list of values for each element.
i.e. {'publisher': ['someone', 'someone else'], 'title': ['a title'],}
"""
for key, element_list in dc_dict.items... | [
"def",
"formatted_dc_dict",
"(",
"dc_dict",
")",
":",
"for",
"key",
",",
"element_list",
"in",
"dc_dict",
".",
"items",
"(",
")",
":",
"new_element_list",
"=",
"[",
"]",
"# Add the content for each element to the new element list.",
"for",
"element",
"in",
"element_... | Change the formatting of the DC data dictionary.
Change the passed in DC data dictionary into a dictionary
with a list of values for each element.
i.e. {'publisher': ['someone', 'someone else'], 'title': ['a title'],} | [
"Change",
"the",
"formatting",
"of",
"the",
"DC",
"data",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L457-L470 | train | Change the formatting of the DC data dictionary into a dictionary that contains a list of values for each element. |
unt-libraries/pyuntl | pyuntl/untldoc.py | generate_dc_xml | def generate_dc_xml(dc_dict):
"""Generate a DC XML string."""
# Define the root namespace.
root_namespace = '{%s}' % DC_NAMESPACES['oai_dc']
# Set the elements namespace URL.
elements_namespace = '{%s}' % DC_NAMESPACES['dc']
schema_location = ('http://www.openarchives.org/OAI/2.0/oai_dc/ '
... | python | def generate_dc_xml(dc_dict):
"""Generate a DC XML string."""
# Define the root namespace.
root_namespace = '{%s}' % DC_NAMESPACES['oai_dc']
# Set the elements namespace URL.
elements_namespace = '{%s}' % DC_NAMESPACES['dc']
schema_location = ('http://www.openarchives.org/OAI/2.0/oai_dc/ '
... | [
"def",
"generate_dc_xml",
"(",
"dc_dict",
")",
":",
"# Define the root namespace.",
"root_namespace",
"=",
"'{%s}'",
"%",
"DC_NAMESPACES",
"[",
"'oai_dc'",
"]",
"# Set the elements namespace URL.",
"elements_namespace",
"=",
"'{%s}'",
"%",
"DC_NAMESPACES",
"[",
"'dc'",
... | Generate a DC XML string. | [
"Generate",
"a",
"DC",
"XML",
"string",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L473-L493 | train | Generate a DC XML string from a dictionary. |
unt-libraries/pyuntl | pyuntl/untldoc.py | generate_dc_json | def generate_dc_json(dc_dict):
"""Generate DC JSON data.
Returns data as a JSON formatted string.
"""
formatted_dict = formatted_dc_dict(dc_dict)
return json.dumps(formatted_dict, sort_keys=True, indent=4) | python | def generate_dc_json(dc_dict):
"""Generate DC JSON data.
Returns data as a JSON formatted string.
"""
formatted_dict = formatted_dc_dict(dc_dict)
return json.dumps(formatted_dict, sort_keys=True, indent=4) | [
"def",
"generate_dc_json",
"(",
"dc_dict",
")",
":",
"formatted_dict",
"=",
"formatted_dc_dict",
"(",
"dc_dict",
")",
"return",
"json",
".",
"dumps",
"(",
"formatted_dict",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
")"
] | Generate DC JSON data.
Returns data as a JSON formatted string. | [
"Generate",
"DC",
"JSON",
"data",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L496-L502 | train | Generate DC JSON data. |
unt-libraries/pyuntl | pyuntl/untldoc.py | highwirepy2dict | def highwirepy2dict(highwire_elements):
"""Convert a list of highwire elements into a dictionary.
The dictionary returned contains the elements in the
UNTL dict format.
"""
highwire_dict = {}
# Make a list of content dictionaries for each element name.
for element in highwire_elements:
... | python | def highwirepy2dict(highwire_elements):
"""Convert a list of highwire elements into a dictionary.
The dictionary returned contains the elements in the
UNTL dict format.
"""
highwire_dict = {}
# Make a list of content dictionaries for each element name.
for element in highwire_elements:
... | [
"def",
"highwirepy2dict",
"(",
"highwire_elements",
")",
":",
"highwire_dict",
"=",
"{",
"}",
"# Make a list of content dictionaries for each element name.",
"for",
"element",
"in",
"highwire_elements",
":",
"if",
"element",
".",
"name",
"not",
"in",
"highwire_dict",
":... | Convert a list of highwire elements into a dictionary.
The dictionary returned contains the elements in the
UNTL dict format. | [
"Convert",
"a",
"list",
"of",
"highwire",
"elements",
"into",
"a",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L510-L522 | train | Convert a list of highwire elements into a dictionary. |
unt-libraries/pyuntl | pyuntl/untldoc.py | generate_highwire_json | def generate_highwire_json(highwire_elements):
"""Convert highwire elements into a JSON structure.
Returns data as a JSON formatted string.
"""
highwire_dict = highwirepy2dict(highwire_elements)
return json.dumps(highwire_dict, sort_keys=True, indent=4) | python | def generate_highwire_json(highwire_elements):
"""Convert highwire elements into a JSON structure.
Returns data as a JSON formatted string.
"""
highwire_dict = highwirepy2dict(highwire_elements)
return json.dumps(highwire_dict, sort_keys=True, indent=4) | [
"def",
"generate_highwire_json",
"(",
"highwire_elements",
")",
":",
"highwire_dict",
"=",
"highwirepy2dict",
"(",
"highwire_elements",
")",
"return",
"json",
".",
"dumps",
"(",
"highwire_dict",
",",
"sort_keys",
"=",
"True",
",",
"indent",
"=",
"4",
")"
] | Convert highwire elements into a JSON structure.
Returns data as a JSON formatted string. | [
"Convert",
"highwire",
"elements",
"into",
"a",
"JSON",
"structure",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L530-L536 | train | Convert highwire elements into a JSON formatted string. |
unt-libraries/pyuntl | pyuntl/untldoc.py | dcdict2rdfpy | def dcdict2rdfpy(dc_dict):
"""Convert a DC dictionary into an RDF Python object."""
ark_prefix = 'ark: ark:'
uri = URIRef('')
# Create the RDF Python object.
rdf_py = ConjunctiveGraph()
# Set DC namespace definition.
DC = Namespace('http://purl.org/dc/elements/1.1/')
# Get the ark for th... | python | def dcdict2rdfpy(dc_dict):
"""Convert a DC dictionary into an RDF Python object."""
ark_prefix = 'ark: ark:'
uri = URIRef('')
# Create the RDF Python object.
rdf_py = ConjunctiveGraph()
# Set DC namespace definition.
DC = Namespace('http://purl.org/dc/elements/1.1/')
# Get the ark for th... | [
"def",
"dcdict2rdfpy",
"(",
"dc_dict",
")",
":",
"ark_prefix",
"=",
"'ark: ark:'",
"uri",
"=",
"URIRef",
"(",
"''",
")",
"# Create the RDF Python object.",
"rdf_py",
"=",
"ConjunctiveGraph",
"(",
")",
"# Set DC namespace definition.",
"DC",
"=",
"Namespace",
"(",
... | Convert a DC dictionary into an RDF Python object. | [
"Convert",
"a",
"DC",
"dictionary",
"into",
"an",
"RDF",
"Python",
"object",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L545-L581 | train | Convert a DC dictionary into an RDF Python object. |
unt-libraries/pyuntl | pyuntl/untldoc.py | add_empty_fields | def add_empty_fields(untl_dict):
"""Add empty values if UNTL fields don't have values."""
# Iterate the ordered UNTL XML element list to determine
# which elements are missing from the untl_dict.
for element in UNTL_XML_ORDER:
if element not in untl_dict:
# Try to create an element w... | python | def add_empty_fields(untl_dict):
"""Add empty values if UNTL fields don't have values."""
# Iterate the ordered UNTL XML element list to determine
# which elements are missing from the untl_dict.
for element in UNTL_XML_ORDER:
if element not in untl_dict:
# Try to create an element w... | [
"def",
"add_empty_fields",
"(",
"untl_dict",
")",
":",
"# Iterate the ordered UNTL XML element list to determine",
"# which elements are missing from the untl_dict.",
"for",
"element",
"in",
"UNTL_XML_ORDER",
":",
"if",
"element",
"not",
"in",
"untl_dict",
":",
"# Try to create... | Add empty values if UNTL fields don't have values. | [
"Add",
"empty",
"values",
"if",
"UNTL",
"fields",
"don",
"t",
"have",
"values",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L606-L648 | train | Add empty values if UNTL fields don t have values. |
unt-libraries/pyuntl | pyuntl/untldoc.py | add_empty_etd_ms_fields | def add_empty_etd_ms_fields(etd_ms_dict):
"""Add empty values for ETD_MS fields that don't have values."""
# Determine which ETD MS elements are missing from the etd_ms_dict.
for element in ETD_MS_ORDER:
if element not in etd_ms_dict:
# Try to create an element with content and qualifier... | python | def add_empty_etd_ms_fields(etd_ms_dict):
"""Add empty values for ETD_MS fields that don't have values."""
# Determine which ETD MS elements are missing from the etd_ms_dict.
for element in ETD_MS_ORDER:
if element not in etd_ms_dict:
# Try to create an element with content and qualifier... | [
"def",
"add_empty_etd_ms_fields",
"(",
"etd_ms_dict",
")",
":",
"# Determine which ETD MS elements are missing from the etd_ms_dict.",
"for",
"element",
"in",
"ETD_MS_ORDER",
":",
"if",
"element",
"not",
"in",
"etd_ms_dict",
":",
"# Try to create an element with content and quali... | Add empty values for ETD_MS fields that don't have values. | [
"Add",
"empty",
"values",
"for",
"ETD_MS",
"fields",
"that",
"don",
"t",
"have",
"values",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L651-L696 | train | Add empty values for ETD_MS fields that don t have values. |
unt-libraries/pyuntl | pyuntl/untldoc.py | find_untl_errors | def find_untl_errors(untl_dict, **kwargs):
"""Add empty required qualifiers to create valid UNTL."""
fix_errors = kwargs.get('fix_errors', False)
error_dict = {}
# Loop through all elements that require qualifiers.
for element_name in REQUIRES_QUALIFIER:
# Loop through the existing elements ... | python | def find_untl_errors(untl_dict, **kwargs):
"""Add empty required qualifiers to create valid UNTL."""
fix_errors = kwargs.get('fix_errors', False)
error_dict = {}
# Loop through all elements that require qualifiers.
for element_name in REQUIRES_QUALIFIER:
# Loop through the existing elements ... | [
"def",
"find_untl_errors",
"(",
"untl_dict",
",",
"*",
"*",
"kwargs",
")",
":",
"fix_errors",
"=",
"kwargs",
".",
"get",
"(",
"'fix_errors'",
",",
"False",
")",
"error_dict",
"=",
"{",
"}",
"# Loop through all elements that require qualifiers.",
"for",
"element_na... | Add empty required qualifiers to create valid UNTL. | [
"Add",
"empty",
"required",
"qualifiers",
"to",
"create",
"valid",
"UNTL",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L699-L717 | train | Find the errors in the UNTL dict. |
unt-libraries/pyuntl | pyuntl/untldoc.py | untlpy2etd_ms | def untlpy2etd_ms(untl_elements, **kwargs):
"""Convert the UNTL elements structure into an ETD_MS structure.
kwargs can be passed to the function for certain effects.
"""
degree_children = {}
date_exists = False
seen_creation = False
# Make the root element.
etd_ms_root = ETD_MS_CONVERS... | python | def untlpy2etd_ms(untl_elements, **kwargs):
"""Convert the UNTL elements structure into an ETD_MS structure.
kwargs can be passed to the function for certain effects.
"""
degree_children = {}
date_exists = False
seen_creation = False
# Make the root element.
etd_ms_root = ETD_MS_CONVERS... | [
"def",
"untlpy2etd_ms",
"(",
"untl_elements",
",",
"*",
"*",
"kwargs",
")",
":",
"degree_children",
"=",
"{",
"}",
"date_exists",
"=",
"False",
"seen_creation",
"=",
"False",
"# Make the root element.",
"etd_ms_root",
"=",
"ETD_MS_CONVERSION_DISPATCH",
"[",
"'thesis... | Convert the UNTL elements structure into an ETD_MS structure.
kwargs can be passed to the function for certain effects. | [
"Convert",
"the",
"UNTL",
"elements",
"structure",
"into",
"an",
"ETD_MS",
"structure",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L720-L813 | train | Convert the UNTL elements structure into an ETD_MS structure. |
unt-libraries/pyuntl | pyuntl/untldoc.py | etd_ms_dict2xmlfile | def etd_ms_dict2xmlfile(filename, metadata_dict):
"""Create an ETD MS XML file."""
try:
f = open(filename, 'w')
f.write(generate_etd_ms_xml(metadata_dict).encode("utf-8"))
f.close()
except:
raise MetadataGeneratorException(
'Failed to create an XML file. Filename:... | python | def etd_ms_dict2xmlfile(filename, metadata_dict):
"""Create an ETD MS XML file."""
try:
f = open(filename, 'w')
f.write(generate_etd_ms_xml(metadata_dict).encode("utf-8"))
f.close()
except:
raise MetadataGeneratorException(
'Failed to create an XML file. Filename:... | [
"def",
"etd_ms_dict2xmlfile",
"(",
"filename",
",",
"metadata_dict",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"generate_etd_ms_xml",
"(",
"metadata_dict",
")",
".",
"encode",
"(",
"\"utf-8\"",
")",
... | Create an ETD MS XML file. | [
"Create",
"an",
"ETD",
"MS",
"XML",
"file",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untldoc.py#L826-L835 | train | Create an ETD MS XML file. |
rhayes777/PyAutoFit | autofit/tools/fit.py | DataFit.signal_to_noise_map | def signal_to_noise_map(self):
"""The signal-to-noise_map of the data and noise-map which are fitted."""
signal_to_noise_map = np.divide(self.data, self.noise_map)
signal_to_noise_map[signal_to_noise_map < 0] = 0
return signal_to_noise_map | python | def signal_to_noise_map(self):
"""The signal-to-noise_map of the data and noise-map which are fitted."""
signal_to_noise_map = np.divide(self.data, self.noise_map)
signal_to_noise_map[signal_to_noise_map < 0] = 0
return signal_to_noise_map | [
"def",
"signal_to_noise_map",
"(",
"self",
")",
":",
"signal_to_noise_map",
"=",
"np",
".",
"divide",
"(",
"self",
".",
"data",
",",
"self",
".",
"noise_map",
")",
"signal_to_noise_map",
"[",
"signal_to_noise_map",
"<",
"0",
"]",
"=",
"0",
"return",
"signal_... | The signal-to-noise_map of the data and noise-map which are fitted. | [
"The",
"signal",
"-",
"to",
"-",
"noise_map",
"of",
"the",
"data",
"and",
"noise",
"-",
"map",
"which",
"are",
"fitted",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/fit.py#L59-L63 | train | The signal - to - noise - map of the data and noise - map which are fitted. |
althonos/moclo | moclo/moclo/core/parts.py | AbstractPart.structure | def structure(cls):
# type: () -> Text
"""Get the part structure, as a DNA regex pattern.
The structure of most parts can be obtained automatically from the
part signature and the restriction enzyme used in the Golden Gate
assembly.
Warning:
If overloading t... | python | def structure(cls):
# type: () -> Text
"""Get the part structure, as a DNA regex pattern.
The structure of most parts can be obtained automatically from the
part signature and the restriction enzyme used in the Golden Gate
assembly.
Warning:
If overloading t... | [
"def",
"structure",
"(",
"cls",
")",
":",
"# type: () -> Text",
"if",
"cls",
".",
"signature",
"is",
"NotImplemented",
":",
"raise",
"NotImplementedError",
"(",
"\"no signature defined\"",
")",
"up",
"=",
"cls",
".",
"cutter",
".",
"elucidate",
"(",
")",
"down... | Get the part structure, as a DNA regex pattern.
The structure of most parts can be obtained automatically from the
part signature and the restriction enzyme used in the Golden Gate
assembly.
Warning:
If overloading this method, the returned pattern must include 3
... | [
"Get",
"the",
"part",
"structure",
"as",
"a",
"DNA",
"regex",
"pattern",
"."
] | 28a03748df8a2fa43f0c0c8098ca64d11559434e | https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/parts.py#L49-L99 | train | Return the structure of the most parts of the class cls. |
althonos/moclo | moclo/moclo/core/parts.py | AbstractPart.characterize | def characterize(cls, record):
"""Load the record in a concrete subclass of this type.
"""
classes = list(cls.__subclasses__())
if not isabstract(cls):
classes.append(cls)
for subclass in classes:
entity = subclass(record)
if entity.is_valid():... | python | def characterize(cls, record):
"""Load the record in a concrete subclass of this type.
"""
classes = list(cls.__subclasses__())
if not isabstract(cls):
classes.append(cls)
for subclass in classes:
entity = subclass(record)
if entity.is_valid():... | [
"def",
"characterize",
"(",
"cls",
",",
"record",
")",
":",
"classes",
"=",
"list",
"(",
"cls",
".",
"__subclasses__",
"(",
")",
")",
"if",
"not",
"isabstract",
"(",
"cls",
")",
":",
"classes",
".",
"append",
"(",
"cls",
")",
"for",
"subclass",
"in",... | Load the record in a concrete subclass of this type. | [
"Load",
"the",
"record",
"in",
"a",
"concrete",
"subclass",
"of",
"this",
"type",
"."
] | 28a03748df8a2fa43f0c0c8098ca64d11559434e | https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/parts.py#L102-L112 | train | Load the record in a concrete subclass of this type. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/channel.py | Channel.get_pty | def get_pty(self, term='vt100', width=80, height=24, width_pixels=0,
height_pixels=0):
"""
Request a pseudo-terminal from the server. This is usually used right
after creating a client channel, to ask the server to provide some
basic terminal semantics for a shell invoke... | python | def get_pty(self, term='vt100', width=80, height=24, width_pixels=0,
height_pixels=0):
"""
Request a pseudo-terminal from the server. This is usually used right
after creating a client channel, to ask the server to provide some
basic terminal semantics for a shell invoke... | [
"def",
"get_pty",
"(",
"self",
",",
"term",
"=",
"'vt100'",
",",
"width",
"=",
"80",
",",
"height",
"=",
"24",
",",
"width_pixels",
"=",
"0",
",",
"height_pixels",
"=",
"0",
")",
":",
"if",
"self",
".",
"closed",
"or",
"self",
".",
"eof_received",
... | Request a pseudo-terminal from the server. This is usually used right
after creating a client channel, to ask the server to provide some
basic terminal semantics for a shell invoked with `invoke_shell`.
It isn't necessary (or desirable) to call this method if you're going
to exectue a s... | [
"Request",
"a",
"pseudo",
"-",
"terminal",
"from",
"the",
"server",
".",
"This",
"is",
"usually",
"used",
"right",
"after",
"creating",
"a",
"client",
"channel",
"to",
"ask",
"the",
"server",
"to",
"provide",
"some",
"basic",
"terminal",
"semantics",
"for",
... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/channel.py#L125-L158 | train | Request a pseudo - terminal from the server. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/channel.py | Channel.invoke_shell | def invoke_shell(self):
"""
Request an interactive shell session on this channel. If the server
allows it, the channel will then be directly connected to the stdin,
stdout, and stderr of the shell.
Normally you would call `get_pty` before this, in which case the
... | python | def invoke_shell(self):
"""
Request an interactive shell session on this channel. If the server
allows it, the channel will then be directly connected to the stdin,
stdout, and stderr of the shell.
Normally you would call `get_pty` before this, in which case the
... | [
"def",
"invoke_shell",
"(",
"self",
")",
":",
"if",
"self",
".",
"closed",
"or",
"self",
".",
"eof_received",
"or",
"self",
".",
"eof_sent",
"or",
"not",
"self",
".",
"active",
":",
"raise",
"SSHException",
"(",
"'Channel is not open'",
")",
"m",
"=",
"M... | Request an interactive shell session on this channel. If the server
allows it, the channel will then be directly connected to the stdin,
stdout, and stderr of the shell.
Normally you would call `get_pty` before this, in which case the
shell will operate through the pty, and the... | [
"Request",
"an",
"interactive",
"shell",
"session",
"on",
"this",
"channel",
".",
"If",
"the",
"server",
"allows",
"it",
"the",
"channel",
"will",
"then",
"be",
"directly",
"connected",
"to",
"the",
"stdin",
"stdout",
"and",
"stderr",
"of",
"the",
"shell",
... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/channel.py#L160-L185 | train | Invoke an interactive shell session on this channel. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/channel.py | Channel.resize_pty | def resize_pty(self, width=80, height=24, width_pixels=0, height_pixels=0):
"""
Resize the pseudo-terminal. This can be used to change the width and
height of the terminal emulation created in a previous `get_pty` call.
:param int width: new width (in characters) of the terminal screen... | python | def resize_pty(self, width=80, height=24, width_pixels=0, height_pixels=0):
"""
Resize the pseudo-terminal. This can be used to change the width and
height of the terminal emulation created in a previous `get_pty` call.
:param int width: new width (in characters) of the terminal screen... | [
"def",
"resize_pty",
"(",
"self",
",",
"width",
"=",
"80",
",",
"height",
"=",
"24",
",",
"width_pixels",
"=",
"0",
",",
"height_pixels",
"=",
"0",
")",
":",
"if",
"self",
".",
"closed",
"or",
"self",
".",
"eof_received",
"or",
"self",
".",
"eof_sent... | Resize the pseudo-terminal. This can be used to change the width and
height of the terminal emulation created in a previous `get_pty` call.
:param int width: new width (in characters) of the terminal screen
:param int height: new height (in characters) of the terminal screen
:param int... | [
"Resize",
"the",
"pseudo",
"-",
"terminal",
".",
"This",
"can",
"be",
"used",
"to",
"change",
"the",
"width",
"and",
"height",
"of",
"the",
"terminal",
"emulation",
"created",
"in",
"a",
"previous",
"get_pty",
"call",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/channel.py#L240-L264 | train | This method is used to resize the pseudo - terminal. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/channel.py | Channel.request_forward_agent | def request_forward_agent(self, handler):
"""
Request for a forward SSH Agent on this channel.
This is only valid for an ssh-agent from OpenSSH !!!
:param function handler:
a required handler to use for incoming SSH Agent connections
:return: True if we are ok, else... | python | def request_forward_agent(self, handler):
"""
Request for a forward SSH Agent on this channel.
This is only valid for an ssh-agent from OpenSSH !!!
:param function handler:
a required handler to use for incoming SSH Agent connections
:return: True if we are ok, else... | [
"def",
"request_forward_agent",
"(",
"self",
",",
"handler",
")",
":",
"if",
"self",
".",
"closed",
"or",
"self",
".",
"eof_received",
"or",
"self",
".",
"eof_sent",
"or",
"not",
"self",
".",
"active",
":",
"raise",
"SSHException",
"(",
"'Channel is not open... | Request for a forward SSH Agent on this channel.
This is only valid for an ssh-agent from OpenSSH !!!
:param function handler:
a required handler to use for incoming SSH Agent connections
:return: True if we are ok, else False (at that time we always return ok)
:raises: SS... | [
"Request",
"for",
"a",
"forward",
"SSH",
"Agent",
"on",
"this",
"channel",
".",
"This",
"is",
"only",
"valid",
"for",
"an",
"ssh",
"-",
"agent",
"from",
"OpenSSH",
"!!!"
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/channel.py#L379-L401 | train | Request a forward SSH Agent on this channel. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/channel.py | Channel.send_stderr | def send_stderr(self, s):
"""
Send data to the channel on the "stderr" stream. This is normally
only used by servers to send output from shell commands -- clients
won't use this. Returns the number of bytes sent, or 0 if the channel
stream is closed. Applications are responsib... | python | def send_stderr(self, s):
"""
Send data to the channel on the "stderr" stream. This is normally
only used by servers to send output from shell commands -- clients
won't use this. Returns the number of bytes sent, or 0 if the channel
stream is closed. Applications are responsib... | [
"def",
"send_stderr",
"(",
"self",
",",
"s",
")",
":",
"size",
"=",
"len",
"(",
"s",
")",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"size",
"=",
"self",
".",
"_wait_for_send_window",
"(",
"size",
")",
"if",
"size",
"==",
"0",
":"... | Send data to the channel on the "stderr" stream. This is normally
only used by servers to send output from shell commands -- clients
won't use this. Returns the number of bytes sent, or 0 if the channel
stream is closed. Applications are responsible for checking that all
data has been... | [
"Send",
"data",
"to",
"the",
"channel",
"on",
"the",
"stderr",
"stream",
".",
"This",
"is",
"normally",
"only",
"used",
"by",
"servers",
"to",
"send",
"output",
"from",
"shell",
"commands",
"--",
"clients",
"won",
"t",
"use",
"this",
".",
"Returns",
"the... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/channel.py#L700-L734 | train | Send data to the channel on the stderr stream. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/transport.py | Transport.global_request | def global_request(self, kind, data=None, wait=True):
"""
Make a global request to the remote host. These are normally
extensions to the SSH2 protocol.
:param str kind: name of the request.
:param tuple data:
an optional tuple containing additional data to attach to... | python | def global_request(self, kind, data=None, wait=True):
"""
Make a global request to the remote host. These are normally
extensions to the SSH2 protocol.
:param str kind: name of the request.
:param tuple data:
an optional tuple containing additional data to attach to... | [
"def",
"global_request",
"(",
"self",
",",
"kind",
",",
"data",
"=",
"None",
",",
"wait",
"=",
"True",
")",
":",
"if",
"wait",
":",
"self",
".",
"completion_event",
"=",
"threading",
".",
"Event",
"(",
")",
"m",
"=",
"Message",
"(",
")",
"m",
".",
... | Make a global request to the remote host. These are normally
extensions to the SSH2 protocol.
:param str kind: name of the request.
:param tuple data:
an optional tuple containing additional data to attach to the
request.
:param bool wait:
``True`` i... | [
"Make",
"a",
"global",
"request",
"to",
"the",
"remote",
"host",
".",
"These",
"are",
"normally",
"extensions",
"to",
"the",
"SSH2",
"protocol",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/transport.py#L777-L812 | train | Makes a global request to the remote host. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/transport.py | Transport._compute_key | def _compute_key(self, id, nbytes):
"""id is 'A' - 'F' for the various keys used by ssh"""
m = Message()
m.add_mpint(self.K)
m.add_bytes(self.H)
m.add_byte(b(id))
m.add_bytes(self.session_id)
out = sofar = sha1(m.asbytes()).digest()
while len(out) < nbytes... | python | def _compute_key(self, id, nbytes):
"""id is 'A' - 'F' for the various keys used by ssh"""
m = Message()
m.add_mpint(self.K)
m.add_bytes(self.H)
m.add_byte(b(id))
m.add_bytes(self.session_id)
out = sofar = sha1(m.asbytes()).digest()
while len(out) < nbytes... | [
"def",
"_compute_key",
"(",
"self",
",",
"id",
",",
"nbytes",
")",
":",
"m",
"=",
"Message",
"(",
")",
"m",
".",
"add_mpint",
"(",
"self",
".",
"K",
")",
"m",
".",
"add_bytes",
"(",
"self",
".",
"H",
")",
"m",
".",
"add_byte",
"(",
"b",
"(",
... | id is 'A' - 'F' for the various keys used by ssh | [
"id",
"is",
"A",
"-",
"F",
"for",
"the",
"various",
"keys",
"used",
"by",
"ssh"
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/transport.py#L1333-L1349 | train | Compute the key for the given id and nbytes. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/transport.py | Transport._send_kex_init | def _send_kex_init(self):
"""
announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support.
"""
self.clear_to_send_lock.acquire()
try:
self.clear_to_send.clear()
finally:
self.clear_to_send_lock.r... | python | def _send_kex_init(self):
"""
announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support.
"""
self.clear_to_send_lock.acquire()
try:
self.clear_to_send.clear()
finally:
self.clear_to_send_lock.r... | [
"def",
"_send_kex_init",
"(",
"self",
")",
":",
"self",
".",
"clear_to_send_lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"clear_to_send",
".",
"clear",
"(",
")",
"finally",
":",
"self",
".",
"clear_to_send_lock",
".",
"release",
"(",
")",
"s... | announce to the other side that we'd like to negotiate keys, and what
kind of key negotiation we support. | [
"announce",
"to",
"the",
"other",
"side",
"that",
"we",
"d",
"like",
"to",
"negotiate",
"keys",
"and",
"what",
"kind",
"of",
"key",
"negotiation",
"we",
"support",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/transport.py#L1564-L1603 | train | Send a KEXINIT message to the other side that we don t know about. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/transport.py | Transport._activate_inbound | def _activate_inbound(self):
"""switch on newly negotiated encryption parameters for inbound traffic"""
block_size = self._cipher_info[self.remote_cipher]['block-size']
if self.server_mode:
IV_in = self._compute_key('A', block_size)
key_in = self._compute_key('C', self._c... | python | def _activate_inbound(self):
"""switch on newly negotiated encryption parameters for inbound traffic"""
block_size = self._cipher_info[self.remote_cipher]['block-size']
if self.server_mode:
IV_in = self._compute_key('A', block_size)
key_in = self._compute_key('C', self._c... | [
"def",
"_activate_inbound",
"(",
"self",
")",
":",
"block_size",
"=",
"self",
".",
"_cipher_info",
"[",
"self",
".",
"remote_cipher",
"]",
"[",
"'block-size'",
"]",
"if",
"self",
".",
"server_mode",
":",
"IV_in",
"=",
"self",
".",
"_compute_key",
"(",
"'A'... | switch on newly negotiated encryption parameters for inbound traffic | [
"switch",
"on",
"newly",
"negotiated",
"encryption",
"parameters",
"for",
"inbound",
"traffic"
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/transport.py#L1702-L1724 | train | Switch on newly negotiated encryption parameters for inbound traffic |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.enable_user | def enable_user(self, user):
"""Enable the root account on the remote host.
Since the host may have been deployed using a Cloud image, it may not
be possible to use the 'root' account. This method ensure the root
account is enable, if this is not the case, it will try to get the name
... | python | def enable_user(self, user):
"""Enable the root account on the remote host.
Since the host may have been deployed using a Cloud image, it may not
be possible to use the 'root' account. This method ensure the root
account is enable, if this is not the case, it will try to get the name
... | [
"def",
"enable_user",
"(",
"self",
",",
"user",
")",
":",
"if",
"user",
"in",
"self",
".",
"ssh_pool",
".",
"_ssh_clients",
":",
"return",
"if",
"user",
"==",
"'root'",
":",
"_root_ssh_client",
"=",
"ssh",
".",
"SshClient",
"(",
"hostname",
"=",
"self",
... | Enable the root account on the remote host.
Since the host may have been deployed using a Cloud image, it may not
be possible to use the 'root' account. This method ensure the root
account is enable, if this is not the case, it will try to get the name
of admin user and use it to re-en... | [
"Enable",
"the",
"root",
"account",
"on",
"the",
"remote",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L54-L103 | train | Enable the root account on the remote host. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.send_file | def send_file(self, local_path, remote_path, user='root', unix_mode=None):
"""Upload a local file on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.send_file(user, local_path, remote_path, unix_mode=unix_mode) | python | def send_file(self, local_path, remote_path, user='root', unix_mode=None):
"""Upload a local file on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.send_file(user, local_path, remote_path, unix_mode=unix_mode) | [
"def",
"send_file",
"(",
"self",
",",
"local_path",
",",
"remote_path",
",",
"user",
"=",
"'root'",
",",
"unix_mode",
"=",
"None",
")",
":",
"self",
".",
"enable_user",
"(",
"user",
")",
"return",
"self",
".",
"ssh_pool",
".",
"send_file",
"(",
"user",
... | Upload a local file on the remote host. | [
"Upload",
"a",
"local",
"file",
"on",
"the",
"remote",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L105-L109 | train | Uploads a local file on the remote host. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.send_dir | def send_dir(self, local_path, remote_path, user='root'):
"""Upload a directory on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.send_dir(user, local_path, remote_path) | python | def send_dir(self, local_path, remote_path, user='root'):
"""Upload a directory on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.send_dir(user, local_path, remote_path) | [
"def",
"send_dir",
"(",
"self",
",",
"local_path",
",",
"remote_path",
",",
"user",
"=",
"'root'",
")",
":",
"self",
".",
"enable_user",
"(",
"user",
")",
"return",
"self",
".",
"ssh_pool",
".",
"send_dir",
"(",
"user",
",",
"local_path",
",",
"remote_pa... | Upload a directory on the remote host. | [
"Upload",
"a",
"directory",
"on",
"the",
"remote",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L111-L115 | train | Upload a directory on the remote host. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.create_file | def create_file(self, path, content, mode='w', user='root'):
"""Create a file on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.create_file(user, path, content, mode) | python | def create_file(self, path, content, mode='w', user='root'):
"""Create a file on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.create_file(user, path, content, mode) | [
"def",
"create_file",
"(",
"self",
",",
"path",
",",
"content",
",",
"mode",
"=",
"'w'",
",",
"user",
"=",
"'root'",
")",
":",
"self",
".",
"enable_user",
"(",
"user",
")",
"return",
"self",
".",
"ssh_pool",
".",
"create_file",
"(",
"user",
",",
"pat... | Create a file on the remote host. | [
"Create",
"a",
"file",
"on",
"the",
"remote",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L121-L125 | train | Create a file on the remote host. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.run | def run(self, cmd, user='root', sudo=False, ignore_error=False,
success_status=(0,), error_callback=None, custom_log=None, retry=0):
"""Run a command on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.run(
user, cmd, sudo=sudo, ignore_error=ignore... | python | def run(self, cmd, user='root', sudo=False, ignore_error=False,
success_status=(0,), error_callback=None, custom_log=None, retry=0):
"""Run a command on the remote host.
"""
self.enable_user(user)
return self.ssh_pool.run(
user, cmd, sudo=sudo, ignore_error=ignore... | [
"def",
"run",
"(",
"self",
",",
"cmd",
",",
"user",
"=",
"'root'",
",",
"sudo",
"=",
"False",
",",
"ignore_error",
"=",
"False",
",",
"success_status",
"=",
"(",
"0",
",",
")",
",",
"error_callback",
"=",
"None",
",",
"custom_log",
"=",
"None",
",",
... | Run a command on the remote host. | [
"Run",
"a",
"command",
"on",
"the",
"remote",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L127-L135 | train | Run a command on the remote host. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.yum_install | def yum_install(self, packages, ignore_error=False):
"""Install some packages on the remote host.
:param packages: ist of packages to install.
"""
return self.run('yum install -y --quiet ' + ' '.join(packages), ignore_error=ignore_error, retry=5) | python | def yum_install(self, packages, ignore_error=False):
"""Install some packages on the remote host.
:param packages: ist of packages to install.
"""
return self.run('yum install -y --quiet ' + ' '.join(packages), ignore_error=ignore_error, retry=5) | [
"def",
"yum_install",
"(",
"self",
",",
"packages",
",",
"ignore_error",
"=",
"False",
")",
":",
"return",
"self",
".",
"run",
"(",
"'yum install -y --quiet '",
"+",
"' '",
".",
"join",
"(",
"packages",
")",
",",
"ignore_error",
"=",
"ignore_error",
",",
"... | Install some packages on the remote host.
:param packages: ist of packages to install. | [
"Install",
"some",
"packages",
"on",
"the",
"remote",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L141-L146 | train | Install some packages on the remote host. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.rhsm_register | def rhsm_register(self, rhsm):
"""Register the host on the RHSM.
:param rhsm: a dict of parameters (login, password, pool_id)
"""
# Get rhsm credentials
login = rhsm.get('login')
password = rhsm.get('password', os.environ.get('RHN_PW'))
pool_id = rhsm.get('pool_i... | python | def rhsm_register(self, rhsm):
"""Register the host on the RHSM.
:param rhsm: a dict of parameters (login, password, pool_id)
"""
# Get rhsm credentials
login = rhsm.get('login')
password = rhsm.get('password', os.environ.get('RHN_PW'))
pool_id = rhsm.get('pool_i... | [
"def",
"rhsm_register",
"(",
"self",
",",
"rhsm",
")",
":",
"# Get rhsm credentials",
"login",
"=",
"rhsm",
".",
"get",
"(",
"'login'",
")",
"password",
"=",
"rhsm",
".",
"get",
"(",
"'password'",
",",
"os",
".",
"environ",
".",
"get",
"(",
"'RHN_PW'",
... | Register the host on the RHSM.
:param rhsm: a dict of parameters (login, password, pool_id) | [
"Register",
"the",
"host",
"on",
"the",
"RHSM",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L155-L177 | train | Register the host on the RHSM. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.enable_repositories | def enable_repositories(self, repositories):
"""Enable a list of RHSM repositories.
:param repositories: a dict in this format:
[{'type': 'rhsm_channel', 'name': 'rhel-7-server-rpms'}]
"""
for r in repositories:
if r['type'] != 'rhsm_channel':
con... | python | def enable_repositories(self, repositories):
"""Enable a list of RHSM repositories.
:param repositories: a dict in this format:
[{'type': 'rhsm_channel', 'name': 'rhel-7-server-rpms'}]
"""
for r in repositories:
if r['type'] != 'rhsm_channel':
con... | [
"def",
"enable_repositories",
"(",
"self",
",",
"repositories",
")",
":",
"for",
"r",
"in",
"repositories",
":",
"if",
"r",
"[",
"'type'",
"]",
"!=",
"'rhsm_channel'",
":",
"continue",
"if",
"r",
"[",
"'name'",
"]",
"not",
"in",
"self",
".",
"rhsm_channe... | Enable a list of RHSM repositories.
:param repositories: a dict in this format:
[{'type': 'rhsm_channel', 'name': 'rhel-7-server-rpms'}] | [
"Enable",
"a",
"list",
"of",
"RHSM",
"repositories",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L179-L202 | train | Enable a list of RHSM repositories. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.create_stack_user | def create_stack_user(self):
"""Create the stack user on the machine.
"""
self.run('adduser -m stack', success_status=(0, 9))
self.create_file('/etc/sudoers.d/stack', 'stack ALL=(root) NOPASSWD:ALL\n')
self.run('mkdir -p /home/stack/.ssh')
self.run('cp /root/.ssh/authoriz... | python | def create_stack_user(self):
"""Create the stack user on the machine.
"""
self.run('adduser -m stack', success_status=(0, 9))
self.create_file('/etc/sudoers.d/stack', 'stack ALL=(root) NOPASSWD:ALL\n')
self.run('mkdir -p /home/stack/.ssh')
self.run('cp /root/.ssh/authoriz... | [
"def",
"create_stack_user",
"(",
"self",
")",
":",
"self",
".",
"run",
"(",
"'adduser -m stack'",
",",
"success_status",
"=",
"(",
"0",
",",
"9",
")",
")",
"self",
".",
"create_file",
"(",
"'/etc/sudoers.d/stack'",
",",
"'stack ALL=(root) NOPASSWD:ALL\\n'",
")",... | Create the stack user on the machine. | [
"Create",
"the",
"stack",
"user",
"on",
"the",
"machine",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L204-L216 | train | Create the stack user on the machine. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.fetch_image | def fetch_image(self, path, dest, user='root'):
"""Store in the user home directory an image from a remote location.
"""
self.run('test -f %s || curl -L -s -o %s %s' % (dest, dest, path),
user=user, ignore_error=True) | python | def fetch_image(self, path, dest, user='root'):
"""Store in the user home directory an image from a remote location.
"""
self.run('test -f %s || curl -L -s -o %s %s' % (dest, dest, path),
user=user, ignore_error=True) | [
"def",
"fetch_image",
"(",
"self",
",",
"path",
",",
"dest",
",",
"user",
"=",
"'root'",
")",
":",
"self",
".",
"run",
"(",
"'test -f %s || curl -L -s -o %s %s'",
"%",
"(",
"dest",
",",
"dest",
",",
"path",
")",
",",
"user",
"=",
"user",
",",
"ignore_e... | Store in the user home directory an image from a remote location. | [
"Store",
"in",
"the",
"user",
"home",
"directory",
"an",
"image",
"from",
"a",
"remote",
"location",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L218-L222 | train | Fetch an image from a remote location. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.clean_system | def clean_system(self):
"""Clean up unnecessary packages from the system.
"""
self.run('systemctl disable NetworkManager', success_status=(0, 1))
self.run('systemctl stop NetworkManager', success_status=(0, 5))
self.run('pkill -9 dhclient', success_status=(0, 1))
self.yum... | python | def clean_system(self):
"""Clean up unnecessary packages from the system.
"""
self.run('systemctl disable NetworkManager', success_status=(0, 1))
self.run('systemctl stop NetworkManager', success_status=(0, 5))
self.run('pkill -9 dhclient', success_status=(0, 1))
self.yum... | [
"def",
"clean_system",
"(",
"self",
")",
":",
"self",
".",
"run",
"(",
"'systemctl disable NetworkManager'",
",",
"success_status",
"=",
"(",
"0",
",",
"1",
")",
")",
"self",
".",
"run",
"(",
"'systemctl stop NetworkManager'",
",",
"success_status",
"=",
"(",
... | Clean up unnecessary packages from the system. | [
"Clean",
"up",
"unnecessary",
"packages",
"from",
"the",
"system",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L232-L240 | train | Clean up unnecessary packages from the system. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.yum_update | def yum_update(self, allow_reboot=False):
"""Do a yum update on the system.
:param allow_reboot: If True and if a new kernel has been installed,
the system will be rebooted
"""
self.run('yum clean all')
self.run('test -f /usr/bin/subscription-manager && subscription-mana... | python | def yum_update(self, allow_reboot=False):
"""Do a yum update on the system.
:param allow_reboot: If True and if a new kernel has been installed,
the system will be rebooted
"""
self.run('yum clean all')
self.run('test -f /usr/bin/subscription-manager && subscription-mana... | [
"def",
"yum_update",
"(",
"self",
",",
"allow_reboot",
"=",
"False",
")",
":",
"self",
".",
"run",
"(",
"'yum clean all'",
")",
"self",
".",
"run",
"(",
"'test -f /usr/bin/subscription-manager && subscription-manager repos --list-enabled'",
",",
"ignore_error",
"=",
"... | Do a yum update on the system.
:param allow_reboot: If True and if a new kernel has been installed,
the system will be rebooted | [
"Do",
"a",
"yum",
"update",
"on",
"the",
"system",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L242-L260 | train | Do a yum update on the system. |
redhat-openstack/python-tripleo-helper | tripleohelper/server.py | Server.set_selinux | def set_selinux(self, state):
"""Help to enable/disable SELinux on the host.
"""
allowed_states = ('enforcing', 'permissive', 'disabled')
if state not in allowed_states:
raise Exception
self.run('setenforce %s' % state)
self.create_file('/etc/sysconfig/selinux... | python | def set_selinux(self, state):
"""Help to enable/disable SELinux on the host.
"""
allowed_states = ('enforcing', 'permissive', 'disabled')
if state not in allowed_states:
raise Exception
self.run('setenforce %s' % state)
self.create_file('/etc/sysconfig/selinux... | [
"def",
"set_selinux",
"(",
"self",
",",
"state",
")",
":",
"allowed_states",
"=",
"(",
"'enforcing'",
",",
"'permissive'",
",",
"'disabled'",
")",
"if",
"state",
"not",
"in",
"allowed_states",
":",
"raise",
"Exception",
"self",
".",
"run",
"(",
"'setenforce ... | Help to enable/disable SELinux on the host. | [
"Help",
"to",
"enable",
"/",
"disable",
"SELinux",
"on",
"the",
"host",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/server.py#L267-L275 | train | Help to enable SELinux on the host. |
nhfruchter/pgh-bustime | pghbustime/utils.py | queryjoin | def queryjoin(argdict=dict(), **kwargs):
"""Turn a dictionary into a querystring for a URL.
>>> args = dict(a=1, b=2, c="foo")
>>> queryjoin(args)
"a=1&b=2&c=foo"
"""
if kwargs: argdict.update(kwargs)
if issubclass(type(argdict), dict):
args = ["{}={}".f... | python | def queryjoin(argdict=dict(), **kwargs):
"""Turn a dictionary into a querystring for a URL.
>>> args = dict(a=1, b=2, c="foo")
>>> queryjoin(args)
"a=1&b=2&c=foo"
"""
if kwargs: argdict.update(kwargs)
if issubclass(type(argdict), dict):
args = ["{}={}".f... | [
"def",
"queryjoin",
"(",
"argdict",
"=",
"dict",
"(",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
":",
"argdict",
".",
"update",
"(",
"kwargs",
")",
"if",
"issubclass",
"(",
"type",
"(",
"argdict",
")",
",",
"dict",
")",
":",
"args",
... | Turn a dictionary into a querystring for a URL.
>>> args = dict(a=1, b=2, c="foo")
>>> queryjoin(args)
"a=1&b=2&c=foo" | [
"Turn",
"a",
"dictionary",
"into",
"a",
"querystring",
"for",
"a",
"URL",
".",
">>>",
"args",
"=",
"dict",
"(",
"a",
"=",
"1",
"b",
"=",
"2",
"c",
"=",
"foo",
")",
">>>",
"queryjoin",
"(",
"args",
")",
"a",
"=",
"1&b",
"=",
"2&c",
"=",
"foo"
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/utils.py#L3-L14 | train | Turn a dictionary into a querystring for a URL. |
nhfruchter/pgh-bustime | pghbustime/utils.py | listlike | def listlike(obj):
"""Is an object iterable like a list (and not a string)?"""
return hasattr(obj, "__iter__") \
and not issubclass(type(obj), str)\
and not issubclass(type(obj), unicode) | python | def listlike(obj):
"""Is an object iterable like a list (and not a string)?"""
return hasattr(obj, "__iter__") \
and not issubclass(type(obj), str)\
and not issubclass(type(obj), unicode) | [
"def",
"listlike",
"(",
"obj",
")",
":",
"return",
"hasattr",
"(",
"obj",
",",
"\"__iter__\"",
")",
"and",
"not",
"issubclass",
"(",
"type",
"(",
"obj",
")",
",",
"str",
")",
"and",
"not",
"issubclass",
"(",
"type",
"(",
"obj",
")",
",",
"unicode",
... | Is an object iterable like a list (and not a string)? | [
"Is",
"an",
"object",
"iterable",
"like",
"a",
"list",
"(",
"and",
"not",
"a",
"string",
")",
"?"
] | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/utils.py#L16-L21 | train | Is an object iterable like a list? |
nhfruchter/pgh-bustime | pghbustime/utils.py | patterntogeojson | def patterntogeojson(pattern, color=False):
import geojson
"""
Turns an an API response of a pattern into a GeoJSON FeatureCollection.
Takes a dict that contains at least `pid`, `ln`, `rtdir`, and `pt`.
>>> api_response = {'ln': '123.45', 'pid': '1', 'pt': [], 'rtdir': 'OUTBOUND'}
>>> ... | python | def patterntogeojson(pattern, color=False):
import geojson
"""
Turns an an API response of a pattern into a GeoJSON FeatureCollection.
Takes a dict that contains at least `pid`, `ln`, `rtdir`, and `pt`.
>>> api_response = {'ln': '123.45', 'pid': '1', 'pt': [], 'rtdir': 'OUTBOUND'}
>>> ... | [
"def",
"patterntogeojson",
"(",
"pattern",
",",
"color",
"=",
"False",
")",
":",
"import",
"geojson",
"# Base properties for the pattern",
"properties",
"=",
"dict",
"(",
"pid",
"=",
"pattern",
"[",
"'pid'",
"]",
",",
"length",
"=",
"pattern",
"[",
"'ln'",
"... | Turns an an API response of a pattern into a GeoJSON FeatureCollection.
Takes a dict that contains at least `pid`, `ln`, `rtdir`, and `pt`.
>>> api_response = {'ln': '123.45', 'pid': '1', 'pt': [], 'rtdir': 'OUTBOUND'}
>>> pt1 = {'lat': '40.449', 'lon': '-79.983', 'seq': '1', 'typ': 'W'}
>>> pt2 = ... | [
"Turns",
"an",
"an",
"API",
"response",
"of",
"a",
"pattern",
"into",
"a",
"GeoJSON",
"FeatureCollection",
".",
"Takes",
"a",
"dict",
"that",
"contains",
"at",
"least",
"pid",
"ln",
"rtdir",
"and",
"pt",
".",
">>>",
"api_response",
"=",
"{",
"ln",
":",
... | b915e8fea28541612f0e79783c2cf12fd3daaac0 | https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/utils.py#L23-L47 | train | Converts a dict that contains at least pid ln rtdir and pt into a GeoJSON FeatureCollection. |
JawboneHealth/jhhalchemy | jhhalchemy/model/time_order.py | get_by_range | def get_by_range(model_cls, *args, **kwargs):
"""
Get ordered list of models for the specified time range.
The timestamp on the earliest model will likely occur before start_timestamp. This is to ensure that we return
the models for the entire range.
:param model_cls: the class of the model to retu... | python | def get_by_range(model_cls, *args, **kwargs):
"""
Get ordered list of models for the specified time range.
The timestamp on the earliest model will likely occur before start_timestamp. This is to ensure that we return
the models for the entire range.
:param model_cls: the class of the model to retu... | [
"def",
"get_by_range",
"(",
"model_cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"start_timestamp",
"=",
"kwargs",
".",
"get",
"(",
"'start_timestamp'",
")",
"end_timestamp",
"=",
"kwargs",
".",
"get",
"(",
"'end_timestamp'",
")",
"if",
"(",
... | Get ordered list of models for the specified time range.
The timestamp on the earliest model will likely occur before start_timestamp. This is to ensure that we return
the models for the entire range.
:param model_cls: the class of the model to return
:param args: arguments specific to the model class
... | [
"Get",
"ordered",
"list",
"of",
"models",
"for",
"the",
"specified",
"time",
"range",
".",
"The",
"timestamp",
"on",
"the",
"earliest",
"model",
"will",
"likely",
"occur",
"before",
"start_timestamp",
".",
"This",
"is",
"to",
"ensure",
"that",
"we",
"return"... | ca0011d644e404561a142c9d7f0a8a569f1f4f27 | https://github.com/JawboneHealth/jhhalchemy/blob/ca0011d644e404561a142c9d7f0a8a569f1f4f27/jhhalchemy/model/time_order.py#L69-L99 | train | Get ordered list of models for the specified time range. |
JawboneHealth/jhhalchemy | jhhalchemy/model/time_order.py | TimeOrderMixin.read_time_range | def read_time_range(cls, *args, **kwargs):
"""
Get all timezones set within a given time. Uses time_dsc_index
SELECT *
FROM <table>
WHERE time_order <= -<start_timestamp>
AND time_order >= -<end_timestamp>
:param args: SQLAlchemy filter criteria, (e.g., uid == u... | python | def read_time_range(cls, *args, **kwargs):
"""
Get all timezones set within a given time. Uses time_dsc_index
SELECT *
FROM <table>
WHERE time_order <= -<start_timestamp>
AND time_order >= -<end_timestamp>
:param args: SQLAlchemy filter criteria, (e.g., uid == u... | [
"def",
"read_time_range",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"criteria",
"=",
"list",
"(",
"args",
")",
"start",
"=",
"kwargs",
".",
"get",
"(",
"'start_timestamp'",
")",
"end",
"=",
"kwargs",
".",
"get",
"(",
"'end_time... | Get all timezones set within a given time. Uses time_dsc_index
SELECT *
FROM <table>
WHERE time_order <= -<start_timestamp>
AND time_order >= -<end_timestamp>
:param args: SQLAlchemy filter criteria, (e.g., uid == uid, type == 1)
:param kwargs: start_timestamp and end_t... | [
"Get",
"all",
"timezones",
"set",
"within",
"a",
"given",
"time",
".",
"Uses",
"time_dsc_index"
] | ca0011d644e404561a142c9d7f0a8a569f1f4f27 | https://github.com/JawboneHealth/jhhalchemy/blob/ca0011d644e404561a142c9d7f0a8a569f1f4f27/jhhalchemy/model/time_order.py#L34-L54 | train | Reads all timezones set within a given time. Uses time_dsc_index
. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.add_data | def add_data(self, data, metadata=None):
"""Add data to the parameter set
Parameters
----------
data: numpy.ndarray
one or more parameter sets. It must either be 1D or 2D, with the
first dimension the number of parameter sets (K), and the second
the n... | python | def add_data(self, data, metadata=None):
"""Add data to the parameter set
Parameters
----------
data: numpy.ndarray
one or more parameter sets. It must either be 1D or 2D, with the
first dimension the number of parameter sets (K), and the second
the n... | [
"def",
"add_data",
"(",
"self",
",",
"data",
",",
"metadata",
"=",
"None",
")",
":",
"subdata",
"=",
"np",
".",
"atleast_2d",
"(",
"data",
")",
"# we try to accommodate transposed input",
"if",
"subdata",
".",
"shape",
"[",
"1",
"]",
"!=",
"self",
".",
"... | Add data to the parameter set
Parameters
----------
data: numpy.ndarray
one or more parameter sets. It must either be 1D or 2D, with the
first dimension the number of parameter sets (K), and the second
the number of elements (N): K x N
metadata: objec... | [
"Add",
"data",
"to",
"the",
"parameter",
"set"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L40-L112 | train | Add data to the parameter set and return the ID of the new object. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.load_from_rho_file | def load_from_rho_file(self, filename):
"""Convenience function that loads two parameter sets from a rho.dat
file, as used by CRMod for forward resistivity/phase models.
Parameters
----------
filename: string, file path
filename of rho.dat file
Returns
... | python | def load_from_rho_file(self, filename):
"""Convenience function that loads two parameter sets from a rho.dat
file, as used by CRMod for forward resistivity/phase models.
Parameters
----------
filename: string, file path
filename of rho.dat file
Returns
... | [
"def",
"load_from_rho_file",
"(",
"self",
",",
"filename",
")",
":",
"data",
"=",
"np",
".",
"loadtxt",
"(",
"filename",
",",
"skiprows",
"=",
"1",
")",
"cid_mag",
"=",
"self",
".",
"add_data",
"(",
"data",
"[",
":",
",",
"0",
"]",
")",
"cid_pha",
... | Convenience function that loads two parameter sets from a rho.dat
file, as used by CRMod for forward resistivity/phase models.
Parameters
----------
filename: string, file path
filename of rho.dat file
Returns
-------
cid_mag: int
ID of m... | [
"Convenience",
"function",
"that",
"loads",
"two",
"parameter",
"sets",
"from",
"a",
"rho",
".",
"dat",
"file",
"as",
"used",
"by",
"CRMod",
"for",
"forward",
"resistivity",
"/",
"phase",
"models",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L114-L134 | train | Convenience function that loads two parameter sets from a rho. dat file. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.load_inv_result | def load_inv_result(self, filename, columns=2):
"""Load one parameter set from a rho*.mag or rho*.pha file produced by
CRTomo.
Parameters
----------
filename : string, file path
Filename to loaded data from
columns : int or iterable of ints, optional
... | python | def load_inv_result(self, filename, columns=2):
"""Load one parameter set from a rho*.mag or rho*.pha file produced by
CRTomo.
Parameters
----------
filename : string, file path
Filename to loaded data from
columns : int or iterable of ints, optional
... | [
"def",
"load_inv_result",
"(",
"self",
",",
"filename",
",",
"columns",
"=",
"2",
")",
":",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"try",
":",
"iterator",
"=",
"iter",
"(",
"columns",
")",
"except",
"TypeError",
":",
"# not i... | Load one parameter set from a rho*.mag or rho*.pha file produced by
CRTomo.
Parameters
----------
filename : string, file path
Filename to loaded data from
columns : int or iterable of ints, optional
column(s) to add to the manager. Defaults to 2 (third c... | [
"Load",
"one",
"parameter",
"set",
"from",
"a",
"rho",
"*",
".",
"mag",
"or",
"rho",
"*",
".",
"pha",
"file",
"produced",
"by",
"CRTomo",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L136-L169 | train | Load one parameter set from a rho*.mag or rho*.pha file produced by
CRTomo. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.load_model_from_file | def load_model_from_file(self, filename):
"""Load one parameter set from a file which contains one value per line
No row is skipped.
Parameters
----------
filename : string, file path
Filename to loaded data from
Returns
-------
pid : int
... | python | def load_model_from_file(self, filename):
"""Load one parameter set from a file which contains one value per line
No row is skipped.
Parameters
----------
filename : string, file path
Filename to loaded data from
Returns
-------
pid : int
... | [
"def",
"load_model_from_file",
"(",
"self",
",",
"filename",
")",
":",
"assert",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"data",
"=",
"np",
".",
"loadtxt",
"(",
"filename",
")",
".",
"squeeze",
"(",
")",
"assert",
"len",
"(",
"data",
... | Load one parameter set from a file which contains one value per line
No row is skipped.
Parameters
----------
filename : string, file path
Filename to loaded data from
Returns
-------
pid : int
ID of parameter set | [
"Load",
"one",
"parameter",
"set",
"from",
"a",
"file",
"which",
"contains",
"one",
"value",
"per",
"line"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L171-L190 | train | Load one parameter set from a file which contains one value per line per line. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.load_from_sens_file | def load_from_sens_file(self, filename):
"""Load real and imaginary parts from a sens.dat file generated by
CRMod
Parameters
----------
filename: string
filename of sensitivity file
Returns
-------
nid_re: int
ID of real part of s... | python | def load_from_sens_file(self, filename):
"""Load real and imaginary parts from a sens.dat file generated by
CRMod
Parameters
----------
filename: string
filename of sensitivity file
Returns
-------
nid_re: int
ID of real part of s... | [
"def",
"load_from_sens_file",
"(",
"self",
",",
"filename",
")",
":",
"sens_data",
"=",
"np",
".",
"loadtxt",
"(",
"filename",
",",
"skiprows",
"=",
"1",
")",
"nid_re",
"=",
"self",
".",
"add_data",
"(",
"sens_data",
"[",
":",
",",
"2",
"]",
")",
"ni... | Load real and imaginary parts from a sens.dat file generated by
CRMod
Parameters
----------
filename: string
filename of sensitivity file
Returns
-------
nid_re: int
ID of real part of sensitivities
nid_im: int
ID of i... | [
"Load",
"real",
"and",
"imaginary",
"parts",
"from",
"a",
"sens",
".",
"dat",
"file",
"generated",
"by",
"CRMod"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L192-L211 | train | Load real and imaginary parts from a sens. dat file generated by CRMod
|
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.save_to_rho_file | def save_to_rho_file(self, filename, cid_mag, cid_pha=None):
"""Save one or two parameter sets in the rho.dat forward model format
Parameters
----------
filename: string (file path)
output filename
cid_mag: int
ID of magnitude parameter set
cid_ph... | python | def save_to_rho_file(self, filename, cid_mag, cid_pha=None):
"""Save one or two parameter sets in the rho.dat forward model format
Parameters
----------
filename: string (file path)
output filename
cid_mag: int
ID of magnitude parameter set
cid_ph... | [
"def",
"save_to_rho_file",
"(",
"self",
",",
"filename",
",",
"cid_mag",
",",
"cid_pha",
"=",
"None",
")",
":",
"mag_data",
"=",
"self",
".",
"parsets",
"[",
"cid_mag",
"]",
"if",
"cid_pha",
"is",
"None",
":",
"pha_data",
"=",
"np",
".",
"zeros",
"(",
... | Save one or two parameter sets in the rho.dat forward model format
Parameters
----------
filename: string (file path)
output filename
cid_mag: int
ID of magnitude parameter set
cid_pha: int, optional
ID of phase parameter set. If not set, will... | [
"Save",
"one",
"or",
"two",
"parameter",
"sets",
"in",
"the",
"rho",
".",
"dat",
"forward",
"model",
"format"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L213-L246 | train | Save one or two parameter sets in the rho. dat forward model format. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.add_empty_dataset | def add_empty_dataset(self, value=1):
"""Create an empty data set. Empty means: all elements have the same
value.
Parameters
----------
value: float, optional
which value to assign all element parameters. Default is one.
"""
subdata = np.ones(self.gri... | python | def add_empty_dataset(self, value=1):
"""Create an empty data set. Empty means: all elements have the same
value.
Parameters
----------
value: float, optional
which value to assign all element parameters. Default is one.
"""
subdata = np.ones(self.gri... | [
"def",
"add_empty_dataset",
"(",
"self",
",",
"value",
"=",
"1",
")",
":",
"subdata",
"=",
"np",
".",
"ones",
"(",
"self",
".",
"grid",
".",
"nr_of_elements",
")",
"*",
"value",
"pid",
"=",
"self",
".",
"add_data",
"(",
"subdata",
")",
"return",
"pid... | Create an empty data set. Empty means: all elements have the same
value.
Parameters
----------
value: float, optional
which value to assign all element parameters. Default is one. | [
"Create",
"an",
"empty",
"data",
"set",
".",
"Empty",
"means",
":",
"all",
"elements",
"have",
"the",
"same",
"value",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L248-L259 | train | Create an empty data set. Empty means all elements have the same value. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan._clean_pid | def _clean_pid(self, pid):
"""if pid is a number, don't do anything. If pid is a list with one
entry, strip the list and return the number. If pid contains more than
one entries, do nothing.
"""
if isinstance(pid, (list, tuple)):
if len(pid) == 1:
retu... | python | def _clean_pid(self, pid):
"""if pid is a number, don't do anything. If pid is a list with one
entry, strip the list and return the number. If pid contains more than
one entries, do nothing.
"""
if isinstance(pid, (list, tuple)):
if len(pid) == 1:
retu... | [
"def",
"_clean_pid",
"(",
"self",
",",
"pid",
")",
":",
"if",
"isinstance",
"(",
"pid",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"if",
"len",
"(",
"pid",
")",
"==",
"1",
":",
"return",
"pid",
"[",
"0",
"]",
"else",
":",
"return",
"pid",
... | if pid is a number, don't do anything. If pid is a list with one
entry, strip the list and return the number. If pid contains more than
one entries, do nothing. | [
"if",
"pid",
"is",
"a",
"number",
"don",
"t",
"do",
"anything",
".",
"If",
"pid",
"is",
"a",
"list",
"with",
"one",
"entry",
"strip",
"the",
"list",
"and",
"return",
"the",
"number",
".",
"If",
"pid",
"contains",
"more",
"than",
"one",
"entries",
"do... | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L261-L271 | train | Clean the pid to be used in the log file. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.modify_area | def modify_area(self, pid, xmin, xmax, zmin, zmax, value):
"""Modify the given dataset in the rectangular area given by the
parameters and assign all parameters inside this area the given value.
Partially contained elements are treated as INSIDE the area, i.e., they
are assigned new val... | python | def modify_area(self, pid, xmin, xmax, zmin, zmax, value):
"""Modify the given dataset in the rectangular area given by the
parameters and assign all parameters inside this area the given value.
Partially contained elements are treated as INSIDE the area, i.e., they
are assigned new val... | [
"def",
"modify_area",
"(",
"self",
",",
"pid",
",",
"xmin",
",",
"xmax",
",",
"zmin",
",",
"zmax",
",",
"value",
")",
":",
"area_polygon",
"=",
"shapgeo",
".",
"Polygon",
"(",
"(",
"(",
"xmin",
",",
"zmax",
")",
",",
"(",
"xmax",
",",
"zmax",
")"... | Modify the given dataset in the rectangular area given by the
parameters and assign all parameters inside this area the given value.
Partially contained elements are treated as INSIDE the area, i.e., they
are assigned new values.
Parameters
----------
pid: int
... | [
"Modify",
"the",
"given",
"dataset",
"in",
"the",
"rectangular",
"area",
"given",
"by",
"the",
"parameters",
"and",
"assign",
"all",
"parameters",
"inside",
"this",
"area",
"the",
"given",
"value",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L273-L319 | train | Modify the given dataset in the rectangular area given by the
parameters and assign all parameters inside this area the given value. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.modify_polygon | def modify_polygon(self, pid, polygon, value):
"""Modify parts of a parameter set by setting all parameters located
in, or touching, the provided :class:`shapely.geometry.Polygon`
instance.
Parameters
----------
pid: int
id of parameter set to vary
po... | python | def modify_polygon(self, pid, polygon, value):
"""Modify parts of a parameter set by setting all parameters located
in, or touching, the provided :class:`shapely.geometry.Polygon`
instance.
Parameters
----------
pid: int
id of parameter set to vary
po... | [
"def",
"modify_polygon",
"(",
"self",
",",
"pid",
",",
"polygon",
",",
"value",
")",
":",
"# create grid polygons",
"grid_polygons",
"=",
"[",
"]",
"for",
"x",
",",
"z",
"in",
"zip",
"(",
"self",
".",
"grid",
".",
"grid",
"[",
"'x'",
"]",
",",
"self"... | Modify parts of a parameter set by setting all parameters located
in, or touching, the provided :class:`shapely.geometry.Polygon`
instance.
Parameters
----------
pid: int
id of parameter set to vary
polygon: :class:`shapely.geometry.Polygon` instance
... | [
"Modify",
"parts",
"of",
"a",
"parameter",
"set",
"by",
"setting",
"all",
"parameters",
"located",
"in",
"or",
"touching",
"the",
"provided",
":",
"class",
":",
"shapely",
".",
"geometry",
".",
"Polygon",
"instance",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L321-L371 | train | Modify parts of a parameter set by setting all parameters located
in or touching the provided shapely. geometry. Polygon instance. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.extract_points | def extract_points(self, pid, points):
"""Extract values at certain points in the grid from a given parameter
set. Cells are selected by interpolating the centroids of the cells
towards the line using a "nearest" scheme.
Note that data is only returned for the points provided. If you wa... | python | def extract_points(self, pid, points):
"""Extract values at certain points in the grid from a given parameter
set. Cells are selected by interpolating the centroids of the cells
towards the line using a "nearest" scheme.
Note that data is only returned for the points provided. If you wa... | [
"def",
"extract_points",
"(",
"self",
",",
"pid",
",",
"points",
")",
":",
"xy",
"=",
"self",
".",
"grid",
".",
"get_element_centroids",
"(",
")",
"data",
"=",
"self",
".",
"parsets",
"[",
"pid",
"]",
"iobj",
"=",
"spi",
".",
"NearestNDInterpolator",
"... | Extract values at certain points in the grid from a given parameter
set. Cells are selected by interpolating the centroids of the cells
towards the line using a "nearest" scheme.
Note that data is only returned for the points provided. If you want to
extract multiple data points along a... | [
"Extract",
"values",
"at",
"certain",
"points",
"in",
"the",
"grid",
"from",
"a",
"given",
"parameter",
"set",
".",
"Cells",
"are",
"selected",
"by",
"interpolating",
"the",
"centroids",
"of",
"the",
"cells",
"towards",
"the",
"line",
"using",
"a",
"nearest"... | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L373-L399 | train | Extract values at certain points in a given parameter set. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.extract_along_line | def extract_along_line(self, pid, xy0, xy1, N=10):
"""Extract parameter values along a given line.
Parameters
----------
pid: int
The parameter id to extract values from
xy0: tuple
A tupe with (x,y) start point coordinates
xy1: tuple
A... | python | def extract_along_line(self, pid, xy0, xy1, N=10):
"""Extract parameter values along a given line.
Parameters
----------
pid: int
The parameter id to extract values from
xy0: tuple
A tupe with (x,y) start point coordinates
xy1: tuple
A... | [
"def",
"extract_along_line",
"(",
"self",
",",
"pid",
",",
"xy0",
",",
"xy1",
",",
"N",
"=",
"10",
")",
":",
"assert",
"N",
">=",
"2",
"xy0",
"=",
"np",
".",
"array",
"(",
"xy0",
")",
".",
"squeeze",
"(",
")",
"xy1",
"=",
"np",
".",
"array",
... | Extract parameter values along a given line.
Parameters
----------
pid: int
The parameter id to extract values from
xy0: tuple
A tupe with (x,y) start point coordinates
xy1: tuple
A tupe with (x,y) end point coordinates
N: integer, opt... | [
"Extract",
"parameter",
"values",
"along",
"a",
"given",
"line",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L401-L437 | train | Extract parameter values along a given line. |
geophysics-ubonn/crtomo_tools | lib/crtomo/parManager.py | ParMan.extract_polygon_area | def extract_polygon_area(self, pid, polygon_points):
"""Extract all data points whose element centroid lies within the given
polygon.
Parameters
----------
Returns
-------
"""
polygon = shapgeo.Polygon(polygon_points)
xy = self.grid.get_element_c... | python | def extract_polygon_area(self, pid, polygon_points):
"""Extract all data points whose element centroid lies within the given
polygon.
Parameters
----------
Returns
-------
"""
polygon = shapgeo.Polygon(polygon_points)
xy = self.grid.get_element_c... | [
"def",
"extract_polygon_area",
"(",
"self",
",",
"pid",
",",
"polygon_points",
")",
":",
"polygon",
"=",
"shapgeo",
".",
"Polygon",
"(",
"polygon_points",
")",
"xy",
"=",
"self",
".",
"grid",
".",
"get_element_centroids",
"(",
")",
"in_poly",
"=",
"[",
"]"... | Extract all data points whose element centroid lies within the given
polygon.
Parameters
----------
Returns
------- | [
"Extract",
"all",
"data",
"points",
"whose",
"element",
"centroid",
"lies",
"within",
"the",
"given",
"polygon",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/parManager.py#L439-L457 | train | Extract all data points whose element centroid lies within the given polygon. |
geophysics-ubonn/crtomo_tools | src/grid_homogenize.py | rotate_point | def rotate_point(xorigin, yorigin, x, y, angle):
"""Rotate the given point by angle
"""
rotx = (x - xorigin) * np.cos(angle) - (y - yorigin) * np.sin(angle)
roty = (x - yorigin) * np.sin(angle) + (y - yorigin) * np.cos(angle)
return rotx, roty | python | def rotate_point(xorigin, yorigin, x, y, angle):
"""Rotate the given point by angle
"""
rotx = (x - xorigin) * np.cos(angle) - (y - yorigin) * np.sin(angle)
roty = (x - yorigin) * np.sin(angle) + (y - yorigin) * np.cos(angle)
return rotx, roty | [
"def",
"rotate_point",
"(",
"xorigin",
",",
"yorigin",
",",
"x",
",",
"y",
",",
"angle",
")",
":",
"rotx",
"=",
"(",
"x",
"-",
"xorigin",
")",
"*",
"np",
".",
"cos",
"(",
"angle",
")",
"-",
"(",
"y",
"-",
"yorigin",
")",
"*",
"np",
".",
"sin"... | Rotate the given point by angle | [
"Rotate",
"the",
"given",
"point",
"by",
"angle"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_homogenize.py#L96-L101 | train | Rotate the given point by angle |
geophysics-ubonn/crtomo_tools | src/grid_homogenize.py | homogenize_grid | def homogenize_grid(grid_old, dx, dy):
"""
1) fit line through electrodes
2) rotate electrodes so that line lies in the horizontal plane
3) translate z-coordinates so that all z-coordinates are negative
"""
# 1 line fit
x = grid_old.electrodes[:, 0]
y = grid_old.electrodes[:, 1]
sor... | python | def homogenize_grid(grid_old, dx, dy):
"""
1) fit line through electrodes
2) rotate electrodes so that line lies in the horizontal plane
3) translate z-coordinates so that all z-coordinates are negative
"""
# 1 line fit
x = grid_old.electrodes[:, 0]
y = grid_old.electrodes[:, 1]
sor... | [
"def",
"homogenize_grid",
"(",
"grid_old",
",",
"dx",
",",
"dy",
")",
":",
"# 1 line fit",
"x",
"=",
"grid_old",
".",
"electrodes",
"[",
":",
",",
"0",
"]",
"y",
"=",
"grid_old",
".",
"electrodes",
"[",
":",
",",
"1",
"]",
"sort_indices",
"=",
"np",
... | 1) fit line through electrodes
2) rotate electrodes so that line lies in the horizontal plane
3) translate z-coordinates so that all z-coordinates are negative | [
"1",
")",
"fit",
"line",
"through",
"electrodes",
"2",
")",
"rotate",
"electrodes",
"so",
"that",
"line",
"lies",
"in",
"the",
"horizontal",
"plane",
"3",
")",
"translate",
"z",
"-",
"coordinates",
"so",
"that",
"all",
"z",
"-",
"coordinates",
"are",
"ne... | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_homogenize.py#L104-L314 | train | homogenize the grid by homogenizing the electrodes |
geophysics-ubonn/crtomo_tools | src/cr_get_modelling_errors.py | get_R_mod | def get_R_mod(options, rho0):
"""Compute synthetic measurements over a homogeneous half-space
"""
tomodir = tdManager.tdMan(
elem_file=options.elem_file,
elec_file=options.elec_file,
config_file=options.config_file,
)
# set model
tomodir.add_homogeneous_model(magnitude=r... | python | def get_R_mod(options, rho0):
"""Compute synthetic measurements over a homogeneous half-space
"""
tomodir = tdManager.tdMan(
elem_file=options.elem_file,
elec_file=options.elec_file,
config_file=options.config_file,
)
# set model
tomodir.add_homogeneous_model(magnitude=r... | [
"def",
"get_R_mod",
"(",
"options",
",",
"rho0",
")",
":",
"tomodir",
"=",
"tdManager",
".",
"tdMan",
"(",
"elem_file",
"=",
"options",
".",
"elem_file",
",",
"elec_file",
"=",
"options",
".",
"elec_file",
",",
"config_file",
"=",
"options",
".",
"config_f... | Compute synthetic measurements over a homogeneous half-space | [
"Compute",
"synthetic",
"measurements",
"over",
"a",
"homogeneous",
"half",
"-",
"space"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_get_modelling_errors.py#L110-L125 | train | Compute synthetic measurements over a homogeneous half - space
|
geophysics-ubonn/crtomo_tools | lib/crtomo/plotManager.py | converter_pm_log10 | def converter_pm_log10(data):
"""Convert the given data to:
log10(subdata) for subdata > 0
log10(-subdata') for subdata' < 0
0 for subdata'' == 0
Parameters
----------
data: array
input data
Returns
-------
array_converted: array
converted data
... | python | def converter_pm_log10(data):
"""Convert the given data to:
log10(subdata) for subdata > 0
log10(-subdata') for subdata' < 0
0 for subdata'' == 0
Parameters
----------
data: array
input data
Returns
-------
array_converted: array
converted data
... | [
"def",
"converter_pm_log10",
"(",
"data",
")",
":",
"# indices_zero = np.where(data == 0)",
"indices_gt_zero",
"=",
"np",
".",
"where",
"(",
"data",
">",
"0",
")",
"indices_lt_zero",
"=",
"np",
".",
"where",
"(",
"data",
"<",
"0",
")",
"data_converted",
"=",
... | Convert the given data to:
log10(subdata) for subdata > 0
log10(-subdata') for subdata' < 0
0 for subdata'' == 0
Parameters
----------
data: array
input data
Returns
-------
array_converted: array
converted data | [
"Convert",
"the",
"given",
"data",
"to",
":"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/plotManager.py#L501-L526 | train | Convert the given data to array
log10 |
geophysics-ubonn/crtomo_tools | lib/crtomo/plotManager.py | plotManager.plot_nodes_pcolor_to_ax | def plot_nodes_pcolor_to_ax(self, ax, nid, **kwargs):
"""Plot node data to an axes object
Parameters
----------
ax : axes object
axes to plot to
nid : int
node id pointing to the respective data set
cmap : string, optional
color map to... | python | def plot_nodes_pcolor_to_ax(self, ax, nid, **kwargs):
"""Plot node data to an axes object
Parameters
----------
ax : axes object
axes to plot to
nid : int
node id pointing to the respective data set
cmap : string, optional
color map to... | [
"def",
"plot_nodes_pcolor_to_ax",
"(",
"self",
",",
"ax",
",",
"nid",
",",
"*",
"*",
"kwargs",
")",
":",
"fig",
"=",
"ax",
".",
"get_figure",
"(",
")",
"x",
"=",
"self",
".",
"grid",
".",
"nodes",
"[",
"'presort'",
"]",
"[",
":",
",",
"1",
"]",
... | Plot node data to an axes object
Parameters
----------
ax : axes object
axes to plot to
nid : int
node id pointing to the respective data set
cmap : string, optional
color map to use. Default: jet
vmin : float, optional
Min... | [
"Plot",
"node",
"data",
"to",
"an",
"axes",
"object"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/plotManager.py#L63-L152 | train | Plot node data to an axes object. |
geophysics-ubonn/crtomo_tools | lib/crtomo/plotManager.py | plotManager.plot_nodes_contour_to_ax | def plot_nodes_contour_to_ax(self, ax, nid, **kwargs):
"""Plot node data to an axes object
Parameters
----------
ax : axes object
axes to plot to
nid : int
node id pointing to the respective data set
cmap : string, optional
color map t... | python | def plot_nodes_contour_to_ax(self, ax, nid, **kwargs):
"""Plot node data to an axes object
Parameters
----------
ax : axes object
axes to plot to
nid : int
node id pointing to the respective data set
cmap : string, optional
color map t... | [
"def",
"plot_nodes_contour_to_ax",
"(",
"self",
",",
"ax",
",",
"nid",
",",
"*",
"*",
"kwargs",
")",
":",
"x",
"=",
"self",
".",
"grid",
".",
"nodes",
"[",
"'presort'",
"]",
"[",
":",
",",
"1",
"]",
"z",
"=",
"self",
".",
"grid",
".",
"nodes",
... | Plot node data to an axes object
Parameters
----------
ax : axes object
axes to plot to
nid : int
node id pointing to the respective data set
cmap : string, optional
color map to use. Default: jet
vmin : float, optional
Min... | [
"Plot",
"node",
"data",
"to",
"an",
"axes",
"object"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/plotManager.py#L154-L208 | train | Plot node data to an axes object. |
geophysics-ubonn/crtomo_tools | lib/crtomo/plotManager.py | plotManager.plot_elements_to_ax | def plot_elements_to_ax(self, cid, ax=None, **kwargs):
"""Plot element data (parameter sets).
If the parameter *ax* is not set, then a new figure will be created
with a corresponding axes.
Parameters
----------
cid : int or :py:class:`numpy.ndarray`
if *cid... | python | def plot_elements_to_ax(self, cid, ax=None, **kwargs):
"""Plot element data (parameter sets).
If the parameter *ax* is not set, then a new figure will be created
with a corresponding axes.
Parameters
----------
cid : int or :py:class:`numpy.ndarray`
if *cid... | [
"def",
"plot_elements_to_ax",
"(",
"self",
",",
"cid",
",",
"ax",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"rasterize",
"=",
"kwargs",
".",
"get",
"(",
"'rasterize'",
",",
"False",
")",
"xmin",
"=",
"kwargs",
".",
"get",
"(",
"'xmin'",
",",
... | Plot element data (parameter sets).
If the parameter *ax* is not set, then a new figure will be created
with a corresponding axes.
Parameters
----------
cid : int or :py:class:`numpy.ndarray`
if *cid* is an int, then treat it as the id of the parameter set
... | [
"Plot",
"element",
"data",
"(",
"parameter",
"sets",
")",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/plotManager.py#L290-L498 | train | Plot the elements of the given set of elements. |
rhayes777/PyAutoFit | autofit/tools/path_util.py | make_and_return_path_from_path_and_folder_names | def make_and_return_path_from_path_and_folder_names(path, folder_names):
""" For a given path, create a directory structure composed of a set of folders and return the path to the \
inner-most folder.
For example, if path='/path/to/folders', and folder_names=['folder1', 'folder2'], the directory created wi... | python | def make_and_return_path_from_path_and_folder_names(path, folder_names):
""" For a given path, create a directory structure composed of a set of folders and return the path to the \
inner-most folder.
For example, if path='/path/to/folders', and folder_names=['folder1', 'folder2'], the directory created wi... | [
"def",
"make_and_return_path_from_path_and_folder_names",
"(",
"path",
",",
"folder_names",
")",
":",
"for",
"folder_name",
"in",
"folder_names",
":",
"path",
"+=",
"folder_name",
"+",
"'/'",
"try",
":",
"os",
".",
"makedirs",
"(",
"path",
")",
"except",
"FileEx... | For a given path, create a directory structure composed of a set of folders and return the path to the \
inner-most folder.
For example, if path='/path/to/folders', and folder_names=['folder1', 'folder2'], the directory created will be
'/path/to/folders/folder1/folder2/' and the returned path will be '/pat... | [
"For",
"a",
"given",
"path",
"create",
"a",
"directory",
"structure",
"composed",
"of",
"a",
"set",
"of",
"folders",
"and",
"return",
"the",
"path",
"to",
"the",
"\\",
"inner",
"-",
"most",
"folder",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/path_util.py#L42-L77 | train | This function creates a directory structure from a set of folder names and returns the path to the inner - most folder. |
redhat-openstack/python-tripleo-helper | tripleohelper/ovb_bmc.py | OvbBmc.register_host | def register_host(self, bm_instance):
"""Register an existing nova VM.
A new interface will be attached to the BMC host with a new IP. An openstackbmc
service will be binded to this IP.
Once the VM has been registered, it is possible to use IPMI on this IP
to start or stop the ... | python | def register_host(self, bm_instance):
"""Register an existing nova VM.
A new interface will be attached to the BMC host with a new IP. An openstackbmc
service will be binded to this IP.
Once the VM has been registered, it is possible to use IPMI on this IP
to start or stop the ... | [
"def",
"register_host",
"(",
"self",
",",
"bm_instance",
")",
":",
"bmc_ip",
"=",
"'10.130.%d.100'",
"%",
"(",
"self",
".",
"_bmc_range_start",
"+",
"self",
".",
"_nic_cpt",
")",
"bmc_net",
"=",
"'10.130.%d.0'",
"%",
"(",
"self",
".",
"_bmc_range_start",
"+"... | Register an existing nova VM.
A new interface will be attached to the BMC host with a new IP. An openstackbmc
service will be binded to this IP.
Once the VM has been registered, it is possible to use IPMI on this IP
to start or stop the virtual machine. | [
"Register",
"an",
"existing",
"nova",
"VM",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_bmc.py#L116-L189 | train | Register an existing nova VM with the BMC host. |
gofed/gofedlib | gofedlib/go/snapshot.py | Snapshot.Godeps | def Godeps(self):
"""Return the snapshot in Godeps.json form
"""
dict = []
for package in sorted(self._packages.keys()):
dict.append({
"ImportPath": str(package),
"Rev": str(self._packages[package])
})
return dict | python | def Godeps(self):
"""Return the snapshot in Godeps.json form
"""
dict = []
for package in sorted(self._packages.keys()):
dict.append({
"ImportPath": str(package),
"Rev": str(self._packages[package])
})
return dict | [
"def",
"Godeps",
"(",
"self",
")",
":",
"dict",
"=",
"[",
"]",
"for",
"package",
"in",
"sorted",
"(",
"self",
".",
"_packages",
".",
"keys",
"(",
")",
")",
":",
"dict",
".",
"append",
"(",
"{",
"\"ImportPath\"",
":",
"str",
"(",
"package",
")",
"... | Return the snapshot in Godeps.json form | [
"Return",
"the",
"snapshot",
"in",
"Godeps",
".",
"json",
"form"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/snapshot.py#L47-L57 | train | Return the snapshot in Godeps. json form
|
gofed/gofedlib | gofedlib/go/snapshot.py | Snapshot.GLOGFILE | def GLOGFILE(self):
"""Return the snapshot in GLOGFILE form
"""
lines = []
for package in sorted(self._packages.keys()):
lines.append("%s %s" % (str(package), str(self._packages[package])))
return "\n".join(lines) | python | def GLOGFILE(self):
"""Return the snapshot in GLOGFILE form
"""
lines = []
for package in sorted(self._packages.keys()):
lines.append("%s %s" % (str(package), str(self._packages[package])))
return "\n".join(lines) | [
"def",
"GLOGFILE",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"package",
"in",
"sorted",
"(",
"self",
".",
"_packages",
".",
"keys",
"(",
")",
")",
":",
"lines",
".",
"append",
"(",
"\"%s %s\"",
"%",
"(",
"str",
"(",
"package",
")",
",... | Return the snapshot in GLOGFILE form | [
"Return",
"the",
"snapshot",
"in",
"GLOGFILE",
"form"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/snapshot.py#L59-L66 | train | Return the snapshot in GLOGFILE form
|
gofed/gofedlib | gofedlib/go/snapshot.py | Snapshot.Glide | def Glide(self):
"""Return the snapshot in glide.lock form
"""
dict = {
"hash": "???",
"updated": str(datetime.datetime.now(tz=pytz.utc).isoformat()),
"imports": [],
}
decomposer = ImportPathsDecomposerBuilder().buildLocalDecomposer()
... | python | def Glide(self):
"""Return the snapshot in glide.lock form
"""
dict = {
"hash": "???",
"updated": str(datetime.datetime.now(tz=pytz.utc).isoformat()),
"imports": [],
}
decomposer = ImportPathsDecomposerBuilder().buildLocalDecomposer()
... | [
"def",
"Glide",
"(",
"self",
")",
":",
"dict",
"=",
"{",
"\"hash\"",
":",
"\"???\"",
",",
"\"updated\"",
":",
"str",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
"tz",
"=",
"pytz",
".",
"utc",
")",
".",
"isoformat",
"(",
")",
")",
",",
"\"i... | Return the snapshot in glide.lock form | [
"Return",
"the",
"snapshot",
"in",
"glide",
".",
"lock",
"form"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/snapshot.py#L68-L91 | train | Return the snapshot in glide. lock form
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.