repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
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
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", "==", "0", ...
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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", ")", ":", "for", "i", "in", "range", "(", "0", ",", "size", ")", ":", "self", ".", "nodes", ".", "append", "(", "Baremetal", "(", "self", ".", "nova_api", ",", "self", ".", "neutron", ",", ...
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
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
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", ")", ":", "parent_stack", "=", "[", "]", "for", "event", ",", "element", "in", "iterparse", "(", "untl_filename", ",", "events", "=", "(", "'start'", ",", "'end'", ")", ")", ":", "if", "NAMESPACE_REGEX", ".", "s...
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
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", ")", ":", "untl_root", "=", "PYUNTL_DISPATCH", "[", "'metadata'", "]", "(", ")", "untl_py_list", "=", "[", "]", "for", "element_name", ",", "element_list", "in", "untl_dict", ".", "items", "(", ")", ":", "for", "elem...
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
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", "=", "{", "}", "form_post", "=", "dict", "(", "post", ".", "copy", "(", ")", ")", "for", "key", ...
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
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
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'", ",", "False", ...
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
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", "=", "kwar...
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
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", "=", "[", "]", "for", "element", "in", "element_list", ":", "new_element_list", ".", "append", "(", "...
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
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", ")", ":", "root_namespace", "=", "'{%s}'", "%", "DC_NAMESPACES", "[", "'oai_dc'", "]", "elements_namespace", "=", "'{%s}'", "%", "DC_NAMESPACES", "[", "'dc'", "]", "schema_location", "=", "(", "'http://www.openarchives.org/O...
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
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
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", "=", "{", "}", "for", "element", "in", "highwire_elements", ":", "if", "element", ".", "name", "not", "in", "highwire_dict", ":", "highwire_dict", "[", "element", ".", "name", "]", ...
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
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
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", "(", "''", ")", "rdf_py", "=", "ConjunctiveGraph", "(", ")", "DC", "=", "Namespace", "(", "'http://purl.org/dc/elements/1.1/'", ")", "for", "element_value", ...
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
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", ")", ":", "for", "element", "in", "UNTL_XML_ORDER", ":", "if", "element", "not", "in", "untl_dict", ":", "try", ":", "py_object", "=", "PYUNTL_DISPATCH", "[", "element", "]", "(", "content", "=", "''", ",", "qua...
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
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", ")", ":", "for", "element", "in", "ETD_MS_ORDER", ":", "if", "element", "not", "in", "etd_ms_dict", ":", "try", ":", "py_object", "=", "ETD_MS_CONVERSION_DISPATCH", "[", "element", "]", "(", "content", "=", ...
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
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", "=", "{", "}", "for", "element_name", "in", "REQUIRES_QUALIFIER", ":", "for", "element"...
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
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", "etd_ms_root", "=", "ETD_MS_CONVERSION_DISPATCH", "[", "'thesis'", "]", "(", ")", "for", ...
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
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
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
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", ")", ":", "if", "cls", ".", "signature", "is", "NotImplemented", ":", "raise", "NotImplementedError", "(", "\"no signature defined\"", ")", "up", "=", "cls", ".", "cutter", ".", "elucidate", "(", ")", "down", "=", "str", "("...
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
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
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
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
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
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
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
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
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
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", ")", ":", "login", "=", "rhsm", ".", "get", "(", "'login'", ")", "password", "=", "rhsm", ".", "get", "(", "'password'", ",", "os", ".", "environ", ".", "get", "(", "'RHN_PW'", ")", ")", "pool_id", ...
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
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
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
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
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
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
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", "(", "star...
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
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_timestamp'...
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
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", ")", "if", "subdata", ".", "shape", "[", "1", "]", "!=", "self", ".", "grid", ".", "nr_of_elements", ":", "if...
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
thiagopbueno/tf-rddlsim
tfrddlsim/viz/navigation_visualizer.py
NavigationVisualizer.render
def render(self, trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array], batch: Optional[int] = None) -> None: '''Render the simulated state-action `trajectories` for Navigation domain. Args: stats: Performance statistics. trajectories: NonF...
python
def render(self, trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array], batch: Optional[int] = None) -> None: '''Render the simulated state-action `trajectories` for Navigation domain. Args: stats: Performance statistics. trajectories: NonF...
[ "def", "render", "(", "self", ",", "trajectories", ":", "Tuple", "[", "NonFluents", ",", "Fluents", ",", "Fluents", ",", "Fluents", ",", "np", ".", "array", "]", ",", "batch", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "...
Render the simulated state-action `trajectories` for Navigation domain. Args: stats: Performance statistics. trajectories: NonFluents, states, actions, interms and rewards. batch: Number of batches to render.
[ "Render", "the", "simulated", "state", "-", "action", "trajectories", "for", "Navigation", "domain", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/navigation_visualizer.py#L44-L82
train
rhayes777/PyAutoFit
autofit/optimize/non_linear.py
persistent_timer
def persistent_timer(func): """ Times the execution of a function. If the process is stopped and restarted then timing is continued using saved files. Parameters ---------- func Some function to be timed Returns ------- timed_function The same function with a timer ...
python
def persistent_timer(func): """ Times the execution of a function. If the process is stopped and restarted then timing is continued using saved files. Parameters ---------- func Some function to be timed Returns ------- timed_function The same function with a timer ...
[ "def", "persistent_timer", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "timed_function", "(", "optimizer_instance", ",", "*", "args", ",", "**", "kwargs", ")", ":", "start_time_path", "=", "\"{}/.start_time\"", ".", "forma...
Times the execution of a function. If the process is stopped and restarted then timing is continued using saved files. Parameters ---------- func Some function to be timed Returns ------- timed_function The same function with a timer attached.
[ "Times", "the", "execution", "of", "a", "function", ".", "If", "the", "process", "is", "stopped", "and", "restarted", "then", "timing", "is", "continued", "using", "saved", "files", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L110-L149
train
rhayes777/PyAutoFit
autofit/optimize/non_linear.py
NonLinearOptimizer.backup_path
def backup_path(self) -> str: """ The path to the backed up optimizer folder. """ return "{}/{}/{}{}/optimizer_backup".format(conf.instance.output_path, self.phase_path, self.phase_name, self.phase_tag)
python
def backup_path(self) -> str: """ The path to the backed up optimizer folder. """ return "{}/{}/{}{}/optimizer_backup".format(conf.instance.output_path, self.phase_path, self.phase_name, self.phase_tag)
[ "def", "backup_path", "(", "self", ")", "->", "str", ":", "return", "\"{}/{}/{}{}/optimizer_backup\"", ".", "format", "(", "conf", ".", "instance", ".", "output_path", ",", "self", ".", "phase_path", ",", "self", ".", "phase_name", ",", "self", ".", "phase_t...
The path to the backed up optimizer folder.
[ "The", "path", "to", "the", "backed", "up", "optimizer", "folder", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L213-L218
train
rhayes777/PyAutoFit
autofit/optimize/non_linear.py
NonLinearOptimizer.backup
def backup(self): """ Copy files from the sym-linked optimizer folder to the backup folder in the workspace. """ try: shutil.rmtree(self.backup_path) except FileNotFoundError: pass try: shutil.copytree(self.opt_path, self.backup_path) ...
python
def backup(self): """ Copy files from the sym-linked optimizer folder to the backup folder in the workspace. """ try: shutil.rmtree(self.backup_path) except FileNotFoundError: pass try: shutil.copytree(self.opt_path, self.backup_path) ...
[ "def", "backup", "(", "self", ")", ":", "try", ":", "shutil", ".", "rmtree", "(", "self", ".", "backup_path", ")", "except", "FileNotFoundError", ":", "pass", "try", ":", "shutil", ".", "copytree", "(", "self", ".", "opt_path", ",", "self", ".", "backu...
Copy files from the sym-linked optimizer folder to the backup folder in the workspace.
[ "Copy", "files", "from", "the", "sym", "-", "linked", "optimizer", "folder", "to", "the", "backup", "folder", "in", "the", "workspace", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L256-L267
train
rhayes777/PyAutoFit
autofit/optimize/non_linear.py
NonLinearOptimizer.restore
def restore(self): """ Copy files from the backup folder to the sym-linked optimizer folder. """ if os.path.exists(self.backup_path): for file in glob.glob(self.backup_path + "/*"): shutil.copy(file, self.path)
python
def restore(self): """ Copy files from the backup folder to the sym-linked optimizer folder. """ if os.path.exists(self.backup_path): for file in glob.glob(self.backup_path + "/*"): shutil.copy(file, self.path)
[ "def", "restore", "(", "self", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "backup_path", ")", ":", "for", "file", "in", "glob", ".", "glob", "(", "self", ".", "backup_path", "+", "\"/*\"", ")", ":", "shutil", ".", "copy", ...
Copy files from the backup folder to the sym-linked optimizer folder.
[ "Copy", "files", "from", "the", "backup", "folder", "to", "the", "sym", "-", "linked", "optimizer", "folder", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L269-L275
train
rhayes777/PyAutoFit
autofit/optimize/non_linear.py
NonLinearOptimizer.config
def config(self, attribute_name, attribute_type=str): """ Get a config field from this optimizer's section in non_linear.ini by a key and value type. Parameters ---------- attribute_name: str The analysis_path of the field attribute_type: type The...
python
def config(self, attribute_name, attribute_type=str): """ Get a config field from this optimizer's section in non_linear.ini by a key and value type. Parameters ---------- attribute_name: str The analysis_path of the field attribute_type: type The...
[ "def", "config", "(", "self", ",", "attribute_name", ",", "attribute_type", "=", "str", ")", ":", "return", "self", ".", "named_config", ".", "get", "(", "self", ".", "__class__", ".", "__name__", ",", "attribute_name", ",", "attribute_type", ")" ]
Get a config field from this optimizer's section in non_linear.ini by a key and value type. Parameters ---------- attribute_name: str The analysis_path of the field attribute_type: type The type of the value Returns ------- attribute ...
[ "Get", "a", "config", "field", "from", "this", "optimizer", "s", "section", "in", "non_linear", ".", "ini", "by", "a", "key", "and", "value", "type", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L277-L293
train
rhayes777/PyAutoFit
autofit/optimize/non_linear.py
MultiNest.weighted_sample_instance_from_weighted_samples
def weighted_sample_instance_from_weighted_samples(self, index): """Setup a model instance of a weighted sample, including its weight and likelihood. Parameters ----------- index : int The index of the weighted sample to return. """ model, weight, likelihood ...
python
def weighted_sample_instance_from_weighted_samples(self, index): """Setup a model instance of a weighted sample, including its weight and likelihood. Parameters ----------- index : int The index of the weighted sample to return. """ model, weight, likelihood ...
[ "def", "weighted_sample_instance_from_weighted_samples", "(", "self", ",", "index", ")", ":", "model", ",", "weight", ",", "likelihood", "=", "self", ".", "weighted_sample_model_from_weighted_samples", "(", "index", ")", "self", ".", "_weighted_sample_model", "=", "mo...
Setup a model instance of a weighted sample, including its weight and likelihood. Parameters ----------- index : int The index of the weighted sample to return.
[ "Setup", "a", "model", "instance", "of", "a", "weighted", "sample", "including", "its", "weight", "and", "likelihood", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L724-L736
train
rhayes777/PyAutoFit
autofit/optimize/non_linear.py
MultiNest.weighted_sample_model_from_weighted_samples
def weighted_sample_model_from_weighted_samples(self, index): """From a weighted sample return the model, weight and likelihood hood. NOTE: GetDist reads the log likelihood from the weighted_sample.txt file (column 2), which are defined as \ -2.0*likelihood. This routine converts these back to ...
python
def weighted_sample_model_from_weighted_samples(self, index): """From a weighted sample return the model, weight and likelihood hood. NOTE: GetDist reads the log likelihood from the weighted_sample.txt file (column 2), which are defined as \ -2.0*likelihood. This routine converts these back to ...
[ "def", "weighted_sample_model_from_weighted_samples", "(", "self", ",", "index", ")", ":", "return", "list", "(", "self", ".", "pdf", ".", "samples", "[", "index", "]", ")", ",", "self", ".", "pdf", ".", "weights", "[", "index", "]", ",", "-", "0.5", "...
From a weighted sample return the model, weight and likelihood hood. NOTE: GetDist reads the log likelihood from the weighted_sample.txt file (column 2), which are defined as \ -2.0*likelihood. This routine converts these back to likelihood. Parameters ----------- index : int ...
[ "From", "a", "weighted", "sample", "return", "the", "model", "weight", "and", "likelihood", "hood", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L738-L749
train
Riminder/python-riminder-api
riminder/hmacutils.py
compare_digest
def compare_digest(a, b): """Compare 2 hash digest.""" py_version = sys.version_info[0] if py_version >= 3: return _compare_digest_py3(a, b) return _compare_digest_py2(a, b)
python
def compare_digest(a, b): """Compare 2 hash digest.""" py_version = sys.version_info[0] if py_version >= 3: return _compare_digest_py3(a, b) return _compare_digest_py2(a, b)
[ "def", "compare_digest", "(", "a", ",", "b", ")", ":", "py_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "py_version", ">=", "3", ":", "return", "_compare_digest_py3", "(", "a", ",", "b", ")", "return", "_compare_digest_py2", "(", "a", ...
Compare 2 hash digest.
[ "Compare", "2", "hash", "digest", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/hmacutils.py#L15-L20
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/generic_visualizer.py
GenericVisualizer._render_trajectories
def _render_trajectories(self, trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array]) -> None: '''Prints the first batch of simulated `trajectories`. Args: trajectories: NonFluents, states, actions, interms and rewards. ''' if self._verbose: ...
python
def _render_trajectories(self, trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array]) -> None: '''Prints the first batch of simulated `trajectories`. Args: trajectories: NonFluents, states, actions, interms and rewards. ''' if self._verbose: ...
[ "def", "_render_trajectories", "(", "self", ",", "trajectories", ":", "Tuple", "[", "NonFluents", ",", "Fluents", ",", "Fluents", ",", "Fluents", ",", "np", ".", "array", "]", ")", "->", "None", ":", "if", "self", ".", "_verbose", ":", "non_fluents", ","...
Prints the first batch of simulated `trajectories`. Args: trajectories: NonFluents, states, actions, interms and rewards.
[ "Prints", "the", "first", "batch", "of", "simulated", "trajectories", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L50-L65
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/generic_visualizer.py
GenericVisualizer._render_batch
def _render_batch(self, non_fluents: NonFluents, states: Fluents, actions: Fluents, interms: Fluents, rewards: np.array, horizon: Optional[int] = None) -> None: '''Prints `non_fluents`, `states`, `actions`, `interms` and `rewards` for given `horizon`. ...
python
def _render_batch(self, non_fluents: NonFluents, states: Fluents, actions: Fluents, interms: Fluents, rewards: np.array, horizon: Optional[int] = None) -> None: '''Prints `non_fluents`, `states`, `actions`, `interms` and `rewards` for given `horizon`. ...
[ "def", "_render_batch", "(", "self", ",", "non_fluents", ":", "NonFluents", ",", "states", ":", "Fluents", ",", "actions", ":", "Fluents", ",", "interms", ":", "Fluents", ",", "rewards", ":", "np", ".", "array", ",", "horizon", ":", "Optional", "[", "int...
Prints `non_fluents`, `states`, `actions`, `interms` and `rewards` for given `horizon`. Args: states (Sequence[Tuple[str, np.array]]): A state trajectory. actions (Sequence[Tuple[str, np.array]]): An action trajectory. interms (Sequence[Tuple[str, np.array]]): An int...
[ "Prints", "non_fluents", "states", "actions", "interms", "and", "rewards", "for", "given", "horizon", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L67-L91
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/generic_visualizer.py
GenericVisualizer._render_timestep
def _render_timestep(self, t: int, s: Fluents, a: Fluents, f: Fluents, r: np.float32) -> None: '''Prints fluents and rewards for the given timestep `t`. Args: t (int): timestep s (Sequence[Tuple[str], np.array]: State fluents. a (S...
python
def _render_timestep(self, t: int, s: Fluents, a: Fluents, f: Fluents, r: np.float32) -> None: '''Prints fluents and rewards for the given timestep `t`. Args: t (int): timestep s (Sequence[Tuple[str], np.array]: State fluents. a (S...
[ "def", "_render_timestep", "(", "self", ",", "t", ":", "int", ",", "s", ":", "Fluents", ",", "a", ":", "Fluents", ",", "f", ":", "Fluents", ",", "r", ":", "np", ".", "float32", ")", "->", "None", ":", "print", "(", "\"============================\"", ...
Prints fluents and rewards for the given timestep `t`. Args: t (int): timestep s (Sequence[Tuple[str], np.array]: State fluents. a (Sequence[Tuple[str], np.array]: Action fluents. f (Sequence[Tuple[str], np.array]: Interm state fluents. r (np.float32)...
[ "Prints", "fluents", "and", "rewards", "for", "the", "given", "timestep", "t", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L93-L115
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/generic_visualizer.py
GenericVisualizer._render_fluent_timestep
def _render_fluent_timestep(self, fluent_type: str, fluents: Sequence[Tuple[str, np.array]], fluent_variables: Sequence[Tuple[str, List[str]]]) -> None: '''Prints `fluents` of given `fluent_type` as list of instantiated variables with corresponding values. Ar...
python
def _render_fluent_timestep(self, fluent_type: str, fluents: Sequence[Tuple[str, np.array]], fluent_variables: Sequence[Tuple[str, List[str]]]) -> None: '''Prints `fluents` of given `fluent_type` as list of instantiated variables with corresponding values. Ar...
[ "def", "_render_fluent_timestep", "(", "self", ",", "fluent_type", ":", "str", ",", "fluents", ":", "Sequence", "[", "Tuple", "[", "str", ",", "np", ".", "array", "]", "]", ",", "fluent_variables", ":", "Sequence", "[", "Tuple", "[", "str", ",", "List", ...
Prints `fluents` of given `fluent_type` as list of instantiated variables with corresponding values. Args: fluent_type (str): Fluent type. fluents (Sequence[Tuple[str, np.array]]): List of pairs (fluent_name, fluent_values). fluent_variables (Sequence[Tuple[str, List...
[ "Prints", "fluents", "of", "given", "fluent_type", "as", "list", "of", "instantiated", "variables", "with", "corresponding", "values", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L117-L136
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/generic_visualizer.py
GenericVisualizer._render_reward
def _render_reward(self, r: np.float32) -> None: '''Prints reward `r`.''' print("reward = {:.4f}".format(float(r))) print()
python
def _render_reward(self, r: np.float32) -> None: '''Prints reward `r`.''' print("reward = {:.4f}".format(float(r))) print()
[ "def", "_render_reward", "(", "self", ",", "r", ":", "np", ".", "float32", ")", "->", "None", ":", "print", "(", "\"reward = {:.4f}\"", ".", "format", "(", "float", "(", "r", ")", ")", ")", "print", "(", ")" ]
Prints reward `r`.
[ "Prints", "reward", "r", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L138-L141
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/generic_visualizer.py
GenericVisualizer._render_round_init
def _render_round_init(self, horizon: int, non_fluents: NonFluents) -> None: '''Prints round init information about `horizon` and `non_fluents`.''' print('*********************************************************') print('>>> ROUND INIT, horizon = {}'.format(horizon)) print('************...
python
def _render_round_init(self, horizon: int, non_fluents: NonFluents) -> None: '''Prints round init information about `horizon` and `non_fluents`.''' print('*********************************************************') print('>>> ROUND INIT, horizon = {}'.format(horizon)) print('************...
[ "def", "_render_round_init", "(", "self", ",", "horizon", ":", "int", ",", "non_fluents", ":", "NonFluents", ")", "->", "None", ":", "print", "(", "'*********************************************************'", ")", "print", "(", "'>>> ROUND INIT, horizon = {}'", ".", ...
Prints round init information about `horizon` and `non_fluents`.
[ "Prints", "round", "init", "information", "about", "horizon", "and", "non_fluents", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L143-L149
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/generic_visualizer.py
GenericVisualizer._render_round_end
def _render_round_end(self, rewards: np.array) -> None: '''Prints round end information about `rewards`.''' print("*********************************************************") print(">>> ROUND END") print("*********************************************************") total_reward = ...
python
def _render_round_end(self, rewards: np.array) -> None: '''Prints round end information about `rewards`.''' print("*********************************************************") print(">>> ROUND END") print("*********************************************************") total_reward = ...
[ "def", "_render_round_end", "(", "self", ",", "rewards", ":", "np", ".", "array", ")", "->", "None", ":", "print", "(", "\"*********************************************************\"", ")", "print", "(", "\">>> ROUND END\"", ")", "print", "(", "\"*********************...
Prints round end information about `rewards`.
[ "Prints", "round", "end", "information", "about", "rewards", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L151-L159
train
edx/edx-celeryutils
celery_utils/persist_on_failure.py
_truncate_to_field
def _truncate_to_field(model, field_name, value): """ Shorten data to fit in the specified model field. If the data were too big for the field, it would cause a failure to insert, so we shorten it, truncating in the middle (because valuable information often shows up at the end. """ field =...
python
def _truncate_to_field(model, field_name, value): """ Shorten data to fit in the specified model field. If the data were too big for the field, it would cause a failure to insert, so we shorten it, truncating in the middle (because valuable information often shows up at the end. """ field =...
[ "def", "_truncate_to_field", "(", "model", ",", "field_name", ",", "value", ")", ":", "field", "=", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "if", "len", "(", "value", ")", ">", "field", ".", "max_length", ":", "midpoint", "=", ...
Shorten data to fit in the specified model field. If the data were too big for the field, it would cause a failure to insert, so we shorten it, truncating in the middle (because valuable information often shows up at the end.
[ "Shorten", "data", "to", "fit", "in", "the", "specified", "model", "field", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/persist_on_failure.py#L45-L61
train
edx/edx-celeryutils
celery_utils/persist_on_failure.py
PersistOnFailureTask.on_failure
def on_failure(self, exc, task_id, args, kwargs, einfo): """ If the task fails, persist a record of the task. """ if not FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).exists(): FailedTask.objects.create( task_name=_truncate_to_field(Failed...
python
def on_failure(self, exc, task_id, args, kwargs, einfo): """ If the task fails, persist a record of the task. """ if not FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).exists(): FailedTask.objects.create( task_name=_truncate_to_field(Failed...
[ "def", "on_failure", "(", "self", ",", "exc", ",", "task_id", ",", "args", ",", "kwargs", ",", "einfo", ")", ":", "if", "not", "FailedTask", ".", "objects", ".", "filter", "(", "task_id", "=", "task_id", ",", "datetime_resolved", "=", "None", ")", ".",...
If the task fails, persist a record of the task.
[ "If", "the", "task", "fails", "persist", "a", "record", "of", "the", "task", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/persist_on_failure.py#L22-L34
train
thiagopbueno/tf-rddlsim
tfrddlsim/viz/abstract_visualizer.py
Visualizer.render
def render(self, trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array], batch: Optional[int] = None) -> None: '''Renders the simulated `trajectories` for the given `batch`. Args: trajectories: NonFluents, states, actions, interms and rewards. ...
python
def render(self, trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array], batch: Optional[int] = None) -> None: '''Renders the simulated `trajectories` for the given `batch`. Args: trajectories: NonFluents, states, actions, interms and rewards. ...
[ "def", "render", "(", "self", ",", "trajectories", ":", "Tuple", "[", "NonFluents", ",", "Fluents", ",", "Fluents", ",", "Fluents", ",", "np", ".", "array", "]", ",", "batch", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "...
Renders the simulated `trajectories` for the given `batch`. Args: trajectories: NonFluents, states, actions, interms and rewards. batch: Number of batches to render.
[ "Renders", "the", "simulated", "trajectories", "for", "the", "given", "batch", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/abstract_visualizer.py#L41-L50
train
grundprinzip/pyxplorer
pyxplorer/types.py
Column.distribution
def distribution(self, limit=1024): """ Build the distribution of distinct values """ res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(), order="__cnt DESC LIMIT %d" % limit) dist = [] cnt = self._table.size() ...
python
def distribution(self, limit=1024): """ Build the distribution of distinct values """ res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(), order="__cnt DESC LIMIT %d" % limit) dist = [] cnt = self._table.size() ...
[ "def", "distribution", "(", "self", ",", "limit", "=", "1024", ")", ":", "res", "=", "self", ".", "_qexec", "(", "\"%s, count(*) as __cnt\"", "%", "self", ".", "name", "(", ")", ",", "group", "=", "\"%s\"", "%", "self", ".", "name", "(", ")", ",", ...
Build the distribution of distinct values
[ "Build", "the", "distribution", "of", "distinct", "values" ]
34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2
https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L91-L105
train
gofed/gofedlib
gofedlib/distribution/distributionnameparser.py
DistributionNameParser.parse
def parse(self, name): """Parse distribution string :param name: distribution string, e.g. "Fedora 23" :type name: string """ name = name.strip() groups = self._parseFedora(name) if groups: self._signature = DistributionNameSignature("Fedora", groups.group(1)) return self raise ValueError("Dist...
python
def parse(self, name): """Parse distribution string :param name: distribution string, e.g. "Fedora 23" :type name: string """ name = name.strip() groups = self._parseFedora(name) if groups: self._signature = DistributionNameSignature("Fedora", groups.group(1)) return self raise ValueError("Dist...
[ "def", "parse", "(", "self", ",", "name", ")", ":", "name", "=", "name", ".", "strip", "(", ")", "groups", "=", "self", ".", "_parseFedora", "(", "name", ")", "if", "groups", ":", "self", ".", "_signature", "=", "DistributionNameSignature", "(", "\"Fed...
Parse distribution string :param name: distribution string, e.g. "Fedora 23" :type name: string
[ "Parse", "distribution", "string" ]
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/distributionnameparser.py#L52-L64
train
zalando-stups/lizzy-client
lizzy_client/token.py
get_token
def get_token(url: str, scopes: str, credentials_dir: str) -> dict: """ Get access token info. """ tokens.configure(url=url, dir=credentials_dir) tokens.manage('lizzy', [scopes]) tokens.start() return tokens.get('lizzy')
python
def get_token(url: str, scopes: str, credentials_dir: str) -> dict: """ Get access token info. """ tokens.configure(url=url, dir=credentials_dir) tokens.manage('lizzy', [scopes]) tokens.start() return tokens.get('lizzy')
[ "def", "get_token", "(", "url", ":", "str", ",", "scopes", ":", "str", ",", "credentials_dir", ":", "str", ")", "->", "dict", ":", "tokens", ".", "configure", "(", "url", "=", "url", ",", "dir", "=", "credentials_dir", ")", "tokens", ".", "manage", "...
Get access token info.
[ "Get", "access", "token", "info", "." ]
0af9733ca5a25ebd0a9dc1453f2a7592efcee56a
https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/token.py#L4-L13
train
peterbe/gg
gg/builtins/config.py
config
def config(config, fork_name="", origin_name=""): """Setting various configuration options""" state = read(config.configfile) any_set = False if fork_name: update(config.configfile, {"FORK_NAME": fork_name}) success_out("fork-name set to: {}".format(fork_name)) any_set = True ...
python
def config(config, fork_name="", origin_name=""): """Setting various configuration options""" state = read(config.configfile) any_set = False if fork_name: update(config.configfile, {"FORK_NAME": fork_name}) success_out("fork-name set to: {}".format(fork_name)) any_set = True ...
[ "def", "config", "(", "config", ",", "fork_name", "=", "\"\"", ",", "origin_name", "=", "\"\"", ")", ":", "state", "=", "read", "(", "config", ".", "configfile", ")", "any_set", "=", "False", "if", "fork_name", ":", "update", "(", "config", ".", "confi...
Setting various configuration options
[ "Setting", "various", "configuration", "options" ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/config.py#L22-L35
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.set_area_to_sip_signature
def set_area_to_sip_signature(self, xmin, xmax, zmin, zmax, spectrum): """Parameterize the eit instance by supplying one SIP spectrum and the area to apply to. Parameters ---------- xmin : float Minimum x coordinate of the area xmax : float Maximu...
python
def set_area_to_sip_signature(self, xmin, xmax, zmin, zmax, spectrum): """Parameterize the eit instance by supplying one SIP spectrum and the area to apply to. Parameters ---------- xmin : float Minimum x coordinate of the area xmax : float Maximu...
[ "def", "set_area_to_sip_signature", "(", "self", ",", "xmin", ",", "xmax", ",", "zmin", ",", "zmax", ",", "spectrum", ")", ":", "assert", "isinstance", "(", "spectrum", ",", "(", "sip_response", ",", "sip_response2", ")", ")", "assert", "np", ".", "all", ...
Parameterize the eit instance by supplying one SIP spectrum and the area to apply to. Parameters ---------- xmin : float Minimum x coordinate of the area xmax : float Maximum x coordinate of the area zmin : float Minimum z coordinate o...
[ "Parameterize", "the", "eit", "instance", "by", "supplying", "one", "SIP", "spectrum", "and", "the", "area", "to", "apply", "to", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L163-L188
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.add_homogeneous_model
def add_homogeneous_model(self, magnitude, phase=0, frequency=None): """Add homogeneous models to one or all tomodirs. Register those as forward models Parameters ---------- magnitude : float Value of homogeneous magnitude model phase : float, optional ...
python
def add_homogeneous_model(self, magnitude, phase=0, frequency=None): """Add homogeneous models to one or all tomodirs. Register those as forward models Parameters ---------- magnitude : float Value of homogeneous magnitude model phase : float, optional ...
[ "def", "add_homogeneous_model", "(", "self", ",", "magnitude", ",", "phase", "=", "0", ",", "frequency", "=", "None", ")", ":", "if", "frequency", "is", "None", ":", "frequencies", "=", "self", ".", "frequencies", "else", ":", "assert", "isinstance", "(", ...
Add homogeneous models to one or all tomodirs. Register those as forward models Parameters ---------- magnitude : float Value of homogeneous magnitude model phase : float, optional Value of homogeneous phase model. Default 0 frequency : float, opt...
[ "Add", "homogeneous", "models", "to", "one", "or", "all", "tomodirs", ".", "Register", "those", "as", "forward", "models" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L195-L218
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.apply_crtomo_cfg
def apply_crtomo_cfg(self): """Set the global crtomo_cfg for all frequencies """ for key in sorted(self.tds.keys()): self.tds[key].crtomo_cfg = self.crtomo_cfg.copy()
python
def apply_crtomo_cfg(self): """Set the global crtomo_cfg for all frequencies """ for key in sorted(self.tds.keys()): self.tds[key].crtomo_cfg = self.crtomo_cfg.copy()
[ "def", "apply_crtomo_cfg", "(", "self", ")", ":", "for", "key", "in", "sorted", "(", "self", ".", "tds", ".", "keys", "(", ")", ")", ":", "self", ".", "tds", "[", "key", "]", ".", "crtomo_cfg", "=", "self", ".", "crtomo_cfg", ".", "copy", "(", ")...
Set the global crtomo_cfg for all frequencies
[ "Set", "the", "global", "crtomo_cfg", "for", "all", "frequencies" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L273-L277
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.apply_noise_models
def apply_noise_models(self): """Set the global noise_model for all frequencies """ for key in sorted(self.tds.keys()): self.tds[key].noise_model = self.noise_model
python
def apply_noise_models(self): """Set the global noise_model for all frequencies """ for key in sorted(self.tds.keys()): self.tds[key].noise_model = self.noise_model
[ "def", "apply_noise_models", "(", "self", ")", ":", "for", "key", "in", "sorted", "(", "self", ".", "tds", ".", "keys", "(", ")", ")", ":", "self", ".", "tds", "[", "key", "]", ".", "noise_model", "=", "self", ".", "noise_model" ]
Set the global noise_model for all frequencies
[ "Set", "the", "global", "noise_model", "for", "all", "frequencies" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L279-L283
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.load_inversion_results
def load_inversion_results(self, sipdir): """Given an sEIT inversion directory, load inversion results and store the corresponding parameter ids in self.assignments Note that all previous data stored in this instance of the eitManager will be overwritten, if required! """ ...
python
def load_inversion_results(self, sipdir): """Given an sEIT inversion directory, load inversion results and store the corresponding parameter ids in self.assignments Note that all previous data stored in this instance of the eitManager will be overwritten, if required! """ ...
[ "def", "load_inversion_results", "(", "self", ",", "sipdir", ")", ":", "frequency_file", "=", "sipdir", "+", "os", ".", "sep", "+", "'frequencies.dat'", "frequencies", "=", "np", ".", "loadtxt", "(", "frequency_file", ")", "self", ".", "_init_frequencies", "("...
Given an sEIT inversion directory, load inversion results and store the corresponding parameter ids in self.assignments Note that all previous data stored in this instance of the eitManager will be overwritten, if required!
[ "Given", "an", "sEIT", "inversion", "directory", "load", "inversion", "results", "and", "store", "the", "corresponding", "parameter", "ids", "in", "self", ".", "assignments" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L305-L341
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.plot_forward_models
def plot_forward_models(self, maglim=None, phalim=None, **kwargs): """Create plots of the forward models Returns ------- mag_fig: dict Dictionary containing the figure and axes objects of the magnitude plots """ return_dict = {} N = len(...
python
def plot_forward_models(self, maglim=None, phalim=None, **kwargs): """Create plots of the forward models Returns ------- mag_fig: dict Dictionary containing the figure and axes objects of the magnitude plots """ return_dict = {} N = len(...
[ "def", "plot_forward_models", "(", "self", ",", "maglim", "=", "None", ",", "phalim", "=", "None", ",", "**", "kwargs", ")", ":", "return_dict", "=", "{", "}", "N", "=", "len", "(", "self", ".", "frequencies", ")", "nrx", "=", "min", "(", "N", ",",...
Create plots of the forward models Returns ------- mag_fig: dict Dictionary containing the figure and axes objects of the magnitude plots
[ "Create", "plots", "of", "the", "forward", "models" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L402-L460
train
geophysics-ubonn/crtomo_tools
lib/crtomo/eitManager.py
eitMan.add_to_configs
def add_to_configs(self, configs): """Add configurations to all tomodirs Parameters ---------- configs : :class:`numpy.ndarray` Nx4 numpy array with abmn configurations """ for f, td in self.tds.items(): td.configs.add_to_configs(configs)
python
def add_to_configs(self, configs): """Add configurations to all tomodirs Parameters ---------- configs : :class:`numpy.ndarray` Nx4 numpy array with abmn configurations """ for f, td in self.tds.items(): td.configs.add_to_configs(configs)
[ "def", "add_to_configs", "(", "self", ",", "configs", ")", ":", "for", "f", ",", "td", "in", "self", ".", "tds", ".", "items", "(", ")", ":", "td", ".", "configs", ".", "add_to_configs", "(", "configs", ")" ]
Add configurations to all tomodirs Parameters ---------- configs : :class:`numpy.ndarray` Nx4 numpy array with abmn configurations
[ "Add", "configurations", "to", "all", "tomodirs" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L462-L472
train