repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
theonion/djes
djes/models.py
Indexable.to_dict
def to_dict(self): """Get a dictionary representation of this item, formatted for Elasticsearch""" out = {} fields = self.__class__.search_objects.mapping.properties.properties for key in fields: # TODO: What if we've mapped the property to a different name? Will we allow t...
python
def to_dict(self): """Get a dictionary representation of this item, formatted for Elasticsearch""" out = {} fields = self.__class__.search_objects.mapping.properties.properties for key in fields: # TODO: What if we've mapped the property to a different name? Will we allow t...
[ "def", "to_dict", "(", "self", ")", ":", "out", "=", "{", "}", "fields", "=", "self", ".", "__class__", ".", "search_objects", ".", "mapping", ".", "properties", ".", "properties", "for", "key", "in", "fields", ":", "# TODO: What if we've mapped the property t...
Get a dictionary representation of this item, formatted for Elasticsearch
[ "Get", "a", "dictionary", "representation", "of", "this", "item", "formatted", "for", "Elasticsearch" ]
train
https://github.com/theonion/djes/blob/8f7347382c74172e82e959e3dfbc12b18fbb523f/djes/models.py#L147-L182
theonion/djes
djes/models.py
Indexable.index
def index(self, refresh=False): """Indexes this object, using a document from `to_dict()`""" es = connections.get_connection("default") index = self.__class__.search_objects.mapping.index doc_type = self.__class__.search_objects.mapping.doc_type es.index(index, doc_type, ...
python
def index(self, refresh=False): """Indexes this object, using a document from `to_dict()`""" es = connections.get_connection("default") index = self.__class__.search_objects.mapping.index doc_type = self.__class__.search_objects.mapping.doc_type es.index(index, doc_type, ...
[ "def", "index", "(", "self", ",", "refresh", "=", "False", ")", ":", "es", "=", "connections", ".", "get_connection", "(", "\"default\"", ")", "index", "=", "self", ".", "__class__", ".", "search_objects", ".", "mapping", ".", "index", "doc_type", "=", "...
Indexes this object, using a document from `to_dict()`
[ "Indexes", "this", "object", "using", "a", "document", "from", "to_dict", "()" ]
train
https://github.com/theonion/djes/blob/8f7347382c74172e82e959e3dfbc12b18fbb523f/djes/models.py#L184-L192
theonion/djes
djes/models.py
Indexable.delete_index
def delete_index(self, refresh=False, ignore=None): """Removes the object from the index if `indexed=False`""" es = connections.get_connection("default") index = self.__class__.search_objects.mapping.index doc_type = self.__class__.search_objects.mapping.doc_type es.delete(index,...
python
def delete_index(self, refresh=False, ignore=None): """Removes the object from the index if `indexed=False`""" es = connections.get_connection("default") index = self.__class__.search_objects.mapping.index doc_type = self.__class__.search_objects.mapping.doc_type es.delete(index,...
[ "def", "delete_index", "(", "self", ",", "refresh", "=", "False", ",", "ignore", "=", "None", ")", ":", "es", "=", "connections", ".", "get_connection", "(", "\"default\"", ")", "index", "=", "self", ".", "__class__", ".", "search_objects", ".", "mapping",...
Removes the object from the index if `indexed=False`
[ "Removes", "the", "object", "from", "the", "index", "if", "indexed", "=", "False" ]
train
https://github.com/theonion/djes/blob/8f7347382c74172e82e959e3dfbc12b18fbb523f/djes/models.py#L194-L199
theonion/djes
djes/models.py
Indexable.get_doc_types
def get_doc_types(cls, exclude_base=False): """Returns the doc_type of this class and all of its descendants.""" names = [] if not exclude_base and hasattr(cls, 'search_objects'): if not getattr(cls.search_objects.mapping, "elastic_abstract", False): names.append(cls....
python
def get_doc_types(cls, exclude_base=False): """Returns the doc_type of this class and all of its descendants.""" names = [] if not exclude_base and hasattr(cls, 'search_objects'): if not getattr(cls.search_objects.mapping, "elastic_abstract", False): names.append(cls....
[ "def", "get_doc_types", "(", "cls", ",", "exclude_base", "=", "False", ")", ":", "names", "=", "[", "]", "if", "not", "exclude_base", "and", "hasattr", "(", "cls", ",", "'search_objects'", ")", ":", "if", "not", "getattr", "(", "cls", ".", "search_object...
Returns the doc_type of this class and all of its descendants.
[ "Returns", "the", "doc_type", "of", "this", "class", "and", "all", "of", "its", "descendants", "." ]
train
https://github.com/theonion/djes/blob/8f7347382c74172e82e959e3dfbc12b18fbb523f/djes/models.py#L234-L242
pvizeli/tellcore-net
tellcorenet.py
TellCoreClient.start
def start(self): """Start client.""" self.proc = [] for telldus, port in ( (TELLDUS_CLIENT, self.port_client), (TELLDUS_EVENTS, self.port_events)): args = shlex.split(SOCAT_CLIENT.format( type=telldus, host=self.host, port=port)) ...
python
def start(self): """Start client.""" self.proc = [] for telldus, port in ( (TELLDUS_CLIENT, self.port_client), (TELLDUS_EVENTS, self.port_events)): args = shlex.split(SOCAT_CLIENT.format( type=telldus, host=self.host, port=port)) ...
[ "def", "start", "(", "self", ")", ":", "self", ".", "proc", "=", "[", "]", "for", "telldus", ",", "port", "in", "(", "(", "TELLDUS_CLIENT", ",", "self", ".", "port_client", ")", ",", "(", "TELLDUS_EVENTS", ",", "self", ".", "port_events", ")", ")", ...
Start client.
[ "Start", "client", "." ]
train
https://github.com/pvizeli/tellcore-net/blob/9d95f721afec8e22dc0cce8712d9a7f663179a45/tellcorenet.py#L27-L40
pvizeli/tellcore-net
tellcorenet.py
TellCoreClient.stop
def stop(self): """Stop client.""" if self.proc: for proc in self.proc: proc.kill() self.proc = None
python
def stop(self): """Stop client.""" if self.proc: for proc in self.proc: proc.kill() self.proc = None
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "proc", ":", "for", "proc", "in", "self", ".", "proc", ":", "proc", ".", "kill", "(", ")", "self", ".", "proc", "=", "None" ]
Stop client.
[ "Stop", "client", "." ]
train
https://github.com/pvizeli/tellcore-net/blob/9d95f721afec8e22dc0cce8712d9a7f663179a45/tellcorenet.py#L42-L47
ssato/python-anytemplate
anytemplate/engines/jinja2.py
_load_file_itr
def _load_file_itr(files, encoding): """ :param files: A list of file paths :: [str] :param encoding: Encoding, e.g. 'utf-8' """ for filename in files: fileobj = jinja2.loaders.open_if_exists(filename) if fileobj is not None: try: yield (fileobj.read().dec...
python
def _load_file_itr(files, encoding): """ :param files: A list of file paths :: [str] :param encoding: Encoding, e.g. 'utf-8' """ for filename in files: fileobj = jinja2.loaders.open_if_exists(filename) if fileobj is not None: try: yield (fileobj.read().dec...
[ "def", "_load_file_itr", "(", "files", ",", "encoding", ")", ":", "for", "filename", "in", "files", ":", "fileobj", "=", "jinja2", ".", "loaders", ".", "open_if_exists", "(", "filename", ")", "if", "fileobj", "is", "not", "None", ":", "try", ":", "yield"...
:param files: A list of file paths :: [str] :param encoding: Encoding, e.g. 'utf-8'
[ ":", "param", "files", ":", "A", "list", "of", "file", "paths", "::", "[", "str", "]", ":", "param", "encoding", ":", "Encoding", "e", ".", "g", ".", "utf", "-", "8" ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/jinja2.py#L43-L55
ssato/python-anytemplate
anytemplate/engines/jinja2.py
FileSystemExLoader.get_source
def get_source(self, environment, template): """.. seealso:: :meth:`jinja2.loaders.FileSystemLoader.get_source` """ pieces = jinja2.loaders.split_template_path(template) for searchpath in self.searchpath: filename = os.path.join(searchpath, *pieces) if self.enable...
python
def get_source(self, environment, template): """.. seealso:: :meth:`jinja2.loaders.FileSystemLoader.get_source` """ pieces = jinja2.loaders.split_template_path(template) for searchpath in self.searchpath: filename = os.path.join(searchpath, *pieces) if self.enable...
[ "def", "get_source", "(", "self", ",", "environment", ",", "template", ")", ":", "pieces", "=", "jinja2", ".", "loaders", ".", "split_template_path", "(", "template", ")", "for", "searchpath", "in", "self", ".", "searchpath", ":", "filename", "=", "os", "....
.. seealso:: :meth:`jinja2.loaders.FileSystemLoader.get_source`
[ "..", "seealso", "::", ":", "meth", ":", "jinja2", ".", "loaders", ".", "FileSystemLoader", ".", "get_source" ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/jinja2.py#L71-L99
ssato/python-anytemplate
anytemplate/engines/jinja2.py
Engine._render
def _render(self, template, context, is_file, at_paths=None, at_encoding=ENCODING, **kwargs): """ Render given template string and return the result. :param template: Template content :param context: A dict or dict-like object to instantiate given template fi...
python
def _render(self, template, context, is_file, at_paths=None, at_encoding=ENCODING, **kwargs): """ Render given template string and return the result. :param template: Template content :param context: A dict or dict-like object to instantiate given template fi...
[ "def", "_render", "(", "self", ",", "template", ",", "context", ",", "is_file", ",", "at_paths", "=", "None", ",", "at_encoding", "=", "ENCODING", ",", "*", "*", "kwargs", ")", ":", "eopts", "=", "self", ".", "filter_options", "(", "kwargs", ",", "self...
Render given template string and return the result. :param template: Template content :param context: A dict or dict-like object to instantiate given template file :param is_file: True if given `template` is a filename :param at_paths: Template search paths :param at...
[ "Render", "given", "template", "string", "and", "return", "the", "result", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/jinja2.py#L127-L158
ssato/python-anytemplate
anytemplate/engines/jinja2.py
Engine.renders_impl
def renders_impl(self, template_content, context, **opts): """ Render given template string and return the result. :param template_content: Template content :param context: A dict or dict-like object to instantiate given template file :param opts: Options such as: ...
python
def renders_impl(self, template_content, context, **opts): """ Render given template string and return the result. :param template_content: Template content :param context: A dict or dict-like object to instantiate given template file :param opts: Options such as: ...
[ "def", "renders_impl", "(", "self", ",", "template_content", ",", "context", ",", "*", "*", "opts", ")", ":", "return", "self", ".", "_render", "(", "template_content", ",", "context", ",", "False", ",", "*", "*", "opts", ")" ]
Render given template string and return the result. :param template_content: Template content :param context: A dict or dict-like object to instantiate given template file :param opts: Options such as: - at_paths: Template search paths - at_encoding: Template...
[ "Render", "given", "template", "string", "and", "return", "the", "result", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/jinja2.py#L160-L182
ssato/python-anytemplate
anytemplate/engines/jinja2.py
Engine.render_impl
def render_impl(self, template, context, **opts): """ Render given template file and return the result. :param template: Template file path :param context: A dict or dict-like object to instantiate given template file :param opts: Options such as: - at_pa...
python
def render_impl(self, template, context, **opts): """ Render given template file and return the result. :param template: Template file path :param context: A dict or dict-like object to instantiate given template file :param opts: Options such as: - at_pa...
[ "def", "render_impl", "(", "self", ",", "template", ",", "context", ",", "*", "*", "opts", ")", ":", "return", "self", ".", "_render", "(", "os", ".", "path", ".", "basename", "(", "template", ")", ",", "context", ",", "True", ",", "*", "*", "opts"...
Render given template file and return the result. :param template: Template file path :param context: A dict or dict-like object to instantiate given template file :param opts: Options such as: - at_paths: Template search paths - at_encoding: Template encodin...
[ "Render", "given", "template", "file", "and", "return", "the", "result", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/jinja2.py#L184-L200
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
estimateKronCovariances
def estimateKronCovariances(phenos,K1r=None,K1c=None,K2r=None,K2c=None,covs=None,Acovs=None,covar_type='lowrank_diag',rank=1): """ estimates the background covariance model before testing Args: phenos: [N x P] SP.array of P phenotypes for N individuals K1r: [N x N] SP.array of LMM-covari...
python
def estimateKronCovariances(phenos,K1r=None,K1c=None,K2r=None,K2c=None,covs=None,Acovs=None,covar_type='lowrank_diag',rank=1): """ estimates the background covariance model before testing Args: phenos: [N x P] SP.array of P phenotypes for N individuals K1r: [N x N] SP.array of LMM-covari...
[ "def", "estimateKronCovariances", "(", "phenos", ",", "K1r", "=", "None", ",", "K1c", "=", "None", ",", "K2r", "=", "None", ",", "K2c", "=", "None", ",", "covs", "=", "None", ",", "Acovs", "=", "None", ",", "covar_type", "=", "'lowrank_diag'", ",", "...
estimates the background covariance model before testing Args: phenos: [N x P] SP.array of P phenotypes for N individuals K1r: [N x N] SP.array of LMM-covariance/kinship koefficients (optional) If not provided, then linear regression analysis is performed K1c: ...
[ "estimates", "the", "background", "covariance", "model", "before", "testing" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L15-L61
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
updateKronCovs
def updateKronCovs(covs,Acovs,N,P): """ make sure that covs and Acovs are lists """ if (covs is None) and (Acovs is None): covs = [SP.ones([N,1])] Acovs = [SP.eye(P)] if Acovs is None or covs is None: raise Exception("Either Acovs or covs is None, while the other isn't") ...
python
def updateKronCovs(covs,Acovs,N,P): """ make sure that covs and Acovs are lists """ if (covs is None) and (Acovs is None): covs = [SP.ones([N,1])] Acovs = [SP.eye(P)] if Acovs is None or covs is None: raise Exception("Either Acovs or covs is None, while the other isn't") ...
[ "def", "updateKronCovs", "(", "covs", ",", "Acovs", ",", "N", ",", "P", ")", ":", "if", "(", "covs", "is", "None", ")", "and", "(", "Acovs", "is", "None", ")", ":", "covs", "=", "[", "SP", ".", "ones", "(", "[", "N", ",", "1", "]", ")", "]"...
make sure that covs and Acovs are lists
[ "make", "sure", "that", "covs", "and", "Acovs", "are", "lists" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L65-L81
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
simple_interaction_kronecker_deprecated
def simple_interaction_kronecker_deprecated(snps,phenos,covs=None,Acovs=None,Asnps1=None,Asnps0=None,K1r=None,K1c=None,K2r=None,K2c=None,covar_type='lowrank_diag',rank=1,searchDelta=False): """ I-variate fixed effects interaction test for phenotype specific SNP effects. (Runs multiple likelihood ratio tests...
python
def simple_interaction_kronecker_deprecated(snps,phenos,covs=None,Acovs=None,Asnps1=None,Asnps0=None,K1r=None,K1c=None,K2r=None,K2c=None,covar_type='lowrank_diag',rank=1,searchDelta=False): """ I-variate fixed effects interaction test for phenotype specific SNP effects. (Runs multiple likelihood ratio tests...
[ "def", "simple_interaction_kronecker_deprecated", "(", "snps", ",", "phenos", ",", "covs", "=", "None", ",", "Acovs", "=", "None", ",", "Asnps1", "=", "None", ",", "Asnps0", "=", "None", ",", "K1r", "=", "None", ",", "K1c", "=", "None", ",", "K2r", "="...
I-variate fixed effects interaction test for phenotype specific SNP effects. (Runs multiple likelihood ratio tests and computes the P-values in python from the likelihood ratios) Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) phenos: [N x P] SP.array of P phenotypes for ...
[ "I", "-", "variate", "fixed", "effects", "interaction", "test", "for", "phenotype", "specific", "SNP", "effects", ".", "(", "Runs", "multiple", "likelihood", "ratio", "tests", "and", "computes", "the", "P", "-", "values", "in", "python", "from", "the", "like...
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L83-L204
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
simple_interaction_kronecker
def simple_interaction_kronecker(snps,phenos,covs=None,Acovs=None,Asnps1=None,Asnps0=None,K1r=None,K1c=None,K2r=None,K2c=None,covar_type='lowrank_diag',rank=1,NumIntervalsDelta0=100,NumIntervalsDeltaAlt=0,searchDelta=False): """ I-variate fixed effects interaction test for phenotype specific SNP effects Ar...
python
def simple_interaction_kronecker(snps,phenos,covs=None,Acovs=None,Asnps1=None,Asnps0=None,K1r=None,K1c=None,K2r=None,K2c=None,covar_type='lowrank_diag',rank=1,NumIntervalsDelta0=100,NumIntervalsDeltaAlt=0,searchDelta=False): """ I-variate fixed effects interaction test for phenotype specific SNP effects Ar...
[ "def", "simple_interaction_kronecker", "(", "snps", ",", "phenos", ",", "covs", "=", "None", ",", "Acovs", "=", "None", ",", "Asnps1", "=", "None", ",", "Asnps0", "=", "None", ",", "K1r", "=", "None", ",", "K1c", "=", "None", ",", "K2r", "=", "None",...
I-variate fixed effects interaction test for phenotype specific SNP effects Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) phenos: [N x P] SP.array of P phenotypes for N individuals covs: list of SP.arrays holding covariates. Each covs[i] has one correspond...
[ "I", "-", "variate", "fixed", "effects", "interaction", "test", "for", "phenotype", "specific", "SNP", "effects" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L208-L328
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
kronecker_lmm
def kronecker_lmm(snps,phenos,covs=None,Acovs=None,Asnps=None,K1r=None,K1c=None,K2r=None,K2c=None,covar_type='lowrank_diag',rank=1,NumIntervalsDelta0=100,NumIntervalsDeltaAlt=0,searchDelta=False): """ simple wrapper for kroneckerLMM code Args: snps: [N x S] SP.array of S SNPs for N individuals (t...
python
def kronecker_lmm(snps,phenos,covs=None,Acovs=None,Asnps=None,K1r=None,K1c=None,K2r=None,K2c=None,covar_type='lowrank_diag',rank=1,NumIntervalsDelta0=100,NumIntervalsDeltaAlt=0,searchDelta=False): """ simple wrapper for kroneckerLMM code Args: snps: [N x S] SP.array of S SNPs for N individuals (t...
[ "def", "kronecker_lmm", "(", "snps", ",", "phenos", ",", "covs", "=", "None", ",", "Acovs", "=", "None", ",", "Asnps", "=", "None", ",", "K1r", "=", "None", ",", "K1c", "=", "None", ",", "K2r", "=", "None", ",", "K2c", "=", "None", ",", "covar_ty...
simple wrapper for kroneckerLMM code Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) phenos: [N x P] SP.array of P phenotypes for N individuals covs: list of SP.arrays holding covariates. Each covs[i] has one corresponding Acovs[i] Acovs: li...
[ "simple", "wrapper", "for", "kroneckerLMM", "code" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L332-L437
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
simple_lmm
def simple_lmm(snps,pheno,K=None,covs=None, test='lrt',NumIntervalsDelta0=100,NumIntervalsDeltaAlt=0,searchDelta=False): """ Univariate fixed effects linear mixed model test for all SNPs Args: snps: [N x S] SP.array of S SNPs for N individuals pheno: [N x 1] SP.array of 1 phenotype for N...
python
def simple_lmm(snps,pheno,K=None,covs=None, test='lrt',NumIntervalsDelta0=100,NumIntervalsDeltaAlt=0,searchDelta=False): """ Univariate fixed effects linear mixed model test for all SNPs Args: snps: [N x S] SP.array of S SNPs for N individuals pheno: [N x 1] SP.array of 1 phenotype for N...
[ "def", "simple_lmm", "(", "snps", ",", "pheno", ",", "K", "=", "None", ",", "covs", "=", "None", ",", "test", "=", "'lrt'", ",", "NumIntervalsDelta0", "=", "100", ",", "NumIntervalsDeltaAlt", "=", "0", ",", "searchDelta", "=", "False", ")", ":", "t0", ...
Univariate fixed effects linear mixed model test for all SNPs Args: snps: [N x S] SP.array of S SNPs for N individuals pheno: [N x 1] SP.array of 1 phenotype for N individuals K: [N x N] SP.array of LMM-covariance/kinship koefficients (optional) If not provid...
[ "Univariate", "fixed", "effects", "linear", "mixed", "model", "test", "for", "all", "SNPs" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L440-L484
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
interact_GxG
def interact_GxG(pheno,snps1,snps2=None,K=None,covs=None): """ Epistasis test between two sets of SNPs Args: pheno: [N x 1] SP.array of 1 phenotype for N individuals snps1: [N x S1] SP.array of S1 SNPs for N individuals snps2: [N x S2] SP.array of S2 SNPs for N individuals ...
python
def interact_GxG(pheno,snps1,snps2=None,K=None,covs=None): """ Epistasis test between two sets of SNPs Args: pheno: [N x 1] SP.array of 1 phenotype for N individuals snps1: [N x S1] SP.array of S1 SNPs for N individuals snps2: [N x S2] SP.array of S2 SNPs for N individuals ...
[ "def", "interact_GxG", "(", "pheno", ",", "snps1", ",", "snps2", "=", "None", ",", "K", "=", "None", ",", "covs", "=", "None", ")", ":", "if", "K", "is", "None", ":", "K", "=", "SP", ".", "eye", "(", "N", ")", "N", "=", "snps1", ".", "shape",...
Epistasis test between two sets of SNPs Args: pheno: [N x 1] SP.array of 1 phenotype for N individuals snps1: [N x S1] SP.array of S1 SNPs for N individuals snps2: [N x S2] SP.array of S2 SNPs for N individuals K: [N x N] SP.array of LMM-covariance/kinship koefficients (opti...
[ "Epistasis", "test", "between", "two", "sets", "of", "SNPs" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L488-L509
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
interact_GxE_1dof
def interact_GxE_1dof(snps,pheno,env,K=None,covs=None, test='lrt'): """ Univariate GxE fixed effects interaction linear mixed model test for all pairs of SNPs and environmental variables. Args: snps: [N x S] SP.array of S SNPs for N individuals pheno: [N x 1] SP.array of 1 phenotype ...
python
def interact_GxE_1dof(snps,pheno,env,K=None,covs=None, test='lrt'): """ Univariate GxE fixed effects interaction linear mixed model test for all pairs of SNPs and environmental variables. Args: snps: [N x S] SP.array of S SNPs for N individuals pheno: [N x 1] SP.array of 1 phenotype ...
[ "def", "interact_GxE_1dof", "(", "snps", ",", "pheno", ",", "env", ",", "K", "=", "None", ",", "covs", "=", "None", ",", "test", "=", "'lrt'", ")", ":", "N", "=", "snps", ".", "shape", "[", "0", "]", "if", "K", "is", "None", ":", "K", "=", "S...
Univariate GxE fixed effects interaction linear mixed model test for all pairs of SNPs and environmental variables. Args: snps: [N x S] SP.array of S SNPs for N individuals pheno: [N x 1] SP.array of 1 phenotype for N individuals env: [N x E] SP.array of E environmental variables ...
[ "Univariate", "GxE", "fixed", "effects", "interaction", "linear", "mixed", "model", "test", "for", "all", "pairs", "of", "SNPs", "and", "environmental", "variables", "." ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L512-L549
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
phenSpecificEffects
def phenSpecificEffects(snps,pheno1,pheno2,K=None,covs=None,test='lrt'): """ Univariate fixed effects interaction test for phenotype specific SNP effects Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno1: [N x 1] SP.array of 1 phenotype for N individuals ...
python
def phenSpecificEffects(snps,pheno1,pheno2,K=None,covs=None,test='lrt'): """ Univariate fixed effects interaction test for phenotype specific SNP effects Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno1: [N x 1] SP.array of 1 phenotype for N individuals ...
[ "def", "phenSpecificEffects", "(", "snps", ",", "pheno1", ",", "pheno2", ",", "K", "=", "None", ",", "covs", "=", "None", ",", "test", "=", "'lrt'", ")", ":", "N", "=", "snps", ".", "shape", "[", "0", "]", "if", "K", "is", "None", ":", "K", "="...
Univariate fixed effects interaction test for phenotype specific SNP effects Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno1: [N x 1] SP.array of 1 phenotype for N individuals pheno2: [N x 1] SP.array of 1 phenotype for N individuals K: [N x N] SP....
[ "Univariate", "fixed", "effects", "interaction", "test", "for", "phenotype", "specific", "SNP", "effects" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L552-L582
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
simple_interaction
def simple_interaction(snps,pheno,Inter,Inter0=None,covs = None,K=None,test='lrt'): """ I-variate fixed effects interaction test for phenotype specific SNP effects Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno: [N x 1] SP.array of 1 phenotype for N individual...
python
def simple_interaction(snps,pheno,Inter,Inter0=None,covs = None,K=None,test='lrt'): """ I-variate fixed effects interaction test for phenotype specific SNP effects Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno: [N x 1] SP.array of 1 phenotype for N individual...
[ "def", "simple_interaction", "(", "snps", ",", "pheno", ",", "Inter", ",", "Inter0", "=", "None", ",", "covs", "=", "None", ",", "K", "=", "None", ",", "test", "=", "'lrt'", ")", ":", "N", "=", "snps", ".", "shape", "[", "0", "]", "if", "covs", ...
I-variate fixed effects interaction test for phenotype specific SNP effects Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno: [N x 1] SP.array of 1 phenotype for N individuals Inter: [N x I] SP.array of I interaction variables to be tested for N ...
[ "I", "-", "variate", "fixed", "effects", "interaction", "test", "for", "phenotype", "specific", "SNP", "effects" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L585-L628
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
forward_lmm_kronecker
def forward_lmm_kronecker(snps,phenos,Asnps=None,Acond=None,K1r=None,K1c=None,K2r=None,K2c=None,covs=None,Acovs=None,threshold = 5e-8, maxiter = 2,qvalues=False, update_covariances = False,**kw_args): """ Kronecker fixed effects test with forward selection Args: snps: [N x S] SP.array of S SNPs f...
python
def forward_lmm_kronecker(snps,phenos,Asnps=None,Acond=None,K1r=None,K1c=None,K2r=None,K2c=None,covs=None,Acovs=None,threshold = 5e-8, maxiter = 2,qvalues=False, update_covariances = False,**kw_args): """ Kronecker fixed effects test with forward selection Args: snps: [N x S] SP.array of S SNPs f...
[ "def", "forward_lmm_kronecker", "(", "snps", ",", "phenos", ",", "Asnps", "=", "None", ",", "Acond", "=", "None", ",", "K1r", "=", "None", ",", "K1c", "=", "None", ",", "K2r", "=", "None", ",", "K2c", "=", "None", ",", "covs", "=", "None", ",", "...
Kronecker fixed effects test with forward selection Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno: [N x P] SP.array of 1 phenotype for N individuals K: [N x N] SP.array of LMM-covariance/kinship koefficients (optional) If not prov...
[ "Kronecker", "fixed", "effects", "test", "with", "forward", "selection" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L632-L766
PMBio/limix-backup
limix/deprecated/archive/qtl_old.py
forward_lmm
def forward_lmm(snps,pheno,K=None,covs=None,qvalues=False,threshold = 5e-8, maxiter = 2,test='lrt',**kw_args): """ univariate fixed effects test with forward selection Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno: [N x 1] SP.array of 1 phenotype for N indivi...
python
def forward_lmm(snps,pheno,K=None,covs=None,qvalues=False,threshold = 5e-8, maxiter = 2,test='lrt',**kw_args): """ univariate fixed effects test with forward selection Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno: [N x 1] SP.array of 1 phenotype for N indivi...
[ "def", "forward_lmm", "(", "snps", ",", "pheno", ",", "K", "=", "None", ",", "covs", "=", "None", ",", "qvalues", "=", "False", ",", "threshold", "=", "5e-8", ",", "maxiter", "=", "2", ",", "test", "=", "'lrt'", ",", "*", "*", "kw_args", ")", ":"...
univariate fixed effects test with forward selection Args: snps: [N x S] SP.array of S SNPs for N individuals (test SNPs) pheno: [N x 1] SP.array of 1 phenotype for N individuals K: [N x N] SP.array of LMM-covariance/kinship koefficients (optional) If not pro...
[ "univariate", "fixed", "effects", "test", "with", "forward", "selection" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/deprecated/archive/qtl_old.py#L769-L843
StyXman/ayrton
ayrton/parser/pyparser/parser.py
Parser.prepare
def prepare(self, start=-1): """Setup the parser for parsing. Takes the starting symbol as an argument. """ if start == -1: start = self.grammar.start self.root = None current_node = Node(start, None, [], 0, 0) self.stack = [] self.stack.appen...
python
def prepare(self, start=-1): """Setup the parser for parsing. Takes the starting symbol as an argument. """ if start == -1: start = self.grammar.start self.root = None current_node = Node(start, None, [], 0, 0) self.stack = [] self.stack.appen...
[ "def", "prepare", "(", "self", ",", "start", "=", "-", "1", ")", ":", "if", "start", "==", "-", "1", ":", "start", "=", "self", ".", "grammar", ".", "start", "self", ".", "root", "=", "None", "current_node", "=", "Node", "(", "start", ",", "None"...
Setup the parser for parsing. Takes the starting symbol as an argument.
[ "Setup", "the", "parser", "for", "parsing", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/parser.py#L92-L102
StyXman/ayrton
ayrton/parser/pyparser/parser.py
Parser.classify
def classify(self, token_type, value, lineno, column, line): """Find the label for a token.""" if token_type == self.grammar.KEYWORD_TOKEN: label_index = self.grammar.keyword_ids.get(value, -1) if label_index != -1: return label_index label_index = self.gr...
python
def classify(self, token_type, value, lineno, column, line): """Find the label for a token.""" if token_type == self.grammar.KEYWORD_TOKEN: label_index = self.grammar.keyword_ids.get(value, -1) if label_index != -1: return label_index label_index = self.gr...
[ "def", "classify", "(", "self", ",", "token_type", ",", "value", ",", "lineno", ",", "column", ",", "line", ")", ":", "if", "token_type", "==", "self", ".", "grammar", ".", "KEYWORD_TOKEN", ":", "label_index", "=", "self", ".", "grammar", ".", "keyword_i...
Find the label for a token.
[ "Find", "the", "label", "for", "a", "token", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/parser.py#L152-L162
StyXman/ayrton
ayrton/parser/pyparser/parser.py
Parser.shift
def shift(self, next_state, token_type, value, lineno, column): """Shift a non-terminal and prepare for the next state.""" dfa, state, node = self.stack[-1] new_node = Node(token_type, value, None, lineno, column) node.children.append(new_node) self.stack[-1] = (dfa, next_state, ...
python
def shift(self, next_state, token_type, value, lineno, column): """Shift a non-terminal and prepare for the next state.""" dfa, state, node = self.stack[-1] new_node = Node(token_type, value, None, lineno, column) node.children.append(new_node) self.stack[-1] = (dfa, next_state, ...
[ "def", "shift", "(", "self", ",", "next_state", ",", "token_type", ",", "value", ",", "lineno", ",", "column", ")", ":", "dfa", ",", "state", ",", "node", "=", "self", ".", "stack", "[", "-", "1", "]", "new_node", "=", "Node", "(", "token_type", ",...
Shift a non-terminal and prepare for the next state.
[ "Shift", "a", "non", "-", "terminal", "and", "prepare", "for", "the", "next", "state", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/parser.py#L164-L169
StyXman/ayrton
ayrton/parser/pyparser/parser.py
Parser.push
def push(self, next_dfa, next_state, node_type, lineno, column): """Push a terminal and adjust the current state.""" dfa, state, node = self.stack[-1] new_node = Node(node_type, None, [], lineno, column) self.stack[-1] = (dfa, next_state, node) self.stack.append((next_dfa, 0, new...
python
def push(self, next_dfa, next_state, node_type, lineno, column): """Push a terminal and adjust the current state.""" dfa, state, node = self.stack[-1] new_node = Node(node_type, None, [], lineno, column) self.stack[-1] = (dfa, next_state, node) self.stack.append((next_dfa, 0, new...
[ "def", "push", "(", "self", ",", "next_dfa", ",", "next_state", ",", "node_type", ",", "lineno", ",", "column", ")", ":", "dfa", ",", "state", ",", "node", "=", "self", ".", "stack", "[", "-", "1", "]", "new_node", "=", "Node", "(", "node_type", ",...
Push a terminal and adjust the current state.
[ "Push", "a", "terminal", "and", "adjust", "the", "current", "state", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/parser.py#L171-L176
StyXman/ayrton
ayrton/parser/pyparser/parser.py
Parser.pop
def pop(self): """Pop an entry off the stack and make its node a child of the last.""" dfa, state, node = self.stack.pop() if self.stack: self.stack[-1][2].children.append(node) else: self.root = node
python
def pop(self): """Pop an entry off the stack and make its node a child of the last.""" dfa, state, node = self.stack.pop() if self.stack: self.stack[-1][2].children.append(node) else: self.root = node
[ "def", "pop", "(", "self", ")", ":", "dfa", ",", "state", ",", "node", "=", "self", ".", "stack", ".", "pop", "(", ")", "if", "self", ".", "stack", ":", "self", ".", "stack", "[", "-", "1", "]", "[", "2", "]", ".", "children", ".", "append", ...
Pop an entry off the stack and make its node a child of the last.
[ "Pop", "an", "entry", "off", "the", "stack", "and", "make", "its", "node", "a", "child", "of", "the", "last", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/parser.py#L178-L184
tchx84/grestful
grestful/object.py
Object._get
def _get(self, url, params=None): """ Wrapper method for GET calls. """ self._call(self.GET, url, params, None)
python
def _get(self, url, params=None): """ Wrapper method for GET calls. """ self._call(self.GET, url, params, None)
[ "def", "_get", "(", "self", ",", "url", ",", "params", "=", "None", ")", ":", "self", ".", "_call", "(", "self", ".", "GET", ",", "url", ",", "params", ",", "None", ")" ]
Wrapper method for GET calls.
[ "Wrapper", "method", "for", "GET", "calls", "." ]
train
https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/object.py#L51-L53
tchx84/grestful
grestful/object.py
Object._post
def _post(self, url, params, uploads=None): """ Wrapper method for POST calls. """ self._call(self.POST, url, params, uploads)
python
def _post(self, url, params, uploads=None): """ Wrapper method for POST calls. """ self._call(self.POST, url, params, uploads)
[ "def", "_post", "(", "self", ",", "url", ",", "params", ",", "uploads", "=", "None", ")", ":", "self", ".", "_call", "(", "self", ".", "POST", ",", "url", ",", "params", ",", "uploads", ")" ]
Wrapper method for POST calls.
[ "Wrapper", "method", "for", "POST", "calls", "." ]
train
https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/object.py#L55-L57
tchx84/grestful
grestful/object.py
Object._call
def _call(self, method, url, params, uploads): """ Initiate resquest to server and handle outcomes. """ try: data = self._request(method, url, params, uploads) except Exception, e: self._failed_cb(e) else: self._completed_cb(data)
python
def _call(self, method, url, params, uploads): """ Initiate resquest to server and handle outcomes. """ try: data = self._request(method, url, params, uploads) except Exception, e: self._failed_cb(e) else: self._completed_cb(data)
[ "def", "_call", "(", "self", ",", "method", ",", "url", ",", "params", ",", "uploads", ")", ":", "try", ":", "data", "=", "self", ".", "_request", "(", "method", ",", "url", ",", "params", ",", "uploads", ")", "except", "Exception", ",", "e", ":", ...
Initiate resquest to server and handle outcomes.
[ "Initiate", "resquest", "to", "server", "and", "handle", "outcomes", "." ]
train
https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/object.py#L63-L70
tchx84/grestful
grestful/object.py
Object._request
def _request(self, method, url, params=None, uploads=None): """ Request to server and handle transfer status. """ c = pycurl.Curl() if method == self.POST: c.setopt(c.POST, 1) if uploads is not None: if isinstance(uploads, dict): # han...
python
def _request(self, method, url, params=None, uploads=None): """ Request to server and handle transfer status. """ c = pycurl.Curl() if method == self.POST: c.setopt(c.POST, 1) if uploads is not None: if isinstance(uploads, dict): # han...
[ "def", "_request", "(", "self", ",", "method", ",", "url", ",", "params", "=", "None", ",", "uploads", "=", "None", ")", ":", "c", "=", "pycurl", ".", "Curl", "(", ")", "if", "method", "==", "self", ".", "POST", ":", "c", ".", "setopt", "(", "c...
Request to server and handle transfer status.
[ "Request", "to", "server", "and", "handle", "transfer", "status", "." ]
train
https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/object.py#L72-L130
tchx84/grestful
grestful/object.py
Object._completed_cb
def _completed_cb(self, data): """ Extract info from data and emit completed. """ try: info = json.loads(data) except ValueError: info = self._hook_data(data) except Exception, e: info = None logging.error('%s: _completed_cb crashed with %s...
python
def _completed_cb(self, data): """ Extract info from data and emit completed. """ try: info = json.loads(data) except ValueError: info = self._hook_data(data) except Exception, e: info = None logging.error('%s: _completed_cb crashed with %s...
[ "def", "_completed_cb", "(", "self", ",", "data", ")", ":", "try", ":", "info", "=", "json", ".", "loads", "(", "data", ")", "except", "ValueError", ":", "info", "=", "self", ".", "_hook_data", "(", "data", ")", "except", "Exception", ",", "e", ":", ...
Extract info from data and emit completed.
[ "Extract", "info", "from", "data", "and", "emit", "completed", "." ]
train
https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/object.py#L132-L144
tchx84/grestful
grestful/object.py
Object._updated_cb
def _updated_cb(self, downtotal, downdone, uptotal, updone): """ Emit update signal, including transfer status metadata. """ self.emit('updated', downtotal, downdone, uptotal, updone)
python
def _updated_cb(self, downtotal, downdone, uptotal, updone): """ Emit update signal, including transfer status metadata. """ self.emit('updated', downtotal, downdone, uptotal, updone)
[ "def", "_updated_cb", "(", "self", ",", "downtotal", ",", "downdone", ",", "uptotal", ",", "updone", ")", ":", "self", ".", "emit", "(", "'updated'", ",", "downtotal", ",", "downdone", ",", "uptotal", ",", "updone", ")" ]
Emit update signal, including transfer status metadata.
[ "Emit", "update", "signal", "including", "transfer", "status", "metadata", "." ]
train
https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/object.py#L150-L152
tchx84/grestful
grestful/object.py
Object._hook_id
def _hook_id(self, info): """ Extract id from info. Override for custom behaviour. """ if isinstance(info, dict) and 'id' in info.keys(): self.id = info['id']
python
def _hook_id(self, info): """ Extract id from info. Override for custom behaviour. """ if isinstance(info, dict) and 'id' in info.keys(): self.id = info['id']
[ "def", "_hook_id", "(", "self", ",", "info", ")", ":", "if", "isinstance", "(", "info", ",", "dict", ")", "and", "'id'", "in", "info", ".", "keys", "(", ")", ":", "self", ".", "id", "=", "info", "[", "'id'", "]" ]
Extract id from info. Override for custom behaviour.
[ "Extract", "id", "from", "info", ".", "Override", "for", "custom", "behaviour", "." ]
train
https://github.com/tchx84/grestful/blob/5f7ee7eb358cf260c97d41f8680e8f168ef5d843/grestful/object.py#L154-L157
praekelt/django-moderator
moderator/management/commands/classifycomments.py
Command.handle
def handle(self, *args, **options): """ Collect all comments that hasn't already been classified or are classified as unsure. Order randomly so we don't rehash previously unsure classifieds when count limiting. """ comments = Comment.objects.filter( Q(...
python
def handle(self, *args, **options): """ Collect all comments that hasn't already been classified or are classified as unsure. Order randomly so we don't rehash previously unsure classifieds when count limiting. """ comments = Comment.objects.filter( Q(...
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "comments", "=", "Comment", ".", "objects", ".", "filter", "(", "Q", "(", "classifiedcomment__isnull", "=", "True", ")", "|", "Q", "(", "classifiedcomment__cls", "=", "...
Collect all comments that hasn't already been classified or are classified as unsure. Order randomly so we don't rehash previously unsure classifieds when count limiting.
[ "Collect", "all", "comments", "that", "hasn", "t", "already", "been", "classified", "or", "are", "classified", "as", "unsure", ".", "Order", "randomly", "so", "we", "don", "t", "rehash", "previously", "unsure", "classifieds", "when", "count", "limiting", "." ]
train
https://github.com/praekelt/django-moderator/blob/72f1d5259128ff5a1a0341d4a573bfd561ba4665/moderator/management/commands/classifycomments.py#L20-L43
xmikos/reparser
reparser.py
Segment.update_text
def update_text(self, token, match): """Update text from results of regex match""" if isinstance(self.text, MatchGroup): self.text = self.text.get_group_value(token, match)
python
def update_text(self, token, match): """Update text from results of regex match""" if isinstance(self.text, MatchGroup): self.text = self.text.get_group_value(token, match)
[ "def", "update_text", "(", "self", ",", "token", ",", "match", ")", ":", "if", "isinstance", "(", "self", ".", "text", ",", "MatchGroup", ")", ":", "self", ".", "text", "=", "self", ".", "text", ".", "get_group_value", "(", "token", ",", "match", ")"...
Update text from results of regex match
[ "Update", "text", "from", "results", "of", "regex", "match" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L17-L20
xmikos/reparser
reparser.py
Segment.update_params
def update_params(self, token, match): """Update dict of params from results of regex match""" for k, v in self.params.items(): if isinstance(v, MatchGroup): self.params[k] = v.get_group_value(token, match)
python
def update_params(self, token, match): """Update dict of params from results of regex match""" for k, v in self.params.items(): if isinstance(v, MatchGroup): self.params[k] = v.get_group_value(token, match)
[ "def", "update_params", "(", "self", ",", "token", ",", "match", ")", ":", "for", "k", ",", "v", "in", "self", ".", "params", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "MatchGroup", ")", ":", "self", ".", "params", "[", "k",...
Update dict of params from results of regex match
[ "Update", "dict", "of", "params", "from", "results", "of", "regex", "match" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L22-L26
xmikos/reparser
reparser.py
Token.modify_pattern
def modify_pattern(self, pattern, group): """Rename groups in regex pattern and enclose it in named group""" pattern = group_regex.sub(r'?P<{}_\1>'.format(self.name), pattern) return r'(?P<{}>{})'.format(group, pattern)
python
def modify_pattern(self, pattern, group): """Rename groups in regex pattern and enclose it in named group""" pattern = group_regex.sub(r'?P<{}_\1>'.format(self.name), pattern) return r'(?P<{}>{})'.format(group, pattern)
[ "def", "modify_pattern", "(", "self", ",", "pattern", ",", "group", ")", ":", "pattern", "=", "group_regex", ".", "sub", "(", "r'?P<{}_\\1>'", ".", "format", "(", "self", ".", "name", ")", ",", "pattern", ")", "return", "r'(?P<{}>{})'", ".", "format", "(...
Rename groups in regex pattern and enclose it in named group
[ "Rename", "groups", "in", "regex", "pattern", "and", "enclose", "it", "in", "named", "group" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L41-L44
xmikos/reparser
reparser.py
MatchGroup.get_group_value
def get_group_value(self, token, match): """Return value of regex match for the specified group""" try: value = match.group('{}_{}'.format(token.name, self.group)) except IndexError: value = '' return self.func(value) if callable(self.func) else value
python
def get_group_value(self, token, match): """Return value of regex match for the specified group""" try: value = match.group('{}_{}'.format(token.name, self.group)) except IndexError: value = '' return self.func(value) if callable(self.func) else value
[ "def", "get_group_value", "(", "self", ",", "token", ",", "match", ")", ":", "try", ":", "value", "=", "match", ".", "group", "(", "'{}_{}'", ".", "format", "(", "token", ".", "name", ",", "self", ".", "group", ")", ")", "except", "IndexError", ":", ...
Return value of regex match for the specified group
[ "Return", "value", "of", "regex", "match", "for", "the", "specified", "group" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L53-L59
xmikos/reparser
reparser.py
Parser.build_regex
def build_regex(self, tokens): """Build compound regex from list of tokens""" patterns = [] for token in tokens: patterns.append(token.pattern_start) if token.pattern_end: patterns.append(token.pattern_end) return re.compile('|'.join(patterns), re....
python
def build_regex(self, tokens): """Build compound regex from list of tokens""" patterns = [] for token in tokens: patterns.append(token.pattern_start) if token.pattern_end: patterns.append(token.pattern_end) return re.compile('|'.join(patterns), re....
[ "def", "build_regex", "(", "self", ",", "tokens", ")", ":", "patterns", "=", "[", "]", "for", "token", "in", "tokens", ":", "patterns", ".", "append", "(", "token", ".", "pattern_start", ")", "if", "token", ".", "pattern_end", ":", "patterns", ".", "ap...
Build compound regex from list of tokens
[ "Build", "compound", "regex", "from", "list", "of", "tokens" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L84-L91
xmikos/reparser
reparser.py
Parser.build_groups
def build_groups(self, tokens): """Build dict of groups from list of tokens""" groups = {} for token in tokens: match_type = MatchType.start if token.group_end else MatchType.single groups[token.group_start] = (token, match_type) if token.group_end: ...
python
def build_groups(self, tokens): """Build dict of groups from list of tokens""" groups = {} for token in tokens: match_type = MatchType.start if token.group_end else MatchType.single groups[token.group_start] = (token, match_type) if token.group_end: ...
[ "def", "build_groups", "(", "self", ",", "tokens", ")", ":", "groups", "=", "{", "}", "for", "token", "in", "tokens", ":", "match_type", "=", "MatchType", ".", "start", "if", "token", ".", "group_end", "else", "MatchType", ".", "single", "groups", "[", ...
Build dict of groups from list of tokens
[ "Build", "dict", "of", "groups", "from", "list", "of", "tokens" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L93-L101
xmikos/reparser
reparser.py
Parser.get_matched_token
def get_matched_token(self, match): """Find which token has been matched by compound regex""" match_groupdict = match.groupdict() for group in self.groups: if match_groupdict[group] is not None: token, match_type = self.groups[group] return (token, mat...
python
def get_matched_token(self, match): """Find which token has been matched by compound regex""" match_groupdict = match.groupdict() for group in self.groups: if match_groupdict[group] is not None: token, match_type = self.groups[group] return (token, mat...
[ "def", "get_matched_token", "(", "self", ",", "match", ")", ":", "match_groupdict", "=", "match", ".", "groupdict", "(", ")", "for", "group", "in", "self", ".", "groups", ":", "if", "match_groupdict", "[", "group", "]", "is", "not", "None", ":", "token",...
Find which token has been matched by compound regex
[ "Find", "which", "token", "has", "been", "matched", "by", "compound", "regex" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L103-L109
xmikos/reparser
reparser.py
Parser.get_params
def get_params(self, token_stack): """Get params from stack of tokens""" params = {} for token in token_stack: params.update(token.params) return params
python
def get_params(self, token_stack): """Get params from stack of tokens""" params = {} for token in token_stack: params.update(token.params) return params
[ "def", "get_params", "(", "self", ",", "token_stack", ")", ":", "params", "=", "{", "}", "for", "token", "in", "token_stack", ":", "params", ".", "update", "(", "token", ".", "params", ")", "return", "params" ]
Get params from stack of tokens
[ "Get", "params", "from", "stack", "of", "tokens" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L111-L116
xmikos/reparser
reparser.py
Parser.remove_token
def remove_token(self, token_stack, token): """Remove last occurance of token from stack""" token_stack.reverse() try: token_stack.remove(token) retval = True except ValueError: retval = False token_stack.reverse() return retval
python
def remove_token(self, token_stack, token): """Remove last occurance of token from stack""" token_stack.reverse() try: token_stack.remove(token) retval = True except ValueError: retval = False token_stack.reverse() return retval
[ "def", "remove_token", "(", "self", ",", "token_stack", ",", "token", ")", ":", "token_stack", ".", "reverse", "(", ")", "try", ":", "token_stack", ".", "remove", "(", "token", ")", "retval", "=", "True", "except", "ValueError", ":", "retval", "=", "Fals...
Remove last occurance of token from stack
[ "Remove", "last", "occurance", "of", "token", "from", "stack" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L118-L127
xmikos/reparser
reparser.py
Parser.parse
def parse(self, text): """Parse text to obtain list of Segments""" text = self.preprocess(text) token_stack = [] last_pos = 0 # Iterate through all matched tokens for match in self.regex.finditer(text): # Find which token has been matched by regex ...
python
def parse(self, text): """Parse text to obtain list of Segments""" text = self.preprocess(text) token_stack = [] last_pos = 0 # Iterate through all matched tokens for match in self.regex.finditer(text): # Find which token has been matched by regex ...
[ "def", "parse", "(", "self", ",", "text", ")", ":", "text", "=", "self", ".", "preprocess", "(", "text", ")", "token_stack", "=", "[", "]", "last_pos", "=", "0", "# Iterate through all matched tokens", "for", "match", "in", "self", ".", "regex", ".", "fi...
Parse text to obtain list of Segments
[ "Parse", "text", "to", "obtain", "list", "of", "Segments" ]
train
https://github.com/xmikos/reparser/blob/0668112a15b9e8e9355a1261040c36b4a6034020/reparser.py#L129-L176
ssato/python-anytemplate
anytemplate/engines/cheetah.py
render_impl
def render_impl(**kwargs): """ :param tmpl: Template content string or file :param at_paths: Template search paths """ if Template is None: tmpl = kwargs.get("file", None) if tmpl is None: tmpl = kwargs.get("source", None) return anytemplate.engines.base.fallb...
python
def render_impl(**kwargs): """ :param tmpl: Template content string or file :param at_paths: Template search paths """ if Template is None: tmpl = kwargs.get("file", None) if tmpl is None: tmpl = kwargs.get("source", None) return anytemplate.engines.base.fallb...
[ "def", "render_impl", "(", "*", "*", "kwargs", ")", ":", "if", "Template", "is", "None", ":", "tmpl", "=", "kwargs", ".", "get", "(", "\"file\"", ",", "None", ")", "if", "tmpl", "is", "None", ":", "tmpl", "=", "kwargs", ".", "get", "(", "\"source\"...
:param tmpl: Template content string or file :param at_paths: Template search paths
[ ":", "param", "tmpl", ":", "Template", "content", "string", "or", "file", ":", "param", "at_paths", ":", "Template", "search", "paths" ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/cheetah.py#L34-L47
ssato/python-anytemplate
anytemplate/engines/cheetah.py
Engine.supports
def supports(cls, template_file=None): """ :return: Whether the engine can process given template file or not. """ if anytemplate.compat.IS_PYTHON_3: cls._priority = 99 return False # Always as it's not ported to python 3. return super(Engine, cls).suppo...
python
def supports(cls, template_file=None): """ :return: Whether the engine can process given template file or not. """ if anytemplate.compat.IS_PYTHON_3: cls._priority = 99 return False # Always as it's not ported to python 3. return super(Engine, cls).suppo...
[ "def", "supports", "(", "cls", ",", "template_file", "=", "None", ")", ":", "if", "anytemplate", ".", "compat", ".", "IS_PYTHON_3", ":", "cls", ".", "_priority", "=", "99", "return", "False", "# Always as it's not ported to python 3.", "return", "super", "(", ...
:return: Whether the engine can process given template file or not.
[ ":", "return", ":", "Whether", "the", "engine", "can", "process", "given", "template", "file", "or", "not", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/cheetah.py#L68-L76
ssato/python-anytemplate
anytemplate/engines/cheetah.py
Engine.__render
def __render(self, context, **kwargs): """ Render template. :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword arguments passed to the template engine to render templates with specific features enabled. :...
python
def __render(self, context, **kwargs): """ Render template. :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword arguments passed to the template engine to render templates with specific features enabled. :...
[ "def", "__render", "(", "self", ",", "context", ",", "*", "*", "kwargs", ")", ":", "# Not pass both searchList and namespaces.", "kwargs", "[", "\"namespaces\"", "]", "=", "[", "context", ",", "]", "+", "kwargs", ".", "get", "(", "\"namespaces\"", ",", "[", ...
Render template. :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword arguments passed to the template engine to render templates with specific features enabled. :return: Rendered string
[ "Render", "template", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/cheetah.py#L86-L109
ssato/python-anytemplate
anytemplate/engines/cheetah.py
Engine.renders_impl
def renders_impl(self, template_content, context, **kwargs): """ Render given template string and return the result. :param template_content: Template content :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword argumen...
python
def renders_impl(self, template_content, context, **kwargs): """ Render given template string and return the result. :param template_content: Template content :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword argumen...
[ "def", "renders_impl", "(", "self", ",", "template_content", ",", "context", ",", "*", "*", "kwargs", ")", ":", "if", "\"file\"", "in", "kwargs", ":", "kwargs", "[", "\"file\"", "]", "=", "None", "kwargs", "[", "\"source\"", "]", "=", "template_content", ...
Render given template string and return the result. :param template_content: Template content :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword arguments such as: - at_paths: Template search paths but it is not actually ...
[ "Render", "given", "template", "string", "and", "return", "the", "result", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/cheetah.py#L111-L133
ssato/python-anytemplate
anytemplate/engines/cheetah.py
Engine.render_impl
def render_impl(self, template, context, **kwargs): """ Render given template file and return the result. :param template: Template file path :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword arguments such as: ...
python
def render_impl(self, template, context, **kwargs): """ Render given template file and return the result. :param template: Template file path :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword arguments such as: ...
[ "def", "render_impl", "(", "self", ",", "template", ",", "context", ",", "*", "*", "kwargs", ")", ":", "if", "\"source\"", "in", "kwargs", ":", "kwargs", "[", "\"source\"", "]", "=", "None", "kwargs", "[", "\"file\"", "]", "=", "template", "return", "s...
Render given template file and return the result. :param template: Template file path :param context: A dict or dict-like object to instantiate given template file :param kwargs: Keyword arguments such as: - at_paths: Template search paths but it is not actually processe...
[ "Render", "given", "template", "file", "and", "return", "the", "result", "." ]
train
https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/cheetah.py#L135-L157
inveniosoftware-contrib/invenio-classifier
invenio_classifier/regexs.py
compute_arxiv_re
def compute_arxiv_re(report_pattern, report_number): """Compute arXiv report-number.""" if report_number is None: report_number = r"\g<name>" report_re = re.compile(r"(?<!<cds\.REPORTNUMBER>)(?<!\w)" + "(?P<name>" + report_pattern + ")" + old_arx...
python
def compute_arxiv_re(report_pattern, report_number): """Compute arXiv report-number.""" if report_number is None: report_number = r"\g<name>" report_re = re.compile(r"(?<!<cds\.REPORTNUMBER>)(?<!\w)" + "(?P<name>" + report_pattern + ")" + old_arx...
[ "def", "compute_arxiv_re", "(", "report_pattern", ",", "report_number", ")", ":", "if", "report_number", "is", "None", ":", "report_number", "=", "r\"\\g<name>\"", "report_re", "=", "re", ".", "compile", "(", "r\"(?<!<cds\\.REPORTNUMBER>)(?<!\\w)\"", "+", "\"(?P<name>...
Compute arXiv report-number.
[ "Compute", "arXiv", "report", "-", "number", "." ]
train
https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/regexs.py#L215-L222
inveniosoftware-contrib/invenio-classifier
invenio_classifier/regexs.py
_create_regex_pattern_add_optional_spaces_to_word_characters
def _create_regex_pattern_add_optional_spaces_to_word_characters(word): r"""Add the regex special characters (\s*) to allow optional spaces. :param word: (string) the word to be inserted into a regex pattern. :return: (string) the regex pattern for that word with optional spaces betwe...
python
def _create_regex_pattern_add_optional_spaces_to_word_characters(word): r"""Add the regex special characters (\s*) to allow optional spaces. :param word: (string) the word to be inserted into a regex pattern. :return: (string) the regex pattern for that word with optional spaces betwe...
[ "def", "_create_regex_pattern_add_optional_spaces_to_word_characters", "(", "word", ")", ":", "new_word", "=", "u\"\"", "for", "ch", "in", "word", ":", "if", "ch", ".", "isspace", "(", ")", ":", "new_word", "+=", "ch", "else", ":", "new_word", "+=", "ch", "+...
r"""Add the regex special characters (\s*) to allow optional spaces. :param word: (string) the word to be inserted into a regex pattern. :return: (string) the regex pattern for that word with optional spaces between all of its characters.
[ "r", "Add", "the", "regex", "special", "characters", "(", "\\", "s", "*", ")", "to", "allow", "optional", "spaces", "." ]
train
https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/regexs.py#L674-L687
inveniosoftware-contrib/invenio-classifier
invenio_classifier/regexs.py
get_reference_section_title_patterns
def get_reference_section_title_patterns(): """Return a list of compiled regex patterns used to search for the title. :return: (list) of compiled regex patterns. """ patterns = [] titles = [u'references', u'references.', u'r\u00C9f\u00E9rences', u'r\u00C9f\...
python
def get_reference_section_title_patterns(): """Return a list of compiled regex patterns used to search for the title. :return: (list) of compiled regex patterns. """ patterns = [] titles = [u'references', u'references.', u'r\u00C9f\u00E9rences', u'r\u00C9f\...
[ "def", "get_reference_section_title_patterns", "(", ")", ":", "patterns", "=", "[", "]", "titles", "=", "[", "u'references'", ",", "u'references.'", ",", "u'r\\u00C9f\\u00E9rences'", ",", "u'r\\u00C9f\\u00C9rences'", ",", "u'reference'", ",", "u'refs'", ",", "u'r\\u00...
Return a list of compiled regex patterns used to search for the title. :return: (list) of compiled regex patterns.
[ "Return", "a", "list", "of", "compiled", "regex", "patterns", "used", "to", "search", "for", "the", "title", "." ]
train
https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/regexs.py#L690-L732
inveniosoftware-contrib/invenio-classifier
invenio_classifier/regexs.py
get_reference_line_numeration_marker_patterns
def get_reference_line_numeration_marker_patterns(prefix=u''): """Return a list of compiled regex patterns used to search for the marker. Marker of a reference line in a full-text document. :param prefix: (string) the possible prefix to a reference line :return: (list) of compiled regex patterns. ...
python
def get_reference_line_numeration_marker_patterns(prefix=u''): """Return a list of compiled regex patterns used to search for the marker. Marker of a reference line in a full-text document. :param prefix: (string) the possible prefix to a reference line :return: (list) of compiled regex patterns. ...
[ "def", "get_reference_line_numeration_marker_patterns", "(", "prefix", "=", "u''", ")", ":", "title", "=", "u\"\"", "if", "type", "(", "prefix", ")", "in", "(", "str", ",", "unicode", ")", ":", "title", "=", "prefix", "g_name", "=", "u'(?P<mark>'", "g_close"...
Return a list of compiled regex patterns used to search for the marker. Marker of a reference line in a full-text document. :param prefix: (string) the possible prefix to a reference line :return: (list) of compiled regex patterns.
[ "Return", "a", "list", "of", "compiled", "regex", "patterns", "used", "to", "search", "for", "the", "marker", "." ]
train
https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/regexs.py#L735-L775
inveniosoftware-contrib/invenio-classifier
invenio_classifier/regexs.py
get_post_reference_section_title_patterns
def get_post_reference_section_title_patterns(): """Return a list of compiled regex patterns for post title section. Search for the title of the section after the reference section in a full-text document. :return: (list) of compiled regex patterns. """ compiled_patterns = [] thead = r'^\s...
python
def get_post_reference_section_title_patterns(): """Return a list of compiled regex patterns for post title section. Search for the title of the section after the reference section in a full-text document. :return: (list) of compiled regex patterns. """ compiled_patterns = [] thead = r'^\s...
[ "def", "get_post_reference_section_title_patterns", "(", ")", ":", "compiled_patterns", "=", "[", "]", "thead", "=", "r'^\\s*([\\{\\(\\<\\[]?\\s*(\\w|\\d)\\s*[\\)\\}\\>\\.\\-\\]]?\\s*)?'", "ttail", "=", "r'(\\s*\\:\\s*)?'", "numatn", "=", "r'(\\d+|\\w\\b|i{1,3}v?|vi{0,3})[\\.\\,]{0...
Return a list of compiled regex patterns for post title section. Search for the title of the section after the reference section in a full-text document. :return: (list) of compiled regex patterns.
[ "Return", "a", "list", "of", "compiled", "regex", "patterns", "for", "post", "title", "section", "." ]
train
https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/regexs.py#L803-L873
inveniosoftware-contrib/invenio-classifier
invenio_classifier/regexs.py
get_post_reference_section_keyword_patterns
def get_post_reference_section_keyword_patterns(): """Return a list of compiled regex patterns for keywords. Keywords that can often be found after, and therefore suggest the end of a reference section in a full-text document. :return: (list) of compiled regex patterns. """ compiled_patterns =...
python
def get_post_reference_section_keyword_patterns(): """Return a list of compiled regex patterns for keywords. Keywords that can often be found after, and therefore suggest the end of a reference section in a full-text document. :return: (list) of compiled regex patterns. """ compiled_patterns =...
[ "def", "get_post_reference_section_keyword_patterns", "(", ")", ":", "compiled_patterns", "=", "[", "]", "patterns", "=", "[", "u'('", "+", "_create_regex_pattern_add_optional_spaces_to_word_characters", "(", "u'prepared'", ")", "+", "# noqa", "r'|'", "+", "_create_regex_...
Return a list of compiled regex patterns for keywords. Keywords that can often be found after, and therefore suggest the end of a reference section in a full-text document. :return: (list) of compiled regex patterns.
[ "Return", "a", "list", "of", "compiled", "regex", "patterns", "for", "keywords", "." ]
train
https://github.com/inveniosoftware-contrib/invenio-classifier/blob/3c758cf34dca6bf0548e7da5de34e5f72e3b255e/invenio_classifier/regexs.py#L876-L897
millar/provstore-api
provstore/bundle_manager.py
BundleManager.refresh
def refresh(self): """ Reload list of bundles from the store :return: self """ self._bundles = {} bundles = self._api.get_bundles(self._document.id) for bundle in bundles: self._bundles[bundle['identifier']] = Bundle(self._api, self._document, bundle...
python
def refresh(self): """ Reload list of bundles from the store :return: self """ self._bundles = {} bundles = self._api.get_bundles(self._document.id) for bundle in bundles: self._bundles[bundle['identifier']] = Bundle(self._api, self._document, bundle...
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "_bundles", "=", "{", "}", "bundles", "=", "self", ".", "_api", ".", "get_bundles", "(", "self", ".", "_document", ".", "id", ")", "for", "bundle", "in", "bundles", ":", "self", ".", "_bundles", ...
Reload list of bundles from the store :return: self
[ "Reload", "list", "of", "bundles", "from", "the", "store" ]
train
https://github.com/millar/provstore-api/blob/0dd506b4f0e00623b95a52caa70debe758817179/provstore/bundle_manager.py#L54-L66
ioos/petulant-bear
petulantbear/netcdf2ncml.py
parse_att
def parse_att(output, att, indent): """ att is a tuple: (name, value) """ if isinstance(att[1], bs): outputStr = '''{indent}<{attribute} {name}="{attname}" {value}="{attvalue}"/>\n'''.format( indent=indent, attribute=ATTRIBUTE, name=NAME, attname=s...
python
def parse_att(output, att, indent): """ att is a tuple: (name, value) """ if isinstance(att[1], bs): outputStr = '''{indent}<{attribute} {name}="{attname}" {value}="{attvalue}"/>\n'''.format( indent=indent, attribute=ATTRIBUTE, name=NAME, attname=s...
[ "def", "parse_att", "(", "output", ",", "att", ",", "indent", ")", ":", "if", "isinstance", "(", "att", "[", "1", "]", ",", "bs", ")", ":", "outputStr", "=", "'''{indent}<{attribute} {name}=\"{attname}\" {value}=\"{attvalue}\"/>\\n'''", ".", "format", "(", "inde...
att is a tuple: (name, value)
[ "att", "is", "a", "tuple", ":", "(", "name", "value", ")" ]
train
https://github.com/ioos/petulant-bear/blob/986c1f96a9467b0903028069c4d4274e62333d06/petulantbear/netcdf2ncml.py#L119-L148
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
create_ctm_miohandler
def create_ctm_miohandler(fileobj, title=None, comment=None, register_prefixes=True, register_templates=True, detect_prefixes=False): """\ """ handler = CTMHandler(fileobj) handler.title = title handler.comment = comment handler.detect_prefixes = detect_prefixes if register_prefixes: ...
python
def create_ctm_miohandler(fileobj, title=None, comment=None, register_prefixes=True, register_templates=True, detect_prefixes=False): """\ """ handler = CTMHandler(fileobj) handler.title = title handler.comment = comment handler.detect_prefixes = detect_prefixes if register_prefixes: ...
[ "def", "create_ctm_miohandler", "(", "fileobj", ",", "title", "=", "None", ",", "comment", "=", "None", ",", "register_prefixes", "=", "True", ",", "register_templates", "=", "True", ",", "detect_prefixes", "=", "False", ")", ":", "handler", "=", "CTMHandler",...
\
[ "\\" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L74-L99
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
register_default_prefixes
def register_default_prefixes(handler): """\ """ for prefix, ns in _PREFIXES.iteritems(): handler.add_prefix(prefix, str(ns))
python
def register_default_prefixes(handler): """\ """ for prefix, ns in _PREFIXES.iteritems(): handler.add_prefix(prefix, str(ns))
[ "def", "register_default_prefixes", "(", "handler", ")", ":", "for", "prefix", ",", "ns", "in", "_PREFIXES", ".", "iteritems", "(", ")", ":", "handler", ".", "add_prefix", "(", "prefix", ",", "str", "(", "ns", ")", ")" ]
\
[ "\\" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L101-L106
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
create_xtm_miohandler
def create_xtm_miohandler(fileobj, title=None, comment=None): """\ """ handler = XTM21Handler(fileobj=fileobj) handler.title = title handler.comment = comment return handler
python
def create_xtm_miohandler(fileobj, title=None, comment=None): """\ """ handler = XTM21Handler(fileobj=fileobj) handler.title = title handler.comment = comment return handler
[ "def", "create_xtm_miohandler", "(", "fileobj", ",", "title", "=", "None", ",", "comment", "=", "None", ")", ":", "handler", "=", "XTM21Handler", "(", "fileobj", "=", "fileobj", ")", "handler", ".", "title", "=", "title", "handler", ".", "comment", "=", ...
\
[ "\\" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L108-L115
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
create_ctm_handler
def create_ctm_handler(fileobj, title=u'Cablegate Topic Map', comment=u'Generated by Cablemap - https://github.com/heuer/cablemap', detect_prefixes=False): """\ Returns a `ICableHandler` instance which writes Compact Topic Maps syntax (CTM). `fileobj` A file-like object. """ return MIOCable...
python
def create_ctm_handler(fileobj, title=u'Cablegate Topic Map', comment=u'Generated by Cablemap - https://github.com/heuer/cablemap', detect_prefixes=False): """\ Returns a `ICableHandler` instance which writes Compact Topic Maps syntax (CTM). `fileobj` A file-like object. """ return MIOCable...
[ "def", "create_ctm_handler", "(", "fileobj", ",", "title", "=", "u'Cablegate Topic Map'", ",", "comment", "=", "u'Generated by Cablemap - https://github.com/heuer/cablemap'", ",", "detect_prefixes", "=", "False", ")", ":", "return", "MIOCableHandler", "(", "create_ctm_mioha...
\ Returns a `ICableHandler` instance which writes Compact Topic Maps syntax (CTM). `fileobj` A file-like object.
[ "\\", "Returns", "a", "ICableHandler", "instance", "which", "writes", "Compact", "Topic", "Maps", "syntax", "(", "CTM", ")", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L117-L124
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
create_xtm_handler
def create_xtm_handler(fileobj, title=u'Cablegate Topic Map', comment=u'Generated by Cablemap - https://github.com/heuer/cablemap'): """\ Returns a `ICableHandler` instance which writes XML Topic Maps syntax (XTM) 2.1. `fileobj` A file-like object. """ return MIOCableHandler(create_xtm_mioh...
python
def create_xtm_handler(fileobj, title=u'Cablegate Topic Map', comment=u'Generated by Cablemap - https://github.com/heuer/cablemap'): """\ Returns a `ICableHandler` instance which writes XML Topic Maps syntax (XTM) 2.1. `fileobj` A file-like object. """ return MIOCableHandler(create_xtm_mioh...
[ "def", "create_xtm_handler", "(", "fileobj", ",", "title", "=", "u'Cablegate Topic Map'", ",", "comment", "=", "u'Generated by Cablemap - https://github.com/heuer/cablemap'", ")", ":", "return", "MIOCableHandler", "(", "create_xtm_miohandler", "(", "fileobj", ",", "title", ...
\ Returns a `ICableHandler` instance which writes XML Topic Maps syntax (XTM) 2.1. `fileobj` A file-like object.
[ "\\", "Returns", "a", "ICableHandler", "instance", "which", "writes", "XML", "Topic", "Maps", "syntax", "(", "XTM", ")", "2", ".", "1", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L126-L133
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
BaseMIOCableHandler._occ
def _occ(self, value, typ, datatype=None): """\ Issues events to create an occurrence. `value` The string value `typ` The occurrence type `datatype` The datatype (default: xsd:string) """ self._handler.occurrence(typ, value, da...
python
def _occ(self, value, typ, datatype=None): """\ Issues events to create an occurrence. `value` The string value `typ` The occurrence type `datatype` The datatype (default: xsd:string) """ self._handler.occurrence(typ, value, da...
[ "def", "_occ", "(", "self", ",", "value", ",", "typ", ",", "datatype", "=", "None", ")", ":", "self", ".", "_handler", ".", "occurrence", "(", "typ", ",", "value", ",", "datatype", ")" ]
\ Issues events to create an occurrence. `value` The string value `typ` The occurrence type `datatype` The datatype (default: xsd:string)
[ "\\", "Issues", "events", "to", "create", "an", "occurrence", "." ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L194-L205
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
BaseMIOCableHandler._assoc
def _assoc(self, typ, role1, player1, role2=None, player2=None, reifier=None): """\ """ h = self._handler h.startAssociation(typ) h.role(role1, player1) if role2: h.role(role2, player2) if reifier: h.reifier(reifier) h.endAssociati...
python
def _assoc(self, typ, role1, player1, role2=None, player2=None, reifier=None): """\ """ h = self._handler h.startAssociation(typ) h.role(role1, player1) if role2: h.role(role2, player2) if reifier: h.reifier(reifier) h.endAssociati...
[ "def", "_assoc", "(", "self", ",", "typ", ",", "role1", ",", "player1", ",", "role2", "=", "None", ",", "player2", "=", "None", ",", "reifier", "=", "None", ")", ":", "h", "=", "self", ".", "_handler", "h", ".", "startAssociation", "(", "typ", ")",...
\
[ "\\" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L207-L218
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
MIOCableHandler._handle_recipient
def _handle_recipient(self, typ, recipient): """\ """ route, name, precedence, mcn = recipient.route, recipient.name, recipient.precedence, recipient.mcn if not name: return h = self._handler h.startAssociation(typ) h.role(psis.CABLE_TYPE, self._cable...
python
def _handle_recipient(self, typ, recipient): """\ """ route, name, precedence, mcn = recipient.route, recipient.name, recipient.precedence, recipient.mcn if not name: return h = self._handler h.startAssociation(typ) h.role(psis.CABLE_TYPE, self._cable...
[ "def", "_handle_recipient", "(", "self", ",", "typ", ",", "recipient", ")", ":", "route", ",", "name", ",", "precedence", ",", "mcn", "=", "recipient", ".", "route", ",", "recipient", ".", "name", ",", "recipient", ".", "precedence", ",", "recipient", "....
\
[ "\\" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L264-L281
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
MIOCableHandler._handle_reference_cable
def _handle_reference_cable(self, reference, handler, reifier): """\ """ cable_ref = psis.cable_psi(reference.value) self._assoc(psis.REFERENCES_TYPE, psis.SOURCE_TYPE, self._cable_psi, psis.TARGET_TYPE, cable_ref, reifier) ...
python
def _handle_reference_cable(self, reference, handler, reifier): """\ """ cable_ref = psis.cable_psi(reference.value) self._assoc(psis.REFERENCES_TYPE, psis.SOURCE_TYPE, self._cable_psi, psis.TARGET_TYPE, cable_ref, reifier) ...
[ "def", "_handle_reference_cable", "(", "self", ",", "reference", ",", "handler", ",", "reifier", ")", ":", "cable_ref", "=", "psis", ".", "cable_psi", "(", "reference", ".", "value", ")", "self", ".", "_assoc", "(", "psis", ".", "REFERENCES_TYPE", ",", "ps...
\
[ "\\" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L303-L316
heuer/cablemap
cablemap.tm/cablemap/tm/handler.py
MIOCableHandler._sent_by
def _sent_by(self, origin, cable): """\ `origin` Topic identity (commonly a subject identifier) of the originator of the cable `cable` Topic identity (commonly a subject identifier) of the cable. """ self._assoc(psis.SENT_BY_TYPE, psis...
python
def _sent_by(self, origin, cable): """\ `origin` Topic identity (commonly a subject identifier) of the originator of the cable `cable` Topic identity (commonly a subject identifier) of the cable. """ self._assoc(psis.SENT_BY_TYPE, psis...
[ "def", "_sent_by", "(", "self", ",", "origin", ",", "cable", ")", ":", "self", ".", "_assoc", "(", "psis", ".", "SENT_BY_TYPE", ",", "psis", ".", "SENDER_TYPE", ",", "origin", ",", "psis", ".", "CABLE_TYPE", ",", "cable", ")" ]
\ `origin` Topic identity (commonly a subject identifier) of the originator of the cable `cable` Topic identity (commonly a subject identifier) of the cable.
[ "\\" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.tm/cablemap/tm/handler.py#L394-L404
ael-code/pyFsdb
fsdb/hashtools.py
calc_digest
def calc_digest(origin, algorithm="sha1", block_size=None): """Calculate digest of a readable object Args: origin -- a readable object for which calculate digest algorithn -- the algorithm to use. See ``hashlib.algorithms_available`` for supported algorithms. block_size -- the size of ...
python
def calc_digest(origin, algorithm="sha1", block_size=None): """Calculate digest of a readable object Args: origin -- a readable object for which calculate digest algorithn -- the algorithm to use. See ``hashlib.algorithms_available`` for supported algorithms. block_size -- the size of ...
[ "def", "calc_digest", "(", "origin", ",", "algorithm", "=", "\"sha1\"", ",", "block_size", "=", "None", ")", ":", "try", ":", "hashM", "=", "hashlib", ".", "new", "(", "algorithm", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'hash algori...
Calculate digest of a readable object Args: origin -- a readable object for which calculate digest algorithn -- the algorithm to use. See ``hashlib.algorithms_available`` for supported algorithms. block_size -- the size of the block to read at each iteration
[ "Calculate", "digest", "of", "a", "readable", "object" ]
train
https://github.com/ael-code/pyFsdb/blob/de33a0d41373307cb32cdd7ba1991b85ff495ee3/fsdb/hashtools.py#L17-L35
StyXman/ayrton
ayrton/execute.py
Command.prepare_fds
def prepare_fds (self): """Create needed file descriptors (pipes, mostly) before forking.""" if '_in' in self.options: i= self.options['_in'] logger.debug ('_in: %r', i) # this condition is complex, but basically handles any type of input # that is not go...
python
def prepare_fds (self): """Create needed file descriptors (pipes, mostly) before forking.""" if '_in' in self.options: i= self.options['_in'] logger.debug ('_in: %r', i) # this condition is complex, but basically handles any type of input # that is not go...
[ "def", "prepare_fds", "(", "self", ")", ":", "if", "'_in'", "in", "self", ".", "options", ":", "i", "=", "self", ".", "options", "[", "'_in'", "]", "logger", ".", "debug", "(", "'_in: %r'", ",", "i", ")", "# this condition is complex, but basically handles a...
Create needed file descriptors (pipes, mostly) before forking.
[ "Create", "needed", "file", "descriptors", "(", "pipes", "mostly", ")", "before", "forking", "." ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/execute.py#L154-L228
StyXman/ayrton
ayrton/parser/pyparser/metaparser.py
nfa_to_dfa
def nfa_to_dfa(start, end): """Convert an NFA to a DFA(s) Each DFA is initially a set of NFA states without labels. We start with the DFA for the start NFA. Then we add labeled arcs to it pointing to another set of NFAs (the next state). Finally, we do the same thing to every DFA that is found a...
python
def nfa_to_dfa(start, end): """Convert an NFA to a DFA(s) Each DFA is initially a set of NFA states without labels. We start with the DFA for the start NFA. Then we add labeled arcs to it pointing to another set of NFAs (the next state). Finally, we do the same thing to every DFA that is found a...
[ "def", "nfa_to_dfa", "(", "start", ",", "end", ")", ":", "base_nfas", "=", "set", "(", ")", "start", ".", "find_unlabeled_states", "(", "base_nfas", ")", "state_stack", "=", "[", "DFA", "(", "base_nfas", ",", "end", ")", "]", "for", "state", "in", "sta...
Convert an NFA to a DFA(s) Each DFA is initially a set of NFA states without labels. We start with the DFA for the start NFA. Then we add labeled arcs to it pointing to another set of NFAs (the next state). Finally, we do the same thing to every DFA that is found and return the list of states.
[ "Convert", "an", "NFA", "to", "a", "DFA", "(", "s", ")" ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/pyparser/metaparser.py#L75-L100
limodou/par
par/md.py
MarkdownHtmlVisitor.visit_wiki_link
def visit_wiki_link(self, node): """ [[(type:)name(#anchor)(|alter name)]] type = 'wiki', or 'image' if type == 'wiki': [[(wiki:)name(#anchor)(|alter name)]] if type == 'image': [[(image:)filelink(|align|width|height)]] float = 'left', 'right' ...
python
def visit_wiki_link(self, node): """ [[(type:)name(#anchor)(|alter name)]] type = 'wiki', or 'image' if type == 'wiki': [[(wiki:)name(#anchor)(|alter name)]] if type == 'image': [[(image:)filelink(|align|width|height)]] float = 'left', 'right' ...
[ "def", "visit_wiki_link", "(", "self", ",", "node", ")", ":", "urljoin", "=", "import_", "(", "'urllib.parse'", ",", "[", "'urljoin'", "]", ",", "via", "=", "'urlparse'", ")", "t", "=", "node", ".", "text", "[", "2", ":", "-", "2", "]", ".", "strip...
[[(type:)name(#anchor)(|alter name)]] type = 'wiki', or 'image' if type == 'wiki': [[(wiki:)name(#anchor)(|alter name)]] if type == 'image': [[(image:)filelink(|align|width|height)]] float = 'left', 'right' width or height = '' will not set
[ "[[", "(", "type", ":", ")", "name", "(", "#anchor", ")", "(", "|alter", "name", ")", "]]", "type", "=", "wiki", "or", "image", "if", "type", "==", "wiki", ":", "[[", "(", "wiki", ":", ")", "name", "(", "#anchor", ")", "(", "|alter", "name", ")...
train
https://github.com/limodou/par/blob/0863c339c8d0d46f8516eb4577b459b9cf2dec8d/par/md.py#L514-L569
PMBio/limix-backup
limix/stats/geno_summary.py
calc_AF
def calc_AF(M,major=0,minor=2): """calculate minor allelel frequency, by default assuming that minor==2""" if minor==2: Nhet = (M==0).sum(axis=0) Nmajor = 2*(M==0).sum(axis=0) Nminor = 2*(M==2).sum(axis=0) af = Nminor/sp.double(2*M.shape[0]) else: Nmajor = (M==0).s...
python
def calc_AF(M,major=0,minor=2): """calculate minor allelel frequency, by default assuming that minor==2""" if minor==2: Nhet = (M==0).sum(axis=0) Nmajor = 2*(M==0).sum(axis=0) Nminor = 2*(M==2).sum(axis=0) af = Nminor/sp.double(2*M.shape[0]) else: Nmajor = (M==0).s...
[ "def", "calc_AF", "(", "M", ",", "major", "=", "0", ",", "minor", "=", "2", ")", ":", "if", "minor", "==", "2", ":", "Nhet", "=", "(", "M", "==", "0", ")", ".", "sum", "(", "axis", "=", "0", ")", "Nmajor", "=", "2", "*", "(", "M", "==", ...
calculate minor allelel frequency, by default assuming that minor==2
[ "calculate", "minor", "allelel", "frequency", "by", "default", "assuming", "that", "minor", "==", "2" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/geno_summary.py#L21-L36
PMBio/limix-backup
limix/stats/geno_summary.py
calc_LD
def calc_LD(M,pos,i_start=[0],max_dist=1000000): """calculate linkage disequilibrium correlations: M: genotype matrix pos: position vector i_start: index to start from for LD calculation dist: distance """ RV = [] DIST = [] for start in i_start: pos0 = pos[start] v0 ...
python
def calc_LD(M,pos,i_start=[0],max_dist=1000000): """calculate linkage disequilibrium correlations: M: genotype matrix pos: position vector i_start: index to start from for LD calculation dist: distance """ RV = [] DIST = [] for start in i_start: pos0 = pos[start] v0 ...
[ "def", "calc_LD", "(", "M", ",", "pos", ",", "i_start", "=", "[", "0", "]", ",", "max_dist", "=", "1000000", ")", ":", "RV", "=", "[", "]", "DIST", "=", "[", "]", "for", "start", "in", "i_start", ":", "pos0", "=", "pos", "[", "start", "]", "v...
calculate linkage disequilibrium correlations: M: genotype matrix pos: position vector i_start: index to start from for LD calculation dist: distance
[ "calculate", "linkage", "disequilibrium", "correlations", ":", "M", ":", "genotype", "matrix", "pos", ":", "position", "vector", "i_start", ":", "index", "to", "start", "from", "for", "LD", "calculation", "dist", ":", "distance" ]
train
https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/stats/geno_summary.py#L38-L61
StyXman/ayrton
ayrton/expansion.py
ToExpand.expand_one
def expand_one (self): "expand the more-to-the-left/outer bracket, return a list of ToExpand's" data= self.indexes.pop (0) left_cb, right_cb= data prefix= self.text[:left_cb] # the body includes the {}'s body= self.text[left_cb:right_cb+1] postfix= self.text[righ...
python
def expand_one (self): "expand the more-to-the-left/outer bracket, return a list of ToExpand's" data= self.indexes.pop (0) left_cb, right_cb= data prefix= self.text[:left_cb] # the body includes the {}'s body= self.text[left_cb:right_cb+1] postfix= self.text[righ...
[ "def", "expand_one", "(", "self", ")", ":", "data", "=", "self", ".", "indexes", ".", "pop", "(", "0", ")", "left_cb", ",", "right_cb", "=", "data", "prefix", "=", "self", ".", "text", "[", ":", "left_cb", "]", "# the body includes the {}'s", "body", "...
expand the more-to-the-left/outer bracket, return a list of ToExpand's
[ "expand", "the", "more", "-", "to", "-", "the", "-", "left", "/", "outer", "bracket", "return", "a", "list", "of", "ToExpand", "s" ]
train
https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/expansion.py#L109-L171
wilzbach/smarkov
smarkov/utils.py
get_suffixes
def get_suffixes(arr): """ Returns all possible suffixes of an array (lazy evaluated) Args: arr: input array Returns: Array of all possible suffixes (as tuples) """ arr = tuple(arr) return [arr] return (arr[i:] for i in range(len(arr)))
python
def get_suffixes(arr): """ Returns all possible suffixes of an array (lazy evaluated) Args: arr: input array Returns: Array of all possible suffixes (as tuples) """ arr = tuple(arr) return [arr] return (arr[i:] for i in range(len(arr)))
[ "def", "get_suffixes", "(", "arr", ")", ":", "arr", "=", "tuple", "(", "arr", ")", "return", "[", "arr", "]", "return", "(", "arr", "[", "i", ":", "]", "for", "i", "in", "range", "(", "len", "(", "arr", ")", ")", ")" ]
Returns all possible suffixes of an array (lazy evaluated) Args: arr: input array Returns: Array of all possible suffixes (as tuples)
[ "Returns", "all", "possible", "suffixes", "of", "an", "array", "(", "lazy", "evaluated", ")", "Args", ":", "arr", ":", "input", "array", "Returns", ":", "Array", "of", "all", "possible", "suffixes", "(", "as", "tuples", ")" ]
train
https://github.com/wilzbach/smarkov/blob/c98c08cc432e18c5c87fb9a6e013b1b8eaa54d37/smarkov/utils.py#L26-L35
wilzbach/smarkov
smarkov/utils.py
weighted_choice
def weighted_choice(item_probabilities): """ Randomly choses an item according to defined weights Args: item_probabilities: list of (item, probability)-tuples Returns: random item according to the given weights """ probability_sum = sum(x[1] for x in item_probabilities) assert pr...
python
def weighted_choice(item_probabilities): """ Randomly choses an item according to defined weights Args: item_probabilities: list of (item, probability)-tuples Returns: random item according to the given weights """ probability_sum = sum(x[1] for x in item_probabilities) assert pr...
[ "def", "weighted_choice", "(", "item_probabilities", ")", ":", "probability_sum", "=", "sum", "(", "x", "[", "1", "]", "for", "x", "in", "item_probabilities", ")", "assert", "probability_sum", ">", "0", "random_value", "=", "random", ".", "random", "(", ")",...
Randomly choses an item according to defined weights Args: item_probabilities: list of (item, probability)-tuples Returns: random item according to the given weights
[ "Randomly", "choses", "an", "item", "according", "to", "defined", "weights", "Args", ":", "item_probabilities", ":", "list", "of", "(", "item", "probability", ")", "-", "tuples", "Returns", ":", "random", "item", "according", "to", "the", "given", "weights" ]
train
https://github.com/wilzbach/smarkov/blob/c98c08cc432e18c5c87fb9a6e013b1b8eaa54d37/smarkov/utils.py#L51-L65
benjamin-hodgson/build
src/build/__init__.py
evaluate_callables
def evaluate_callables(data): """ Call any callable values in the input dictionary; return a new dictionary containing the evaluated results. Useful for lazily evaluating default values in ``build`` methods. >>> data = {"spam": "ham", "eggs": (lambda: 123)} >>> result = evaluate_callables(data)...
python
def evaluate_callables(data): """ Call any callable values in the input dictionary; return a new dictionary containing the evaluated results. Useful for lazily evaluating default values in ``build`` methods. >>> data = {"spam": "ham", "eggs": (lambda: 123)} >>> result = evaluate_callables(data)...
[ "def", "evaluate_callables", "(", "data", ")", ":", "sequence", "=", "(", "(", "k", ",", "v", "(", ")", "if", "callable", "(", "v", ")", "else", "v", ")", "for", "k", ",", "v", "in", "data", ".", "items", "(", ")", ")", "return", "type", "(", ...
Call any callable values in the input dictionary; return a new dictionary containing the evaluated results. Useful for lazily evaluating default values in ``build`` methods. >>> data = {"spam": "ham", "eggs": (lambda: 123)} >>> result = evaluate_callables(data) >>> result == {'eggs': 123, 'spam': '...
[ "Call", "any", "callable", "values", "in", "the", "input", "dictionary", ";", "return", "a", "new", "dictionary", "containing", "the", "evaluated", "results", ".", "Useful", "for", "lazily", "evaluating", "default", "values", "in", "build", "methods", "." ]
train
https://github.com/benjamin-hodgson/build/blob/d6e314cc1e26c2d3f605035e8a38d6bc12fde792/src/build/__init__.py#L67-L79
whtsky/parguments
parguments/cli.py
prompt
def prompt(name, default=None): """ Grab user input from command line. :param name: prompt text :param default: default value if no input provided. """ prompt = name + (default and ' [%s]' % default or '') prompt += name.endswith('?') and ' ' or ': ' while True: rv = raw_input(...
python
def prompt(name, default=None): """ Grab user input from command line. :param name: prompt text :param default: default value if no input provided. """ prompt = name + (default and ' [%s]' % default or '') prompt += name.endswith('?') and ' ' or ': ' while True: rv = raw_input(...
[ "def", "prompt", "(", "name", ",", "default", "=", "None", ")", ":", "prompt", "=", "name", "+", "(", "default", "and", "' [%s]'", "%", "default", "or", "''", ")", "prompt", "+=", "name", ".", "endswith", "(", "'?'", ")", "and", "' '", "or", "': '"...
Grab user input from command line. :param name: prompt text :param default: default value if no input provided.
[ "Grab", "user", "input", "from", "command", "line", "." ]
train
https://github.com/whtsky/parguments/blob/96aa23af411a67c2f70d856e81fa186bb187daab/parguments/cli.py#L42-L57
whtsky/parguments
parguments/cli.py
prompt_pass
def prompt_pass(name, default=None): """ Grabs hidden (password) input from command line. :param name: prompt text :param default: default value if no input provided. """ prompt = name + (default and ' [%s]' % default or '') prompt += name.endswith('?') and ' ' or ': ' while True: ...
python
def prompt_pass(name, default=None): """ Grabs hidden (password) input from command line. :param name: prompt text :param default: default value if no input provided. """ prompt = name + (default and ' [%s]' % default or '') prompt += name.endswith('?') and ' ' or ': ' while True: ...
[ "def", "prompt_pass", "(", "name", ",", "default", "=", "None", ")", ":", "prompt", "=", "name", "+", "(", "default", "and", "' [%s]'", "%", "default", "or", "''", ")", "prompt", "+=", "name", ".", "endswith", "(", "'?'", ")", "and", "' '", "or", "...
Grabs hidden (password) input from command line. :param name: prompt text :param default: default value if no input provided.
[ "Grabs", "hidden", "(", "password", ")", "input", "from", "command", "line", "." ]
train
https://github.com/whtsky/parguments/blob/96aa23af411a67c2f70d856e81fa186bb187daab/parguments/cli.py#L60-L75
whtsky/parguments
parguments/cli.py
prompt_bool
def prompt_bool(name, default=False, yes_choices=None, no_choices=None): """ Grabs user input from command line and converts to boolean value. :param name: prompt text :param default: default value if no input provided. :param yes_choices: default 'y', 'yes', '1', 'on', 'true', 't' :param n...
python
def prompt_bool(name, default=False, yes_choices=None, no_choices=None): """ Grabs user input from command line and converts to boolean value. :param name: prompt text :param default: default value if no input provided. :param yes_choices: default 'y', 'yes', '1', 'on', 'true', 't' :param n...
[ "def", "prompt_bool", "(", "name", ",", "default", "=", "False", ",", "yes_choices", "=", "None", ",", "no_choices", "=", "None", ")", ":", "yes_choices", "=", "yes_choices", "or", "(", "'y'", ",", "'yes'", ",", "'1'", ",", "'on'", ",", "'true'", ",", ...
Grabs user input from command line and converts to boolean value. :param name: prompt text :param default: default value if no input provided. :param yes_choices: default 'y', 'yes', '1', 'on', 'true', 't' :param no_choices: default 'n', 'no', '0', 'off', 'false', 'f'
[ "Grabs", "user", "input", "from", "command", "line", "and", "converts", "to", "boolean", "value", "." ]
train
https://github.com/whtsky/parguments/blob/96aa23af411a67c2f70d856e81fa186bb187daab/parguments/cli.py#L78-L97
whtsky/parguments
parguments/cli.py
prompt_choices
def prompt_choices(name, choices, default=None, no_choice=('none',)): """ Grabs user input from command line from set of provided choices. :param name: prompt text :param choices: list or tuple of available choices. :param default: default value if no input provided. :param no_choice: acceptabl...
python
def prompt_choices(name, choices, default=None, no_choice=('none',)): """ Grabs user input from command line from set of provided choices. :param name: prompt text :param choices: list or tuple of available choices. :param default: default value if no input provided. :param no_choice: acceptabl...
[ "def", "prompt_choices", "(", "name", ",", "choices", ",", "default", "=", "None", ",", "no_choice", "=", "(", "'none'", ",", ")", ")", ":", "_choices", "=", "[", "]", "options", "=", "[", "]", "for", "choice", "in", "choices", ":", "options", ".", ...
Grabs user input from command line from set of provided choices. :param name: prompt text :param choices: list or tuple of available choices. :param default: default value if no input provided. :param no_choice: acceptable list of strings for "null choice"
[ "Grabs", "user", "input", "from", "command", "line", "from", "set", "of", "provided", "choices", "." ]
train
https://github.com/whtsky/parguments/blob/96aa23af411a67c2f70d856e81fa186bb187daab/parguments/cli.py#L100-L123
KelSolaar/Foundations
foundations/guerilla.py
attribute_warfare
def attribute_warfare(object): """ Alterates object attributes using guerilla / monkey patching. :param object: Object to alterate. :type object: object :return: Object. :rtype: object """ def attribute_warfare_wrapper(attribute): """ Alterates object attributes using g...
python
def attribute_warfare(object): """ Alterates object attributes using guerilla / monkey patching. :param object: Object to alterate. :type object: object :return: Object. :rtype: object """ def attribute_warfare_wrapper(attribute): """ Alterates object attributes using g...
[ "def", "attribute_warfare", "(", "object", ")", ":", "def", "attribute_warfare_wrapper", "(", "attribute", ")", ":", "\"\"\"\n Alterates object attributes using guerilla / monkey patching.\n\n :param attribute: Attribute to alterate.\n :type attribute: object\n :r...
Alterates object attributes using guerilla / monkey patching. :param object: Object to alterate. :type object: object :return: Object. :rtype: object
[ "Alterates", "object", "attributes", "using", "guerilla", "/", "monkey", "patching", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/guerilla.py#L31-L54
KelSolaar/Foundations
foundations/guerilla.py
base_warfare
def base_warfare(name, bases, attributes): """ Adds any number of attributes to an existing class. :param name: Name. :type name: unicode :param bases: Bases. :type bases: list :param attributes: Attributes. :type attributes: dict :return: Base. :rtype: object """ asser...
python
def base_warfare(name, bases, attributes): """ Adds any number of attributes to an existing class. :param name: Name. :type name: unicode :param bases: Bases. :type bases: list :param attributes: Attributes. :type attributes: dict :return: Base. :rtype: object """ asser...
[ "def", "base_warfare", "(", "name", ",", "bases", ",", "attributes", ")", ":", "assert", "len", "(", "bases", ")", "==", "1", ",", "\"{0} | '{1}' object has multiple bases!\"", ".", "format", "(", "__name__", ",", "name", ")", "base", "=", "foundations", "."...
Adds any number of attributes to an existing class. :param name: Name. :type name: unicode :param bases: Bases. :type bases: list :param attributes: Attributes. :type attributes: dict :return: Base. :rtype: object
[ "Adds", "any", "number", "of", "attributes", "to", "an", "existing", "class", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/guerilla.py#L57-L77
pennlabs/penncoursereview-sdk-python
penncoursereview/api.py
Resource._update
def _update(self, data): """Update the object with new data.""" for k, v in six.iteritems(data): new_value = v if isinstance(v, dict): new_value = type(self)(v) elif isinstance(v, list): new_value = [(type(self)(e) if isinstance(e, dict...
python
def _update(self, data): """Update the object with new data.""" for k, v in six.iteritems(data): new_value = v if isinstance(v, dict): new_value = type(self)(v) elif isinstance(v, list): new_value = [(type(self)(e) if isinstance(e, dict...
[ "def", "_update", "(", "self", ",", "data", ")", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "data", ")", ":", "new_value", "=", "v", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "new_value", "=", "type", "(", "self", ...
Update the object with new data.
[ "Update", "the", "object", "with", "new", "data", "." ]
train
https://github.com/pennlabs/penncoursereview-sdk-python/blob/f9f2f1bfcadf0aff50133e35d761f6d1cf85b564/penncoursereview/api.py#L47-L56
rjw57/starman
starman/stats.py
MultivariateNormal.rvs
def rvs(self, size=1): """Convenience method to sample from this distribution. Args: size (int or tuple): Shape of return value. Each element is drawn independently from this distribution. """ return np.random.multivariate_normal(self.mean, self.cov, size)
python
def rvs(self, size=1): """Convenience method to sample from this distribution. Args: size (int or tuple): Shape of return value. Each element is drawn independently from this distribution. """ return np.random.multivariate_normal(self.mean, self.cov, size)
[ "def", "rvs", "(", "self", ",", "size", "=", "1", ")", ":", "return", "np", ".", "random", ".", "multivariate_normal", "(", "self", ".", "mean", ",", "self", ".", "cov", ",", "size", ")" ]
Convenience method to sample from this distribution. Args: size (int or tuple): Shape of return value. Each element is drawn independently from this distribution.
[ "Convenience", "method", "to", "sample", "from", "this", "distribution", "." ]
train
https://github.com/rjw57/starman/blob/1f9475e2354c9630a61f4898ad871de1d2fdbc71/starman/stats.py#L48-L56
carta/franz
franz/kafka/producer.py
Producer._send_message_to_topic
def _send_message_to_topic(self, topic, message): """ Send a message to a Kafka topic. Parameters ---------- topic : str The kafka topic where the message should be sent to. message : FranzEvent The message to be sent. Raises ----...
python
def _send_message_to_topic(self, topic, message): """ Send a message to a Kafka topic. Parameters ---------- topic : str The kafka topic where the message should be sent to. message : FranzEvent The message to be sent. Raises ----...
[ "def", "_send_message_to_topic", "(", "self", ",", "topic", ",", "message", ")", ":", "message_result", "=", "self", ".", "producer", ".", "send", "(", "topic", ",", "message", ")", "self", ".", "check_for_message_exception", "(", "message_result", ")", "retur...
Send a message to a Kafka topic. Parameters ---------- topic : str The kafka topic where the message should be sent to. message : FranzEvent The message to be sent. Raises ------ franz.InvalidMessage
[ "Send", "a", "message", "to", "a", "Kafka", "topic", "." ]
train
https://github.com/carta/franz/blob/85678878eee8dad0fbe933d0cff819c2d16caa12/franz/kafka/producer.py#L35-L52
carta/franz
franz/kafka/producer.py
Producer.check_for_message_exception
def check_for_message_exception(cls, message_result): """ Makes sure there isn't an error when sending the message. Kafka will silently catch exceptions and not bubble them up. Parameters ---------- message_result : FutureRecordMetadata """ exception = me...
python
def check_for_message_exception(cls, message_result): """ Makes sure there isn't an error when sending the message. Kafka will silently catch exceptions and not bubble them up. Parameters ---------- message_result : FutureRecordMetadata """ exception = me...
[ "def", "check_for_message_exception", "(", "cls", ",", "message_result", ")", ":", "exception", "=", "message_result", ".", "exception", "if", "isinstance", "(", "exception", ",", "BaseException", ")", ":", "raise", "exception" ]
Makes sure there isn't an error when sending the message. Kafka will silently catch exceptions and not bubble them up. Parameters ---------- message_result : FutureRecordMetadata
[ "Makes", "sure", "there", "isn", "t", "an", "error", "when", "sending", "the", "message", ".", "Kafka", "will", "silently", "catch", "exceptions", "and", "not", "bubble", "them", "up", "." ]
train
https://github.com/carta/franz/blob/85678878eee8dad0fbe933d0cff819c2d16caa12/franz/kafka/producer.py#L55-L67
heuer/cablemap
examples/converttocsv.py
generate_csv
def generate_csv(in_dir, out): """\ Walks through the `in_dir` and generates the CSV file `out` """ writer = UnicodeWriter(open(out, 'wb'), delimiter=';') writer.writerow(('Reference ID', 'Created', 'Origin', 'Subject')) for cable in cables_from_source(in_dir): writer.writerow((cable.ref...
python
def generate_csv(in_dir, out): """\ Walks through the `in_dir` and generates the CSV file `out` """ writer = UnicodeWriter(open(out, 'wb'), delimiter=';') writer.writerow(('Reference ID', 'Created', 'Origin', 'Subject')) for cable in cables_from_source(in_dir): writer.writerow((cable.ref...
[ "def", "generate_csv", "(", "in_dir", ",", "out", ")", ":", "writer", "=", "UnicodeWriter", "(", "open", "(", "out", ",", "'wb'", ")", ",", "delimiter", "=", "';'", ")", "writer", ".", "writerow", "(", "(", "'Reference ID'", ",", "'Created'", ",", "'Or...
\ Walks through the `in_dir` and generates the CSV file `out`
[ "\\", "Walks", "through", "the", "in_dir", "and", "generates", "the", "CSV", "file", "out" ]
train
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/examples/converttocsv.py#L47-L54
KelSolaar/Foundations
foundations/rotating_backup.py
RotatingBackup.source
def source(self, value): """ Setter for **self.__source** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "source"...
python
def source(self, value): """ Setter for **self.__source** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( "source"...
[ "def", "source", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "unicode", ",", "\"'{0}' attribute: '{1}' type is not 'unicode'!\"", ".", "format", "(", "\"source\"", ",", "value", ")"...
Setter for **self.__source** attribute. :param value: Attribute value. :type value: unicode
[ "Setter", "for", "**", "self", ".", "__source", "**", "attribute", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/rotating_backup.py#L99-L111
KelSolaar/Foundations
foundations/rotating_backup.py
RotatingBackup.destination
def destination(self, value): """ Setter for **self.__destination** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( ...
python
def destination(self, value): """ Setter for **self.__destination** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) is unicode, "'{0}' attribute: '{1}' type is not 'unicode'!".format( ...
[ "def", "destination", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "unicode", ",", "\"'{0}' attribute: '{1}' type is not 'unicode'!\"", ".", "format", "(", "\"destination\"", ",", "val...
Setter for **self.__destination** attribute. :param value: Attribute value. :type value: unicode
[ "Setter", "for", "**", "self", ".", "__destination", "**", "attribute", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/rotating_backup.py#L136-L147
KelSolaar/Foundations
foundations/rotating_backup.py
RotatingBackup.count
def count(self, value): """ Setter for **self.__count** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "count", value) ...
python
def count(self, value): """ Setter for **self.__count** attribute. :param value: Attribute value. :type value: int """ if value is not None: assert type(value) is int, "'{0}' attribute: '{1}' type is not 'int'!".format( "count", value) ...
[ "def", "count", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "int", ",", "\"'{0}' attribute: '{1}' type is not 'int'!\"", ".", "format", "(", "\"count\"", ",", "value", ")", "asser...
Setter for **self.__count** attribute. :param value: Attribute value. :type value: int
[ "Setter", "for", "**", "self", ".", "__count", "**", "attribute", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/rotating_backup.py#L172-L184
KelSolaar/Foundations
foundations/rotating_backup.py
RotatingBackup.backup
def backup(self): """ Does the rotating backup. :return: Method success. :rtype: bool """ LOGGER.debug("> Storing '{0}' file backup.".format(self.__source)) foundations.common.path_exists(self.__destination) or foundations.io.set_directory(self.__destination) ...
python
def backup(self): """ Does the rotating backup. :return: Method success. :rtype: bool """ LOGGER.debug("> Storing '{0}' file backup.".format(self.__source)) foundations.common.path_exists(self.__destination) or foundations.io.set_directory(self.__destination) ...
[ "def", "backup", "(", "self", ")", ":", "LOGGER", ".", "debug", "(", "\"> Storing '{0}' file backup.\"", ".", "format", "(", "self", ".", "__source", ")", ")", "foundations", ".", "common", ".", "path_exists", "(", "self", ".", "__destination", ")", "or", ...
Does the rotating backup. :return: Method success. :rtype: bool
[ "Does", "the", "rotating", "backup", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/rotating_backup.py#L196-L217
KelSolaar/Foundations
foundations/common.py
ordered_uniqify
def ordered_uniqify(sequence): """ Uniqifies the given hashable sequence while preserving its order. :param sequence: Sequence. :type sequence: object :return: Uniqified sequence. :rtype: list """ items = set() return [key for key in sequence if key not in items and not items.add(k...
python
def ordered_uniqify(sequence): """ Uniqifies the given hashable sequence while preserving its order. :param sequence: Sequence. :type sequence: object :return: Uniqified sequence. :rtype: list """ items = set() return [key for key in sequence if key not in items and not items.add(k...
[ "def", "ordered_uniqify", "(", "sequence", ")", ":", "items", "=", "set", "(", ")", "return", "[", "key", "for", "key", "in", "sequence", "if", "key", "not", "in", "items", "and", "not", "items", ".", "add", "(", "key", ")", "]" ]
Uniqifies the given hashable sequence while preserving its order. :param sequence: Sequence. :type sequence: object :return: Uniqified sequence. :rtype: list
[ "Uniqifies", "the", "given", "hashable", "sequence", "while", "preserving", "its", "order", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/common.py#L86-L97
KelSolaar/Foundations
foundations/common.py
unpack_default
def unpack_default(iterable, length=3, default=None): """ Unpacks given iterable maintaining given length and filling missing entries with given default. :param iterable: iterable. :type iterable: object :param length: Iterable length. :type length: int :param default: Filling default objec...
python
def unpack_default(iterable, length=3, default=None): """ Unpacks given iterable maintaining given length and filling missing entries with given default. :param iterable: iterable. :type iterable: object :param length: Iterable length. :type length: int :param default: Filling default objec...
[ "def", "unpack_default", "(", "iterable", ",", "length", "=", "3", ",", "default", "=", "None", ")", ":", "return", "itertools", ".", "islice", "(", "itertools", ".", "chain", "(", "iter", "(", "iterable", ")", ",", "itertools", ".", "repeat", "(", "de...
Unpacks given iterable maintaining given length and filling missing entries with given default. :param iterable: iterable. :type iterable: object :param length: Iterable length. :type length: int :param default: Filling default object. :type default: object :return: Unpacked iterable. :...
[ "Unpacks", "given", "iterable", "maintaining", "given", "length", "and", "filling", "missing", "entries", "with", "given", "default", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/common.py#L100-L114
KelSolaar/Foundations
foundations/common.py
dependency_resolver
def dependency_resolver(dependencies): """ Resolves given dependencies. :param dependencies: Dependencies to resolve. :type dependencies: dict :return: Resolved dependencies. :rtype: list """ items = dict((key, set(dependencies[key])) for key in dependencies) resolved_dependencies ...
python
def dependency_resolver(dependencies): """ Resolves given dependencies. :param dependencies: Dependencies to resolve. :type dependencies: dict :return: Resolved dependencies. :rtype: list """ items = dict((key, set(dependencies[key])) for key in dependencies) resolved_dependencies ...
[ "def", "dependency_resolver", "(", "dependencies", ")", ":", "items", "=", "dict", "(", "(", "key", ",", "set", "(", "dependencies", "[", "key", "]", ")", ")", "for", "key", "in", "dependencies", ")", "resolved_dependencies", "=", "[", "]", "while", "ite...
Resolves given dependencies. :param dependencies: Dependencies to resolve. :type dependencies: dict :return: Resolved dependencies. :rtype: list
[ "Resolves", "given", "dependencies", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/common.py#L198-L215
KelSolaar/Foundations
foundations/common.py
is_internet_available
def is_internet_available(ips=CONNECTION_IPS, timeout=1.0): """ Returns if an internet connection is available. :param ips: Address ips to check against. :type ips: list :param timeout: Timeout in seconds. :type timeout: int :return: Is internet available. :rtype: bool """ whil...
python
def is_internet_available(ips=CONNECTION_IPS, timeout=1.0): """ Returns if an internet connection is available. :param ips: Address ips to check against. :type ips: list :param timeout: Timeout in seconds. :type timeout: int :return: Is internet available. :rtype: bool """ whil...
[ "def", "is_internet_available", "(", "ips", "=", "CONNECTION_IPS", ",", "timeout", "=", "1.0", ")", ":", "while", "ips", ":", "try", ":", "urllib2", ".", "urlopen", "(", "\"http://{0}\"", ".", "format", "(", "ips", ".", "pop", "(", "0", ")", ")", ",", ...
Returns if an internet connection is available. :param ips: Address ips to check against. :type ips: list :param timeout: Timeout in seconds. :type timeout: int :return: Is internet available. :rtype: bool
[ "Returns", "if", "an", "internet", "connection", "is", "available", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/common.py#L218-L238
KelSolaar/Foundations
foundations/common.py
get_host_address
def get_host_address(host=None, default_address=DEFAULT_HOST_IP): """ Returns the given host address. :param host: Host to retrieve the address. :type host: unicode :param default_address: Default address if the host is unreachable. :type default_address: unicode :return: Host address. ...
python
def get_host_address(host=None, default_address=DEFAULT_HOST_IP): """ Returns the given host address. :param host: Host to retrieve the address. :type host: unicode :param default_address: Default address if the host is unreachable. :type default_address: unicode :return: Host address. ...
[ "def", "get_host_address", "(", "host", "=", "None", ",", "default_address", "=", "DEFAULT_HOST_IP", ")", ":", "try", ":", "return", "unicode", "(", "socket", ".", "gethostbyname", "(", "host", "or", "socket", ".", "gethostname", "(", ")", ")", ",", "Const...
Returns the given host address. :param host: Host to retrieve the address. :type host: unicode :param default_address: Default address if the host is unreachable. :type default_address: unicode :return: Host address. :rtype: unicode
[ "Returns", "the", "given", "host", "address", "." ]
train
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/common.py#L241-L258
getfleety/coralillo
coralillo/core.py
Form.validate
def validate(cls, **kwargs): ''' Validates the data received as keyword arguments whose name match this class attributes. ''' # errors can store multiple errors # obj is an instance in case validation succeeds # redis is needed for database validation errors = ValidationE...
python
def validate(cls, **kwargs): ''' Validates the data received as keyword arguments whose name match this class attributes. ''' # errors can store multiple errors # obj is an instance in case validation succeeds # redis is needed for database validation errors = ValidationE...
[ "def", "validate", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "# errors can store multiple errors", "# obj is an instance in case validation succeeds", "# redis is needed for database validation", "errors", "=", "ValidationErrors", "(", ")", "obj", "=", "cls", "(", ")...
Validates the data received as keyword arguments whose name match this class attributes.
[ "Validates", "the", "data", "received", "as", "keyword", "arguments", "whose", "name", "match", "this", "class", "attributes", "." ]
train
https://github.com/getfleety/coralillo/blob/9cac101738a0fa7c1106f129604c00ef703370e1/coralillo/core.py#L68-L110