repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
pgxcentre/geneparse
geneparse/utils.py
code_minor
def code_minor(genotypes): """Encode the genotypes with respect to the minor allele. This confirms that "reference" is the major allele and that "coded" is the minor allele. In other words, this function can be used to make sure that the genotype value is the number of minor alleles for an individ...
python
def code_minor(genotypes): """Encode the genotypes with respect to the minor allele. This confirms that "reference" is the major allele and that "coded" is the minor allele. In other words, this function can be used to make sure that the genotype value is the number of minor alleles for an individ...
[ "def", "code_minor", "(", "genotypes", ")", ":", "warnings", ".", "warn", "(", "\"deprecated: use 'Genotypes.code_minor'\"", ",", "DeprecationWarning", ")", "_", ",", "minor_coded", "=", "maf", "(", "genotypes", ")", "if", "not", "minor_coded", ":", "return", "f...
Encode the genotypes with respect to the minor allele. This confirms that "reference" is the major allele and that "coded" is the minor allele. In other words, this function can be used to make sure that the genotype value is the number of minor alleles for an individual.
[ "Encode", "the", "genotypes", "with", "respect", "to", "the", "minor", "allele", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L54-L69
train
Encode the genotypes with respect to the minor allele.
pgxcentre/geneparse
geneparse/utils.py
maf
def maf(genotypes): """Computes the MAF and returns a boolean indicating if the minor allele is currently the coded allele. """ warnings.warn("deprecated: use 'Genotypes.maf'", DeprecationWarning) g = genotypes.genotypes maf = np.nansum(g) / (2 * np.sum(~np.isnan(g))) if maf > 0.5: ...
python
def maf(genotypes): """Computes the MAF and returns a boolean indicating if the minor allele is currently the coded allele. """ warnings.warn("deprecated: use 'Genotypes.maf'", DeprecationWarning) g = genotypes.genotypes maf = np.nansum(g) / (2 * np.sum(~np.isnan(g))) if maf > 0.5: ...
[ "def", "maf", "(", "genotypes", ")", ":", "warnings", ".", "warn", "(", "\"deprecated: use 'Genotypes.maf'\"", ",", "DeprecationWarning", ")", "g", "=", "genotypes", ".", "genotypes", "maf", "=", "np", ".", "nansum", "(", "g", ")", "/", "(", "2", "*", "n...
Computes the MAF and returns a boolean indicating if the minor allele is currently the coded allele.
[ "Computes", "the", "MAF", "and", "returns", "a", "boolean", "indicating", "if", "the", "minor", "allele", "is", "currently", "the", "coded", "allele", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L72-L84
train
Computes the MAF and returns a boolean indicating if the minor allele is currently the coded allele.
pgxcentre/geneparse
geneparse/utils.py
genotype_to_df
def genotype_to_df(g, samples, as_string=False): """Convert a genotype object to a pandas dataframe. By default, the encoded values are stored, but the as_string argument can be used to represent it as characters (alleles) instead. """ name = g.variant.name if g.variant.name else "genotypes" d...
python
def genotype_to_df(g, samples, as_string=False): """Convert a genotype object to a pandas dataframe. By default, the encoded values are stored, but the as_string argument can be used to represent it as characters (alleles) instead. """ name = g.variant.name if g.variant.name else "genotypes" d...
[ "def", "genotype_to_df", "(", "g", ",", "samples", ",", "as_string", "=", "False", ")", ":", "name", "=", "g", ".", "variant", ".", "name", "if", "g", ".", "variant", ".", "name", "else", "\"genotypes\"", "df", "=", "pd", ".", "DataFrame", "(", "g", ...
Convert a genotype object to a pandas dataframe. By default, the encoded values are stored, but the as_string argument can be used to represent it as characters (alleles) instead.
[ "Convert", "a", "genotype", "object", "to", "a", "pandas", "dataframe", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L133-L155
train
Convert a genotype object to a pandas dataframe.
pgxcentre/geneparse
geneparse/utils.py
compute_ld
def compute_ld(cur_geno, other_genotypes, r2=False): """Compute LD between a marker and a list of markers. Args: cur_geno (Genotypes): The genotypes of the marker. other_genotypes (list): A list of genotypes. Returns: numpy.array: An array containing the r or r**2 values between cu...
python
def compute_ld(cur_geno, other_genotypes, r2=False): """Compute LD between a marker and a list of markers. Args: cur_geno (Genotypes): The genotypes of the marker. other_genotypes (list): A list of genotypes. Returns: numpy.array: An array containing the r or r**2 values between cu...
[ "def", "compute_ld", "(", "cur_geno", ",", "other_genotypes", ",", "r2", "=", "False", ")", ":", "# Normalizing the current genotypes", "norm_cur", "=", "normalize_genotypes", "(", "cur_geno", ")", "# Normalizing and creating the matrix for the other genotypes", "norm_others"...
Compute LD between a marker and a list of markers. Args: cur_geno (Genotypes): The genotypes of the marker. other_genotypes (list): A list of genotypes. Returns: numpy.array: An array containing the r or r**2 values between cur_geno and other_genotypes. Note: ...
[ "Compute", "LD", "between", "a", "marker", "and", "a", "list", "of", "markers", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L158-L207
train
Compute the LD between a marker and a list of genotypes.
pgxcentre/geneparse
geneparse/utils.py
normalize_genotypes
def normalize_genotypes(genotypes): """Normalize the genotypes. Args: genotypes (Genotypes): The genotypes to normalize. Returns: numpy.array: The normalized genotypes. """ genotypes = genotypes.genotypes return (genotypes - np.nanmean(genotypes)) / np.nanstd(genotypes)
python
def normalize_genotypes(genotypes): """Normalize the genotypes. Args: genotypes (Genotypes): The genotypes to normalize. Returns: numpy.array: The normalized genotypes. """ genotypes = genotypes.genotypes return (genotypes - np.nanmean(genotypes)) / np.nanstd(genotypes)
[ "def", "normalize_genotypes", "(", "genotypes", ")", ":", "genotypes", "=", "genotypes", ".", "genotypes", "return", "(", "genotypes", "-", "np", ".", "nanmean", "(", "genotypes", ")", ")", "/", "np", ".", "nanstd", "(", "genotypes", ")" ]
Normalize the genotypes. Args: genotypes (Genotypes): The genotypes to normalize. Returns: numpy.array: The normalized genotypes.
[ "Normalize", "the", "genotypes", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/utils.py#L210-L221
train
Normalizes the genotypes.
geophysics-ubonn/crtomo_tools
lib/crtomo/interface.py
crmod_interface._get_tdm
def _get_tdm(self, m): """For a given model, return a tdMan instance Parameters ---------- m : ndarray Model parameters (linear, ohm m) """ m = np.atleast_2d(m) assert len(m.shape) == 2 tdm = crtomo.tdMan(grid=self.grid, tempdir=self.tempdir) ...
python
def _get_tdm(self, m): """For a given model, return a tdMan instance Parameters ---------- m : ndarray Model parameters (linear, ohm m) """ m = np.atleast_2d(m) assert len(m.shape) == 2 tdm = crtomo.tdMan(grid=self.grid, tempdir=self.tempdir) ...
[ "def", "_get_tdm", "(", "self", ",", "m", ")", ":", "m", "=", "np", ".", "atleast_2d", "(", "m", ")", "assert", "len", "(", "m", ".", "shape", ")", "==", "2", "tdm", "=", "crtomo", ".", "tdMan", "(", "grid", "=", "self", ".", "grid", ",", "te...
For a given model, return a tdMan instance Parameters ---------- m : ndarray Model parameters (linear, ohm m)
[ "For", "a", "given", "model", "return", "a", "tdMan", "instance" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/interface.py#L43-L63
train
Returns a tdMan instance for a given model.
geophysics-ubonn/crtomo_tools
lib/crtomo/interface.py
crmod_interface.forward_complex
def forward_complex(self, log_sigma): """Compute a model response, i.e. complex impedances Parameters ---------- log_sigma : 1xN or 2xN numpy.ndarray Model parameters log sigma, N the number of cells. If first dimension is of length one, assume phase values to be...
python
def forward_complex(self, log_sigma): """Compute a model response, i.e. complex impedances Parameters ---------- log_sigma : 1xN or 2xN numpy.ndarray Model parameters log sigma, N the number of cells. If first dimension is of length one, assume phase values to be...
[ "def", "forward_complex", "(", "self", ",", "log_sigma", ")", ":", "m", "=", "1.0", "/", "np", ".", "exp", "(", "log_sigma", ")", "tdm", "=", "self", ".", "_get_tdm", "(", "m", ")", "measurements", "=", "tdm", ".", "measurements", "(", ")", "# import...
Compute a model response, i.e. complex impedances Parameters ---------- log_sigma : 1xN or 2xN numpy.ndarray Model parameters log sigma, N the number of cells. If first dimension is of length one, assume phase values to be zero Returns ------- me...
[ "Compute", "a", "model", "response", "i", ".", "e", ".", "complex", "impedances" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/interface.py#L65-L86
train
Compute a model response i. e. complex impedances of the next set of cells.
geophysics-ubonn/crtomo_tools
lib/crtomo/interface.py
crmod_interface.J
def J(self, log_sigma): """Return the sensitivity matrix Parameters ---------- log_sigma : numpy.ndarray log_e conductivities """ m = 1.0 / np.exp(log_sigma) tdm = self._get_tdm(m) tdm.model( sensitivities=True, # out...
python
def J(self, log_sigma): """Return the sensitivity matrix Parameters ---------- log_sigma : numpy.ndarray log_e conductivities """ m = 1.0 / np.exp(log_sigma) tdm = self._get_tdm(m) tdm.model( sensitivities=True, # out...
[ "def", "J", "(", "self", ",", "log_sigma", ")", ":", "m", "=", "1.0", "/", "np", ".", "exp", "(", "log_sigma", ")", "tdm", "=", "self", ".", "_get_tdm", "(", "m", ")", "tdm", ".", "model", "(", "sensitivities", "=", "True", ",", "# output_directory...
Return the sensitivity matrix Parameters ---------- log_sigma : numpy.ndarray log_e conductivities
[ "Return", "the", "sensitivity", "matrix" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/interface.py#L88-L136
train
Return the sensitivity matrix for the current set of resources.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/rsakey.py
RSAKey.generate
def generate(bits, progress_func=None): """ Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key. :param int bits: number of bits the generated key should be. :param function progress_func: an optional fu...
python
def generate(bits, progress_func=None): """ Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key. :param int bits: number of bits the generated key should be. :param function progress_func: an optional fu...
[ "def", "generate", "(", "bits", ",", "progress_func", "=", "None", ")", ":", "rsa", "=", "RSA", ".", "generate", "(", "bits", ",", "os", ".", "urandom", ",", "progress_func", ")", "key", "=", "RSAKey", "(", "vals", "=", "(", "rsa", ".", "e", ",", ...
Generate a new private RSA key. This factory function can be used to generate a new host key or authentication key. :param int bits: number of bits the generated key should be. :param function progress_func: an optional function to call at key points in key generation (used ...
[ "Generate", "a", "new", "private", "RSA", "key", ".", "This", "factory", "function", "can", "be", "used", "to", "generate", "a", "new", "host", "key", "or", "authentication", "key", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/rsakey.py#L134-L150
train
This factory function can be used to generate a new private RSA key.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/rsakey.py
RSAKey._pkcs1imify
def _pkcs1imify(self, data): """ turn a 20-byte SHA1 hash into a blob of data as large as the key's N, using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre. """ size = len(util.deflate_long(self.n, 0)) filler = max_byte * (size - len(SHA1_DIGESTINFO) - len(data) -...
python
def _pkcs1imify(self, data): """ turn a 20-byte SHA1 hash into a blob of data as large as the key's N, using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre. """ size = len(util.deflate_long(self.n, 0)) filler = max_byte * (size - len(SHA1_DIGESTINFO) - len(data) -...
[ "def", "_pkcs1imify", "(", "self", ",", "data", ")", ":", "size", "=", "len", "(", "util", ".", "deflate_long", "(", "self", ".", "n", ",", "0", ")", ")", "filler", "=", "max_byte", "*", "(", "size", "-", "len", "(", "SHA1_DIGESTINFO", ")", "-", ...
turn a 20-byte SHA1 hash into a blob of data as large as the key's N, using PKCS1's \"emsa-pkcs1-v1_5\" encoding. totally bizarre.
[ "turn", "a", "20", "-", "byte", "SHA1", "hash", "into", "a", "blob", "of", "data", "as", "large", "as", "the", "key", "s", "N", "using", "PKCS1", "s", "\\", "emsa", "-", "pkcs1", "-", "v1_5", "\\", "encoding", ".", "totally", "bizarre", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/rsakey.py#L155-L162
train
Convert a 20 - byte SHA1 hash into a blob of data as large as the key s N using PKCS1 s EMA - PKCS1 - v1_5 encoding.
redhat-openstack/python-tripleo-helper
tripleohelper/baremetal.py
BaremetalFactory.set_ironic_uuid
def set_ironic_uuid(self, uuid_list): """Map a list of Ironic UUID to BM nodes. """ # TODO(Gonéri): ensure we adjust the correct node i = iter(self.nodes) for uuid in uuid_list: node = next(i) node.uuid = uuid
python
def set_ironic_uuid(self, uuid_list): """Map a list of Ironic UUID to BM nodes. """ # TODO(Gonéri): ensure we adjust the correct node i = iter(self.nodes) for uuid in uuid_list: node = next(i) node.uuid = uuid
[ "def", "set_ironic_uuid", "(", "self", ",", "uuid_list", ")", ":", "# TODO(Gonéri): ensure we adjust the correct node", "i", "=", "iter", "(", "self", ".", "nodes", ")", "for", "uuid", "in", "uuid_list", ":", "node", "=", "next", "(", "i", ")", "node", ".", ...
Map a list of Ironic UUID to BM nodes.
[ "Map", "a", "list", "of", "Ironic", "UUID", "to", "BM", "nodes", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/baremetal.py#L89-L96
train
Map a list of Ironic UUID to BM nodes.
althonos/moclo
moclo/moclo/registry/_utils.py
find_resistance
def find_resistance(record): """Infer the antibiotics resistance of the given record. Arguments: record (`~Bio.SeqRecord.SeqRecord`): an annotated sequence. Raises: RuntimeError: when there's not exactly one resistance cassette. """ for feature in record.features: labels =...
python
def find_resistance(record): """Infer the antibiotics resistance of the given record. Arguments: record (`~Bio.SeqRecord.SeqRecord`): an annotated sequence. Raises: RuntimeError: when there's not exactly one resistance cassette. """ for feature in record.features: labels =...
[ "def", "find_resistance", "(", "record", ")", ":", "for", "feature", "in", "record", ".", "features", ":", "labels", "=", "set", "(", "feature", ".", "qualifiers", ".", "get", "(", "\"label\"", ",", "[", "]", ")", ")", "cassettes", "=", "labels", ".", ...
Infer the antibiotics resistance of the given record. Arguments: record (`~Bio.SeqRecord.SeqRecord`): an annotated sequence. Raises: RuntimeError: when there's not exactly one resistance cassette.
[ "Infer", "the", "antibiotics", "resistance", "of", "the", "given", "record", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/registry/_utils.py#L16-L33
train
Infer the antibiotics resistance of the given record.
Riminder/python-riminder-api
riminder/riminder.py
Riminder.get
def get(self, resource_endpoint, query_params={}): """Don't use it.""" url = self._create_request_url(resource_endpoint) if query_params: return req.get(url, headers=self.auth_header, params=query_params) else: return req.get(url, headers=self.auth_header)
python
def get(self, resource_endpoint, query_params={}): """Don't use it.""" url = self._create_request_url(resource_endpoint) if query_params: return req.get(url, headers=self.auth_header, params=query_params) else: return req.get(url, headers=self.auth_header)
[ "def", "get", "(", "self", ",", "resource_endpoint", ",", "query_params", "=", "{", "}", ")", ":", "url", "=", "self", ".", "_create_request_url", "(", "resource_endpoint", ")", "if", "query_params", ":", "return", "req", ".", "get", "(", "url", ",", "he...
Don't use it.
[ "Don", "t", "use", "it", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/riminder.py#L44-L50
train
Don t use it.
Riminder/python-riminder-api
riminder/riminder.py
Riminder.post
def post(self, resource_endpoint, data={}, files=None): """Don't use it.""" url = self._create_request_url(resource_endpoint) if files: data = self._prepare_params_for_file_upload(data) return req.post(url, headers=self.auth_header, files=files, data=data) else: ...
python
def post(self, resource_endpoint, data={}, files=None): """Don't use it.""" url = self._create_request_url(resource_endpoint) if files: data = self._prepare_params_for_file_upload(data) return req.post(url, headers=self.auth_header, files=files, data=data) else: ...
[ "def", "post", "(", "self", ",", "resource_endpoint", ",", "data", "=", "{", "}", ",", "files", "=", "None", ")", ":", "url", "=", "self", ".", "_create_request_url", "(", "resource_endpoint", ")", "if", "files", ":", "data", "=", "self", ".", "_prepar...
Don't use it.
[ "Don", "t", "use", "it", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/riminder.py#L52-L59
train
Don t use it.
Riminder/python-riminder-api
riminder/riminder.py
Riminder.patch
def patch(self, resource_endpoint, data={}): """Don't use it.""" url = self._create_request_url(resource_endpoint) return req.patch(url, headers=self.auth_header, json=data)
python
def patch(self, resource_endpoint, data={}): """Don't use it.""" url = self._create_request_url(resource_endpoint) return req.patch(url, headers=self.auth_header, json=data)
[ "def", "patch", "(", "self", ",", "resource_endpoint", ",", "data", "=", "{", "}", ")", ":", "url", "=", "self", ".", "_create_request_url", "(", "resource_endpoint", ")", "return", "req", ".", "patch", "(", "url", ",", "headers", "=", "self", ".", "au...
Don't use it.
[ "Don", "t", "use", "it", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/riminder.py#L61-L64
train
Don t use it.
althonos/moclo
moclo/moclo/record.py
CircularRecord.reverse_complement
def reverse_complement( self, id=False, name=False, description=False, features=True, annotations=False, letter_annotations=True, dbxrefs=False, ): """Return a new ``CircularRecord`` with reverse complement sequence. """ return ...
python
def reverse_complement( self, id=False, name=False, description=False, features=True, annotations=False, letter_annotations=True, dbxrefs=False, ): """Return a new ``CircularRecord`` with reverse complement sequence. """ return ...
[ "def", "reverse_complement", "(", "self", ",", "id", "=", "False", ",", "name", "=", "False", ",", "description", "=", "False", ",", "features", "=", "True", ",", "annotations", "=", "False", ",", "letter_annotations", "=", "True", ",", "dbxrefs", "=", "...
Return a new ``CircularRecord`` with reverse complement sequence.
[ "Return", "a", "new", "CircularRecord", "with", "reverse", "complement", "sequence", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/record.py#L141-L163
train
Returns a new instance of the class with reverse complement sequence.
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.load_private_key
def load_private_key(self, priv_key): """Register the SSH private key.""" with open(priv_key) as fd: self._private_key = paramiko.RSAKey.from_private_key(fd)
python
def load_private_key(self, priv_key): """Register the SSH private key.""" with open(priv_key) as fd: self._private_key = paramiko.RSAKey.from_private_key(fd)
[ "def", "load_private_key", "(", "self", ",", "priv_key", ")", ":", "with", "open", "(", "priv_key", ")", "as", "fd", ":", "self", ".", "_private_key", "=", "paramiko", ".", "RSAKey", ".", "from_private_key", "(", "fd", ")" ]
Register the SSH private key.
[ "Register", "the", "SSH", "private", "key", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L68-L71
train
Register the SSH private key.
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.start
def start(self): """Start the ssh client and connect to the host. It will wait until the ssh service is available during 90 seconds. If it doesn't succed to connect then the function will raise an SSHException. """ if self.via_ip: connect_to = self.via_ip ...
python
def start(self): """Start the ssh client and connect to the host. It will wait until the ssh service is available during 90 seconds. If it doesn't succed to connect then the function will raise an SSHException. """ if self.via_ip: connect_to = self.via_ip ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "via_ip", ":", "connect_to", "=", "self", ".", "via_ip", "self", ".", "description", "=", "'[%s@%s via %s]'", "%", "(", "self", ".", "_user", ",", "self", ".", "_hostname", ",", "self", ".", "...
Start the ssh client and connect to the host. It will wait until the ssh service is available during 90 seconds. If it doesn't succed to connect then the function will raise an SSHException.
[ "Start", "the", "ssh", "client", "and", "connect", "to", "the", "host", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L98-L142
train
Start the ssh client and connect to the host.
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.run
def run(self, cmd, sudo=False, ignore_error=False, success_status=(0,), error_callback=None, custom_log=None, retry=0): """Run a command on the remote host. The command is run on the remote host, if there is a redirected host then the command will be run on that redirected host. See...
python
def run(self, cmd, sudo=False, ignore_error=False, success_status=(0,), error_callback=None, custom_log=None, retry=0): """Run a command on the remote host. The command is run on the remote host, if there is a redirected host then the command will be run on that redirected host. See...
[ "def", "run", "(", "self", ",", "cmd", ",", "sudo", "=", "False", ",", "ignore_error", "=", "False", ",", "success_status", "=", "(", "0", ",", ")", ",", "error_callback", "=", "None", ",", "custom_log", "=", "None", ",", "retry", "=", "0", ")", ":...
Run a command on the remote host. The command is run on the remote host, if there is a redirected host then the command will be run on that redirected host. See __init__. :param cmd: the command to run :type cmd: str :param sudo: True if the command should be run with sudo, thi...
[ "Run", "a", "command", "on", "the", "remote", "host", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L163-L221
train
Runs a command on the remote host.
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient._get_channel
def _get_channel(self): """Returns a channel according to if there is a redirection to do or not. """ channel = self._transport.open_session() channel.set_combine_stderr(True) channel.get_pty() return channel
python
def _get_channel(self): """Returns a channel according to if there is a redirection to do or not. """ channel = self._transport.open_session() channel.set_combine_stderr(True) channel.get_pty() return channel
[ "def", "_get_channel", "(", "self", ")", ":", "channel", "=", "self", ".", "_transport", ".", "open_session", "(", ")", "channel", ".", "set_combine_stderr", "(", "True", ")", "channel", ".", "get_pty", "(", ")", "return", "channel" ]
Returns a channel according to if there is a redirection to do or not.
[ "Returns", "a", "channel", "according", "to", "if", "there", "is", "a", "redirection", "to", "do", "or", "not", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L237-L244
train
Returns a channel according to if there is a redirection to do or not.
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.send_file
def send_file(self, local_path, remote_path, unix_mode=None): """Send a file to the remote host. :param local_path: the local path of the file :type local_path: str :param remote_path: the remote path of the file :type remote_path: str :return: the file attributes ...
python
def send_file(self, local_path, remote_path, unix_mode=None): """Send a file to the remote host. :param local_path: the local path of the file :type local_path: str :param remote_path: the remote path of the file :type remote_path: str :return: the file attributes ...
[ "def", "send_file", "(", "self", ",", "local_path", ",", "remote_path", ",", "unix_mode", "=", "None", ")", ":", "self", ".", "_check_started", "(", ")", "sftp", "=", "paramiko", ".", "SFTPClient", ".", "from_transport", "(", "self", ".", "_transport", ")"...
Send a file to the remote host. :param local_path: the local path of the file :type local_path: str :param remote_path: the remote path of the file :type remote_path: str :return: the file attributes :rtype: paramiko.sftp_attr.SFTPAttributes
[ "Send", "a", "file", "to", "the", "remote", "host", ".", ":", "param", "local_path", ":", "the", "local", "path", "of", "the", "file", ":", "type", "local_path", ":", "str", ":", "param", "remote_path", ":", "the", "remote", "path", "of", "the", "file"...
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L246-L259
train
Send a file to the remote host.
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.send_dir
def send_dir(self, local_path, remote_path): """Send a directory to the remote host. :param local_path: the local path of the directory :type local_path: str :param remote_path: the remote path of the directory :type remote_path: str :return: the file attributes :...
python
def send_dir(self, local_path, remote_path): """Send a directory to the remote host. :param local_path: the local path of the directory :type local_path: str :param remote_path: the remote path of the directory :type remote_path: str :return: the file attributes :...
[ "def", "send_dir", "(", "self", ",", "local_path", ",", "remote_path", ")", ":", "directory", ",", "parent", "=", "os", ".", "path", ".", "split", "(", "local_path", ")", "os", ".", "chdir", "(", "directory", ")", "self", ".", "_check_started", "(", ")...
Send a directory to the remote host. :param local_path: the local path of the directory :type local_path: str :param remote_path: the remote path of the directory :type remote_path: str :return: the file attributes :rtype: paramiko.sftp_attr.SFTPAttributes
[ "Send", "a", "directory", "to", "the", "remote", "host", ".", ":", "param", "local_path", ":", "the", "local", "path", "of", "the", "directory", ":", "type", "local_path", ":", "str", ":", "param", "remote_path", ":", "the", "remote", "path", "of", "the"...
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L261-L281
train
Send a directory to the remote host.
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
SshClient.create_file
def create_file(self, path, content, mode='w'): """Create a file with a content. :param path: the path of the file. :type path: str :param content: the content of the file :type content: str :param mode: the mode of the file while opening it :type mode: str ...
python
def create_file(self, path, content, mode='w'): """Create a file with a content. :param path: the path of the file. :type path: str :param content: the content of the file :type content: str :param mode: the mode of the file while opening it :type mode: str ...
[ "def", "create_file", "(", "self", ",", "path", ",", "content", ",", "mode", "=", "'w'", ")", ":", "self", ".", "_check_started", "(", ")", "sftp", "=", "paramiko", ".", "SFTPClient", ".", "from_transport", "(", "self", ".", "_transport", ")", "with", ...
Create a file with a content. :param path: the path of the file. :type path: str :param content: the content of the file :type content: str :param mode: the mode of the file while opening it :type mode: str
[ "Create", "a", "file", "with", "a", "content", ".", ":", "param", "path", ":", "the", "path", "of", "the", "file", ".", ":", "type", "path", ":", "str", ":", "param", "content", ":", "the", "content", "of", "the", "file", ":", "type", "content", ":...
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L288-L301
train
Create a file with a content.
geophysics-ubonn/crtomo_tools
lib/crtomo/debug.py
get_grid
def get_grid(key): """Return a :class:`crtomo.grid.crt_grid` instance, with a debug grid that is distributed with the crtomo package. Multiple grids are available: * key=20 - a 20 electrode grid with 1m spacing, 4 elements between electrodes, rectangular elements. * key=40 - a 40 elec...
python
def get_grid(key): """Return a :class:`crtomo.grid.crt_grid` instance, with a debug grid that is distributed with the crtomo package. Multiple grids are available: * key=20 - a 20 electrode grid with 1m spacing, 4 elements between electrodes, rectangular elements. * key=40 - a 40 elec...
[ "def", "get_grid", "(", "key", ")", ":", "rbase", "=", "grid_files", "[", "key", "]", "elem_file", "=", "pk", ".", "resource_filename", "(", "'crtomo'", ",", "rbase", "[", "'elem'", "]", ")", "elec_file", "=", "pk", ".", "resource_filename", "(", "'crtom...
Return a :class:`crtomo.grid.crt_grid` instance, with a debug grid that is distributed with the crtomo package. Multiple grids are available: * key=20 - a 20 electrode grid with 1m spacing, 4 elements between electrodes, rectangular elements. * key=40 - a 40 electrode grid with 1m spacing...
[ "Return", "a", ":", "class", ":", "crtomo", ".", "grid", ".", "crt_grid", "instance", "with", "a", "debug", "grid", "that", "is", "distributed", "with", "the", "crtomo", "package", ".", "Multiple", "grids", "are", "available", ":" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/debug.py#L27-L53
train
Return a crtomo. grid. crt_grid instance that contains the specified key.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/packet.py
Packetizer.readline
def readline(self, timeout): """ Read a line from the socket. We assume no data is pending after the line, so it's okay to attempt large reads. """ buf = self.__remainder while not linefeed_byte in buf: buf += self._read_timeout(timeout) n = buf.index...
python
def readline(self, timeout): """ Read a line from the socket. We assume no data is pending after the line, so it's okay to attempt large reads. """ buf = self.__remainder while not linefeed_byte in buf: buf += self._read_timeout(timeout) n = buf.index...
[ "def", "readline", "(", "self", ",", "timeout", ")", ":", "buf", "=", "self", ".", "__remainder", "while", "not", "linefeed_byte", "in", "buf", ":", "buf", "+=", "self", ".", "_read_timeout", "(", "timeout", ")", "n", "=", "buf", ".", "index", "(", "...
Read a line from the socket. We assume no data is pending after the line, so it's okay to attempt large reads.
[ "Read", "a", "line", "from", "the", "socket", ".", "We", "assume", "no", "data", "is", "pending", "after", "the", "line", "so", "it", "s", "okay", "to", "attempt", "large", "reads", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/packet.py#L264-L277
train
Read a line from the socket.
NJDFan/ctypes-bitfield
bitfield/__init__.py
make_bf
def make_bf(name, fields, basetype=c_uint32, doc=None): """ Create a new Bitfield class, correctly assigning the anonymous fields from the Union in order to get the desired behavior. Parameters:: name The name of the class. This is similar to the namedtuple rec...
python
def make_bf(name, fields, basetype=c_uint32, doc=None): """ Create a new Bitfield class, correctly assigning the anonymous fields from the Union in order to get the desired behavior. Parameters:: name The name of the class. This is similar to the namedtuple rec...
[ "def", "make_bf", "(", "name", ",", "fields", ",", "basetype", "=", "c_uint32", ",", "doc", "=", "None", ")", ":", "# We need to hack on the fields array to get our integer sizes correct.", "unsigned_types", "=", "[", "c_uint8", ",", "c_uint16", ",", "c_uint32", ","...
Create a new Bitfield class, correctly assigning the anonymous fields from the Union in order to get the desired behavior. Parameters:: name The name of the class. This is similar to the namedtuple recipe, in that you'll generally pass the same name here as ...
[ "Create", "a", "new", "Bitfield", "class", "correctly", "assigning", "the", "anonymous", "fields", "from", "the", "Union", "in", "order", "to", "get", "the", "desired", "behavior", ".", "Parameters", "::", "name", "The", "name", "of", "the", "class", ".", ...
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/__init__.py#L120-L199
train
Creates a new bitfield class from a list of fields and a type of the underlying register.
NJDFan/ctypes-bitfield
bitfield/__init__.py
print_fields
def print_fields(bf, *args, **kwargs): """ Print all the fields of a Bitfield object to stdout. This is primarly a diagnostic aid during debugging. """ vals = {k: hex(v) for k, v in bf.items()} print(bf.base, vals, *args, **kwargs)
python
def print_fields(bf, *args, **kwargs): """ Print all the fields of a Bitfield object to stdout. This is primarly a diagnostic aid during debugging. """ vals = {k: hex(v) for k, v in bf.items()} print(bf.base, vals, *args, **kwargs)
[ "def", "print_fields", "(", "bf", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "vals", "=", "{", "k", ":", "hex", "(", "v", ")", "for", "k", ",", "v", "in", "bf", ".", "items", "(", ")", "}", "print", "(", "bf", ".", "base", ",", ...
Print all the fields of a Bitfield object to stdout. This is primarly a diagnostic aid during debugging.
[ "Print", "all", "the", "fields", "of", "a", "Bitfield", "object", "to", "stdout", ".", "This", "is", "primarly", "a", "diagnostic", "aid", "during", "debugging", "." ]
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/__init__.py#L201-L208
train
Print all the fields of a Bitfield object to stdout.
NJDFan/ctypes-bitfield
bitfield/__init__.py
Bitfield.clone
def clone(self): """Return a new bitfield with the same value. The returned value is a copy, and so is no longer linked to the original bitfield. This is important when the original is located at anything other than normal memory, with accesses to it either slow or havi...
python
def clone(self): """Return a new bitfield with the same value. The returned value is a copy, and so is no longer linked to the original bitfield. This is important when the original is located at anything other than normal memory, with accesses to it either slow or havi...
[ "def", "clone", "(", "self", ")", ":", "temp", "=", "self", ".", "__class__", "(", ")", "temp", ".", "base", "=", "self", ".", "base", "return", "temp" ]
Return a new bitfield with the same value. The returned value is a copy, and so is no longer linked to the original bitfield. This is important when the original is located at anything other than normal memory, with accesses to it either slow or having side effects. Creating a...
[ "Return", "a", "new", "bitfield", "with", "the", "same", "value", ".", "The", "returned", "value", "is", "a", "copy", "and", "so", "is", "no", "longer", "linked", "to", "the", "original", "bitfield", ".", "This", "is", "important", "when", "the", "origin...
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/__init__.py#L44-L56
train
Return a new bitfield with the same value.
NJDFan/ctypes-bitfield
bitfield/__init__.py
Bitfield.items
def items(self): """ Returns an iterator over the named bitfields in the structure as 2-tuples of (key, value). Uses a clone so as to only read from the underlying data once. """ temp = self.clone() return [(f, getattr(temp, f)) for f in iter(self)]
python
def items(self): """ Returns an iterator over the named bitfields in the structure as 2-tuples of (key, value). Uses a clone so as to only read from the underlying data once. """ temp = self.clone() return [(f, getattr(temp, f)) for f in iter(self)]
[ "def", "items", "(", "self", ")", ":", "temp", "=", "self", ".", "clone", "(", ")", "return", "[", "(", "f", ",", "getattr", "(", "temp", ",", "f", ")", ")", "for", "f", "in", "iter", "(", "self", ")", "]" ]
Returns an iterator over the named bitfields in the structure as 2-tuples of (key, value). Uses a clone so as to only read from the underlying data once.
[ "Returns", "an", "iterator", "over", "the", "named", "bitfields", "in", "the", "structure", "as", "2", "-", "tuples", "of", "(", "key", "value", ")", ".", "Uses", "a", "clone", "so", "as", "to", "only", "read", "from", "the", "underlying", "data", "onc...
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/__init__.py#L58-L66
train
Returns an iterator over the named bitfields in the structure as 2 - tuples of ( key value ).
NJDFan/ctypes-bitfield
bitfield/__init__.py
Bitfield.update
def update(self, E=None, **F): ''' D.update([E, ]**F) -> None Update the bitfield from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D.k = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D.k = v In either case, this...
python
def update(self, E=None, **F): ''' D.update([E, ]**F) -> None Update the bitfield from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D.k = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D.k = v In either case, this...
[ "def", "update", "(", "self", ",", "E", "=", "None", ",", "*", "*", "F", ")", ":", "temp", "=", "self", ".", "clone", "(", ")", "if", "E", ":", "try", ":", "for", "k", "in", "E", ".", "keys", "(", ")", ":", "setattr", "(", "temp", ",", "k...
D.update([E, ]**F) -> None Update the bitfield from dict/iterable E and F. If E present and has a .keys() method, does: for k in E: D.k = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D.k = v In either case, this is followed by: for k in F: D.k = F[k] ...
[ "D", ".", "update", "(", "[", "E", "]", "**", "F", ")", "-", ">", "None", "Update", "the", "bitfield", "from", "dict", "/", "iterable", "E", "and", "F", ".", "If", "E", "present", "and", "has", "a", ".", "keys", "()", "method", "does", ":", "fo...
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/__init__.py#L68-L94
train
Update the bitfield from dict E and F.
NikolayDachev/jadm
lib/tabulate-0.7.2/tabulate.py
_normalize_tabular_data
def _normalize_tabular_data(tabular_data, headers): """Transform a supported data type to a list of lists, and a list of headers. Supported tabular data types: * list-of-lists or another iterable of iterables * list of named tuples (usually used with headers="keys") * 2D NumPy arrays * NumP...
python
def _normalize_tabular_data(tabular_data, headers): """Transform a supported data type to a list of lists, and a list of headers. Supported tabular data types: * list-of-lists or another iterable of iterables * list of named tuples (usually used with headers="keys") * 2D NumPy arrays * NumP...
[ "def", "_normalize_tabular_data", "(", "tabular_data", ",", "headers", ")", ":", "if", "hasattr", "(", "tabular_data", ",", "\"keys\"", ")", "and", "hasattr", "(", "tabular_data", ",", "\"values\"", ")", ":", "# dict-like and pandas.DataFrame?", "if", "hasattr", "...
Transform a supported data type to a list of lists, and a list of headers. Supported tabular data types: * list-of-lists or another iterable of iterables * list of named tuples (usually used with headers="keys") * 2D NumPy arrays * NumPy record arrays (usually used with headers="keys") * d...
[ "Transform", "a", "supported", "data", "type", "to", "a", "list", "of", "lists", "and", "a", "list", "of", "headers", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/tabulate-0.7.2/tabulate.py#L466-L537
train
Transform a supported data type to a list of lists and a list of headers.
gebn/wood
wood/comparison.py
Comparison.new
def new(self, base: pathlib.PurePath = pathlib.PurePath(), include_intermediates: bool = True) -> Iterator[str]: """ Find the list of new paths in this comparison. :param base: The base directory to prepend to the right entity's name. :param include_intermediates: Whether to...
python
def new(self, base: pathlib.PurePath = pathlib.PurePath(), include_intermediates: bool = True) -> Iterator[str]: """ Find the list of new paths in this comparison. :param base: The base directory to prepend to the right entity's name. :param include_intermediates: Whether to...
[ "def", "new", "(", "self", ",", "base", ":", "pathlib", ".", "PurePath", "=", "pathlib", ".", "PurePath", "(", ")", ",", "include_intermediates", ":", "bool", "=", "True", ")", "->", "Iterator", "[", "str", "]", ":", "if", "self", ".", "is_new", ":",...
Find the list of new paths in this comparison. :param base: The base directory to prepend to the right entity's name. :param include_intermediates: Whether to include new non-empty directories in the returned iterable. If you o...
[ "Find", "the", "list", "of", "new", "paths", "in", "this", "comparison", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L61-L76
train
Find the list of new paths in this comparison.
gebn/wood
wood/comparison.py
Comparison.modified
def modified(self, base: pathlib.PurePath = pathlib.PurePath()) \ -> Iterator[str]: """ Find the paths of modified files. There is no option to include intermediate directories, as all files and directories exist in both the left and right trees. :param base: The bas...
python
def modified(self, base: pathlib.PurePath = pathlib.PurePath()) \ -> Iterator[str]: """ Find the paths of modified files. There is no option to include intermediate directories, as all files and directories exist in both the left and right trees. :param base: The bas...
[ "def", "modified", "(", "self", ",", "base", ":", "pathlib", ".", "PurePath", "=", "pathlib", ".", "PurePath", "(", ")", ")", "->", "Iterator", "[", "str", "]", ":", "# N.B. this method will only ever return files, as directories cannot", "# be \"modified\"", "if", ...
Find the paths of modified files. There is no option to include intermediate directories, as all files and directories exist in both the left and right trees. :param base: The base directory to recursively append to the right entity. :return: An iterable of paths of...
[ "Find", "the", "paths", "of", "modified", "files", ".", "There", "is", "no", "option", "to", "include", "intermediate", "directories", "as", "all", "files", "and", "directories", "exist", "in", "both", "the", "left", "and", "right", "trees", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L91-L105
train
Find the paths of modified files in both the left and right trees.
gebn/wood
wood/comparison.py
Comparison.deleted
def deleted(self, base: pathlib.PurePath = pathlib.PurePath(), include_children: bool = True, include_directories: bool = True) -> Iterator[str]: """ Find the paths of entities deleted between the left and right entities in this comparison. :param base: T...
python
def deleted(self, base: pathlib.PurePath = pathlib.PurePath(), include_children: bool = True, include_directories: bool = True) -> Iterator[str]: """ Find the paths of entities deleted between the left and right entities in this comparison. :param base: T...
[ "def", "deleted", "(", "self", ",", "base", ":", "pathlib", ".", "PurePath", "=", "pathlib", ".", "PurePath", "(", ")", ",", "include_children", ":", "bool", "=", "True", ",", "include_directories", ":", "bool", "=", "True", ")", "->", "Iterator", "[", ...
Find the paths of entities deleted between the left and right entities in this comparison. :param base: The base directory to recursively append to entities. :param include_children: Whether to recursively include children of deleted directories. These are thems...
[ "Find", "the", "paths", "of", "entities", "deleted", "between", "the", "left", "and", "right", "entities", "in", "this", "comparison", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L116-L133
train
Find the paths of deleted entities between the left and right entities.
gebn/wood
wood/comparison.py
Comparison.compare
def compare(left: Optional[L], right: Optional[R]) -> 'Comparison[L, R]': """ Calculate the comparison of two entities. | left | right | Return Type | |===========|===========|=========================| | file | file | FileComparison | ...
python
def compare(left: Optional[L], right: Optional[R]) -> 'Comparison[L, R]': """ Calculate the comparison of two entities. | left | right | Return Type | |===========|===========|=========================| | file | file | FileComparison | ...
[ "def", "compare", "(", "left", ":", "Optional", "[", "L", "]", ",", "right", ":", "Optional", "[", "R", "]", ")", "->", "'Comparison[L, R]'", ":", "if", "isinstance", "(", "left", ",", "File", ")", "and", "isinstance", "(", "right", ",", "Directory", ...
Calculate the comparison of two entities. | left | right | Return Type | |===========|===========|=========================| | file | file | FileComparison | | file | directory | FileDirectoryComparison | | file | None | Fil...
[ "Calculate", "the", "comparison", "of", "two", "entities", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L157-L189
train
Calculate the comparison of two entities.
gebn/wood
wood/comparison.py
Comparison.print_hierarchy
def print_hierarchy(self, level: int = 0, file: IO[str] = sys.stdout) \ -> None: """ Print this comparison and its children with indentation to represent nesting. :param level: The level of indentation to use. This is mostly for internal use, but you ca...
python
def print_hierarchy(self, level: int = 0, file: IO[str] = sys.stdout) \ -> None: """ Print this comparison and its children with indentation to represent nesting. :param level: The level of indentation to use. This is mostly for internal use, but you ca...
[ "def", "print_hierarchy", "(", "self", ",", "level", ":", "int", "=", "0", ",", "file", ":", "IO", "[", "str", "]", "=", "sys", ".", "stdout", ")", "->", "None", ":", "print", "(", "' '", "*", "self", ".", "_INDENT_SIZE", "*", "level", "+", "str"...
Print this comparison and its children with indentation to represent nesting. :param level: The level of indentation to use. This is mostly for internal use, but you can use it to inset the root comparison. :param file: The stream to print to. Default...
[ "Print", "this", "comparison", "and", "its", "children", "with", "indentation", "to", "represent", "nesting", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L191-L202
train
Print this comparison and its children with indentation to represent the root .
gebn/wood
wood/comparison.py
FileComparison.is_modified
def is_modified(self) -> bool: """ Find whether the files on the left and right are different. Note, modified implies the contents of the file have changed, which is predicated on the file existing on both the left and right. Therefore this will be false if the file on the left h...
python
def is_modified(self) -> bool: """ Find whether the files on the left and right are different. Note, modified implies the contents of the file have changed, which is predicated on the file existing on both the left and right. Therefore this will be false if the file on the left h...
[ "def", "is_modified", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "is_new", "or", "self", ".", "is_deleted", ":", "return", "False", "return", "self", ".", "left", ".", "md5", "!=", "self", ".", "right", ".", "md5" ]
Find whether the files on the left and right are different. Note, modified implies the contents of the file have changed, which is predicated on the file existing on both the left and right. Therefore this will be false if the file on the left has been deleted, or the file on the right i...
[ "Find", "whether", "the", "files", "on", "the", "left", "and", "right", "are", "different", ".", "Note", "modified", "implies", "the", "contents", "of", "the", "file", "have", "changed", "which", "is", "predicated", "on", "the", "file", "existing", "on", "...
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/comparison.py#L224-L236
train
Return whether the file on the left and right are different.
pgxcentre/geneparse
geneparse/index/impute2.py
generate_index
def generate_index(fn, cols=None, names=None, sep=" "): """Build a index for the given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field se...
python
def generate_index(fn, cols=None, names=None, sep=" "): """Build a index for the given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field se...
[ "def", "generate_index", "(", "fn", ",", "cols", "=", "None", ",", "names", "=", "None", ",", "sep", "=", "\" \"", ")", ":", "# Some assertions", "assert", "cols", "is", "not", "None", ",", "\"'cols' was not set\"", "assert", "names", "is", "not", "None", ...
Build a index for the given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Returns: pandas.DataFrame: the index.
[ "Build", "a", "index", "for", "the", "given", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L59-L92
train
Builds a index for the given file.
pgxcentre/geneparse
geneparse/index/impute2.py
get_open_func
def get_open_func(fn, return_fmt=False): """Get the opening function. Args: fn (str): the name of the file. return_fmt (bool): if the file format needs to be returned. Returns: tuple: either a tuple containing two elements: a boolean telling if the format is bgzip, and the ...
python
def get_open_func(fn, return_fmt=False): """Get the opening function. Args: fn (str): the name of the file. return_fmt (bool): if the file format needs to be returned. Returns: tuple: either a tuple containing two elements: a boolean telling if the format is bgzip, and the ...
[ "def", "get_open_func", "(", "fn", ",", "return_fmt", "=", "False", ")", ":", "# The file might be compressed using bgzip", "bgzip", "=", "None", "with", "open", "(", "fn", ",", "\"rb\"", ")", "as", "i_file", ":", "bgzip", "=", "i_file", ".", "read", "(", ...
Get the opening function. Args: fn (str): the name of the file. return_fmt (bool): if the file format needs to be returned. Returns: tuple: either a tuple containing two elements: a boolean telling if the format is bgzip, and the opening function.
[ "Get", "the", "opening", "function", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L95-L133
train
Get the opening function.
pgxcentre/geneparse
geneparse/index/impute2.py
get_index
def get_index(fn, cols, names, sep): """Restores the index for a given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Re...
python
def get_index(fn, cols, names, sep): """Restores the index for a given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Re...
[ "def", "get_index", "(", "fn", ",", "cols", ",", "names", ",", "sep", ")", ":", "if", "not", "has_index", "(", "fn", ")", ":", "# The index doesn't exists, generate it", "return", "generate_index", "(", "fn", ",", "cols", ",", "names", ",", "sep", ")", "...
Restores the index for a given file. Args: fn (str): the name of the file. cols (list): a list containing column to keep (as int). names (list): the name corresponding to the column to keep (as str). sep (str): the field separator. Returns: pandas.DataFrame: the index. ...
[ "Restores", "the", "index", "for", "a", "given", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L136-L165
train
Restores the index for a given file.
pgxcentre/geneparse
geneparse/index/impute2.py
write_index
def write_index(fn, index): """Writes the index to file. Args: fn (str): the name of the file that will contain the index. index (pandas.DataFrame): the index. """ with open(fn, "wb") as o_file: o_file.write(_CHECK_STRING) o_file.write(zlib.compress(bytes( i...
python
def write_index(fn, index): """Writes the index to file. Args: fn (str): the name of the file that will contain the index. index (pandas.DataFrame): the index. """ with open(fn, "wb") as o_file: o_file.write(_CHECK_STRING) o_file.write(zlib.compress(bytes( i...
[ "def", "write_index", "(", "fn", ",", "index", ")", ":", "with", "open", "(", "fn", ",", "\"wb\"", ")", "as", "o_file", ":", "o_file", ".", "write", "(", "_CHECK_STRING", ")", "o_file", ".", "write", "(", "zlib", ".", "compress", "(", "bytes", "(", ...
Writes the index to file. Args: fn (str): the name of the file that will contain the index. index (pandas.DataFrame): the index.
[ "Writes", "the", "index", "to", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L168-L181
train
Writes the index to file.
pgxcentre/geneparse
geneparse/index/impute2.py
read_index
def read_index(fn): """Reads index from file. Args: fn (str): the name of the file containing the index. Returns: pandas.DataFrame: the index of the file. Before reading the index, we check the first couple of bytes to see if it is a valid index file. """ index = None ...
python
def read_index(fn): """Reads index from file. Args: fn (str): the name of the file containing the index. Returns: pandas.DataFrame: the index of the file. Before reading the index, we check the first couple of bytes to see if it is a valid index file. """ index = None ...
[ "def", "read_index", "(", "fn", ")", ":", "index", "=", "None", "with", "open", "(", "fn", ",", "\"rb\"", ")", "as", "i_file", ":", "if", "i_file", ".", "read", "(", "len", "(", "_CHECK_STRING", ")", ")", "!=", "_CHECK_STRING", ":", "raise", "ValueEr...
Reads index from file. Args: fn (str): the name of the file containing the index. Returns: pandas.DataFrame: the index of the file. Before reading the index, we check the first couple of bytes to see if it is a valid index file.
[ "Reads", "index", "from", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/impute2.py#L184-L206
train
Reads index from file.
rhayes777/PyAutoFit
autofit/tools/pipeline.py
make_path
def make_path(phase) -> str: """ Create the path to the folder at which the metadata and optimizer pickle should be saved """ return "{}/{}{}{}".format(conf.instance.output_path, phase.phase_path, phase.phase_name, phase.phase_tag)
python
def make_path(phase) -> str: """ Create the path to the folder at which the metadata and optimizer pickle should be saved """ return "{}/{}{}{}".format(conf.instance.output_path, phase.phase_path, phase.phase_name, phase.phase_tag)
[ "def", "make_path", "(", "phase", ")", "->", "str", ":", "return", "\"{}/{}{}{}\"", ".", "format", "(", "conf", ".", "instance", ".", "output_path", ",", "phase", ".", "phase_path", ",", "phase", ".", "phase_name", ",", "phase", ".", "phase_tag", ")" ]
Create the path to the folder at which the metadata and optimizer pickle should be saved
[ "Create", "the", "path", "to", "the", "folder", "at", "which", "the", "metadata", "and", "optimizer", "pickle", "should", "be", "saved" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L177-L181
train
Create the path to the folder where the metadata and optimizer pickle should be saved
rhayes777/PyAutoFit
autofit/tools/pipeline.py
save_optimizer_for_phase
def save_optimizer_for_phase(phase): """ Save the optimizer associated with the phase as a pickle """ with open(make_optimizer_pickle_path(phase), "w+b") as f: f.write(pickle.dumps(phase.optimizer))
python
def save_optimizer_for_phase(phase): """ Save the optimizer associated with the phase as a pickle """ with open(make_optimizer_pickle_path(phase), "w+b") as f: f.write(pickle.dumps(phase.optimizer))
[ "def", "save_optimizer_for_phase", "(", "phase", ")", ":", "with", "open", "(", "make_optimizer_pickle_path", "(", "phase", ")", ",", "\"w+b\"", ")", "as", "f", ":", "f", ".", "write", "(", "pickle", ".", "dumps", "(", "phase", ".", "optimizer", ")", ")"...
Save the optimizer associated with the phase as a pickle
[ "Save", "the", "optimizer", "associated", "with", "the", "phase", "as", "a", "pickle" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L184-L189
train
Save the optimizer associated with the phase as a pickle
rhayes777/PyAutoFit
autofit/tools/pipeline.py
assert_optimizer_pickle_matches_for_phase
def assert_optimizer_pickle_matches_for_phase(phase): """ Assert that the previously saved optimizer is equal to the phase's optimizer if a saved optimizer is found. Parameters ---------- phase The phase Raises ------- exc.PipelineException """ path = make_optimizer_pic...
python
def assert_optimizer_pickle_matches_for_phase(phase): """ Assert that the previously saved optimizer is equal to the phase's optimizer if a saved optimizer is found. Parameters ---------- phase The phase Raises ------- exc.PipelineException """ path = make_optimizer_pic...
[ "def", "assert_optimizer_pickle_matches_for_phase", "(", "phase", ")", ":", "path", "=", "make_optimizer_pickle_path", "(", "phase", ")", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "with", "open", "(", "path", ",", "\"r+b\"", ")", "as", ...
Assert that the previously saved optimizer is equal to the phase's optimizer if a saved optimizer is found. Parameters ---------- phase The phase Raises ------- exc.PipelineException
[ "Assert", "that", "the", "previously", "saved", "optimizer", "is", "equal", "to", "the", "phase", "s", "optimizer", "if", "a", "saved", "optimizer", "is", "found", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L192-L212
train
Assert that the previously saved optimizer is equal to the phase s optimizer.
rhayes777/PyAutoFit
autofit/tools/pipeline.py
ResultsCollection.add
def add(self, phase_name, result): """ Add the result of a phase. Parameters ---------- phase_name: str The name of the phase result The result of that phase """ if phase_name in self.__result_dict: raise exc.PipelineEx...
python
def add(self, phase_name, result): """ Add the result of a phase. Parameters ---------- phase_name: str The name of the phase result The result of that phase """ if phase_name in self.__result_dict: raise exc.PipelineEx...
[ "def", "add", "(", "self", ",", "phase_name", ",", "result", ")", ":", "if", "phase_name", "in", "self", ".", "__result_dict", ":", "raise", "exc", ".", "PipelineException", "(", "\"Results from a phase called {} already exist in the pipeline\"", ".", "format", "(",...
Add the result of a phase. Parameters ---------- phase_name: str The name of the phase result The result of that phase
[ "Add", "the", "result", "of", "a", "phase", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L38-L53
train
Adds the result of a phase.
rhayes777/PyAutoFit
autofit/tools/pipeline.py
ResultsCollection.from_phase
def from_phase(self, phase_name): """ Returns the result of a previous phase by its name Parameters ---------- phase_name: str The name of a previous phase Returns ------- result: Result The result of that phase Raises ...
python
def from_phase(self, phase_name): """ Returns the result of a previous phase by its name Parameters ---------- phase_name: str The name of a previous phase Returns ------- result: Result The result of that phase Raises ...
[ "def", "from_phase", "(", "self", ",", "phase_name", ")", ":", "try", ":", "return", "self", ".", "__result_dict", "[", "phase_name", "]", "except", "KeyError", ":", "raise", "exc", ".", "PipelineException", "(", "\"No previous phase named {} found in results ({})\"...
Returns the result of a previous phase by its name Parameters ---------- phase_name: str The name of a previous phase Returns ------- result: Result The result of that phase Raises ------ exc.PipelineException ...
[ "Returns", "the", "result", "of", "a", "previous", "phase", "by", "its", "name" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L74-L97
train
Returns the result of a previous phase by its name.
rhayes777/PyAutoFit
autofit/tools/pipeline.py
Pipeline.save_metadata
def save_metadata(self, phase, data_name): """ Save metadata associated with the phase, such as the name of the pipeline, the name of the phase and the name of the data being fit """ with open("{}/.metadata".format(make_path(phase)), "w+") as f: f.write("pipeline={}\n...
python
def save_metadata(self, phase, data_name): """ Save metadata associated with the phase, such as the name of the pipeline, the name of the phase and the name of the data being fit """ with open("{}/.metadata".format(make_path(phase)), "w+") as f: f.write("pipeline={}\n...
[ "def", "save_metadata", "(", "self", ",", "phase", ",", "data_name", ")", ":", "with", "open", "(", "\"{}/.metadata\"", ".", "format", "(", "make_path", "(", "phase", ")", ")", ",", "\"w+\"", ")", "as", "f", ":", "f", ".", "write", "(", "\"pipeline={}\...
Save metadata associated with the phase, such as the name of the pipeline, the name of the phase and the name of the data being fit
[ "Save", "metadata", "associated", "with", "the", "phase", "such", "as", "the", "name", "of", "the", "pipeline", "the", "name", "of", "the", "phase", "and", "the", "name", "of", "the", "data", "being", "fit" ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L134-L141
train
Save the metadata associated with the given phase.
rhayes777/PyAutoFit
autofit/tools/pipeline.py
Pipeline.run_function
def run_function(self, func, data_name=None, assert_optimizer_pickle_matches=True): """ Run the function for each phase in the pipeline. Parameters ---------- assert_optimizer_pickle_matches data_name func A function that takes a phase and prior resul...
python
def run_function(self, func, data_name=None, assert_optimizer_pickle_matches=True): """ Run the function for each phase in the pipeline. Parameters ---------- assert_optimizer_pickle_matches data_name func A function that takes a phase and prior resul...
[ "def", "run_function", "(", "self", ",", "func", ",", "data_name", "=", "None", ",", "assert_optimizer_pickle_matches", "=", "True", ")", ":", "results", "=", "ResultsCollection", "(", ")", "for", "i", ",", "phase", "in", "enumerate", "(", "self", ".", "ph...
Run the function for each phase in the pipeline. Parameters ---------- assert_optimizer_pickle_matches data_name func A function that takes a phase and prior results, returning results for that phase Returns ------- results: ResultsCollection...
[ "Run", "the", "function", "for", "each", "phase", "in", "the", "pipeline", "." ]
a9e6144abb08edfc6a6906c4030d7119bf8d3e14
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/tools/pipeline.py#L143-L167
train
Runs the function for each phase in the pipeline and returns the results for that phase.
Riminder/python-riminder-api
riminder/bytesutils.py
strtobytes
def strtobytes(input, encoding): """Take a str and transform it into a byte array.""" py_version = sys.version_info[0] if py_version >= 3: return _strtobytes_py3(input, encoding) return _strtobytes_py2(input, encoding)
python
def strtobytes(input, encoding): """Take a str and transform it into a byte array.""" py_version = sys.version_info[0] if py_version >= 3: return _strtobytes_py3(input, encoding) return _strtobytes_py2(input, encoding)
[ "def", "strtobytes", "(", "input", ",", "encoding", ")", ":", "py_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "py_version", ">=", "3", ":", "return", "_strtobytes_py3", "(", "input", ",", "encoding", ")", "return", "_strtobytes_py2", "(...
Take a str and transform it into a byte array.
[ "Take", "a", "str", "and", "transform", "it", "into", "a", "byte", "array", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/bytesutils.py#L14-L19
train
Take a str and transform it into a byte array.
pgxcentre/geneparse
geneparse/index/__main__.py
index_impute2
def index_impute2(fn): """Indexes an IMPUTE2 file. Args: fn (str): The name of the IMPUTE2 file. """ logger.info("Indexing {} (IMPUTE2)".format(fn)) impute2_index(fn, cols=[0, 1, 2], names=["chrom", "name", "pos"], sep=" ") logger.info("Index generated")
python
def index_impute2(fn): """Indexes an IMPUTE2 file. Args: fn (str): The name of the IMPUTE2 file. """ logger.info("Indexing {} (IMPUTE2)".format(fn)) impute2_index(fn, cols=[0, 1, 2], names=["chrom", "name", "pos"], sep=" ") logger.info("Index generated")
[ "def", "index_impute2", "(", "fn", ")", ":", "logger", ".", "info", "(", "\"Indexing {} (IMPUTE2)\"", ".", "format", "(", "fn", ")", ")", "impute2_index", "(", "fn", ",", "cols", "=", "[", "0", ",", "1", ",", "2", "]", ",", "names", "=", "[", "\"ch...
Indexes an IMPUTE2 file. Args: fn (str): The name of the IMPUTE2 file.
[ "Indexes", "an", "IMPUTE2", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/__main__.py#L60-L69
train
Indexes an IMPUTE2 file.
pgxcentre/geneparse
geneparse/index/__main__.py
index_bgen
def index_bgen(fn, legacy=False): """Indexes a BGEN file. Args: fn (str): The name of the BGEN file. """ logger.info("Indexing {} (BGEN) using 'bgenix'{}".format( fn, " (legacy mode)" if legacy else "", )) command = ["bgenix", "-g", fn, "-index"] if legacy: command....
python
def index_bgen(fn, legacy=False): """Indexes a BGEN file. Args: fn (str): The name of the BGEN file. """ logger.info("Indexing {} (BGEN) using 'bgenix'{}".format( fn, " (legacy mode)" if legacy else "", )) command = ["bgenix", "-g", fn, "-index"] if legacy: command....
[ "def", "index_bgen", "(", "fn", ",", "legacy", "=", "False", ")", ":", "logger", ".", "info", "(", "\"Indexing {} (BGEN) using 'bgenix'{}\"", ".", "format", "(", "fn", ",", "\" (legacy mode)\"", "if", "legacy", "else", "\"\"", ",", ")", ")", "command", "=", ...
Indexes a BGEN file. Args: fn (str): The name of the BGEN file.
[ "Indexes", "a", "BGEN", "file", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/__main__.py#L72-L91
train
Indexes a BGEN file.
pgxcentre/geneparse
geneparse/index/__main__.py
parse_args
def parse_args(): """Parses the arguments and options.""" parser = argparse.ArgumentParser( prog="geneparse-indexer", description="Genotype file indexer." ) # IMPUTE2 files group = parser.add_argument_group("IMPUTE2 index") group.add_argument( "--impute2", metavar="IMPUT...
python
def parse_args(): """Parses the arguments and options.""" parser = argparse.ArgumentParser( prog="geneparse-indexer", description="Genotype file indexer." ) # IMPUTE2 files group = parser.add_argument_group("IMPUTE2 index") group.add_argument( "--impute2", metavar="IMPUT...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "\"geneparse-indexer\"", ",", "description", "=", "\"Genotype file indexer.\"", ")", "# IMPUTE2 files", "group", "=", "parser", ".", "add_argument_group", "(", ...
Parses the arguments and options.
[ "Parses", "the", "arguments", "and", "options", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/index/__main__.py#L94-L124
train
Parses the arguments and options.
unt-libraries/pyuntl
pyuntl/untl_structure.py
create_untl_xml_subelement
def create_untl_xml_subelement(parent, element, prefix=''): """Create a UNTL XML subelement.""" subelement = SubElement(parent, prefix + element.tag) if element.content is not None: subelement.text = element.content if element.qualifier is not None: subelement.attrib["qualifier"] = eleme...
python
def create_untl_xml_subelement(parent, element, prefix=''): """Create a UNTL XML subelement.""" subelement = SubElement(parent, prefix + element.tag) if element.content is not None: subelement.text = element.content if element.qualifier is not None: subelement.attrib["qualifier"] = eleme...
[ "def", "create_untl_xml_subelement", "(", "parent", ",", "element", ",", "prefix", "=", "''", ")", ":", "subelement", "=", "SubElement", "(", "parent", ",", "prefix", "+", "element", ".", "tag", ")", "if", "element", ".", "content", "is", "not", "None", ...
Create a UNTL XML subelement.
[ "Create", "a", "UNTL", "XML", "subelement", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L22-L35
train
Create a UNTL XML subelement.
unt-libraries/pyuntl
pyuntl/untl_structure.py
add_missing_children
def add_missing_children(required_children, element_children): """Determine if there are elements not in the children that need to be included as blank elements in the form. """ element_tags = [element.tag for element in element_children] # Loop through the elements that should be in the form. f...
python
def add_missing_children(required_children, element_children): """Determine if there are elements not in the children that need to be included as blank elements in the form. """ element_tags = [element.tag for element in element_children] # Loop through the elements that should be in the form. f...
[ "def", "add_missing_children", "(", "required_children", ",", "element_children", ")", ":", "element_tags", "=", "[", "element", ".", "tag", "for", "element", "in", "element_children", "]", "# Loop through the elements that should be in the form.", "for", "contained_element...
Determine if there are elements not in the children that need to be included as blank elements in the form.
[ "Determine", "if", "there", "are", "elements", "not", "in", "the", "children", "that", "need", "to", "be", "included", "as", "blank", "elements", "in", "the", "form", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L38-L53
train
Determine if there are elements not in the children that need to be included as blank elements in the form.
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.set_qualifier
def set_qualifier(self, value): """Set the qualifier for the element. Verifies the element is allowed to have a qualifier, and throws an exception if not. """ if self.allows_qualifier: self.qualifier = value.strip() else: raise UNTLStructureExcept...
python
def set_qualifier(self, value): """Set the qualifier for the element. Verifies the element is allowed to have a qualifier, and throws an exception if not. """ if self.allows_qualifier: self.qualifier = value.strip() else: raise UNTLStructureExcept...
[ "def", "set_qualifier", "(", "self", ",", "value", ")", ":", "if", "self", ".", "allows_qualifier", ":", "self", ".", "qualifier", "=", "value", ".", "strip", "(", ")", "else", ":", "raise", "UNTLStructureException", "(", "'Element \"%s\" does not allow a qualif...
Set the qualifier for the element. Verifies the element is allowed to have a qualifier, and throws an exception if not.
[ "Set", "the", "qualifier", "for", "the", "element", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L85-L96
train
Sets the qualifier for the element.
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.add_child
def add_child(self, child): """Add a child object to the current one. Checks the contained_children list to make sure that the object is allowable, and throws an exception if not. """ if child.tag in self.contained_children: self.children.append(child) else: ...
python
def add_child(self, child): """Add a child object to the current one. Checks the contained_children list to make sure that the object is allowable, and throws an exception if not. """ if child.tag in self.contained_children: self.children.append(child) else: ...
[ "def", "add_child", "(", "self", ",", "child", ")", ":", "if", "child", ".", "tag", "in", "self", ".", "contained_children", ":", "self", ".", "children", ".", "append", "(", "child", ")", "else", ":", "raise", "UNTLStructureException", "(", "'Invalid chil...
Add a child object to the current one. Checks the contained_children list to make sure that the object is allowable, and throws an exception if not.
[ "Add", "a", "child", "object", "to", "the", "current", "one", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L98-L112
train
Adds a child object to the current one.
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.set_content
def set_content(self, content): """Set textual content for the object/node. Verifies the node is allowed to contain content, and throws an exception if not. """ if self.allows_content: self.content = content.strip() else: raise UNTLStructureExcept...
python
def set_content(self, content): """Set textual content for the object/node. Verifies the node is allowed to contain content, and throws an exception if not. """ if self.allows_content: self.content = content.strip() else: raise UNTLStructureExcept...
[ "def", "set_content", "(", "self", ",", "content", ")", ":", "if", "self", ".", "allows_content", ":", "self", ".", "content", "=", "content", ".", "strip", "(", ")", "else", ":", "raise", "UNTLStructureException", "(", "'Element \"%s\" does not allow textual co...
Set textual content for the object/node. Verifies the node is allowed to contain content, and throws an exception if not.
[ "Set", "textual", "content", "for", "the", "object", "/", "node", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L114-L125
train
Sets the textual content for the object.
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.add_form
def add_form(self, **kwargs): """Add the form attribute to the UNTL Python object.""" vocabularies = kwargs.get('vocabularies', None) qualifier = kwargs.get('qualifier', None) content = kwargs.get('content', None) parent_tag = kwargs.get('parent_tag', None) superuser = kw...
python
def add_form(self, **kwargs): """Add the form attribute to the UNTL Python object.""" vocabularies = kwargs.get('vocabularies', None) qualifier = kwargs.get('qualifier', None) content = kwargs.get('content', None) parent_tag = kwargs.get('parent_tag', None) superuser = kw...
[ "def", "add_form", "(", "self", ",", "*", "*", "kwargs", ")", ":", "vocabularies", "=", "kwargs", ".", "get", "(", "'vocabularies'", ",", "None", ")", "qualifier", "=", "kwargs", ".", "get", "(", "'qualifier'", ",", "None", ")", "content", "=", "kwargs...
Add the form attribute to the UNTL Python object.
[ "Add", "the", "form", "attribute", "to", "the", "UNTL", "Python", "object", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L127-L191
train
Add the form attribute to the UNTL Python object.
unt-libraries/pyuntl
pyuntl/untl_structure.py
UNTLElement.record_content_length
def record_content_length(self): """Calculate length of record, excluding metadata.""" untldict = py2dict(self) untldict.pop('meta', None) return len(str(untldict))
python
def record_content_length(self): """Calculate length of record, excluding metadata.""" untldict = py2dict(self) untldict.pop('meta', None) return len(str(untldict))
[ "def", "record_content_length", "(", "self", ")", ":", "untldict", "=", "py2dict", "(", "self", ")", "untldict", ".", "pop", "(", "'meta'", ",", "None", ")", "return", "len", "(", "str", "(", "untldict", ")", ")" ]
Calculate length of record, excluding metadata.
[ "Calculate", "length", "of", "record", "excluding", "metadata", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L204-L208
train
Calculate length of record excluding metadata.
unt-libraries/pyuntl
pyuntl/untl_structure.py
FormGenerator.create_form_data
def create_form_data(self, **kwargs): """Create groupings of form elements.""" # Get the specified keyword arguments. children = kwargs.get('children', []) sort_order = kwargs.get('sort_order', None) solr_response = kwargs.get('solr_response', None) superuser = kwargs.get...
python
def create_form_data(self, **kwargs): """Create groupings of form elements.""" # Get the specified keyword arguments. children = kwargs.get('children', []) sort_order = kwargs.get('sort_order', None) solr_response = kwargs.get('solr_response', None) superuser = kwargs.get...
[ "def", "create_form_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Get the specified keyword arguments.", "children", "=", "kwargs", ".", "get", "(", "'children'", ",", "[", "]", ")", "sort_order", "=", "kwargs", ".", "get", "(", "'sort_order'", "...
Create groupings of form elements.
[ "Create", "groupings", "of", "form", "elements", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L216-L295
train
Create the form data for the UNTL elements.
unt-libraries/pyuntl
pyuntl/untl_structure.py
FormGenerator.create_form_groupings
def create_form_groupings(self, vocabularies, solr_response, element_group_dict, sort_order): """Create a group object from groupings of element objects.""" element_list = [] #...
python
def create_form_groupings(self, vocabularies, solr_response, element_group_dict, sort_order): """Create a group object from groupings of element objects.""" element_list = [] #...
[ "def", "create_form_groupings", "(", "self", ",", "vocabularies", ",", "solr_response", ",", "element_group_dict", ",", "sort_order", ")", ":", "element_list", "=", "[", "]", "# Loop through the group dictionary.", "for", "group_name", ",", "group_list", "in", "elemen...
Create a group object from groupings of element objects.
[ "Create", "a", "group", "object", "from", "groupings", "of", "element", "objects", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L297-L324
train
Create a list of group objects from groupings of element objects.
unt-libraries/pyuntl
pyuntl/untl_structure.py
FormGenerator.get_vocabularies
def get_vocabularies(self): """Get the vocabularies to pull the qualifiers from.""" # Timeout in seconds. timeout = 15 socket.setdefaulttimeout(timeout) # Create the ordered vocabulary URL. vocab_url = VOCABULARIES_URL.replace('all', 'all-verbose') # Request the v...
python
def get_vocabularies(self): """Get the vocabularies to pull the qualifiers from.""" # Timeout in seconds. timeout = 15 socket.setdefaulttimeout(timeout) # Create the ordered vocabulary URL. vocab_url = VOCABULARIES_URL.replace('all', 'all-verbose') # Request the v...
[ "def", "get_vocabularies", "(", "self", ")", ":", "# Timeout in seconds.", "timeout", "=", "15", "socket", ".", "setdefaulttimeout", "(", "timeout", ")", "# Create the ordered vocabulary URL.", "vocab_url", "=", "VOCABULARIES_URL", ".", "replace", "(", "'all'", ",", ...
Get the vocabularies to pull the qualifiers from.
[ "Get", "the", "vocabularies", "to", "pull", "the", "qualifiers", "from", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L326-L338
train
Get the vocabularies to pull the qualifiers from.
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_xml_string
def create_xml_string(self): """Create a UNTL document in a string from a UNTL metadata root object. untl_xml_string = metadata_root_object.create_xml_string() """ root = self.create_xml() xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring( root, pr...
python
def create_xml_string(self): """Create a UNTL document in a string from a UNTL metadata root object. untl_xml_string = metadata_root_object.create_xml_string() """ root = self.create_xml() xml = '<?xml version="1.0" encoding="UTF-8"?>\n' + tostring( root, pr...
[ "def", "create_xml_string", "(", "self", ")", ":", "root", "=", "self", ".", "create_xml", "(", ")", "xml", "=", "'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n'", "+", "tostring", "(", "root", ",", "pretty_print", "=", "True", ")", "return", "xml" ]
Create a UNTL document in a string from a UNTL metadata root object. untl_xml_string = metadata_root_object.create_xml_string()
[ "Create", "a", "UNTL", "document", "in", "a", "string", "from", "a", "UNTL", "metadata", "root", "object", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L358-L369
train
Create a UNTL document in a string from a UNTL metadata root object.
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_xml
def create_xml(self, useNamespace=False): """Create an ElementTree representation of the object.""" UNTL_NAMESPACE = 'http://digital2.library.unt.edu/untl/' UNTL = '{%s}' % UNTL_NAMESPACE NSMAP = {'untl': UNTL_NAMESPACE} if useNamespace: root = Element(UNTL + self.t...
python
def create_xml(self, useNamespace=False): """Create an ElementTree representation of the object.""" UNTL_NAMESPACE = 'http://digital2.library.unt.edu/untl/' UNTL = '{%s}' % UNTL_NAMESPACE NSMAP = {'untl': UNTL_NAMESPACE} if useNamespace: root = Element(UNTL + self.t...
[ "def", "create_xml", "(", "self", ",", "useNamespace", "=", "False", ")", ":", "UNTL_NAMESPACE", "=", "'http://digital2.library.unt.edu/untl/'", "UNTL", "=", "'{%s}'", "%", "UNTL_NAMESPACE", "NSMAP", "=", "{", "'untl'", ":", "UNTL_NAMESPACE", "}", "if", "useNamesp...
Create an ElementTree representation of the object.
[ "Create", "an", "ElementTree", "representation", "of", "the", "object", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L371-L392
train
Create an ElementTree representation of the object.
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_element_dict
def create_element_dict(self): """Convert a UNTL Python object into a UNTL Python dictionary.""" untl_dict = {} # Loop through all UNTL elements in the Python object. for element in self.children: # If an entry for the element list hasn't been made in the # dictio...
python
def create_element_dict(self): """Convert a UNTL Python object into a UNTL Python dictionary.""" untl_dict = {} # Loop through all UNTL elements in the Python object. for element in self.children: # If an entry for the element list hasn't been made in the # dictio...
[ "def", "create_element_dict", "(", "self", ")", ":", "untl_dict", "=", "{", "}", "# Loop through all UNTL elements in the Python object.", "for", "element", "in", "self", ".", "children", ":", "# If an entry for the element list hasn't been made in the", "# dictionary, start an...
Convert a UNTL Python object into a UNTL Python dictionary.
[ "Convert", "a", "UNTL", "Python", "object", "into", "a", "UNTL", "Python", "dictionary", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L394-L423
train
Convert a UNTL Python object into a UNTL Python dictionary.
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.create_xml_file
def create_xml_file(self, untl_filename): """Create a UNTL file. Writes file to supplied file path. """ try: f = open(untl_filename, 'w') f.write(self.create_xml_string().encode('utf-8')) f.close() except: raise UNTLStructureExcept...
python
def create_xml_file(self, untl_filename): """Create a UNTL file. Writes file to supplied file path. """ try: f = open(untl_filename, 'w') f.write(self.create_xml_string().encode('utf-8')) f.close() except: raise UNTLStructureExcept...
[ "def", "create_xml_file", "(", "self", ",", "untl_filename", ")", ":", "try", ":", "f", "=", "open", "(", "untl_filename", ",", "'w'", ")", "f", ".", "write", "(", "self", ".", "create_xml_string", "(", ")", ".", "encode", "(", "'utf-8'", ")", ")", "...
Create a UNTL file. Writes file to supplied file path.
[ "Create", "a", "UNTL", "file", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L425-L437
train
Create a UNTL XML file.
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.sort_untl
def sort_untl(self, sort_structure): """Sort the UNTL Python object by the index of a sort structure pre-ordered list. """ self.children.sort(key=lambda obj: sort_structure.index(obj.tag))
python
def sort_untl(self, sort_structure): """Sort the UNTL Python object by the index of a sort structure pre-ordered list. """ self.children.sort(key=lambda obj: sort_structure.index(obj.tag))
[ "def", "sort_untl", "(", "self", ",", "sort_structure", ")", ":", "self", ".", "children", ".", "sort", "(", "key", "=", "lambda", "obj", ":", "sort_structure", ".", "index", "(", "obj", ".", "tag", ")", ")" ]
Sort the UNTL Python object by the index of a sort structure pre-ordered list.
[ "Sort", "the", "UNTL", "Python", "object", "by", "the", "index", "of", "a", "sort", "structure", "pre", "-", "ordered", "list", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L439-L443
train
Sort the UNTL Python object by the index of a sort structure pre - ordered list.
unt-libraries/pyuntl
pyuntl/untl_structure.py
Metadata.generate_form_data
def generate_form_data(self, **kwargs): """Create a form dictionary with the key being the element name and the value being a list of form element objects. """ # Add elements that are missing from the form. self.children = add_missing_children( self.contained_children...
python
def generate_form_data(self, **kwargs): """Create a form dictionary with the key being the element name and the value being a list of form element objects. """ # Add elements that are missing from the form. self.children = add_missing_children( self.contained_children...
[ "def", "generate_form_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Add elements that are missing from the form.", "self", ".", "children", "=", "add_missing_children", "(", "self", ".", "contained_children", ",", "self", ".", "children", ")", "# Add chi...
Create a form dictionary with the key being the element name and the value being a list of form element objects.
[ "Create", "a", "form", "dictionary", "with", "the", "key", "being", "the", "element", "name", "and", "the", "value", "being", "a", "list", "of", "form", "element", "objects", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/untl_structure.py#L449-L461
train
Create a form dictionary with the key being the element name and the value being a list of form element objects.
eventifyio/eventify
eventify/tracking/__init__.py
track_event
async def track_event(event, state, service_name): """ Store state of events in memory :param event: Event object :param state: EventState object :param service_name: Name of service name """ redis = await aioredis.create_redis( (EVENT_TRACKING_HOST, 6379), loop=loop) now = date...
python
async def track_event(event, state, service_name): """ Store state of events in memory :param event: Event object :param state: EventState object :param service_name: Name of service name """ redis = await aioredis.create_redis( (EVENT_TRACKING_HOST, 6379), loop=loop) now = date...
[ "async", "def", "track_event", "(", "event", ",", "state", ",", "service_name", ")", ":", "redis", "=", "await", "aioredis", ".", "create_redis", "(", "(", "EVENT_TRACKING_HOST", ",", "6379", ")", ",", "loop", "=", "loop", ")", "now", "=", "datetime", "....
Store state of events in memory :param event: Event object :param state: EventState object :param service_name: Name of service name
[ "Store", "state", "of", "events", "in", "memory", ":", "param", "event", ":", "Event", "object", ":", "param", "state", ":", "EventState", "object", ":", "param", "service_name", ":", "Name", "of", "service", "name" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/tracking/__init__.py#L17-L37
train
Store state of an event in memory
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
contributor_director
def contributor_director(**kwargs): """Define the expanded qualifier name.""" if kwargs.get('qualifier') in ETD_MS_CONTRIBUTOR_EXPANSION: # Return the element object. return ETD_MSContributor( role=ETD_MS_CONTRIBUTOR_EXPANSION[kwargs.get('qualifier')], **kwargs ) ...
python
def contributor_director(**kwargs): """Define the expanded qualifier name.""" if kwargs.get('qualifier') in ETD_MS_CONTRIBUTOR_EXPANSION: # Return the element object. return ETD_MSContributor( role=ETD_MS_CONTRIBUTOR_EXPANSION[kwargs.get('qualifier')], **kwargs ) ...
[ "def", "contributor_director", "(", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'qualifier'", ")", "in", "ETD_MS_CONTRIBUTOR_EXPANSION", ":", "# Return the element object.", "return", "ETD_MSContributor", "(", "role", "=", "ETD_MS_CONTRIBUTOR_EXPAN...
Define the expanded qualifier name.
[ "Define", "the", "expanded", "qualifier", "name", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L211-L220
train
Define the expanded qualifier name.
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
date_director
def date_director(**kwargs): """Direct which class should be used based on the date qualifier or if the date should be converted at all. """ # If the date is a creation date, return the element object. if kwargs.get('qualifier') == 'creation': return ETD_MSDate(content=kwargs.get('content')....
python
def date_director(**kwargs): """Direct which class should be used based on the date qualifier or if the date should be converted at all. """ # If the date is a creation date, return the element object. if kwargs.get('qualifier') == 'creation': return ETD_MSDate(content=kwargs.get('content')....
[ "def", "date_director", "(", "*", "*", "kwargs", ")", ":", "# If the date is a creation date, return the element object.", "if", "kwargs", ".", "get", "(", "'qualifier'", ")", "==", "'creation'", ":", "return", "ETD_MSDate", "(", "content", "=", "kwargs", ".", "ge...
Direct which class should be used based on the date qualifier or if the date should be converted at all.
[ "Direct", "which", "class", "should", "be", "used", "based", "on", "the", "date", "qualifier", "or", "if", "the", "date", "should", "be", "converted", "at", "all", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L234-L245
train
Direct which class should be used based on the date qualifier
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
identifier_director
def identifier_director(**kwargs): """Direct how to handle the identifier element.""" ark = kwargs.get('ark', None) qualifier = kwargs.get('qualifier', None) content = kwargs.get('content', '') # See if the ark and domain name were given. if ark: content = 'http://digital.library.unt.ed...
python
def identifier_director(**kwargs): """Direct how to handle the identifier element.""" ark = kwargs.get('ark', None) qualifier = kwargs.get('qualifier', None) content = kwargs.get('content', '') # See if the ark and domain name were given. if ark: content = 'http://digital.library.unt.ed...
[ "def", "identifier_director", "(", "*", "*", "kwargs", ")", ":", "ark", "=", "kwargs", ".", "get", "(", "'ark'", ",", "None", ")", "qualifier", "=", "kwargs", ".", "get", "(", "'qualifier'", ",", "None", ")", "content", "=", "kwargs", ".", "get", "("...
Direct how to handle the identifier element.
[ "Direct", "how", "to", "handle", "the", "identifier", "element", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L248-L259
train
Direct how to handle the identifier element.
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
subject_director
def subject_director(**kwargs): """Direct how to handle a subject element.""" if kwargs.get('qualifier') not in ['KWD', '']: return ETD_MSSubject(scheme=kwargs.get('qualifier'), **kwargs) else: return ETD_MSSubject(content=kwargs.get('content'))
python
def subject_director(**kwargs): """Direct how to handle a subject element.""" if kwargs.get('qualifier') not in ['KWD', '']: return ETD_MSSubject(scheme=kwargs.get('qualifier'), **kwargs) else: return ETD_MSSubject(content=kwargs.get('content'))
[ "def", "subject_director", "(", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'qualifier'", ")", "not", "in", "[", "'KWD'", ",", "''", "]", ":", "return", "ETD_MSSubject", "(", "scheme", "=", "kwargs", ".", "get", "(", "'qualifier'", ...
Direct how to handle a subject element.
[ "Direct", "how", "to", "handle", "a", "subject", "element", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L262-L267
train
Direct how to handle a subject element.
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
ETD_MSElement.add_child
def add_child(self, child): """Add a child object to the current one. Checks the contained_children list to make sure that the object is allowable, and throws an exception if not. """ # Make sure the child exists before adding it. if child: # Add the child if...
python
def add_child(self, child): """Add a child object to the current one. Checks the contained_children list to make sure that the object is allowable, and throws an exception if not. """ # Make sure the child exists before adding it. if child: # Add the child if...
[ "def", "add_child", "(", "self", ",", "child", ")", ":", "# Make sure the child exists before adding it.", "if", "child", ":", "# Add the child if it is allowed to exist under the parent.", "if", "child", ".", "tag", "in", "self", ".", "contained_children", ":", "self", ...
Add a child object to the current one. Checks the contained_children list to make sure that the object is allowable, and throws an exception if not.
[ "Add", "a", "child", "object", "to", "the", "current", "one", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L52-L67
train
Adds a child object to the current one.
unt-libraries/pyuntl
pyuntl/etd_ms_structure.py
ETD_MSElement.get_child_content
def get_child_content(self, children, element_name): """Get the requested element content from a list of children.""" # Loop through the children and get the specified element. for child in children: # If the child is the requested element, return its content. if child.ta...
python
def get_child_content(self, children, element_name): """Get the requested element content from a list of children.""" # Loop through the children and get the specified element. for child in children: # If the child is the requested element, return its content. if child.ta...
[ "def", "get_child_content", "(", "self", ",", "children", ",", "element_name", ")", ":", "# Loop through the children and get the specified element.", "for", "child", "in", "children", ":", "# If the child is the requested element, return its content.", "if", "child", ".", "t...
Get the requested element content from a list of children.
[ "Get", "the", "requested", "element", "content", "from", "a", "list", "of", "children", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/etd_ms_structure.py#L69-L76
train
Get the requested element content from a list of children.
geophysics-ubonn/crtomo_tools
src/td_residuals.py
shiftedColorMap
def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'): ''' Function to offset the "center" of a colormap. Useful for data with a negative min and positive max and you want the middle of the colormap's dynamic range to be at zero Parameters ---------- cmap: T...
python
def shiftedColorMap(cmap, start=0, midpoint=0.5, stop=1.0, name='shiftedcmap'): ''' Function to offset the "center" of a colormap. Useful for data with a negative min and positive max and you want the middle of the colormap's dynamic range to be at zero Parameters ---------- cmap: T...
[ "def", "shiftedColorMap", "(", "cmap", ",", "start", "=", "0", ",", "midpoint", "=", "0.5", ",", "stop", "=", "1.0", ",", "name", "=", "'shiftedcmap'", ")", ":", "cdict", "=", "{", "'red'", ":", "[", "]", ",", "'green'", ":", "[", "]", ",", "'blu...
Function to offset the "center" of a colormap. Useful for data with a negative min and positive max and you want the middle of the colormap's dynamic range to be at zero Parameters ---------- cmap: The matplotlib colormap to be altered start: Offset from lowest point in the colo...
[ "Function", "to", "offset", "the", "center", "of", "a", "colormap", ".", "Useful", "for", "data", "with", "a", "negative", "min", "and", "positive", "max", "and", "you", "want", "the", "middle", "of", "the", "colormap", "s", "dynamic", "range", "to", "be...
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_residuals.py#L10-L60
train
Function to compute the shifted color map for a given colormap.
geophysics-ubonn/crtomo_tools
src/td_residuals.py
read_lastmodfile
def read_lastmodfile(directory): """ Return the number of the final inversion result. """ filename = '{0}/exe/inv.lastmod'.format(directory) # filename HAS to exist. Otherwise the inversion was not finished if(not os.path.isfile(filename)): return None linestring = open(filename, 'r...
python
def read_lastmodfile(directory): """ Return the number of the final inversion result. """ filename = '{0}/exe/inv.lastmod'.format(directory) # filename HAS to exist. Otherwise the inversion was not finished if(not os.path.isfile(filename)): return None linestring = open(filename, 'r...
[ "def", "read_lastmodfile", "(", "directory", ")", ":", "filename", "=", "'{0}/exe/inv.lastmod'", ".", "format", "(", "directory", ")", "# filename HAS to exist. Otherwise the inversion was not finished", "if", "(", "not", "os", ".", "path", ".", "isfile", "(", "filena...
Return the number of the final inversion result.
[ "Return", "the", "number", "of", "the", "final", "inversion", "result", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_residuals.py#L63-L76
train
Read the last mod file in the specified directory.
Riminder/python-riminder-api
riminder/webhook.py
Webhook.setHandler
def setHandler(self, event_name, callback): """Set an handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) if callable(event_name): raise TypeError('{} is not callable'.format(callback)) sel...
python
def setHandler(self, event_name, callback): """Set an handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) if callable(event_name): raise TypeError('{} is not callable'.format(callback)) sel...
[ "def", "setHandler", "(", "self", ",", "event_name", ",", "callback", ")", ":", "if", "event_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'{} is not a valid event'", ".", "format", "(", "event_name", ")", ")", "if", "callabl...
Set an handler for given event.
[ "Set", "an", "handler", "for", "given", "event", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L59-L65
train
Set an event handler for given event.
Riminder/python-riminder-api
riminder/webhook.py
Webhook.isHandlerPresent
def isHandlerPresent(self, event_name): """Check if an event has an handler.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) return self.handlers[event_name] is not None
python
def isHandlerPresent(self, event_name): """Check if an event has an handler.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) return self.handlers[event_name] is not None
[ "def", "isHandlerPresent", "(", "self", ",", "event_name", ")", ":", "if", "event_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'{} is not a valid event'", ".", "format", "(", "event_name", ")", ")", "return", "self", ".", "h...
Check if an event has an handler.
[ "Check", "if", "an", "event", "has", "an", "handler", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L67-L71
train
Check if an event has a handler.
Riminder/python-riminder-api
riminder/webhook.py
Webhook.removeHandler
def removeHandler(self, event_name): """Remove handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) self.handlers[event_name] = None
python
def removeHandler(self, event_name): """Remove handler for given event.""" if event_name not in self.handlers: raise ValueError('{} is not a valid event'.format(event_name)) self.handlers[event_name] = None
[ "def", "removeHandler", "(", "self", ",", "event_name", ")", ":", "if", "event_name", "not", "in", "self", ".", "handlers", ":", "raise", "ValueError", "(", "'{} is not a valid event'", ".", "format", "(", "event_name", ")", ")", "self", ".", "handlers", "["...
Remove handler for given event.
[ "Remove", "handler", "for", "given", "event", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L73-L77
train
Remove handler for given event.
Riminder/python-riminder-api
riminder/webhook.py
Webhook._get_fct_number_of_arg
def _get_fct_number_of_arg(self, fct): """Get the number of argument of a fuction.""" py_version = sys.version_info[0] if py_version >= 3: return len(inspect.signature(fct).parameters) return len(inspect.getargspec(fct)[0])
python
def _get_fct_number_of_arg(self, fct): """Get the number of argument of a fuction.""" py_version = sys.version_info[0] if py_version >= 3: return len(inspect.signature(fct).parameters) return len(inspect.getargspec(fct)[0])
[ "def", "_get_fct_number_of_arg", "(", "self", ",", "fct", ")", ":", "py_version", "=", "sys", ".", "version_info", "[", "0", "]", "if", "py_version", ">=", "3", ":", "return", "len", "(", "inspect", ".", "signature", "(", "fct", ")", ".", "parameters", ...
Get the number of argument of a fuction.
[ "Get", "the", "number", "of", "argument", "of", "a", "fuction", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L95-L100
train
Get the number of argument of a fuction.
Riminder/python-riminder-api
riminder/webhook.py
Webhook.handle
def handle(self, request_headers={}, signature_header=None): """Handle request.""" if self.client.webhook_secret is None: raise ValueError('Error: no webhook secret.') encoded_header = self._get_signature_header(signature_header, request_headers) decoded_request = self._decod...
python
def handle(self, request_headers={}, signature_header=None): """Handle request.""" if self.client.webhook_secret is None: raise ValueError('Error: no webhook secret.') encoded_header = self._get_signature_header(signature_header, request_headers) decoded_request = self._decod...
[ "def", "handle", "(", "self", ",", "request_headers", "=", "{", "}", ",", "signature_header", "=", "None", ")", ":", "if", "self", ".", "client", ".", "webhook_secret", "is", "None", ":", "raise", "ValueError", "(", "'Error: no webhook secret.'", ")", "encod...
Handle request.
[ "Handle", "request", "." ]
01279f0ece08cf3d1dd45f76de6d9edf7fafec90
https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/webhook.py#L102-L116
train
Handle a request.
eventifyio/eventify
eventify/service.py
event_tracker
def event_tracker(func): """ Event tracking handler """ @wraps(func) async def wrapper(*args, **kwargs): """ Wraps function to provide redis tracking """ event = Event(args[0]) session = kwargs['session'] service_name = session.name awa...
python
def event_tracker(func): """ Event tracking handler """ @wraps(func) async def wrapper(*args, **kwargs): """ Wraps function to provide redis tracking """ event = Event(args[0]) session = kwargs['session'] service_name = session.name awa...
[ "def", "event_tracker", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "async", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n Wraps function to provide redis\n tracking\n \"\"\"", "event", "=", "Event...
Event tracking handler
[ "Event", "tracking", "handler" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/service.py#L19-L35
train
A decorator that tracks the execution of a function in Redis.
albert12132/templar
templar/api/publish.py
publish
def publish(config, source=None, template=None, destination=None, jinja_env=None, no_write=False): """Given a config, performs an end-to-end publishing pipeline and returns the result: linking -> compiling -> templating -> writing NOTE: at most one of source and template can be None. If both are None,...
python
def publish(config, source=None, template=None, destination=None, jinja_env=None, no_write=False): """Given a config, performs an end-to-end publishing pipeline and returns the result: linking -> compiling -> templating -> writing NOTE: at most one of source and template can be None. If both are None,...
[ "def", "publish", "(", "config", ",", "source", "=", "None", ",", "template", "=", "None", ",", "destination", "=", "None", ",", "jinja_env", "=", "None", ",", "no_write", "=", "False", ")", ":", "if", "not", "isinstance", "(", "config", ",", "Config",...
Given a config, performs an end-to-end publishing pipeline and returns the result: linking -> compiling -> templating -> writing NOTE: at most one of source and template can be None. If both are None, the publisher effectively has nothing to do; an exception is raised. PARAMETERS: config ...
[ "Given", "a", "config", "performs", "an", "end", "-", "to", "-", "end", "publishing", "pipeline", "and", "returns", "the", "result", ":" ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/publish.py#L18-L104
train
This function performs a end - to - end publishing pipeline and returns the result of the publishing pipeline.
KnightConan/sspdatatables
src/sspdatatables/utils/decorator.py
ensure_ajax
def ensure_ajax(valid_request_methods, error_response_context=None): """ Intends to ensure the received the request is ajax request and it is included in the valid request methods :param valid_request_methods: list: list of valid request methods, such as 'GET', 'POST' :param error_response_co...
python
def ensure_ajax(valid_request_methods, error_response_context=None): """ Intends to ensure the received the request is ajax request and it is included in the valid request methods :param valid_request_methods: list: list of valid request methods, such as 'GET', 'POST' :param error_response_co...
[ "def", "ensure_ajax", "(", "valid_request_methods", ",", "error_response_context", "=", "None", ")", ":", "def", "real_decorator", "(", "view_func", ")", ":", "def", "wrap_func", "(", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "n...
Intends to ensure the received the request is ajax request and it is included in the valid request methods :param valid_request_methods: list: list of valid request methods, such as 'GET', 'POST' :param error_response_context: None/dict: context dictionary to render, if error occurs :return...
[ "Intends", "to", "ensure", "the", "received", "the", "request", "is", "ajax", "request", "and", "it", "is", "included", "in", "the", "valid", "request", "methods" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/decorator.py#L8-L38
train
This is a decorator that ensures the received request is ajax request and it is included in the list of allowed request methods.
KnightConan/sspdatatables
src/sspdatatables/utils/decorator.py
generate_error_json_response
def generate_error_json_response(error_dict, error_response_context=None): """ Intends to build an error json response. If the error_response_context is None, then we generate this response using data tables format :param error_dict: str/dict: contains the error message(s) :param error_response_con...
python
def generate_error_json_response(error_dict, error_response_context=None): """ Intends to build an error json response. If the error_response_context is None, then we generate this response using data tables format :param error_dict: str/dict: contains the error message(s) :param error_response_con...
[ "def", "generate_error_json_response", "(", "error_dict", ",", "error_response_context", "=", "None", ")", ":", "response", "=", "error_dict", "if", "isinstance", "(", "error_dict", ",", "str", ")", ":", "response", "=", "{", "\"error\"", ":", "response", "}", ...
Intends to build an error json response. If the error_response_context is None, then we generate this response using data tables format :param error_dict: str/dict: contains the error message(s) :param error_response_context: None/dict: context dictionary to render, if error occurs :return: JsonR...
[ "Intends", "to", "build", "an", "error", "json", "response", ".", "If", "the", "error_response_context", "is", "None", "then", "we", "generate", "this", "response", "using", "data", "tables", "format" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/decorator.py#L41-L59
train
Generates a json response for an error
gofed/gofedlib
gofedlib/go/symbolsextractor/extractor.py
GoSymbolsExtractor._mergeGoSymbols
def _mergeGoSymbols(self, jsons = []): """ Exported symbols for a given package does not have any prefix. So I can drop all import paths that are file specific and merge all symbols. Assuming all files in the given package has mutual exclusive symbols. """ # <siXy> imports are per file, exports are per pa...
python
def _mergeGoSymbols(self, jsons = []): """ Exported symbols for a given package does not have any prefix. So I can drop all import paths that are file specific and merge all symbols. Assuming all files in the given package has mutual exclusive symbols. """ # <siXy> imports are per file, exports are per pa...
[ "def", "_mergeGoSymbols", "(", "self", ",", "jsons", "=", "[", "]", ")", ":", "# <siXy> imports are per file, exports are per package", "# on the highest level we have: pkgname, types, funcs, vars, imports.", "symbols", "=", "{", "}", "symbols", "[", "\"types\"", "]", "=", ...
Exported symbols for a given package does not have any prefix. So I can drop all import paths that are file specific and merge all symbols. Assuming all files in the given package has mutual exclusive symbols.
[ "Exported", "symbols", "for", "a", "given", "package", "does", "not", "have", "any", "prefix", ".", "So", "I", "can", "drop", "all", "import", "paths", "that", "are", "file", "specific", "and", "merge", "all", "symbols", ".", "Assuming", "all", "files", ...
0674c248fe3d8706f98f912996b65af469f96b10
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/symbolsextractor/extractor.py#L203-L222
train
Merge all exported symbols for a given package.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/_winapi.py
format_system_message
def format_system_message(errno): """ Call FormatMessage with a system error number to retrieve the descriptive error message. """ # first some flags used by FormatMessageW ALLOCATE_BUFFER = 0x100 ARGUMENT_ARRAY = 0x2000 FROM_HMODULE = 0x800 FROM_STRING = 0x400 FROM_SYSTEM = 0x10...
python
def format_system_message(errno): """ Call FormatMessage with a system error number to retrieve the descriptive error message. """ # first some flags used by FormatMessageW ALLOCATE_BUFFER = 0x100 ARGUMENT_ARRAY = 0x2000 FROM_HMODULE = 0x800 FROM_STRING = 0x400 FROM_SYSTEM = 0x10...
[ "def", "format_system_message", "(", "errno", ")", ":", "# first some flags used by FormatMessageW", "ALLOCATE_BUFFER", "=", "0x100", "ARGUMENT_ARRAY", "=", "0x2000", "FROM_HMODULE", "=", "0x800", "FROM_STRING", "=", "0x400", "FROM_SYSTEM", "=", "0x1000", "IGNORE_INSERTS"...
Call FormatMessage with a system error number to retrieve the descriptive error message.
[ "Call", "FormatMessage", "with", "a", "system", "error", "number", "to", "retrieve", "the", "descriptive", "error", "message", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/_winapi.py#L25-L62
train
Get a descriptive error message from a system error number.
NikolayDachev/jadm
lib/paramiko-1.14.1/paramiko/_winapi.py
MemoryMap.read
def read(self, n): """ Read n bytes from mapped view. """ out = ctypes.create_string_buffer(n) ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n) self.pos += n return out.raw
python
def read(self, n): """ Read n bytes from mapped view. """ out = ctypes.create_string_buffer(n) ctypes.windll.kernel32.RtlMoveMemory(out, self.view + self.pos, n) self.pos += n return out.raw
[ "def", "read", "(", "self", ",", "n", ")", ":", "out", "=", "ctypes", ".", "create_string_buffer", "(", "n", ")", "ctypes", ".", "windll", ".", "kernel32", ".", "RtlMoveMemory", "(", "out", ",", "self", ".", "view", "+", "self", ".", "pos", ",", "n...
Read n bytes from mapped view.
[ "Read", "n", "bytes", "from", "mapped", "view", "." ]
12bb550445edfcd87506f7cba7a6a35d413c5511
https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/_winapi.py#L145-L152
train
Read n bytes from mapped view.
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/transition_simulator.py
ActionSimulationCell._output
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]: '''Converts `fluents` to tensors with datatype tf.float32.''' output = [] for _, fluent in fluents: tensor = fluent.tensor if tensor.dtype != tf.float32: tensor = tf.cast(tensor, tf.fl...
python
def _output(cls, fluents: Sequence[FluentPair]) -> Sequence[tf.Tensor]: '''Converts `fluents` to tensors with datatype tf.float32.''' output = [] for _, fluent in fluents: tensor = fluent.tensor if tensor.dtype != tf.float32: tensor = tf.cast(tensor, tf.fl...
[ "def", "_output", "(", "cls", ",", "fluents", ":", "Sequence", "[", "FluentPair", "]", ")", "->", "Sequence", "[", "tf", ".", "Tensor", "]", ":", "output", "=", "[", "]", "for", "_", ",", "fluent", "in", "fluents", ":", "tensor", "=", "fluent", "."...
Converts `fluents` to tensors with datatype tf.float32.
[ "Converts", "fluents", "to", "tensors", "with", "datatype", "tf", ".", "float32", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/transition_simulator.py#L124-L132
train
Converts fluents to tensors with datatype tf. float32.
255BITS/hyperchamber
hyperchamber/selector.py
Selector.set
def set(self, key, value): """Sets a hyperparameter. Can be used to set an array of hyperparameters.""" self.store[key]=value return self.store
python
def set(self, key, value): """Sets a hyperparameter. Can be used to set an array of hyperparameters.""" self.store[key]=value return self.store
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "store", "[", "key", "]", "=", "value", "return", "self", ".", "store" ]
Sets a hyperparameter. Can be used to set an array of hyperparameters.
[ "Sets", "a", "hyperparameter", ".", "Can", "be", "used", "to", "set", "an", "array", "of", "hyperparameters", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L29-L32
train
Sets a hyperparameter. Can be used to set an array of hyperparameters.
255BITS/hyperchamber
hyperchamber/selector.py
Selector.get_config_value
def get_config_value(self, k, i): """Gets the ith config value for k. e.g. get_config_value('x', 1)""" if(not isinstance(self.store[k], list)): return self.store[k] else: return self.store[k][i]
python
def get_config_value(self, k, i): """Gets the ith config value for k. e.g. get_config_value('x', 1)""" if(not isinstance(self.store[k], list)): return self.store[k] else: return self.store[k][i]
[ "def", "get_config_value", "(", "self", ",", "k", ",", "i", ")", ":", "if", "(", "not", "isinstance", "(", "self", ".", "store", "[", "k", "]", ",", "list", ")", ")", ":", "return", "self", ".", "store", "[", "k", "]", "else", ":", "return", "s...
Gets the ith config value for k. e.g. get_config_value('x', 1)
[ "Gets", "the", "ith", "config", "value", "for", "k", ".", "e", ".", "g", ".", "get_config_value", "(", "x", "1", ")" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L44-L49
train
Gets the ith config value for k. e. g. get_config_value ( x 1 )
255BITS/hyperchamber
hyperchamber/selector.py
Selector.configs
def configs(self, max_configs=1, offset=None, serial=False, create_uuid=True): """Generate max configs, each one a dictionary. e.g. [{'x': 1}] Will also add a config UUID, useful for tracking configs. You can turn this off by passing create_uuid=False. """ if len(self.st...
python
def configs(self, max_configs=1, offset=None, serial=False, create_uuid=True): """Generate max configs, each one a dictionary. e.g. [{'x': 1}] Will also add a config UUID, useful for tracking configs. You can turn this off by passing create_uuid=False. """ if len(self.st...
[ "def", "configs", "(", "self", ",", "max_configs", "=", "1", ",", "offset", "=", "None", ",", "serial", "=", "False", ",", "create_uuid", "=", "True", ")", ":", "if", "len", "(", "self", ".", "store", ")", "==", "0", ":", "return", "[", "]", "con...
Generate max configs, each one a dictionary. e.g. [{'x': 1}] Will also add a config UUID, useful for tracking configs. You can turn this off by passing create_uuid=False.
[ "Generate", "max", "configs", "each", "one", "a", "dictionary", ".", "e", ".", "g", ".", "[", "{", "x", ":", "1", "}", "]" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L51-L75
train
Generate max_configs each one a dictionary. e. g. [ x 1 ]
255BITS/hyperchamber
hyperchamber/selector.py
Selector.config_at
def config_at(self, i): """Gets the ith config""" selections = {} for key in self.store: value = self.store[key] if isinstance(value, list): selected = i % len(value) i = i // len(value) selections[key]= value[selected] else: sele...
python
def config_at(self, i): """Gets the ith config""" selections = {} for key in self.store: value = self.store[key] if isinstance(value, list): selected = i % len(value) i = i // len(value) selections[key]= value[selected] else: sele...
[ "def", "config_at", "(", "self", ",", "i", ")", ":", "selections", "=", "{", "}", "for", "key", "in", "self", ".", "store", ":", "value", "=", "self", ".", "store", "[", "key", "]", "if", "isinstance", "(", "value", ",", "list", ")", ":", "select...
Gets the ith config
[ "Gets", "the", "ith", "config" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L77-L89
train
Gets the ith config
255BITS/hyperchamber
hyperchamber/selector.py
Selector.top
def top(self, sort_by): """Get the best results according to your custom sort method.""" sort = sorted(self.results, key=sort_by) return sort
python
def top(self, sort_by): """Get the best results according to your custom sort method.""" sort = sorted(self.results, key=sort_by) return sort
[ "def", "top", "(", "self", ",", "sort_by", ")", ":", "sort", "=", "sorted", "(", "self", ".", "results", ",", "key", "=", "sort_by", ")", "return", "sort" ]
Get the best results according to your custom sort method.
[ "Get", "the", "best", "results", "according", "to", "your", "custom", "sort", "method", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L101-L104
train
Get the best results according to your custom sort method.
255BITS/hyperchamber
hyperchamber/selector.py
Selector.load
def load(self, filename): """Loads a config from disk""" content = open(filename) return Config(json.load(content))
python
def load(self, filename): """Loads a config from disk""" content = open(filename) return Config(json.load(content))
[ "def", "load", "(", "self", ",", "filename", ")", ":", "content", "=", "open", "(", "filename", ")", "return", "Config", "(", "json", ".", "load", "(", "content", ")", ")" ]
Loads a config from disk
[ "Loads", "a", "config", "from", "disk" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L110-L113
train
Loads a config from disk
255BITS/hyperchamber
hyperchamber/selector.py
Selector.load_or_create_config
def load_or_create_config(self, filename, config=None): """Loads a config from disk. Defaults to a random config if none is specified""" os.makedirs(os.path.dirname(os.path.expanduser(filename)), exist_ok=True) if os.path.exists(filename): return self.load(filename) if(conf...
python
def load_or_create_config(self, filename, config=None): """Loads a config from disk. Defaults to a random config if none is specified""" os.makedirs(os.path.dirname(os.path.expanduser(filename)), exist_ok=True) if os.path.exists(filename): return self.load(filename) if(conf...
[ "def", "load_or_create_config", "(", "self", ",", "filename", ",", "config", "=", "None", ")", ":", "os", ".", "makedirs", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "expanduser", "(", "filename", ")", ")", ",", "exist_ok", ...
Loads a config from disk. Defaults to a random config if none is specified
[ "Loads", "a", "config", "from", "disk", ".", "Defaults", "to", "a", "random", "config", "if", "none", "is", "specified" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L115-L125
train
Loads a config from disk. Defaults to a random config if none is specified.
255BITS/hyperchamber
hyperchamber/selector.py
Selector.save
def save(self, filename, config): """Loads a config from disk""" return open(os.path.expanduser(filename), 'w').write(json.dumps(config, cls=HCEncoder, sort_keys=True, indent=2, separators=(',', ': ')))
python
def save(self, filename, config): """Loads a config from disk""" return open(os.path.expanduser(filename), 'w').write(json.dumps(config, cls=HCEncoder, sort_keys=True, indent=2, separators=(',', ': ')))
[ "def", "save", "(", "self", ",", "filename", ",", "config", ")", ":", "return", "open", "(", "os", ".", "path", ".", "expanduser", "(", "filename", ")", ",", "'w'", ")", ".", "write", "(", "json", ".", "dumps", "(", "config", ",", "cls", "=", "HC...
Loads a config from disk
[ "Loads", "a", "config", "from", "disk" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/hyperchamber/selector.py#L127-L129
train
Loads a config from disk
redhat-openstack/python-tripleo-helper
tripleohelper/undercloud.py
Undercloud.configure
def configure(self, repositories): """Prepare the system to be ready for an undercloud installation. """ self.enable_repositories(repositories) self.create_stack_user() self.install_base_packages() self.clean_system() self.yum_update(allow_reboot=True) sel...
python
def configure(self, repositories): """Prepare the system to be ready for an undercloud installation. """ self.enable_repositories(repositories) self.create_stack_user() self.install_base_packages() self.clean_system() self.yum_update(allow_reboot=True) sel...
[ "def", "configure", "(", "self", ",", "repositories", ")", ":", "self", ".", "enable_repositories", "(", "repositories", ")", "self", ".", "create_stack_user", "(", ")", "self", ".", "install_base_packages", "(", ")", "self", ".", "clean_system", "(", ")", "...
Prepare the system to be ready for an undercloud installation.
[ "Prepare", "the", "system", "to", "be", "ready", "for", "an", "undercloud", "installation", "." ]
bfa165538335edb1088170c7a92f097167225c81
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/undercloud.py#L32-L42
train
Configure the system to be ready for an undercloud installation.