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 |
|---|---|---|---|---|---|---|---|---|---|---|
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelModuleIndex.generate | def generate(self, docnames=None):
"""Returns entries for index given by ``name``. If ``docnames`` is given,
restrict to entries referring to these docnames.
Retunrs tuple of ``(content, collapse)``. ``collapse`` is bool. When
True, sub-entries should start collapsed for output formats ... | python | def generate(self, docnames=None):
"""Returns entries for index given by ``name``. If ``docnames`` is given,
restrict to entries referring to these docnames.
Retunrs tuple of ``(content, collapse)``. ``collapse`` is bool. When
True, sub-entries should start collapsed for output formats ... | [
"def",
"generate",
"(",
"self",
",",
"docnames",
"=",
"None",
")",
":",
"content",
"=",
"{",
"}",
"# list of prefixes to ignore",
"ignores",
"=",
"self",
".",
"domain",
".",
"env",
".",
"config",
"[",
"'chapeldomain_modindex_common_prefix'",
"]",
"ignores",
"=... | Returns entries for index given by ``name``. If ``docnames`` is given,
restrict to entries referring to these docnames.
Retunrs tuple of ``(content, collapse)``. ``collapse`` is bool. When
True, sub-entries should start collapsed for output formats that
support collapsing.
``co... | [
"Returns",
"entries",
"for",
"index",
"given",
"by",
"name",
".",
"If",
"docnames",
"is",
"given",
"restrict",
"to",
"entries",
"referring",
"to",
"these",
"docnames",
"."
] | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L637-L731 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain.clear_doc | def clear_doc(self, docname):
"""Remove the data associated with this instance of the domain."""
for fullname, (fn, x) in self.data['objects'].items():
if fn == docname:
del self.data['objects'][fullname]
for modname, (fn, x, x, x) in self.data['modules'].items():
... | python | def clear_doc(self, docname):
"""Remove the data associated with this instance of the domain."""
for fullname, (fn, x) in self.data['objects'].items():
if fn == docname:
del self.data['objects'][fullname]
for modname, (fn, x, x, x) in self.data['modules'].items():
... | [
"def",
"clear_doc",
"(",
"self",
",",
"docname",
")",
":",
"for",
"fullname",
",",
"(",
"fn",
",",
"x",
")",
"in",
"self",
".",
"data",
"[",
"'objects'",
"]",
".",
"items",
"(",
")",
":",
"if",
"fn",
"==",
"docname",
":",
"del",
"self",
".",
"d... | Remove the data associated with this instance of the domain. | [
"Remove",
"the",
"data",
"associated",
"with",
"this",
"instance",
"of",
"the",
"domain",
"."
] | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L808-L821 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain.find_obj | def find_obj(self, env, modname, classname, name, type_name, searchmode=0):
"""Find a Chapel object for "name", possibly with module or class/record
name. Returns a list of (name, object entry) tuples.
:arg int searchmode: If 1, search more specific names first. Otherwise,
search bu... | python | def find_obj(self, env, modname, classname, name, type_name, searchmode=0):
"""Find a Chapel object for "name", possibly with module or class/record
name. Returns a list of (name, object entry) tuples.
:arg int searchmode: If 1, search more specific names first. Otherwise,
search bu... | [
"def",
"find_obj",
"(",
"self",
",",
"env",
",",
"modname",
",",
"classname",
",",
"name",
",",
"type_name",
",",
"searchmode",
"=",
"0",
")",
":",
"if",
"name",
"[",
"-",
"2",
":",
"]",
"==",
"'()'",
":",
"name",
"=",
"name",
"[",
":",
"-",
"2... | Find a Chapel object for "name", possibly with module or class/record
name. Returns a list of (name, object entry) tuples.
:arg int searchmode: If 1, search more specific names first. Otherwise,
search built-ins first and then get more specific. | [
"Find",
"a",
"Chapel",
"object",
"for",
"name",
"possibly",
"with",
"module",
"or",
"class",
"/",
"record",
"name",
".",
"Returns",
"a",
"list",
"of",
"(",
"name",
"object",
"entry",
")",
"tuples",
"."
] | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L823-L880 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain.resolve_xref | def resolve_xref(self, env, fromdocname, builder,
type_name, target, node, contnode):
"""Resolve the pending_xref *node* with give *type_name* and *target*. Returns
None if xref node can not be resolved. If xref can be resolved, returns
new node containing the *contnode*.
... | python | def resolve_xref(self, env, fromdocname, builder,
type_name, target, node, contnode):
"""Resolve the pending_xref *node* with give *type_name* and *target*. Returns
None if xref node can not be resolved. If xref can be resolved, returns
new node containing the *contnode*.
... | [
"def",
"resolve_xref",
"(",
"self",
",",
"env",
",",
"fromdocname",
",",
"builder",
",",
"type_name",
",",
"target",
",",
"node",
",",
"contnode",
")",
":",
"# Special case the :chpl:chplref:`chplmodindex` instances.",
"if",
"type_name",
"==",
"'chplref'",
":",
"i... | Resolve the pending_xref *node* with give *type_name* and *target*. Returns
None if xref node can not be resolved. If xref can be resolved, returns
new node containing the *contnode*. | [
"Resolve",
"the",
"pending_xref",
"*",
"node",
"*",
"with",
"give",
"*",
"type_name",
"*",
"and",
"*",
"target",
"*",
".",
"Returns",
"None",
"if",
"xref",
"node",
"can",
"not",
"be",
"resolved",
".",
"If",
"xref",
"can",
"be",
"resolved",
"returns",
"... | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L882-L928 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain.resolve_any_xref | def resolve_any_xref(self, env, fromdocname, builder, target,
node, contnode):
"""Similar to :py:meth:`ChapelDomain.resolve_xref`, but applies to *any* or
similar role where type is not known. This returns a list of tuples
with ("domain:role", newnode).
"""
... | python | def resolve_any_xref(self, env, fromdocname, builder, target,
node, contnode):
"""Similar to :py:meth:`ChapelDomain.resolve_xref`, but applies to *any* or
similar role where type is not known. This returns a list of tuples
with ("domain:role", newnode).
"""
... | [
"def",
"resolve_any_xref",
"(",
"self",
",",
"env",
",",
"fromdocname",
",",
"builder",
",",
"target",
",",
"node",
",",
"contnode",
")",
":",
"modname",
"=",
"node",
".",
"get",
"(",
"'chpl:module'",
")",
"clsname",
"=",
"node",
".",
"get",
"(",
"'chp... | Similar to :py:meth:`ChapelDomain.resolve_xref`, but applies to *any* or
similar role where type is not known. This returns a list of tuples
with ("domain:role", newnode). | [
"Similar",
"to",
":",
"py",
":",
"meth",
":",
"ChapelDomain",
".",
"resolve_xref",
"but",
"applies",
"to",
"*",
"any",
"*",
"or",
"similar",
"role",
"where",
"type",
"is",
"not",
"known",
".",
"This",
"returns",
"a",
"list",
"of",
"tuples",
"with",
"("... | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L930-L953 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain._make_refnode | def _make_refnode(self, fromdocname, builder, docname, labelid, sectname,
contnode, **kwargs):
"""Return reference node for something like ``:chpl:chplref:``."""
nodeclass = kwargs.pop('nodeclass', nodes.reference)
newnode = nodeclass('', '', internal=True, **kwargs)
... | python | def _make_refnode(self, fromdocname, builder, docname, labelid, sectname,
contnode, **kwargs):
"""Return reference node for something like ``:chpl:chplref:``."""
nodeclass = kwargs.pop('nodeclass', nodes.reference)
newnode = nodeclass('', '', internal=True, **kwargs)
... | [
"def",
"_make_refnode",
"(",
"self",
",",
"fromdocname",
",",
"builder",
",",
"docname",
",",
"labelid",
",",
"sectname",
",",
"contnode",
",",
"*",
"*",
"kwargs",
")",
":",
"nodeclass",
"=",
"kwargs",
".",
"pop",
"(",
"'nodeclass'",
",",
"nodes",
".",
... | Return reference node for something like ``:chpl:chplref:``. | [
"Return",
"reference",
"node",
"for",
"something",
"like",
":",
"chpl",
":",
"chplref",
":",
"."
] | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L955-L973 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain._make_module_refnode | def _make_module_refnode(self, builder, fromdocname, name, contnode):
"""Helper function to generate new xref node based on
current environment.
"""
# Get additional info for modules.
docname, synopsis, platform, deprecated = self.data['modules'][name]
title = name
... | python | def _make_module_refnode(self, builder, fromdocname, name, contnode):
"""Helper function to generate new xref node based on
current environment.
"""
# Get additional info for modules.
docname, synopsis, platform, deprecated = self.data['modules'][name]
title = name
... | [
"def",
"_make_module_refnode",
"(",
"self",
",",
"builder",
",",
"fromdocname",
",",
"name",
",",
"contnode",
")",
":",
"# Get additional info for modules.",
"docname",
",",
"synopsis",
",",
"platform",
",",
"deprecated",
"=",
"self",
".",
"data",
"[",
"'modules... | Helper function to generate new xref node based on
current environment. | [
"Helper",
"function",
"to",
"generate",
"new",
"xref",
"node",
"based",
"on",
"current",
"environment",
"."
] | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L975-L989 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain.merge_domaindata | def merge_domaindata(self, docnames, otherdata):
"""Merge in data regarding *docnames* from a different domaindata inventory
(coming froma subprocess in a parallel build).
"""
for fullname, (fn, objtype) in otherdata['objects'].items():
if fn in docnames:
self... | python | def merge_domaindata(self, docnames, otherdata):
"""Merge in data regarding *docnames* from a different domaindata inventory
(coming froma subprocess in a parallel build).
"""
for fullname, (fn, objtype) in otherdata['objects'].items():
if fn in docnames:
self... | [
"def",
"merge_domaindata",
"(",
"self",
",",
"docnames",
",",
"otherdata",
")",
":",
"for",
"fullname",
",",
"(",
"fn",
",",
"objtype",
")",
"in",
"otherdata",
"[",
"'objects'",
"]",
".",
"items",
"(",
")",
":",
"if",
"fn",
"in",
"docnames",
":",
"se... | Merge in data regarding *docnames* from a different domaindata inventory
(coming froma subprocess in a parallel build). | [
"Merge",
"in",
"data",
"regarding",
"*",
"docnames",
"*",
"from",
"a",
"different",
"domaindata",
"inventory",
"(",
"coming",
"froma",
"subprocess",
"in",
"a",
"parallel",
"build",
")",
"."
] | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L991-L1006 |
chapel-lang/sphinxcontrib-chapeldomain | sphinxcontrib/chapeldomain.py | ChapelDomain.get_objects | def get_objects(self):
"""Return iterable of "object descriptions", which are tuple with these items:
* `name`
* `dispname`
* `type`
* `docname`
* `anchor`
* `priority`
For details on each item, see
:py:meth:`~sphinx.domains.Domain.get_objects`.
... | python | def get_objects(self):
"""Return iterable of "object descriptions", which are tuple with these items:
* `name`
* `dispname`
* `type`
* `docname`
* `anchor`
* `priority`
For details on each item, see
:py:meth:`~sphinx.domains.Domain.get_objects`.
... | [
"def",
"get_objects",
"(",
"self",
")",
":",
"for",
"modname",
",",
"info",
"in",
"self",
".",
"data",
"[",
"'modules'",
"]",
".",
"items",
"(",
")",
":",
"yield",
"(",
"modname",
",",
"modname",
",",
"'module'",
",",
"info",
"[",
"0",
"]",
",",
... | Return iterable of "object descriptions", which are tuple with these items:
* `name`
* `dispname`
* `type`
* `docname`
* `anchor`
* `priority`
For details on each item, see
:py:meth:`~sphinx.domains.Domain.get_objects`. | [
"Return",
"iterable",
"of",
"object",
"descriptions",
"which",
"are",
"tuple",
"with",
"these",
"items",
":"
] | train | https://github.com/chapel-lang/sphinxcontrib-chapeldomain/blob/00970fe1b3aed5deb1186bec19bf0912d2f92853/sphinxcontrib/chapeldomain.py#L1008-L1025 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | main | def main(argString=None):
"""The main function.
:param argString: the options.
:type argString: list of strings
These are the steps of the modules:
1. Prints the options.
2. Reads the population file (:py:func:`read_population_file`).
3. Reads the ``mds`` file (:py:func:`read_mds_file`).... | python | def main(argString=None):
"""The main function.
:param argString: the options.
:type argString: list of strings
These are the steps of the modules:
1. Prints the options.
2. Reads the population file (:py:func:`read_population_file`).
3. Reads the ``mds`` file (:py:func:`read_mds_file`).... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | The main function.
:param argString: the options.
:type argString: list of strings
These are the steps of the modules:
1. Prints the options.
2. Reads the population file (:py:func:`read_population_file`).
3. Reads the ``mds`` file (:py:func:`read_mds_file`).
4. Computes the three refere... | [
"The",
"main",
"function",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L34-L117 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | overwrite_tex | def overwrite_tex(tex_fn, nb_outliers, script_options):
"""Overwrites the TeX summary file with new values.
:param tex_fn: the name of the TeX summary file to overwrite.
:param nb_outliers: the number of outliers.
:param script_options: the script options.
:type tex_fn: str
:type nb_outliers: ... | python | def overwrite_tex(tex_fn, nb_outliers, script_options):
"""Overwrites the TeX summary file with new values.
:param tex_fn: the name of the TeX summary file to overwrite.
:param nb_outliers: the number of outliers.
:param script_options: the script options.
:type tex_fn: str
:type nb_outliers: ... | [
"def",
"overwrite_tex",
"(",
"tex_fn",
",",
"nb_outliers",
",",
"script_options",
")",
":",
"# Getting the content of the TeX file",
"content",
"=",
"None",
"with",
"open",
"(",
"tex_fn",
",",
"\"r\"",
")",
"as",
"i_file",
":",
"content",
"=",
"i_file",
".",
"... | Overwrites the TeX summary file with new values.
:param tex_fn: the name of the TeX summary file to overwrite.
:param nb_outliers: the number of outliers.
:param script_options: the script options.
:type tex_fn: str
:type nb_outliers: int
:type options: argparse.Namespace | [
"Overwrites",
"the",
"TeX",
"summary",
"file",
"with",
"new",
"values",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L120-L223 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | find_outliers | def find_outliers(mds, centers, center_info, ref_pop, options):
"""Finds the outliers for a given population.
:param mds: the ``mds`` information about each samples.
:param centers: the centers of the three reference population clusters.
:param center_info: the label of the three reference population c... | python | def find_outliers(mds, centers, center_info, ref_pop, options):
"""Finds the outliers for a given population.
:param mds: the ``mds`` information about each samples.
:param centers: the centers of the three reference population clusters.
:param center_info: the label of the three reference population c... | [
"def",
"find_outliers",
"(",
"mds",
",",
"centers",
",",
"center_info",
",",
"ref_pop",
",",
"options",
")",
":",
"# Importing matplotlib for plotting purposes",
"import",
"matplotlib",
"as",
"mpl",
"if",
"options",
".",
"format",
"!=",
"\"X11\"",
"and",
"mpl",
... | Finds the outliers for a given population.
:param mds: the ``mds`` information about each samples.
:param centers: the centers of the three reference population clusters.
:param center_info: the label of the three reference population clusters.
:param ref_pop: the reference population for which we need... | [
"Finds",
"the",
"outliers",
"for",
"a",
"given",
"population",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L226-L474 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | find_ref_centers | def find_ref_centers(mds):
"""Finds the center of the three reference clusters.
:param mds: the ``mds`` information about each samples.
:type mds: numpy.recarray
:returns: a tuple with a :py:class:`numpy.array` containing the centers of
the three reference population cluster as first el... | python | def find_ref_centers(mds):
"""Finds the center of the three reference clusters.
:param mds: the ``mds`` information about each samples.
:type mds: numpy.recarray
:returns: a tuple with a :py:class:`numpy.array` containing the centers of
the three reference population cluster as first el... | [
"def",
"find_ref_centers",
"(",
"mds",
")",
":",
"# Computing the centers of each of the reference clusters",
"ceu_mds",
"=",
"mds",
"[",
"mds",
"[",
"\"pop\"",
"]",
"==",
"\"CEU\"",
"]",
"yri_mds",
"=",
"mds",
"[",
"mds",
"[",
"\"pop\"",
"]",
"==",
"\"YRI\"",
... | Finds the center of the three reference clusters.
:param mds: the ``mds`` information about each samples.
:type mds: numpy.recarray
:returns: a tuple with a :py:class:`numpy.array` containing the centers of
the three reference population cluster as first element, and a
:py:cla... | [
"Finds",
"the",
"center",
"of",
"the",
"three",
"reference",
"clusters",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L477-L509 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | read_mds_file | def read_mds_file(file_name, c1, c2, pops):
"""Reads a MDS file.
:param file_name: the name of the ``mds`` file.
:param c1: the first component to read (x axis).
:param c2: the second component to read (y axis).
:param pops: the population of each sample.
:type file_name: str
:type c1: str... | python | def read_mds_file(file_name, c1, c2, pops):
"""Reads a MDS file.
:param file_name: the name of the ``mds`` file.
:param c1: the first component to read (x axis).
:param c2: the second component to read (y axis).
:param pops: the population of each sample.
:type file_name: str
:type c1: str... | [
"def",
"read_mds_file",
"(",
"file_name",
",",
"c1",
",",
"c2",
",",
"pops",
")",
":",
"mds",
"=",
"[",
"]",
"max_fid",
"=",
"0",
"max_iid",
"=",
"0",
"with",
"open",
"(",
"file_name",
",",
"'rb'",
")",
"as",
"input_file",
":",
"# Getting and checking ... | Reads a MDS file.
:param file_name: the name of the ``mds`` file.
:param c1: the first component to read (x axis).
:param c2: the second component to read (y axis).
:param pops: the population of each sample.
:type file_name: str
:type c1: str
:type c2: str
:type pops: dict
:retur... | [
"Reads",
"a",
"MDS",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L512-L574 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | read_population_file | def read_population_file(file_name):
"""Reads the population file.
:param file_name: the name of the population file.
:type file_name: str
:returns: a :py:class:`dict` containing the population for each of the
samples.
The population file should contain three columns:
1. The f... | python | def read_population_file(file_name):
"""Reads the population file.
:param file_name: the name of the population file.
:type file_name: str
:returns: a :py:class:`dict` containing the population for each of the
samples.
The population file should contain three columns:
1. The f... | [
"def",
"read_population_file",
"(",
"file_name",
")",
":",
"pops",
"=",
"{",
"}",
"required_pops",
"=",
"{",
"\"CEU\"",
",",
"\"YRI\"",
",",
"\"JPT-CHB\"",
",",
"\"SOURCE\"",
"}",
"with",
"open",
"(",
"file_name",
",",
"'rb'",
")",
"as",
"input_file",
":",... | Reads the population file.
:param file_name: the name of the population file.
:type file_name: str
:returns: a :py:class:`dict` containing the population for each of the
samples.
The population file should contain three columns:
1. The family ID.
2. The individual ID.
3. T... | [
"Reads",
"the",
"population",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L577-L617 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is rai... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is rai... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Checking the input files",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"args",
".",
"mds",
")",
":",
"msg",
"=",
"\"{}: no such file\"",
".",
"format",
"(",
"args",
".",
"mds",
")",
"raise",
"ProgramE... | Checks the arguments and options.
:param args: a :py:class:`argparse.Namespace` object containing the options
of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L620-L649 |
lemieuxl/pyGenClean | pyGenClean/Ethnicity/find_outliers.py | add_custom_options | def add_custom_options(parser):
"""Adds custom options to a parser.
:param parser: the parser to which to add options.
:type parser: argparse.ArgumentParser
"""
parser.add_argument("--outliers-of", type=str, metavar="POP",
default="CEU", choices=["CEU", "YRI", "JPT-CHB"],
... | python | def add_custom_options(parser):
"""Adds custom options to a parser.
:param parser: the parser to which to add options.
:type parser: argparse.ArgumentParser
"""
parser.add_argument("--outliers-of", type=str, metavar="POP",
default="CEU", choices=["CEU", "YRI", "JPT-CHB"],
... | [
"def",
"add_custom_options",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"\"--outliers-of\"",
",",
"type",
"=",
"str",
",",
"metavar",
"=",
"\"POP\"",
",",
"default",
"=",
"\"CEU\"",
",",
"choices",
"=",
"[",
"\"CEU\"",
",",
"\"YRI\"",
","... | Adds custom options to a parser.
:param parser: the parser to which to add options.
:type parser: argparse.ArgumentParser | [
"Adds",
"custom",
"options",
"to",
"a",
"parser",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/Ethnicity/find_outliers.py#L696-L720 |
titusz/epubcheck | src/epubcheck/models.py | Message.from_data | def from_data(cls, data):
"""Create a list of Messages from deserialized epubcheck json output.
:param dict data: Decoded epubcheck json data
:return list[Message]: List of messages
"""
messages = []
filename = data['checker']['filename']
for m in data['messages'... | python | def from_data(cls, data):
"""Create a list of Messages from deserialized epubcheck json output.
:param dict data: Decoded epubcheck json data
:return list[Message]: List of messages
"""
messages = []
filename = data['checker']['filename']
for m in data['messages'... | [
"def",
"from_data",
"(",
"cls",
",",
"data",
")",
":",
"messages",
"=",
"[",
"]",
"filename",
"=",
"data",
"[",
"'checker'",
"]",
"[",
"'filename'",
"]",
"for",
"m",
"in",
"data",
"[",
"'messages'",
"]",
":",
"for",
"l",
"in",
"m",
"[",
"'locations... | Create a list of Messages from deserialized epubcheck json output.
:param dict data: Decoded epubcheck json data
:return list[Message]: List of messages | [
"Create",
"a",
"list",
"of",
"Messages",
"from",
"deserialized",
"epubcheck",
"json",
"output",
"."
] | train | https://github.com/titusz/epubcheck/blob/7adde81543d3ae7385ab7062adb76e1414d49c2e/src/epubcheck/models.py#L95-L115 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/ArgSetter.py | ArgSetter.show | def show(self):
"""
if the dialog is showed again or is not started with exec_
naming the done button to 'update' make more sense
because now the dialog doesn't block (anymore)
"""
self.btn_done.clicked.connect(lambda: self.btn_done.setText('update'))
QtWid... | python | def show(self):
"""
if the dialog is showed again or is not started with exec_
naming the done button to 'update' make more sense
because now the dialog doesn't block (anymore)
"""
self.btn_done.clicked.connect(lambda: self.btn_done.setText('update'))
QtWid... | [
"def",
"show",
"(",
"self",
")",
":",
"self",
".",
"btn_done",
".",
"clicked",
".",
"connect",
"(",
"lambda",
":",
"self",
".",
"btn_done",
".",
"setText",
"(",
"'update'",
")",
")",
"QtWidgets",
".",
"QDialog",
".",
"show",
"(",
"self",
")"
] | if the dialog is showed again or is not started with exec_
naming the done button to 'update' make more sense
because now the dialog doesn't block (anymore) | [
"if",
"the",
"dialog",
"is",
"showed",
"again",
"or",
"is",
"not",
"started",
"with",
"exec_",
"naming",
"the",
"done",
"button",
"to",
"update",
"make",
"more",
"sense",
"because",
"now",
"the",
"dialog",
"doesn",
"t",
"block",
"(",
"anymore",
")"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/ArgSetter.py#L221-L228 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/ArgSetter.py | ArgSetter.check | def check(self):
"""check whether all attributes are setted and have the right dtype"""
for name, valItem, dtype in self.values:
val = valItem.text()
if dtype:
try:
val = dtype(val)
except:
msgBox = Q... | python | def check(self):
"""check whether all attributes are setted and have the right dtype"""
for name, valItem, dtype in self.values:
val = valItem.text()
if dtype:
try:
val = dtype(val)
except:
msgBox = Q... | [
"def",
"check",
"(",
"self",
")",
":",
"for",
"name",
",",
"valItem",
",",
"dtype",
"in",
"self",
".",
"values",
":",
"val",
"=",
"valItem",
".",
"text",
"(",
")",
"if",
"dtype",
":",
"try",
":",
"val",
"=",
"dtype",
"(",
"val",
")",
"except",
... | check whether all attributes are setted and have the right dtype | [
"check",
"whether",
"all",
"attributes",
"are",
"setted",
"and",
"have",
"the",
"right",
"dtype"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/ArgSetter.py#L243-L257 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/ArgSetter.py | ArgSetter.done | def done(self, result):
"""save the geometry before dialog is close to restore it later"""
self._geometry = self.geometry()
QtWidgets.QDialog.done(self, result) | python | def done(self, result):
"""save the geometry before dialog is close to restore it later"""
self._geometry = self.geometry()
QtWidgets.QDialog.done(self, result) | [
"def",
"done",
"(",
"self",
",",
"result",
")",
":",
"self",
".",
"_geometry",
"=",
"self",
".",
"geometry",
"(",
")",
"QtWidgets",
".",
"QDialog",
".",
"done",
"(",
"self",
",",
"result",
")"
] | save the geometry before dialog is close to restore it later | [
"save",
"the",
"geometry",
"before",
"dialog",
"is",
"close",
"to",
"restore",
"it",
"later"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/ArgSetter.py#L263-L266 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/ArgSetter.py | ArgSetter.stayOpen | def stayOpen(self):
"""optional dialog restore"""
if not self._wantToClose:
self.show()
self.setGeometry(self._geometry) | python | def stayOpen(self):
"""optional dialog restore"""
if not self._wantToClose:
self.show()
self.setGeometry(self._geometry) | [
"def",
"stayOpen",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_wantToClose",
":",
"self",
".",
"show",
"(",
")",
"self",
".",
"setGeometry",
"(",
"self",
".",
"_geometry",
")"
] | optional dialog restore | [
"optional",
"dialog",
"restore"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/ArgSetter.py#L268-L272 |
coins13/twins | twins/ics.py | get_start_date | def get_start_date(module, x):
""" 曜日による最初の授業の日を返す """
weekdays = ['月', '火', '水', '木', '金', '土', '日']
a, b = parse_module(module)
module = a + b[0]
d = datetime.datetime(*start_dates[module])
days = weekdays.index(x) - d.weekday()
if days < 0:
days += 7
delta = datetime.timedelt... | python | def get_start_date(module, x):
""" 曜日による最初の授業の日を返す """
weekdays = ['月', '火', '水', '木', '金', '土', '日']
a, b = parse_module(module)
module = a + b[0]
d = datetime.datetime(*start_dates[module])
days = weekdays.index(x) - d.weekday()
if days < 0:
days += 7
delta = datetime.timedelt... | [
"def",
"get_start_date",
"(",
"module",
",",
"x",
")",
":",
"weekdays",
"=",
"[",
"'月', ",
"'",
"', '水",
"'",
" '木',",
" ",
"金', '",
"土",
", '日'",
"]",
"",
"",
"",
"",
"a",
",",
"b",
"=",
"parse_module",
"(",
"module",
")",
"module",
"=",
"a",
... | 曜日による最初の授業の日を返す | [
"曜日による最初の授業の日を返す"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/ics.py#L67-L78 |
coins13/twins | twins/ics.py | get_end_date | def get_end_date(module):
""" モジュールの終わりの日を返す """
a, b = parse_module(module)
module = a + b[-1]
return datetime.datetime(*end_dates[module]) | python | def get_end_date(module):
""" モジュールの終わりの日を返す """
a, b = parse_module(module)
module = a + b[-1]
return datetime.datetime(*end_dates[module]) | [
"def",
"get_end_date",
"(",
"module",
")",
":",
"a",
",",
"b",
"=",
"parse_module",
"(",
"module",
")",
"module",
"=",
"a",
"+",
"b",
"[",
"-",
"1",
"]",
"return",
"datetime",
".",
"datetime",
"(",
"*",
"end_dates",
"[",
"module",
"]",
")"
] | モジュールの終わりの日を返す | [
"モジュールの終わりの日を返す"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/ics.py#L81-L85 |
coins13/twins | twins/ics.py | parse_stupid_date | def parse_stupid_date(c):
"""
kdbが返してくる間抜けな授業時間をパースしてdatetimeを返す
例:
月1
木3,4
水3,4金5,6
月・火・水3-6
sqlite3 ~/.course_list.db 'select periods from courses'|sort|uniq
"""
start_time = {
1: { "hour": 8, "minute": 40 },
2: { "hour": 10, "minute": 10 ... | python | def parse_stupid_date(c):
"""
kdbが返してくる間抜けな授業時間をパースしてdatetimeを返す
例:
月1
木3,4
水3,4金5,6
月・火・水3-6
sqlite3 ~/.course_list.db 'select periods from courses'|sort|uniq
"""
start_time = {
1: { "hour": 8, "minute": 40 },
2: { "hour": 10, "minute": 10 ... | [
"def",
"parse_stupid_date",
"(",
"c",
")",
":",
"start_time",
"=",
"{",
"1",
":",
"{",
"\"hour\"",
":",
"8",
",",
"\"minute\"",
":",
"40",
"}",
",",
"2",
":",
"{",
"\"hour\"",
":",
"10",
",",
"\"minute\"",
":",
"10",
"}",
",",
"3",
":",
"{",
"\... | kdbが返してくる間抜けな授業時間をパースしてdatetimeを返す
例:
月1
木3,4
水3,4金5,6
月・火・水3-6
sqlite3 ~/.course_list.db 'select periods from courses'|sort|uniq | [
"kdbが返してくる間抜けな授業時間をパースしてdatetimeを返す"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/ics.py#L88-L151 |
coins13/twins | twins/ics.py | generate_ics | def generate_ics(courses):
""".ics作るやつ"""
events = ""
for c in courses:
created = strftime(datetime.datetime.utcnow()) + "Z"
summary = c["title"]
location = c["room"]
description = "{id}・{modules}・{credit}単位".format(**c)
try:
dates = parse_stupid_date(c)
... | python | def generate_ics(courses):
""".ics作るやつ"""
events = ""
for c in courses:
created = strftime(datetime.datetime.utcnow()) + "Z"
summary = c["title"]
location = c["room"]
description = "{id}・{modules}・{credit}単位".format(**c)
try:
dates = parse_stupid_date(c)
... | [
"def",
"generate_ics",
"(",
"courses",
")",
":",
"events",
"=",
"\"\"",
"for",
"c",
"in",
"courses",
":",
"created",
"=",
"strftime",
"(",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
")",
"+",
"\"Z\"",
"summary",
"=",
"c",
"[",
"\"title\"",
... | .ics作るやつ | [
".",
"ics作るやつ"
] | train | https://github.com/coins13/twins/blob/d66cc850007a25f01812a9d8c7e3efe64a631ca2/twins/ics.py#L153-L179 |
photo/openphoto-python | trovebox/http.py | Http.configure | def configure(self, **kwds):
"""
Update Trovebox HTTP client configuration.
:param api_version: Include a Trovebox API version in all requests.
This can be used to ensure that your application will continue
to work even if the Trovebox API is updated to a new revision.
... | python | def configure(self, **kwds):
"""
Update Trovebox HTTP client configuration.
:param api_version: Include a Trovebox API version in all requests.
This can be used to ensure that your application will continue
to work even if the Trovebox API is updated to a new revision.
... | [
"def",
"configure",
"(",
"self",
",",
"*",
"*",
"kwds",
")",
":",
"for",
"item",
"in",
"kwds",
":",
"self",
".",
"config",
"[",
"item",
"]",
"=",
"kwds",
"[",
"item",
"]"
] | Update Trovebox HTTP client configuration.
:param api_version: Include a Trovebox API version in all requests.
This can be used to ensure that your application will continue
to work even if the Trovebox API is updated to a new revision.
[default: None]
:param ssl_ver... | [
"Update",
"Trovebox",
"HTTP",
"client",
"configuration",
"."
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/http.py#L64-L76 |
photo/openphoto-python | trovebox/http.py | Http.get | def get(self, endpoint, process_response=True, **params):
"""
Performs an HTTP GET from the specified endpoint (API path),
passing parameters if given.
The api_version is prepended to the endpoint,
if it was specified when the Trovebox object was created.
Returns... | python | def get(self, endpoint, process_response=True, **params):
"""
Performs an HTTP GET from the specified endpoint (API path),
passing parameters if given.
The api_version is prepended to the endpoint,
if it was specified when the Trovebox object was created.
Returns... | [
"def",
"get",
"(",
"self",
",",
"endpoint",
",",
"process_response",
"=",
"True",
",",
"*",
"*",
"params",
")",
":",
"params",
"=",
"self",
".",
"_process_params",
"(",
"params",
")",
"url",
"=",
"self",
".",
"_construct_url",
"(",
"endpoint",
")",
"if... | Performs an HTTP GET from the specified endpoint (API path),
passing parameters if given.
The api_version is prepended to the endpoint,
if it was specified when the Trovebox object was created.
Returns the decoded JSON dictionary, and raises exceptions if an
error co... | [
"Performs",
"an",
"HTTP",
"GET",
"from",
"the",
"specified",
"endpoint",
"(",
"API",
"path",
")",
"passing",
"parameters",
"if",
"given",
".",
"The",
"api_version",
"is",
"prepended",
"to",
"the",
"endpoint",
"if",
"it",
"was",
"specified",
"when",
"the",
... | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/http.py#L78-L122 |
photo/openphoto-python | trovebox/http.py | Http._construct_url | def _construct_url(self, endpoint):
"""Return the full URL to the specified endpoint"""
parsed_url = urlparse(self.host)
scheme = parsed_url[0]
host = parsed_url[1]
# Handle host without a scheme specified (eg. www.example.com)
if scheme == "":
scheme = "http"... | python | def _construct_url(self, endpoint):
"""Return the full URL to the specified endpoint"""
parsed_url = urlparse(self.host)
scheme = parsed_url[0]
host = parsed_url[1]
# Handle host without a scheme specified (eg. www.example.com)
if scheme == "":
scheme = "http"... | [
"def",
"_construct_url",
"(",
"self",
",",
"endpoint",
")",
":",
"parsed_url",
"=",
"urlparse",
"(",
"self",
".",
"host",
")",
"scheme",
"=",
"parsed_url",
"[",
"0",
"]",
"host",
"=",
"parsed_url",
"[",
"1",
"]",
"# Handle host without a scheme specified (eg. ... | Return the full URL to the specified endpoint | [
"Return",
"the",
"full",
"URL",
"to",
"the",
"specified",
"endpoint"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/http.py#L180-L194 |
photo/openphoto-python | trovebox/http.py | Http._process_params | def _process_params(self, params):
""" Converts Unicode/lists/booleans inside HTTP parameters """
processed_params = {}
for key, value in params.items():
processed_params[key] = self._process_param_value(value)
return processed_params | python | def _process_params(self, params):
""" Converts Unicode/lists/booleans inside HTTP parameters """
processed_params = {}
for key, value in params.items():
processed_params[key] = self._process_param_value(value)
return processed_params | [
"def",
"_process_params",
"(",
"self",
",",
"params",
")",
":",
"processed_params",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"params",
".",
"items",
"(",
")",
":",
"processed_params",
"[",
"key",
"]",
"=",
"self",
".",
"_process_param_value",
"("... | Converts Unicode/lists/booleans inside HTTP parameters | [
"Converts",
"Unicode",
"/",
"lists",
"/",
"booleans",
"inside",
"HTTP",
"parameters"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/http.py#L196-L202 |
photo/openphoto-python | trovebox/http.py | Http._process_param_value | def _process_param_value(self, value):
"""
Returns a UTF-8 string representation of the parameter value,
recursing into lists.
"""
# Extract IDs from objects
if isinstance(value, TroveboxObject):
return str(value.id).encode('utf-8')
# Ensure strings a... | python | def _process_param_value(self, value):
"""
Returns a UTF-8 string representation of the parameter value,
recursing into lists.
"""
# Extract IDs from objects
if isinstance(value, TroveboxObject):
return str(value.id).encode('utf-8')
# Ensure strings a... | [
"def",
"_process_param_value",
"(",
"self",
",",
"value",
")",
":",
"# Extract IDs from objects",
"if",
"isinstance",
"(",
"value",
",",
"TroveboxObject",
")",
":",
"return",
"str",
"(",
"value",
".",
"id",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"# Ensure ... | Returns a UTF-8 string representation of the parameter value,
recursing into lists. | [
"Returns",
"a",
"UTF",
"-",
"8",
"string",
"representation",
"of",
"the",
"parameter",
"value",
"recursing",
"into",
"lists",
"."
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/http.py#L204-L233 |
photo/openphoto-python | trovebox/http.py | Http._process_response | def _process_response(response):
"""
Decodes the JSON response, returning a dict.
Raises an exception if an invalid response code is received.
"""
if response.status_code == 404:
raise Trovebox404Error("HTTP Error %d: %s" %
(response... | python | def _process_response(response):
"""
Decodes the JSON response, returning a dict.
Raises an exception if an invalid response code is received.
"""
if response.status_code == 404:
raise Trovebox404Error("HTTP Error %d: %s" %
(response... | [
"def",
"_process_response",
"(",
"response",
")",
":",
"if",
"response",
".",
"status_code",
"==",
"404",
":",
"raise",
"Trovebox404Error",
"(",
"\"HTTP Error %d: %s\"",
"%",
"(",
"response",
".",
"status_code",
",",
"response",
".",
"reason",
")",
")",
"try",... | Decodes the JSON response, returning a dict.
Raises an exception if an invalid response code is received. | [
"Decodes",
"the",
"JSON",
"response",
"returning",
"a",
"dict",
".",
"Raises",
"an",
"exception",
"if",
"an",
"invalid",
"response",
"code",
"is",
"received",
"."
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/http.py#L236-L263 |
photo/openphoto-python | trovebox/objects/activity.py | Activity._update_fields_with_objects | def _update_fields_with_objects(self):
""" Convert dict fields into objects, where appropriate """
# Update the data with photo objects
if self.type is not None:
if self.type.startswith("photo"):
self.data = Photo(self._client, self.data)
else:
... | python | def _update_fields_with_objects(self):
""" Convert dict fields into objects, where appropriate """
# Update the data with photo objects
if self.type is not None:
if self.type.startswith("photo"):
self.data = Photo(self._client, self.data)
else:
... | [
"def",
"_update_fields_with_objects",
"(",
"self",
")",
":",
"# Update the data with photo objects",
"if",
"self",
".",
"type",
"is",
"not",
"None",
":",
"if",
"self",
".",
"type",
".",
"startswith",
"(",
"\"photo\"",
")",
":",
"self",
".",
"data",
"=",
"Pho... | Convert dict fields into objects, where appropriate | [
"Convert",
"dict",
"fields",
"into",
"objects",
"where",
"appropriate"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/objects/activity.py#L17-L25 |
erikdejonge/pyprofiler | main_profile.py | get_print_list | def get_print_list():
"""
get_print_list
"""
profiler = start_profile()
meth1()
meth2()
meth3()
meth4()
return end_profile(profiler, returnvalue=True) | python | def get_print_list():
"""
get_print_list
"""
profiler = start_profile()
meth1()
meth2()
meth3()
meth4()
return end_profile(profiler, returnvalue=True) | [
"def",
"get_print_list",
"(",
")",
":",
"profiler",
"=",
"start_profile",
"(",
")",
"meth1",
"(",
")",
"meth2",
"(",
")",
"meth3",
"(",
")",
"meth4",
"(",
")",
"return",
"end_profile",
"(",
"profiler",
",",
"returnvalue",
"=",
"True",
")"
] | get_print_list | [
"get_print_list"
] | train | https://github.com/erikdejonge/pyprofiler/blob/e32dfcfeb5f1340d4274e7a683c1c5b414595c0e/main_profile.py#L85-L94 |
erikdejonge/pyprofiler | main_profile.py | main | def main():
"""
main
"""
profiler = start_profile()
meth1()
meth2()
meth3()
meth4()
aggregate()
end_profile(profiler)
runsnake_profile_method("aggregate", globals(), locals()) | python | def main():
"""
main
"""
profiler = start_profile()
meth1()
meth2()
meth3()
meth4()
aggregate()
end_profile(profiler)
runsnake_profile_method("aggregate", globals(), locals()) | [
"def",
"main",
"(",
")",
":",
"profiler",
"=",
"start_profile",
"(",
")",
"meth1",
"(",
")",
"meth2",
"(",
")",
"meth3",
"(",
")",
"meth4",
"(",
")",
"aggregate",
"(",
")",
"end_profile",
"(",
"profiler",
")",
"runsnake_profile_method",
"(",
"\"aggregate... | main | [
"main"
] | train | https://github.com/erikdejonge/pyprofiler/blob/e32dfcfeb5f1340d4274e7a683c1c5b414595c0e/main_profile.py#L97-L108 |
vinitkumar/pycrawler | webcrawler.py | Webcrawler.crawl | def crawl(self):
"""crawl function to return list of crawled urls."""
page = Linkfetcher(self.root)
page.linkfetch()
queue = Queue()
for url in page.urls:
queue.put(url)
followed = [self.root]
n = 0
while True:
try:
... | python | def crawl(self):
"""crawl function to return list of crawled urls."""
page = Linkfetcher(self.root)
page.linkfetch()
queue = Queue()
for url in page.urls:
queue.put(url)
followed = [self.root]
n = 0
while True:
try:
... | [
"def",
"crawl",
"(",
"self",
")",
":",
"page",
"=",
"Linkfetcher",
"(",
"self",
".",
"root",
")",
"page",
".",
"linkfetch",
"(",
")",
"queue",
"=",
"Queue",
"(",
")",
"for",
"url",
"in",
"page",
".",
"urls",
":",
"queue",
".",
"put",
"(",
"url",
... | crawl function to return list of crawled urls. | [
"crawl",
"function",
"to",
"return",
"list",
"of",
"crawled",
"urls",
"."
] | train | https://github.com/vinitkumar/pycrawler/blob/d3fe6d2da1469fc701c4fe04df88cee9cc8cd9c3/webcrawler.py#L23-L62 |
Kromey/django-simplecaptcha | simplecaptcha/widgets.py | CaptchaWidget.render | def render(self, name, value, attrs=None):
"""Override the render() method to replace value with our current values
This approach is based on the approach that Django's PasswordInput
widget uses to ensure that passwords are not re-rendered in forms,
except instead of prohibiting initial... | python | def render(self, name, value, attrs=None):
"""Override the render() method to replace value with our current values
This approach is based on the approach that Django's PasswordInput
widget uses to ensure that passwords are not re-rendered in forms,
except instead of prohibiting initial... | [
"def",
"render",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"_values",
"return",
"super",
"(",
")",
".",
"render",
"(",
"name",
",",
"value",
",",
"attrs",
")"
] | Override the render() method to replace value with our current values
This approach is based on the approach that Django's PasswordInput
widget uses to ensure that passwords are not re-rendered in forms,
except instead of prohibiting initial values we set them to those for
our generated... | [
"Override",
"the",
"render",
"()",
"method",
"to",
"replace",
"value",
"with",
"our",
"current",
"values"
] | train | https://github.com/Kromey/django-simplecaptcha/blob/16dd401e3317daf78143e9250f98b48c22cabd2d/simplecaptcha/widgets.py#L40-L49 |
Kromey/django-simplecaptcha | simplecaptcha/widgets.py | CaptchaWidget.generate_captcha | def generate_captcha(self):
"""Generated a fresh captcha
This method randomly generates a simple captcha question. It then
generates a timestamp for the current time, and signs the answer
cryptographically to protect against tampering and replay attacks.
"""
# Generate a... | python | def generate_captcha(self):
"""Generated a fresh captcha
This method randomly generates a simple captcha question. It then
generates a timestamp for the current time, and signs the answer
cryptographically to protect against tampering and replay attacks.
"""
# Generate a... | [
"def",
"generate_captcha",
"(",
"self",
")",
":",
"# Generate a fresh question",
"self",
".",
"_question",
",",
"answer",
"=",
"self",
".",
"_generate_question",
"(",
")",
"# Get the current time, then sign the answer cryptographically",
"timestamp",
"=",
"time",
".",
"... | Generated a fresh captcha
This method randomly generates a simple captcha question. It then
generates a timestamp for the current time, and signs the answer
cryptographically to protect against tampering and replay attacks. | [
"Generated",
"a",
"fresh",
"captcha"
] | train | https://github.com/Kromey/django-simplecaptcha/blob/16dd401e3317daf78143e9250f98b48c22cabd2d/simplecaptcha/widgets.py#L51-L66 |
Kromey/django-simplecaptcha | simplecaptcha/widgets.py | CaptchaWidget._generate_question | def _generate_question(self):
"""Generate a random arithmetic question
This method randomly generates a simple addition, subtraction, or
multiplication question with two integers between 1 and 10, and then
returns both question (formatted as a string) and answer.
"""
x =... | python | def _generate_question(self):
"""Generate a random arithmetic question
This method randomly generates a simple addition, subtraction, or
multiplication question with two integers between 1 and 10, and then
returns both question (formatted as a string) and answer.
"""
x =... | [
"def",
"_generate_question",
"(",
"self",
")",
":",
"x",
"=",
"random",
".",
"randint",
"(",
"1",
",",
"10",
")",
"y",
"=",
"random",
".",
"randint",
"(",
"1",
",",
"10",
")",
"operator",
"=",
"random",
".",
"choice",
"(",
"(",
"'+'",
",",
"'-'",... | Generate a random arithmetic question
This method randomly generates a simple addition, subtraction, or
multiplication question with two integers between 1 and 10, and then
returns both question (formatted as a string) and answer. | [
"Generate",
"a",
"random",
"arithmetic",
"question"
] | train | https://github.com/Kromey/django-simplecaptcha/blob/16dd401e3317daf78143e9250f98b48c22cabd2d/simplecaptcha/widgets.py#L68-L97 |
Kromey/django-simplecaptcha | simplecaptcha/widgets.py | CaptchaWidget.hash_answer | def hash_answer(self, answer, timestamp):
"""Cryptographically hash the answer with the provided timestamp
This method allows the widget to securely generate time-sensitive
signatures that will both prevent tampering with the answer as well as
provide some protection against replay atta... | python | def hash_answer(self, answer, timestamp):
"""Cryptographically hash the answer with the provided timestamp
This method allows the widget to securely generate time-sensitive
signatures that will both prevent tampering with the answer as well as
provide some protection against replay atta... | [
"def",
"hash_answer",
"(",
"self",
",",
"answer",
",",
"timestamp",
")",
":",
"# Ensure our values are string before we start hashing",
"timestamp",
"=",
"str",
"(",
"timestamp",
")",
"answer",
"=",
"str",
"(",
"answer",
")",
"hashed",
"=",
"''",
"# Hashing multip... | Cryptographically hash the answer with the provided timestamp
This method allows the widget to securely generate time-sensitive
signatures that will both prevent tampering with the answer as well as
provide some protection against replay attacks by limiting how long a
given signature is... | [
"Cryptographically",
"hash",
"the",
"answer",
"with",
"the",
"provided",
"timestamp"
] | train | https://github.com/Kromey/django-simplecaptcha/blob/16dd401e3317daf78143e9250f98b48c22cabd2d/simplecaptcha/widgets.py#L99-L119 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/baf_lrr_plot.py | main | def main(argString=None):
"""The main function of this module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Reads the problematic samples (:py:func:`read_problematic_samples`).
3. Finds and checks the raw files for each of the proble... | python | def main(argString=None):
"""The main function of this module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Reads the problematic samples (:py:func:`read_problematic_samples`).
3. Finds and checks the raw files for each of the proble... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"# Reading the problematic samples",
"samples",
"=",
"read_problematic_samples",
"(",
"args",
... | The main function of this module.
:param argString: the options.
:type argString: list
These are the steps:
1. Prints the options.
2. Reads the problematic samples (:py:func:`read_problematic_samples`).
3. Finds and checks the raw files for each of the problematic samples
(:py:func:`c... | [
"The",
"main",
"function",
"of",
"this",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/baf_lrr_plot.py#L32-L59 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/baf_lrr_plot.py | check_file_names | def check_file_names(samples, raw_dir, options):
"""Check if all files are present.
:param samples: a list of tuples with the family ID as first element (str)
and sample ID as last element (str).
:param raw_dir: the directory containing the raw files.
:param options: the options.
... | python | def check_file_names(samples, raw_dir, options):
"""Check if all files are present.
:param samples: a list of tuples with the family ID as first element (str)
and sample ID as last element (str).
:param raw_dir: the directory containing the raw files.
:param options: the options.
... | [
"def",
"check_file_names",
"(",
"samples",
",",
"raw_dir",
",",
"options",
")",
":",
"file_names",
"=",
"{",
"}",
"for",
"sample",
"in",
"samples",
":",
"the_sample",
"=",
"None",
"try",
":",
"the_sample",
"=",
"sample",
"[",
"1",
"]",
"except",
"IndexEr... | Check if all files are present.
:param samples: a list of tuples with the family ID as first element (str)
and sample ID as last element (str).
:param raw_dir: the directory containing the raw files.
:param options: the options.
:type samples: list of tuples
:type raw_dir: str
... | [
"Check",
"if",
"all",
"files",
"are",
"present",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/baf_lrr_plot.py#L62-L99 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/baf_lrr_plot.py | read_problematic_samples | def read_problematic_samples(file_name):
"""Reads a file with sample IDs.
:param file_name: the name of the file containing problematic samples after
sex check.
:type file_name: str
:returns: a set of problematic samples (tuple containing the family ID as
first ele... | python | def read_problematic_samples(file_name):
"""Reads a file with sample IDs.
:param file_name: the name of the file containing problematic samples after
sex check.
:type file_name: str
:returns: a set of problematic samples (tuple containing the family ID as
first ele... | [
"def",
"read_problematic_samples",
"(",
"file_name",
")",
":",
"problematic_samples",
"=",
"set",
"(",
")",
"open_func",
"=",
"open",
"if",
"file_name",
".",
"endswith",
"(",
"\".gz\"",
")",
":",
"open_func",
"=",
"gzip",
".",
"open",
"with",
"open_func",
"(... | Reads a file with sample IDs.
:param file_name: the name of the file containing problematic samples after
sex check.
:type file_name: str
:returns: a set of problematic samples (tuple containing the family ID as
first element and the sample ID as last element).
Re... | [
"Reads",
"a",
"file",
"with",
"sample",
"IDs",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/baf_lrr_plot.py#L102-L128 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/baf_lrr_plot.py | plot_baf_lrr | def plot_baf_lrr(file_names, options):
"""Plot BAF and LRR for a list of files.
:param file_names: contains the name of the input file for each sample.
:param options: the options.
:type file_names: dict
:type options: argparse.Namespace
Plots the BAF (B Allele Frequency) and LRR (Log R Ratio... | python | def plot_baf_lrr(file_names, options):
"""Plot BAF and LRR for a list of files.
:param file_names: contains the name of the input file for each sample.
:param options: the options.
:type file_names: dict
:type options: argparse.Namespace
Plots the BAF (B Allele Frequency) and LRR (Log R Ratio... | [
"def",
"plot_baf_lrr",
"(",
"file_names",
",",
"options",
")",
":",
"# importing important stuff",
"import",
"matplotlib",
"as",
"mpl",
"if",
"options",
".",
"format",
"!=",
"\"X11\"",
"and",
"mpl",
".",
"get_backend",
"(",
")",
"!=",
"\"agg\"",
":",
"mpl",
... | Plot BAF and LRR for a list of files.
:param file_names: contains the name of the input file for each sample.
:param options: the options.
:type file_names: dict
:type options: argparse.Namespace
Plots the BAF (B Allele Frequency) and LRR (Log R Ratio) of each samples.
Only the sexual chromos... | [
"Plot",
"BAF",
"and",
"LRR",
"for",
"a",
"list",
"of",
"files",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/baf_lrr_plot.py#L167-L306 |
lemieuxl/pyGenClean | pyGenClean/SexCheck/baf_lrr_plot.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Checking the input file",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"args",
".",
"problematic_samples",
")",
":",
"msg",
"=",
"\"{}: no such file\"",
".",
"format",
"(",
"args",
".",
"problematic_samples"... | Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to t... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/SexCheck/baf_lrr_plot.py#L309-L338 |
gasparka/pyhacores | pyhacores/cordic/to_polar.py | chirp_stimul | def chirp_stimul():
""" Amplitude modulated chirp signal """
from scipy.signal import chirp, hilbert
duration = 1.0
fs = 256
samples = int(fs * duration)
t = np.arange(samples) / fs
signal = chirp(t, 20.0, t[-1], 100.0)
signal *= (1.0 + 0.5 * np.sin(2.0 * np.pi * 3.0 * t))
analytic_s... | python | def chirp_stimul():
""" Amplitude modulated chirp signal """
from scipy.signal import chirp, hilbert
duration = 1.0
fs = 256
samples = int(fs * duration)
t = np.arange(samples) / fs
signal = chirp(t, 20.0, t[-1], 100.0)
signal *= (1.0 + 0.5 * np.sin(2.0 * np.pi * 3.0 * t))
analytic_s... | [
"def",
"chirp_stimul",
"(",
")",
":",
"from",
"scipy",
".",
"signal",
"import",
"chirp",
",",
"hilbert",
"duration",
"=",
"1.0",
"fs",
"=",
"256",
"samples",
"=",
"int",
"(",
"fs",
"*",
"duration",
")",
"t",
"=",
"np",
".",
"arange",
"(",
"samples",
... | Amplitude modulated chirp signal | [
"Amplitude",
"modulated",
"chirp",
"signal"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/cordic/to_polar.py#L117-L129 |
gasparka/pyhacores | pyhacores/cordic/to_polar.py | ToPolar.main | def main(self, c):
"""
:type c: Complex
:return: abs (gain corrected) angle (in 1 to -1 range)
"""
phase = Sfix(0.0, 0, -17)
abs, _, angle = self.core.main(c.real, c.imag, phase)
# get rid of CORDIC gain and extra bits
self.y_abs = abs * (1.0 / 1.646760)... | python | def main(self, c):
"""
:type c: Complex
:return: abs (gain corrected) angle (in 1 to -1 range)
"""
phase = Sfix(0.0, 0, -17)
abs, _, angle = self.core.main(c.real, c.imag, phase)
# get rid of CORDIC gain and extra bits
self.y_abs = abs * (1.0 / 1.646760)... | [
"def",
"main",
"(",
"self",
",",
"c",
")",
":",
"phase",
"=",
"Sfix",
"(",
"0.0",
",",
"0",
",",
"-",
"17",
")",
"abs",
",",
"_",
",",
"angle",
"=",
"self",
".",
"core",
".",
"main",
"(",
"c",
".",
"real",
",",
"c",
".",
"imag",
",",
"pha... | :type c: Complex
:return: abs (gain corrected) angle (in 1 to -1 range) | [
":",
"type",
"c",
":",
"Complex",
":",
"return",
":",
"abs",
"(",
"gain",
"corrected",
")",
"angle",
"(",
"in",
"1",
"to",
"-",
"1",
"range",
")"
] | train | https://github.com/gasparka/pyhacores/blob/16c186fbbf90385f2ba3498395123e79b6fcf340/pyhacores/cordic/to_polar.py#L18-L30 |
MikaSoftware/django-starterkit | starterkit/auth/backends.py | UserModelEmailBackend.authenticate | def authenticate(self, username="", password="", **kwargs):
"""Allow users to log in with their email address."""
try:
user = get_user_model().objects.filter(email__iexact=username)[0]
if check_password(password, user.password):
return user
else:
... | python | def authenticate(self, username="", password="", **kwargs):
"""Allow users to log in with their email address."""
try:
user = get_user_model().objects.filter(email__iexact=username)[0]
if check_password(password, user.password):
return user
else:
... | [
"def",
"authenticate",
"(",
"self",
",",
"username",
"=",
"\"\"",
",",
"password",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"user",
"=",
"get_user_model",
"(",
")",
".",
"objects",
".",
"filter",
"(",
"email__iexact",
"=",
"username"... | Allow users to log in with their email address. | [
"Allow",
"users",
"to",
"log",
"in",
"with",
"their",
"email",
"address",
"."
] | train | https://github.com/MikaSoftware/django-starterkit/blob/b82c4cb56ab8ec0b46136e9efcc3d6481fca1eeb/starterkit/auth/backends.py#L11-L21 |
MikaSoftware/django-starterkit | starterkit/auth/backends.py | UserModelUsernameOrEmailBackend.authenticate | def authenticate(self, username=None, password=None, **kwargs):
"""Allow users to log in with their email address or username."""
try:
# Try to fetch the user by searching the username or email field
user = get_user_model().objects.filter(Q(username=username)|Q(email=username))[0]... | python | def authenticate(self, username=None, password=None, **kwargs):
"""Allow users to log in with their email address or username."""
try:
# Try to fetch the user by searching the username or email field
user = get_user_model().objects.filter(Q(username=username)|Q(email=username))[0]... | [
"def",
"authenticate",
"(",
"self",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"# Try to fetch the user by searching the username or email field",
"user",
"=",
"get_user_model",
"(",
")",
".",
"obje... | Allow users to log in with their email address or username. | [
"Allow",
"users",
"to",
"log",
"in",
"with",
"their",
"email",
"address",
"or",
"username",
"."
] | train | https://github.com/MikaSoftware/django-starterkit/blob/b82c4cb56ab8ec0b46136e9efcc3d6481fca1eeb/starterkit/auth/backends.py#L27-L38 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain._build_preconditions_table | def _build_preconditions_table(self):
'''Builds the local action precondition expressions.'''
self.local_action_preconditions = dict()
self.global_action_preconditions = []
action_fluents = self.action_fluents
for precond in self.preconds:
scope = precond.scope
... | python | def _build_preconditions_table(self):
'''Builds the local action precondition expressions.'''
self.local_action_preconditions = dict()
self.global_action_preconditions = []
action_fluents = self.action_fluents
for precond in self.preconds:
scope = precond.scope
... | [
"def",
"_build_preconditions_table",
"(",
"self",
")",
":",
"self",
".",
"local_action_preconditions",
"=",
"dict",
"(",
")",
"self",
".",
"global_action_preconditions",
"=",
"[",
"]",
"action_fluents",
"=",
"self",
".",
"action_fluents",
"for",
"precond",
"in",
... | Builds the local action precondition expressions. | [
"Builds",
"the",
"local",
"action",
"precondition",
"expressions",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L68-L81 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain._build_action_bound_constraints_table | def _build_action_bound_constraints_table(self):
'''Builds the lower and upper action bound constraint expressions.'''
self.action_lower_bound_constraints = {}
self.action_upper_bound_constraints = {}
for name, preconds in self.local_action_preconditions.items():
for precon... | python | def _build_action_bound_constraints_table(self):
'''Builds the lower and upper action bound constraint expressions.'''
self.action_lower_bound_constraints = {}
self.action_upper_bound_constraints = {}
for name, preconds in self.local_action_preconditions.items():
for precon... | [
"def",
"_build_action_bound_constraints_table",
"(",
"self",
")",
":",
"self",
".",
"action_lower_bound_constraints",
"=",
"{",
"}",
"self",
".",
"action_upper_bound_constraints",
"=",
"{",
"}",
"for",
"name",
",",
"preconds",
"in",
"self",
".",
"local_action_precon... | Builds the lower and upper action bound constraint expressions. | [
"Builds",
"the",
"lower",
"and",
"upper",
"action",
"bound",
"constraint",
"expressions",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L83-L111 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain._extract_lower_bound | def _extract_lower_bound(self, name: str, expr: Expression) -> Optional[Expression]:
'''Returns the lower bound expression of the action with given `name`.'''
etype = expr.etype
args = expr.args
if etype[1] in ['<=', '<']:
if args[1].is_pvariable_expression() and args[1].name... | python | def _extract_lower_bound(self, name: str, expr: Expression) -> Optional[Expression]:
'''Returns the lower bound expression of the action with given `name`.'''
etype = expr.etype
args = expr.args
if etype[1] in ['<=', '<']:
if args[1].is_pvariable_expression() and args[1].name... | [
"def",
"_extract_lower_bound",
"(",
"self",
",",
"name",
":",
"str",
",",
"expr",
":",
"Expression",
")",
"->",
"Optional",
"[",
"Expression",
"]",
":",
"etype",
"=",
"expr",
".",
"etype",
"args",
"=",
"expr",
".",
"args",
"if",
"etype",
"[",
"1",
"]... | Returns the lower bound expression of the action with given `name`. | [
"Returns",
"the",
"lower",
"bound",
"expression",
"of",
"the",
"action",
"with",
"given",
"name",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L114-L124 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.non_fluents | def non_fluents(self) -> Dict[str, PVariable]:
'''Returns non-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_non_fluent() } | python | def non_fluents(self) -> Dict[str, PVariable]:
'''Returns non-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_non_fluent() } | [
"def",
"non_fluents",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"PVariable",
"]",
":",
"return",
"{",
"str",
"(",
"pvar",
")",
":",
"pvar",
"for",
"pvar",
"in",
"self",
".",
"pvariables",
"if",
"pvar",
".",
"is_non_fluent",
"(",
")",
"}"
] | Returns non-fluent pvariables. | [
"Returns",
"non",
"-",
"fluent",
"pvariables",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L139-L141 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.state_fluents | def state_fluents(self) -> Dict[str, PVariable]:
'''Returns state-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_state_fluent() } | python | def state_fluents(self) -> Dict[str, PVariable]:
'''Returns state-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_state_fluent() } | [
"def",
"state_fluents",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"PVariable",
"]",
":",
"return",
"{",
"str",
"(",
"pvar",
")",
":",
"pvar",
"for",
"pvar",
"in",
"self",
".",
"pvariables",
"if",
"pvar",
".",
"is_state_fluent",
"(",
")",
"}"
] | Returns state-fluent pvariables. | [
"Returns",
"state",
"-",
"fluent",
"pvariables",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L144-L146 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.action_fluents | def action_fluents(self) -> Dict[str, PVariable]:
'''Returns action-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_action_fluent() } | python | def action_fluents(self) -> Dict[str, PVariable]:
'''Returns action-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_action_fluent() } | [
"def",
"action_fluents",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"PVariable",
"]",
":",
"return",
"{",
"str",
"(",
"pvar",
")",
":",
"pvar",
"for",
"pvar",
"in",
"self",
".",
"pvariables",
"if",
"pvar",
".",
"is_action_fluent",
"(",
")",
"}"... | Returns action-fluent pvariables. | [
"Returns",
"action",
"-",
"fluent",
"pvariables",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L149-L151 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.intermediate_fluents | def intermediate_fluents(self) -> Dict[str, PVariable]:
'''Returns interm-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_intermediate_fluent() } | python | def intermediate_fluents(self) -> Dict[str, PVariable]:
'''Returns interm-fluent pvariables.'''
return { str(pvar): pvar for pvar in self.pvariables if pvar.is_intermediate_fluent() } | [
"def",
"intermediate_fluents",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"PVariable",
"]",
":",
"return",
"{",
"str",
"(",
"pvar",
")",
":",
"pvar",
"for",
"pvar",
"in",
"self",
".",
"pvariables",
"if",
"pvar",
".",
"is_intermediate_fluent",
"(",
... | Returns interm-fluent pvariables. | [
"Returns",
"interm",
"-",
"fluent",
"pvariables",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L154-L156 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.intermediate_cpfs | def intermediate_cpfs(self) -> List[CPF]:
'''Returns list of intermediate-fluent CPFs in level order.'''
_, cpfs = self.cpfs
interm_cpfs = [cpf for cpf in cpfs if cpf.name in self.intermediate_fluents]
interm_cpfs = sorted(interm_cpfs, key=lambda cpf: (self.intermediate_fluents[cpf.name]... | python | def intermediate_cpfs(self) -> List[CPF]:
'''Returns list of intermediate-fluent CPFs in level order.'''
_, cpfs = self.cpfs
interm_cpfs = [cpf for cpf in cpfs if cpf.name in self.intermediate_fluents]
interm_cpfs = sorted(interm_cpfs, key=lambda cpf: (self.intermediate_fluents[cpf.name]... | [
"def",
"intermediate_cpfs",
"(",
"self",
")",
"->",
"List",
"[",
"CPF",
"]",
":",
"_",
",",
"cpfs",
"=",
"self",
".",
"cpfs",
"interm_cpfs",
"=",
"[",
"cpf",
"for",
"cpf",
"in",
"cpfs",
"if",
"cpf",
".",
"name",
"in",
"self",
".",
"intermediate_fluen... | Returns list of intermediate-fluent CPFs in level order. | [
"Returns",
"list",
"of",
"intermediate",
"-",
"fluent",
"CPFs",
"in",
"level",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L159-L164 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.state_cpfs | def state_cpfs(self) -> List[CPF]:
'''Returns list of state-fluent CPFs.'''
_, cpfs = self.cpfs
state_cpfs = []
for cpf in cpfs:
name = utils.rename_next_state_fluent(cpf.name)
if name in self.state_fluents:
state_cpfs.append(cpf)
state_cpf... | python | def state_cpfs(self) -> List[CPF]:
'''Returns list of state-fluent CPFs.'''
_, cpfs = self.cpfs
state_cpfs = []
for cpf in cpfs:
name = utils.rename_next_state_fluent(cpf.name)
if name in self.state_fluents:
state_cpfs.append(cpf)
state_cpf... | [
"def",
"state_cpfs",
"(",
"self",
")",
"->",
"List",
"[",
"CPF",
"]",
":",
"_",
",",
"cpfs",
"=",
"self",
".",
"cpfs",
"state_cpfs",
"=",
"[",
"]",
"for",
"cpf",
"in",
"cpfs",
":",
"name",
"=",
"utils",
".",
"rename_next_state_fluent",
"(",
"cpf",
... | Returns list of state-fluent CPFs. | [
"Returns",
"list",
"of",
"state",
"-",
"fluent",
"CPFs",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L167-L176 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.interm_fluent_ordering | def interm_fluent_ordering(self) -> List[str]:
'''The list of intermediate-fluent names in canonical order.
Returns:
List[str]: A list of fluent names.
'''
interm_fluents = self.intermediate_fluents.values()
key = lambda pvar: (pvar.level, pvar.name)
return [... | python | def interm_fluent_ordering(self) -> List[str]:
'''The list of intermediate-fluent names in canonical order.
Returns:
List[str]: A list of fluent names.
'''
interm_fluents = self.intermediate_fluents.values()
key = lambda pvar: (pvar.level, pvar.name)
return [... | [
"def",
"interm_fluent_ordering",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"interm_fluents",
"=",
"self",
".",
"intermediate_fluents",
".",
"values",
"(",
")",
"key",
"=",
"lambda",
"pvar",
":",
"(",
"pvar",
".",
"level",
",",
"pvar",
".",
... | The list of intermediate-fluent names in canonical order.
Returns:
List[str]: A list of fluent names. | [
"The",
"list",
"of",
"intermediate",
"-",
"fluent",
"names",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L206-L214 |
thiagopbueno/pyrddl | pyrddl/domain.py | Domain.next_state_fluent_ordering | def next_state_fluent_ordering(self) -> List[str]:
'''The list of next state-fluent names in canonical order.
Returns:
List[str]: A list of fluent names.
'''
key = lambda x: x.name
return [cpf.name for cpf in sorted(self.state_cpfs, key=key)] | python | def next_state_fluent_ordering(self) -> List[str]:
'''The list of next state-fluent names in canonical order.
Returns:
List[str]: A list of fluent names.
'''
key = lambda x: x.name
return [cpf.name for cpf in sorted(self.state_cpfs, key=key)] | [
"def",
"next_state_fluent_ordering",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"key",
"=",
"lambda",
"x",
":",
"x",
".",
"name",
"return",
"[",
"cpf",
".",
"name",
"for",
"cpf",
"in",
"sorted",
"(",
"self",
".",
"state_cpfs",
",",
"key",
... | The list of next state-fluent names in canonical order.
Returns:
List[str]: A list of fluent names. | [
"The",
"list",
"of",
"next",
"state",
"-",
"fluent",
"names",
"in",
"canonical",
"order",
"."
] | train | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/domain.py#L217-L224 |
disqus/porkchop | porkchop/backend.py | Carbon.send | def send(self):
""" self.data format: {metric_name: [(t1, val1), (t2, val2)]} """
buf_sz = 500
to_send = {}
for mn in self.data.iterkeys():
while len(self.data[mn]) > 0:
l = len(to_send)
if l < buf_sz:
to_send.setdefault(mn... | python | def send(self):
""" self.data format: {metric_name: [(t1, val1), (t2, val2)]} """
buf_sz = 500
to_send = {}
for mn in self.data.iterkeys():
while len(self.data[mn]) > 0:
l = len(to_send)
if l < buf_sz:
to_send.setdefault(mn... | [
"def",
"send",
"(",
"self",
")",
":",
"buf_sz",
"=",
"500",
"to_send",
"=",
"{",
"}",
"for",
"mn",
"in",
"self",
".",
"data",
".",
"iterkeys",
"(",
")",
":",
"while",
"len",
"(",
"self",
".",
"data",
"[",
"mn",
"]",
")",
">",
"0",
":",
"l",
... | self.data format: {metric_name: [(t1, val1), (t2, val2)]} | [
"self",
".",
"data",
"format",
":",
"{",
"metric_name",
":",
"[",
"(",
"t1",
"val1",
")",
"(",
"t2",
"val2",
")",
"]",
"}"
] | train | https://github.com/disqus/porkchop/blob/32458d0a2c1557f765c4c9734feb931546c1e3ef/porkchop/backend.py#L48-L81 |
williamjameshandley/fgivenx | fgivenx/dkl.py | DKL | def DKL(arrays):
"""
Compute the Kullback-Leibler divergence from one distribution Q to another
P, where Q and P are represented by a set of samples.
Parameters
----------
arrays: tuple(1D numpy.array,1D numpy.array)
samples defining distributions P & Q respectively
Returns
---... | python | def DKL(arrays):
"""
Compute the Kullback-Leibler divergence from one distribution Q to another
P, where Q and P are represented by a set of samples.
Parameters
----------
arrays: tuple(1D numpy.array,1D numpy.array)
samples defining distributions P & Q respectively
Returns
---... | [
"def",
"DKL",
"(",
"arrays",
")",
":",
"samples",
",",
"prior_samples",
"=",
"arrays",
"samples",
"=",
"samples",
"[",
"~",
"numpy",
".",
"isnan",
"(",
"samples",
")",
"]",
"prior_samples",
"=",
"prior_samples",
"[",
"~",
"numpy",
".",
"isnan",
"(",
"p... | Compute the Kullback-Leibler divergence from one distribution Q to another
P, where Q and P are represented by a set of samples.
Parameters
----------
arrays: tuple(1D numpy.array,1D numpy.array)
samples defining distributions P & Q respectively
Returns
-------
float:
Kullb... | [
"Compute",
"the",
"Kullback",
"-",
"Leibler",
"divergence",
"from",
"one",
"distribution",
"Q",
"to",
"another",
"P",
"where",
"Q",
"and",
"P",
"are",
"represented",
"by",
"a",
"set",
"of",
"samples",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/dkl.py#L7-L28 |
williamjameshandley/fgivenx | fgivenx/dkl.py | compute_dkl | def compute_dkl(fsamps, prior_fsamps, **kwargs):
"""
Compute the Kullback Leibler divergence for function samples for posterior
and prior pre-calculated at a range of x values.
Parameters
----------
fsamps: 2D numpy.array
Posterior function samples, as computed by
:func:`fgivenx... | python | def compute_dkl(fsamps, prior_fsamps, **kwargs):
"""
Compute the Kullback Leibler divergence for function samples for posterior
and prior pre-calculated at a range of x values.
Parameters
----------
fsamps: 2D numpy.array
Posterior function samples, as computed by
:func:`fgivenx... | [
"def",
"compute_dkl",
"(",
"fsamps",
",",
"prior_fsamps",
",",
"*",
"*",
"kwargs",
")",
":",
"parallel",
"=",
"kwargs",
".",
"pop",
"(",
"'parallel'",
",",
"False",
")",
"cache",
"=",
"kwargs",
".",
"pop",
"(",
"'cache'",
",",
"''",
")",
"tqdm_kwargs",... | Compute the Kullback Leibler divergence for function samples for posterior
and prior pre-calculated at a range of x values.
Parameters
----------
fsamps: 2D numpy.array
Posterior function samples, as computed by
:func:`fgivenx.compute_samples`
prior_fsamps: 2D numpy.array
P... | [
"Compute",
"the",
"Kullback",
"Leibler",
"divergence",
"for",
"function",
"samples",
"for",
"posterior",
"and",
"prior",
"pre",
"-",
"calculated",
"at",
"a",
"range",
"of",
"x",
"values",
"."
] | train | https://github.com/williamjameshandley/fgivenx/blob/a16790652a3cef3cfacd4b97da62786cb66fec13/fgivenx/dkl.py#L31-L78 |
ilblackdragon/django-misc | misc/templatetags/share_buttons.py | current_site_url | def current_site_url():
"""Returns fully qualified URL (no trailing slash) for the current site."""
protocol = getattr(settings, 'MY_SITE_PROTOCOL', 'https')
port = getattr(settings, 'MY_SITE_PORT', '')
url = '%s://%s' % (protocol, settings.SITE_DOMAIN)
if port:
url += ':%s' % port
r... | python | def current_site_url():
"""Returns fully qualified URL (no trailing slash) for the current site."""
protocol = getattr(settings, 'MY_SITE_PROTOCOL', 'https')
port = getattr(settings, 'MY_SITE_PORT', '')
url = '%s://%s' % (protocol, settings.SITE_DOMAIN)
if port:
url += ':%s' % port
r... | [
"def",
"current_site_url",
"(",
")",
":",
"protocol",
"=",
"getattr",
"(",
"settings",
",",
"'MY_SITE_PROTOCOL'",
",",
"'https'",
")",
"port",
"=",
"getattr",
"(",
"settings",
",",
"'MY_SITE_PORT'",
",",
"''",
")",
"url",
"=",
"'%s://%s'",
"%",
"(",
"proto... | Returns fully qualified URL (no trailing slash) for the current site. | [
"Returns",
"fully",
"qualified",
"URL",
"(",
"no",
"trailing",
"slash",
")",
"for",
"the",
"current",
"site",
"."
] | train | https://github.com/ilblackdragon/django-misc/blob/0accd2dc97de656a1c9e275be81e817f78a2eb9d/misc/templatetags/share_buttons.py#L23-L30 |
kissmetrics/py-KISSmetrics | KISSmetrics/client.py | Client.record | def record(self, person, event, properties=None, timestamp=None,
path=KISSmetrics.RECORD_PATH):
"""Record `event` for `person` with any `properties`.
:param person: the individual performing the `event`
:param event: the `event` name that was performed
:param properties: ... | python | def record(self, person, event, properties=None, timestamp=None,
path=KISSmetrics.RECORD_PATH):
"""Record `event` for `person` with any `properties`.
:param person: the individual performing the `event`
:param event: the `event` name that was performed
:param properties: ... | [
"def",
"record",
"(",
"self",
",",
"person",
",",
"event",
",",
"properties",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"path",
"=",
"KISSmetrics",
".",
"RECORD_PATH",
")",
":",
"this_request",
"=",
"request",
".",
"record",
"(",
"self",
".",
"k... | Record `event` for `person` with any `properties`.
:param person: the individual performing the `event`
:param event: the `event` name that was performed
:param properties: any additional data to include
:type properties: dict
:param timestamp: when the `event` was performed; op... | [
"Record",
"event",
"for",
"person",
"with",
"any",
"properties",
"."
] | train | https://github.com/kissmetrics/py-KISSmetrics/blob/705bf3fe26dd440abdf37bf213396b68af385523/KISSmetrics/client.py#L31-L53 |
kissmetrics/py-KISSmetrics | KISSmetrics/client.py | Client.set | def set(self, person, properties=None, timestamp=None,
path=KISSmetrics.SET_PATH):
"""Set a property (or properties) for a `person`.
:param person: individual to associate properties with
:param properties: key-value pairs to associate with `person`
:type properties: dict
... | python | def set(self, person, properties=None, timestamp=None,
path=KISSmetrics.SET_PATH):
"""Set a property (or properties) for a `person`.
:param person: individual to associate properties with
:param properties: key-value pairs to associate with `person`
:type properties: dict
... | [
"def",
"set",
"(",
"self",
",",
"person",
",",
"properties",
"=",
"None",
",",
"timestamp",
"=",
"None",
",",
"path",
"=",
"KISSmetrics",
".",
"SET_PATH",
")",
":",
"this_request",
"=",
"request",
".",
"set",
"(",
"self",
".",
"key",
",",
"person",
"... | Set a property (or properties) for a `person`.
:param person: individual to associate properties with
:param properties: key-value pairs to associate with `person`
:type properties: dict
:param timestamp: when the `event` was performed; optional for
back-dating... | [
"Set",
"a",
"property",
"(",
"or",
"properties",
")",
"for",
"a",
"person",
"."
] | train | https://github.com/kissmetrics/py-KISSmetrics/blob/705bf3fe26dd440abdf37bf213396b68af385523/KISSmetrics/client.py#L55-L75 |
kissmetrics/py-KISSmetrics | KISSmetrics/client.py | Client.alias | def alias(self, person, identity, path=KISSmetrics.ALIAS_PATH):
"""Map `person` to `identity`; actions done by one resolve to other.
:param person: consider as same individual ``identity``; the
source of the alias operation
:type person: str or unicode
:param iden... | python | def alias(self, person, identity, path=KISSmetrics.ALIAS_PATH):
"""Map `person` to `identity`; actions done by one resolve to other.
:param person: consider as same individual ``identity``; the
source of the alias operation
:type person: str or unicode
:param iden... | [
"def",
"alias",
"(",
"self",
",",
"person",
",",
"identity",
",",
"path",
"=",
"KISSmetrics",
".",
"ALIAS_PATH",
")",
":",
"this_request",
"=",
"request",
".",
"alias",
"(",
"self",
".",
"key",
",",
"person",
",",
"identity",
",",
"scheme",
"=",
"self"... | Map `person` to `identity`; actions done by one resolve to other.
:param person: consider as same individual ``identity``; the
source of the alias operation
:type person: str or unicode
:param identity: consider as an alias of ``person``; the target
... | [
"Map",
"person",
"to",
"identity",
";",
"actions",
"done",
"by",
"one",
"resolve",
"to",
"other",
"."
] | train | https://github.com/kissmetrics/py-KISSmetrics/blob/705bf3fe26dd440abdf37bf213396b68af385523/KISSmetrics/client.py#L77-L112 |
chainreactionmfg/mutablerecords | mutablerecords/records.py | CopyRecord | def CopyRecord(record, **field_overrides):
"""Copies a record and its fields, recurses for any field that is a Record.
For records that have nested mutable fields, use copy.deepcopy.
Args:
record: A Record instance to be copied.
**field_overrides: Fields and their values to override in... | python | def CopyRecord(record, **field_overrides):
"""Copies a record and its fields, recurses for any field that is a Record.
For records that have nested mutable fields, use copy.deepcopy.
Args:
record: A Record instance to be copied.
**field_overrides: Fields and their values to override in... | [
"def",
"CopyRecord",
"(",
"record",
",",
"*",
"*",
"field_overrides",
")",
":",
"fields",
"=",
"field_overrides",
"for",
"field",
"in",
"record",
".",
"__slots__",
":",
"if",
"field",
"in",
"field_overrides",
":",
"continue",
"value",
"=",
"getattr",
"(",
... | Copies a record and its fields, recurses for any field that is a Record.
For records that have nested mutable fields, use copy.deepcopy.
Args:
record: A Record instance to be copied.
**field_overrides: Fields and their values to override in the new copy.
Returns: A copy of the given r... | [
"Copies",
"a",
"record",
"and",
"its",
"fields",
"recurses",
"for",
"any",
"field",
"that",
"is",
"a",
"Record",
".",
"For",
"records",
"that",
"have",
"nested",
"mutable",
"fields",
"use",
"copy",
".",
"deepcopy",
".",
"Args",
":",
"record",
":",
"A",
... | train | https://github.com/chainreactionmfg/mutablerecords/blob/5abde828c96de4c452dd51d5e0cc33fb47b72e89/mutablerecords/records.py#L204-L228 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/Table.py | Table.saveAs | def saveAs(self, path):
"""
save to file under given name
"""
if not path:
path = self._dialogs.getSaveFileName(filter='*.csv')
if path:
self._setPath(path)
with open(str(self._path), 'wb') as stream:
writer = csv.writer(stream)... | python | def saveAs(self, path):
"""
save to file under given name
"""
if not path:
path = self._dialogs.getSaveFileName(filter='*.csv')
if path:
self._setPath(path)
with open(str(self._path), 'wb') as stream:
writer = csv.writer(stream)... | [
"def",
"saveAs",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
":",
"path",
"=",
"self",
".",
"_dialogs",
".",
"getSaveFileName",
"(",
"filter",
"=",
"'*.csv'",
")",
"if",
"path",
":",
"self",
".",
"_setPath",
"(",
"path",
")",
"with",
"... | save to file under given name | [
"save",
"to",
"file",
"under",
"given",
"name"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/Table.py#L80-L92 |
radjkarl/fancyWidgets | fancywidgets/pyQtBased/Table.py | Table._textToTable | def _textToTable(self, text, separator='\t'):
"""
format csv, [[...]], ((..)) strings to a 2d table
"""
table = None
if text.startswith('[[') or text.startswith('(('):
try:
# maybe it's already formated as a list e.g. "[['1','2'],[...]]"
... | python | def _textToTable(self, text, separator='\t'):
"""
format csv, [[...]], ((..)) strings to a 2d table
"""
table = None
if text.startswith('[[') or text.startswith('(('):
try:
# maybe it's already formated as a list e.g. "[['1','2'],[...]]"
... | [
"def",
"_textToTable",
"(",
"self",
",",
"text",
",",
"separator",
"=",
"'\\t'",
")",
":",
"table",
"=",
"None",
"if",
"text",
".",
"startswith",
"(",
"'[['",
")",
"or",
"text",
".",
"startswith",
"(",
"'(('",
")",
":",
"try",
":",
"# maybe it's alread... | format csv, [[...]], ((..)) strings to a 2d table | [
"format",
"csv",
"[[",
"...",
"]]",
"((",
"..",
"))",
"strings",
"to",
"a",
"2d",
"table"
] | train | https://github.com/radjkarl/fancyWidgets/blob/ffe0d5747c5296c78575f0e0909af915a4a5698f/fancywidgets/pyQtBased/Table.py#L225-L255 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS.py | main | def main():
"""The main function of the module.
These are the steps:
1. Reads the population file (:py:func:`readPopulations`).
2. Extract the MDS data (:py:func:`extractData`).
3. Plots the MDS data (:py:func:`plotMDS`).
"""
# Getting and checking the options
args = parseArgs()
c... | python | def main():
"""The main function of the module.
These are the steps:
1. Reads the population file (:py:func:`readPopulations`).
2. Extract the MDS data (:py:func:`extractData`).
3. Plots the MDS data (:py:func:`plotMDS`).
"""
# Getting and checking the options
args = parseArgs()
c... | [
"def",
"main",
"(",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
")",
"checkArgs",
"(",
"args",
")",
"# Reads the population file",
"populations",
"=",
"readPopulations",
"(",
"args",
".",
"population_file",
")",
"# Acquire the data",... | The main function of the module.
These are the steps:
1. Reads the population file (:py:func:`readPopulations`).
2. Extract the MDS data (:py:func:`extractData`).
3. Plots the MDS data (:py:func:`plotMDS`). | [
"The",
"main",
"function",
"of",
"the",
"module",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS.py#L36-L66 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS.py | readPopulations | def readPopulations(inputFileName):
"""Reads a population file.
:param inputFileName: the name of the population file.
:type inputFileName: str
:returns: a :py:class:`dict` of population for each of the samples.
"""
populations = {}
with open(inputFileName, "r") as inputFile:
for... | python | def readPopulations(inputFileName):
"""Reads a population file.
:param inputFileName: the name of the population file.
:type inputFileName: str
:returns: a :py:class:`dict` of population for each of the samples.
"""
populations = {}
with open(inputFileName, "r") as inputFile:
for... | [
"def",
"readPopulations",
"(",
"inputFileName",
")",
":",
"populations",
"=",
"{",
"}",
"with",
"open",
"(",
"inputFileName",
",",
"\"r\"",
")",
"as",
"inputFile",
":",
"for",
"line",
"in",
"inputFile",
":",
"row",
"=",
"line",
".",
"rstrip",
"(",
"\"\\r... | Reads a population file.
:param inputFileName: the name of the population file.
:type inputFileName: str
:returns: a :py:class:`dict` of population for each of the samples. | [
"Reads",
"a",
"population",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS.py#L69-L100 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS.py | plotMDS | def plotMDS(data, theOrders, theLabels, theColors, theSizes, theMarkers,
options):
"""Plot the MDS data.
:param data: the data to plot (MDS values).
:param theOrders: the order of the populations to plot.
:param theLabels: the names of populations to plot.
:param theColors: the colors o... | python | def plotMDS(data, theOrders, theLabels, theColors, theSizes, theMarkers,
options):
"""Plot the MDS data.
:param data: the data to plot (MDS values).
:param theOrders: the order of the populations to plot.
:param theLabels: the names of populations to plot.
:param theColors: the colors o... | [
"def",
"plotMDS",
"(",
"data",
",",
"theOrders",
",",
"theLabels",
",",
"theColors",
",",
"theSizes",
",",
"theMarkers",
",",
"options",
")",
":",
"# Do the import",
"import",
"matplotlib",
"as",
"mpl",
"if",
"options",
".",
"format",
"!=",
"\"X11\"",
"and",... | Plot the MDS data.
:param data: the data to plot (MDS values).
:param theOrders: the order of the populations to plot.
:param theLabels: the names of populations to plot.
:param theColors: the colors of the populations to plot.
:param theSizes: the sizes of the markers for each population to plot.
... | [
"Plot",
"the",
"MDS",
"data",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS.py#L103-L164 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS.py | extractData | def extractData(fileName, populations):
"""Extract the C1 and C2 columns for plotting.
:param fileName: the name of the MDS file.
:param populations: the population of each sample in the MDS file.
:type fileName: str
:type fileName: dict
:returns: the MDS data with information about the popul... | python | def extractData(fileName, populations):
"""Extract the C1 and C2 columns for plotting.
:param fileName: the name of the MDS file.
:param populations: the population of each sample in the MDS file.
:type fileName: str
:type fileName: dict
:returns: the MDS data with information about the popul... | [
"def",
"extractData",
"(",
"fileName",
",",
"populations",
")",
":",
"# The different population labels",
"possibleLabels",
"=",
"list",
"(",
"set",
"(",
"populations",
".",
"values",
"(",
")",
")",
")",
"nbPossibleLabels",
"=",
"len",
"(",
"possibleLabels",
")"... | Extract the C1 and C2 columns for plotting.
:param fileName: the name of the MDS file.
:param populations: the population of each sample in the MDS file.
:type fileName: str
:type fileName: dict
:returns: the MDS data with information about the population of each
sample. The first e... | [
"Extract",
"the",
"C1",
"and",
"C2",
"columns",
"for",
"plotting",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS.py#L167-L226 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS.py | checkArgs | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | python | def checkArgs(args):
"""Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` clas... | [
"def",
"checkArgs",
"(",
"args",
")",
":",
"# Check in input file",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"args",
".",
"file",
")",
":",
"msg",
"=",
"\"%s: no such file\"",
"%",
"args",
".",
"file",
"raise",
"ProgramError",
"(",
"msg",
")",... | Checks the arguments and options.
:param args: an object containing the options of the program.
:type args: argparse.Namespace
:returns: ``True`` if everything was OK.
If there is a problem with an option, an exception is raised using the
:py:class:`ProgramError` class, a message is printed to t... | [
"Checks",
"the",
"arguments",
"and",
"options",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS.py#L229-L256 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS.py | parseArgs | def parseArgs(): # pragma: no cover
"""Parses the command line options and arguments.
:returns: A :py:class:`argparse.Namespace` object created by the
:py:mod:`argparse` module. It contains the values of the
different options.
===================== ====== =====================... | python | def parseArgs(): # pragma: no cover
"""Parses the command line options and arguments.
:returns: A :py:class:`argparse.Namespace` object created by the
:py:mod:`argparse` module. It contains the values of the
different options.
===================== ====== =====================... | [
"def",
"parseArgs",
"(",
")",
":",
"# pragma: no cover",
"# The INPUT files",
"group",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"Input File\"",
")",
"group",
".",
"add_argument",
"(",
"\"--file\"",
",",
"type",
"=",
"str",
",",
"metavar",
"=",
"\"FILE\""... | Parses the command line options and arguments.
:returns: A :py:class:`argparse.Namespace` object created by the
:py:mod:`argparse` module. It contains the values of the
different options.
===================== ====== =========================================
Options ... | [
"Parses",
"the",
"command",
"line",
"options",
"and",
"arguments",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS.py#L259-L306 |
lemieuxl/pyGenClean | pyGenClean/PlinkUtils/plot_MDS.py | addCustomOptions | def addCustomOptions(parser):
"""Adds custom options to a parser.
:param parser: the parser.
:type parser: argparse.parser
"""
parser.add_argument("--format", type=str, metavar="FORMAT", default="png",
choices=["png", "ps", "pdf", "X11"],
help="The ... | python | def addCustomOptions(parser):
"""Adds custom options to a parser.
:param parser: the parser.
:type parser: argparse.parser
"""
parser.add_argument("--format", type=str, metavar="FORMAT", default="png",
choices=["png", "ps", "pdf", "X11"],
help="The ... | [
"def",
"addCustomOptions",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"\"--format\"",
",",
"type",
"=",
"str",
",",
"metavar",
"=",
"\"FORMAT\"",
",",
"default",
"=",
"\"png\"",
",",
"choices",
"=",
"[",
"\"png\"",
",",
"\"ps\"",
",",
"... | Adds custom options to a parser.
:param parser: the parser.
:type parser: argparse.parser | [
"Adds",
"custom",
"options",
"to",
"a",
"parser",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/PlinkUtils/plot_MDS.py#L309-L328 |
photo/openphoto-python | trovebox/api/api_activity.py | ApiActivities.list | def list(self, options=None, **kwds):
"""
Endpoint: /activities[/<options>]/list.json
Returns a list of Activity objects.
The options parameter can be used to narrow down the activities.
Eg: options={"type": "photo-upload"}
"""
option_string = self._build_option_... | python | def list(self, options=None, **kwds):
"""
Endpoint: /activities[/<options>]/list.json
Returns a list of Activity objects.
The options parameter can be used to narrow down the activities.
Eg: options={"type": "photo-upload"}
"""
option_string = self._build_option_... | [
"def",
"list",
"(",
"self",
",",
"options",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"option_string",
"=",
"self",
".",
"_build_option_string",
"(",
"options",
")",
"activities",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"/activities%s/list.json... | Endpoint: /activities[/<options>]/list.json
Returns a list of Activity objects.
The options parameter can be used to narrow down the activities.
Eg: options={"type": "photo-upload"} | [
"Endpoint",
":",
"/",
"activities",
"[",
"/",
"<options",
">",
"]",
"/",
"list",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_activity.py#L10-L22 |
photo/openphoto-python | trovebox/api/api_activity.py | ApiActivity.view | def view(self, activity, **kwds):
"""
Endpoint: /activity/<id>/view.json
Requests all properties of an activity.
Returns the requested activity object.
"""
result = self._client.get("/activity/%s/view.json" %
self._extract_id(activity),
... | python | def view(self, activity, **kwds):
"""
Endpoint: /activity/<id>/view.json
Requests all properties of an activity.
Returns the requested activity object.
"""
result = self._client.get("/activity/%s/view.json" %
self._extract_id(activity),
... | [
"def",
"view",
"(",
"self",
",",
"activity",
",",
"*",
"*",
"kwds",
")",
":",
"result",
"=",
"self",
".",
"_client",
".",
"get",
"(",
"\"/activity/%s/view.json\"",
"%",
"self",
".",
"_extract_id",
"(",
"activity",
")",
",",
"*",
"*",
"kwds",
")",
"["... | Endpoint: /activity/<id>/view.json
Requests all properties of an activity.
Returns the requested activity object. | [
"Endpoint",
":",
"/",
"activity",
"/",
"<id",
">",
"/",
"view",
".",
"json"
] | train | https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_activity.py#L37-L51 |
radujica/baloo | baloo/weld/cache.py | Cache._generate_placeholder | def _generate_placeholder(readable_text=None):
"""Generate a placeholder name to use while updating WeldObject.
Parameters
----------
readable_text : str, optional
Appended to the name for a more understandable placeholder.
Returns
-------
str
... | python | def _generate_placeholder(readable_text=None):
"""Generate a placeholder name to use while updating WeldObject.
Parameters
----------
readable_text : str, optional
Appended to the name for a more understandable placeholder.
Returns
-------
str
... | [
"def",
"_generate_placeholder",
"(",
"readable_text",
"=",
"None",
")",
":",
"name",
"=",
"'_interm_'",
"+",
"str",
"(",
"Cache",
".",
"_counter",
")",
"Cache",
".",
"_counter",
"+=",
"1",
"if",
"readable_text",
"is",
"not",
"None",
":",
"assert",
"isinsta... | Generate a placeholder name to use while updating WeldObject.
Parameters
----------
readable_text : str, optional
Appended to the name for a more understandable placeholder.
Returns
-------
str
Placeholder. | [
"Generate",
"a",
"placeholder",
"name",
"to",
"use",
"while",
"updating",
"WeldObject",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/cache.py#L62-L83 |
radujica/baloo | baloo/weld/cache.py | Cache.cache_intermediate_result | def cache_intermediate_result(cls, result, readable_name=None):
"""Add result to the cached data.
Parameters
----------
result : LazyResult
Data to cache.
readable_name : str
Will be used when generating a name for this intermediate result.
Retur... | python | def cache_intermediate_result(cls, result, readable_name=None):
"""Add result to the cached data.
Parameters
----------
result : LazyResult
Data to cache.
readable_name : str
Will be used when generating a name for this intermediate result.
Retur... | [
"def",
"cache_intermediate_result",
"(",
"cls",
",",
"result",
",",
"readable_name",
"=",
"None",
")",
":",
"from",
".",
"lazy_result",
"import",
"LazyResult",
"assert",
"isinstance",
"(",
"result",
",",
"LazyResult",
")",
"dependency_name",
"=",
"Cache",
".",
... | Add result to the cached data.
Parameters
----------
result : LazyResult
Data to cache.
readable_name : str
Will be used when generating a name for this intermediate result.
Returns
-------
str
A generated placeholder name uni... | [
"Add",
"result",
"to",
"the",
"cached",
"data",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/cache.py#L105-L127 |
radujica/baloo | baloo/weld/cache.py | Cache.create_fake_array_input | def create_fake_array_input(cls, dependency, readable_name, index=None):
"""Create fake Weld inputs to be used in future WeldObjects.
Parameters
----------
dependency : str
The Weld input name of the actual intermediate result, obtained from cache_intermediate_result.
... | python | def create_fake_array_input(cls, dependency, readable_name, index=None):
"""Create fake Weld inputs to be used in future WeldObjects.
Parameters
----------
dependency : str
The Weld input name of the actual intermediate result, obtained from cache_intermediate_result.
... | [
"def",
"create_fake_array_input",
"(",
"cls",
",",
"dependency",
",",
"readable_name",
",",
"index",
"=",
"None",
")",
":",
"assert",
"dependency",
"in",
"Cache",
".",
"_intermediate_results",
"assert",
"isinstance",
"(",
"readable_name",
",",
"str",
")",
"name"... | Create fake Weld inputs to be used in future WeldObjects.
Parameters
----------
dependency : str
The Weld input name of the actual intermediate result, obtained from cache_intermediate_result.
readable_name : str
User-friendly string that will be used to generate... | [
"Create",
"fake",
"Weld",
"inputs",
"to",
"be",
"used",
"in",
"future",
"WeldObjects",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/cache.py#L130-L162 |
radujica/baloo | baloo/weld/cache.py | Cache.cache_fake_input | def cache_fake_input(cls, weld_input_id, fake_weld_input):
"""Cache the fake Weld input to be seen by LazyResult.evaluate
Parameters
----------
weld_input_id : str
Generated when registering the fake_weld_input in WeldObject.update.
fake_weld_input : _FakeWeldInput
... | python | def cache_fake_input(cls, weld_input_id, fake_weld_input):
"""Cache the fake Weld input to be seen by LazyResult.evaluate
Parameters
----------
weld_input_id : str
Generated when registering the fake_weld_input in WeldObject.update.
fake_weld_input : _FakeWeldInput
... | [
"def",
"cache_fake_input",
"(",
"cls",
",",
"weld_input_id",
",",
"fake_weld_input",
")",
":",
"assert",
"isinstance",
"(",
"weld_input_id",
",",
"str",
")",
"assert",
"isinstance",
"(",
"fake_weld_input",
",",
"_FakeWeldInput",
")",
"Cache",
".",
"_cache",
"[",... | Cache the fake Weld input to be seen by LazyResult.evaluate
Parameters
----------
weld_input_id : str
Generated when registering the fake_weld_input in WeldObject.update.
fake_weld_input : _FakeWeldInput
The fake Weld input previously generated by create_fake_arr... | [
"Cache",
"the",
"fake",
"Weld",
"input",
"to",
"be",
"seen",
"by",
"LazyResult",
".",
"evaluate"
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/cache.py#L165-L179 |
radujica/baloo | baloo/weld/cache.py | Cache.get | def get(cls, key):
"""Retrieve a fake Weld input. Evaluate its intermediate result dependency if not yet done.
Parameters
----------
key : str
Weld input name previously obtained through create_fake_array_input.
Returns
-------
numpy.ndarray or tuple... | python | def get(cls, key):
"""Retrieve a fake Weld input. Evaluate its intermediate result dependency if not yet done.
Parameters
----------
key : str
Weld input name previously obtained through create_fake_array_input.
Returns
-------
numpy.ndarray or tuple... | [
"def",
"get",
"(",
"cls",
",",
"key",
")",
":",
"assert",
"isinstance",
"(",
"key",
",",
"str",
")",
"data",
"=",
"cls",
".",
"_cache",
"[",
"key",
"]",
"if",
"isinstance",
"(",
"data",
",",
"_FakeWeldInput",
")",
":",
"data",
"=",
"data",
".",
"... | Retrieve a fake Weld input. Evaluate its intermediate result dependency if not yet done.
Parameters
----------
key : str
Weld input name previously obtained through create_fake_array_input.
Returns
-------
numpy.ndarray or tuple
The corresponding... | [
"Retrieve",
"a",
"fake",
"Weld",
"input",
".",
"Evaluate",
"its",
"intermediate",
"result",
"dependency",
"if",
"not",
"yet",
"done",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/cache.py#L182-L204 |
b3j0f/aop | b3j0f/aop/advice/core.py | _add_advices | def _add_advices(target, advices):
"""Add advices on input target.
:param Callable target: target from where add advices.
:param advices: advices to weave on input target.
:type advices: routine or list.
:param bool ordered: ensure advices to add will be done in input order
"""
interceptio... | python | def _add_advices(target, advices):
"""Add advices on input target.
:param Callable target: target from where add advices.
:param advices: advices to weave on input target.
:type advices: routine or list.
:param bool ordered: ensure advices to add will be done in input order
"""
interceptio... | [
"def",
"_add_advices",
"(",
"target",
",",
"advices",
")",
":",
"interception_fn",
"=",
"_get_function",
"(",
"target",
")",
"target_advices",
"=",
"getattr",
"(",
"interception_fn",
",",
"_ADVICES",
",",
"[",
"]",
")",
"target_advices",
"+=",
"advices",
"seta... | Add advices on input target.
:param Callable target: target from where add advices.
:param advices: advices to weave on input target.
:type advices: routine or list.
:param bool ordered: ensure advices to add will be done in input order | [
"Add",
"advices",
"on",
"input",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L81-L95 |
b3j0f/aop | b3j0f/aop/advice/core.py | _remove_advices | def _remove_advices(target, advices, ctx):
"""Remove advices from input target.
:param advices: advices to remove. If None, remove all advices.
"""
# if ctx is not None
if ctx is not None: # check if intercepted ctx is ctx
_, intercepted_ctx = get_intercepted(target)
if intercepted... | python | def _remove_advices(target, advices, ctx):
"""Remove advices from input target.
:param advices: advices to remove. If None, remove all advices.
"""
# if ctx is not None
if ctx is not None: # check if intercepted ctx is ctx
_, intercepted_ctx = get_intercepted(target)
if intercepted... | [
"def",
"_remove_advices",
"(",
"target",
",",
"advices",
",",
"ctx",
")",
":",
"# if ctx is not None",
"if",
"ctx",
"is",
"not",
"None",
":",
"# check if intercepted ctx is ctx",
"_",
",",
"intercepted_ctx",
"=",
"get_intercepted",
"(",
"target",
")",
"if",
"int... | Remove advices from input target.
:param advices: advices to remove. If None, remove all advices. | [
"Remove",
"advices",
"from",
"input",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L98-L127 |
b3j0f/aop | b3j0f/aop/advice/core.py | get_advices | def get_advices(target, ctx=None, local=False):
"""Get element advices.
:param target: target from where get advices.
:param ctx: ctx from where get target.
:param bool local: If ctx is not None or target is a method, if True
(False by default) get only target advices without resolving super
... | python | def get_advices(target, ctx=None, local=False):
"""Get element advices.
:param target: target from where get advices.
:param ctx: ctx from where get target.
:param bool local: If ctx is not None or target is a method, if True
(False by default) get only target advices without resolving super
... | [
"def",
"get_advices",
"(",
"target",
",",
"ctx",
"=",
"None",
",",
"local",
"=",
"False",
")",
":",
"result",
"=",
"[",
"]",
"if",
"is_intercepted",
"(",
"target",
")",
":",
"# find ctx if not given",
"if",
"ctx",
"is",
"None",
":",
"ctx",
"=",
"find_c... | Get element advices.
:param target: target from where get advices.
:param ctx: ctx from where get target.
:param bool local: If ctx is not None or target is a method, if True
(False by default) get only target advices without resolving super
target advices in a super ctx.
:return: list ... | [
"Get",
"element",
"advices",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L130-L205 |
b3j0f/aop | b3j0f/aop/advice/core.py | _namematcher | def _namematcher(regex):
"""Checks if a target name matches with an input regular expression."""
matcher = re_compile(regex)
def match(target):
target_name = getattr(target, '__name__', '')
result = matcher.match(target_name)
return result
return match | python | def _namematcher(regex):
"""Checks if a target name matches with an input regular expression."""
matcher = re_compile(regex)
def match(target):
target_name = getattr(target, '__name__', '')
result = matcher.match(target_name)
return result
return match | [
"def",
"_namematcher",
"(",
"regex",
")",
":",
"matcher",
"=",
"re_compile",
"(",
"regex",
")",
"def",
"match",
"(",
"target",
")",
":",
"target_name",
"=",
"getattr",
"(",
"target",
",",
"'__name__'",
",",
"''",
")",
"result",
"=",
"matcher",
".",
"ma... | Checks if a target name matches with an input regular expression. | [
"Checks",
"if",
"a",
"target",
"name",
"matches",
"with",
"an",
"input",
"regular",
"expression",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L208-L218 |
b3j0f/aop | b3j0f/aop/advice/core.py | weave | def weave(
target, advices, pointcut=None, ctx=None, depth=1, public=False,
pointcut_application=None, ttl=None
):
"""Weave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on tar... | python | def weave(
target, advices, pointcut=None, ctx=None, depth=1, public=False,
pointcut_application=None, ttl=None
):
"""Weave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on tar... | [
"def",
"weave",
"(",
"target",
",",
"advices",
",",
"pointcut",
"=",
"None",
",",
"ctx",
"=",
"None",
",",
"depth",
"=",
"1",
",",
"public",
"=",
"False",
",",
"pointcut_application",
"=",
"None",
",",
"ttl",
"=",
"None",
")",
":",
"result",
"=",
"... | Weave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on target.
:param ctx: target ctx (class or instance).
:param pointcut: condition for weaving advices on joinpointe.
The conditi... | [
"Weave",
"advices",
"on",
"target",
"with",
"input",
"pointcut",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L234-L313 |
b3j0f/aop | b3j0f/aop/advice/core.py | _weave | def _weave(
target, advices, pointcut, ctx, depth, depth_predicate, intercepted,
pointcut_application
):
"""Weave deeply advices in target.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on target.
:param ctx: ta... | python | def _weave(
target, advices, pointcut, ctx, depth, depth_predicate, intercepted,
pointcut_application
):
"""Weave deeply advices in target.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on target.
:param ctx: ta... | [
"def",
"_weave",
"(",
"target",
",",
"advices",
",",
"pointcut",
",",
"ctx",
",",
"depth",
",",
"depth_predicate",
",",
"intercepted",
",",
"pointcut_application",
")",
":",
"# if weaving has to be done",
"if",
"pointcut",
"is",
"None",
"or",
"pointcut",
"(",
... | Weave deeply advices in target.
:param callable target: target from where checking pointcut and
weaving advices.
:param advices: advices to weave on target.
:param ctx: target ctx (class or instance).
:param pointcut: condition for weaving advices on joinpointe.
The condition depends on... | [
"Weave",
"deeply",
"advices",
"in",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L316-L390 |
b3j0f/aop | b3j0f/aop/advice/core.py | unweave | def unweave(
target, advices=None, pointcut=None, ctx=None, depth=1, public=False,
):
"""Unweave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param pointcut: condition for weaving advices on joinpointe.
The con... | python | def unweave(
target, advices=None, pointcut=None, ctx=None, depth=1, public=False,
):
"""Unweave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param pointcut: condition for weaving advices on joinpointe.
The con... | [
"def",
"unweave",
"(",
"target",
",",
"advices",
"=",
"None",
",",
"pointcut",
"=",
"None",
",",
"ctx",
"=",
"None",
",",
"depth",
"=",
"1",
",",
"public",
"=",
"False",
",",
")",
":",
"# ensure advices is a list if not None",
"if",
"advices",
"is",
"not... | Unweave advices on target with input pointcut.
:param callable target: target from where checking pointcut and
weaving advices.
:param pointcut: condition for weaving advices on joinpointe.
The condition depends on its type.
:type pointcut:
- NoneType: advices are weaved on target.... | [
"Unweave",
"advices",
"on",
"target",
"with",
"input",
"pointcut",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L393-L449 |
b3j0f/aop | b3j0f/aop/advice/core.py | _unweave | def _unweave(target, advices, pointcut, ctx, depth, depth_predicate):
"""Unweave deeply advices in target."""
# if weaving has to be done
if pointcut is None or pointcut(target):
# do something only if target is intercepted
if is_intercepted(target):
_remove_advices(target=targe... | python | def _unweave(target, advices, pointcut, ctx, depth, depth_predicate):
"""Unweave deeply advices in target."""
# if weaving has to be done
if pointcut is None or pointcut(target):
# do something only if target is intercepted
if is_intercepted(target):
_remove_advices(target=targe... | [
"def",
"_unweave",
"(",
"target",
",",
"advices",
",",
"pointcut",
",",
"ctx",
",",
"depth",
",",
"depth_predicate",
")",
":",
"# if weaving has to be done",
"if",
"pointcut",
"is",
"None",
"or",
"pointcut",
"(",
"target",
")",
":",
"# do something only if targe... | Unweave deeply advices in target. | [
"Unweave",
"deeply",
"advices",
"in",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L452-L471 |
b3j0f/aop | b3j0f/aop/advice/core.py | weave_on | def weave_on(advices, pointcut=None, ctx=None, depth=1, ttl=None):
"""Decorator for weaving advices on a callable target.
:param pointcut: condition for weaving advices on joinpointe.
The condition depends on its type.
:param ctx: target ctx (instance or class).
:type pointcut:
- NoneTy... | python | def weave_on(advices, pointcut=None, ctx=None, depth=1, ttl=None):
"""Decorator for weaving advices on a callable target.
:param pointcut: condition for weaving advices on joinpointe.
The condition depends on its type.
:param ctx: target ctx (instance or class).
:type pointcut:
- NoneTy... | [
"def",
"weave_on",
"(",
"advices",
",",
"pointcut",
"=",
"None",
",",
"ctx",
"=",
"None",
",",
"depth",
"=",
"1",
",",
"ttl",
"=",
"None",
")",
":",
"def",
"__weave",
"(",
"target",
")",
":",
"\"\"\"Internal weave function.\"\"\"",
"weave",
"(",
"target"... | Decorator for weaving advices on a callable target.
:param pointcut: condition for weaving advices on joinpointe.
The condition depends on its type.
:param ctx: target ctx (instance or class).
:type pointcut:
- NoneType: advices are weaved on target.
- str: target name is compared t... | [
"Decorator",
"for",
"weaving",
"advices",
"on",
"a",
"callable",
"target",
"."
] | train | https://github.com/b3j0f/aop/blob/22b9ba335d103edd929c25eb6dbb94037d3615bc/b3j0f/aop/advice/core.py#L474-L502 |
jpvanhal/siilo | siilo/storages/filesystem.py | FileSystemStorage._compute_path | def _compute_path(self, name):
"""
Compute the file path in the filesystem from the given name.
:param name: the filename for which the to compute the path
:raises FileNotWithinStorage: if the computed path is not within
:attr:`base_directory`.
"""
path = sel... | python | def _compute_path(self, name):
"""
Compute the file path in the filesystem from the given name.
:param name: the filename for which the to compute the path
:raises FileNotWithinStorage: if the computed path is not within
:attr:`base_directory`.
"""
path = sel... | [
"def",
"_compute_path",
"(",
"self",
",",
"name",
")",
":",
"path",
"=",
"self",
".",
"_normalize_path",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"base_directory",
",",
"name",
")",
")",
"if",
"not",
"path",
".",
"startswith",
"(",
"sel... | Compute the file path in the filesystem from the given name.
:param name: the filename for which the to compute the path
:raises FileNotWithinStorage: if the computed path is not within
:attr:`base_directory`. | [
"Compute",
"the",
"file",
"path",
"in",
"the",
"filesystem",
"from",
"the",
"given",
"name",
"."
] | train | https://github.com/jpvanhal/siilo/blob/1c8600c252be78cbc1fc31fa59eb24163b955857/siilo/storages/filesystem.py#L110-L121 |
radujica/baloo | baloo/weld/weld_group.py | weld_groupby_aggregate_dictmerger | def weld_groupby_aggregate_dictmerger(arrays, weld_types, by_indices, operation):
"""Groups by the columns in by.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Entire DataFrame data.
weld_types : list of WeldType
Corresponding to data.
by_indices : list of... | python | def weld_groupby_aggregate_dictmerger(arrays, weld_types, by_indices, operation):
"""Groups by the columns in by.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Entire DataFrame data.
weld_types : list of WeldType
Corresponding to data.
by_indices : list of... | [
"def",
"weld_groupby_aggregate_dictmerger",
"(",
"arrays",
",",
"weld_types",
",",
"by_indices",
",",
"operation",
")",
":",
"weld_struct",
"=",
"weld_arrays_to_vec_of_struct",
"(",
"arrays",
",",
"weld_types",
")",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object"... | Groups by the columns in by.
Parameters
----------
arrays : list of (numpy.ndarray or WeldObject)
Entire DataFrame data.
weld_types : list of WeldType
Corresponding to data.
by_indices : list of int
Indices of which arrays to group by.
operation : {'+', '*', 'min', 'max'... | [
"Groups",
"by",
"the",
"columns",
"in",
"by",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_group.py#L4-L65 |
radujica/baloo | baloo/weld/weld_group.py | weld_groupby_aggregate | def weld_groupby_aggregate(grouped_df, weld_types, by_indices, aggregation, result_type=None):
"""Perform aggregation on grouped data.
Parameters
----------
grouped_df : WeldObject
DataFrame which has been grouped through weld_groupby.
weld_types : list of WeldType
Corresponding to ... | python | def weld_groupby_aggregate(grouped_df, weld_types, by_indices, aggregation, result_type=None):
"""Perform aggregation on grouped data.
Parameters
----------
grouped_df : WeldObject
DataFrame which has been grouped through weld_groupby.
weld_types : list of WeldType
Corresponding to ... | [
"def",
"weld_groupby_aggregate",
"(",
"grouped_df",
",",
"weld_types",
",",
"by_indices",
",",
"aggregation",
",",
"result_type",
"=",
"None",
")",
":",
"obj_id",
",",
"weld_obj",
"=",
"create_weld_object",
"(",
"grouped_df",
")",
"all_indices",
"=",
"list",
"("... | Perform aggregation on grouped data.
Parameters
----------
grouped_df : WeldObject
DataFrame which has been grouped through weld_groupby.
weld_types : list of WeldType
Corresponding to data.
by_indices : list of int
Indices of which arrays to group by.
aggregation : {'+'... | [
"Perform",
"aggregation",
"on",
"grouped",
"data",
"."
] | train | https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_group.py#L219-L284 |
jlmadurga/yowsup-celery | yowsup_celery/stack.py | YowsupStack.asynloop | def asynloop(self, auto_connect=False, timeout=10, detached_delay=0.2):
"""
Non-blocking event loop consuming messages until connection is lost,
or shutdown is requested.
:param int timeout: number of secs for asyncore timeout
:param float detached_delay: float secs to sleep w... | python | def asynloop(self, auto_connect=False, timeout=10, detached_delay=0.2):
"""
Non-blocking event loop consuming messages until connection is lost,
or shutdown is requested.
:param int timeout: number of secs for asyncore timeout
:param float detached_delay: float secs to sleep w... | [
"def",
"asynloop",
"(",
"self",
",",
"auto_connect",
"=",
"False",
",",
"timeout",
"=",
"10",
",",
"detached_delay",
"=",
"0.2",
")",
":",
"if",
"auto_connect",
":",
"self",
".",
"broadcastEvent",
"(",
"YowLayerEvent",
"(",
"YowNetworkLayer",
".",
"EVENT_STA... | Non-blocking event loop consuming messages until connection is lost,
or shutdown is requested.
:param int timeout: number of secs for asyncore timeout
:param float detached_delay: float secs to sleep when exiting asyncore loop and execution detached queue
callbacks | [
"Non",
"-",
"blocking",
"event",
"loop",
"consuming",
"messages",
"until",
"connection",
"is",
"lost",
"or",
"shutdown",
"is",
"requested",
".",
":",
"param",
"int",
"timeout",
":",
"number",
"of",
"secs",
"for",
"asyncore",
"timeout",
":",
"param",
"float",... | train | https://github.com/jlmadurga/yowsup-celery/blob/f694950e5746ec9a6bf7d88ff5a68c71652a50ae/yowsup_celery/stack.py#L54-L90 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | main | def main(argString=None):
"""Check for duplicated samples in a tfam/tped file.
:param argString: the options
:type argString: list
Here are the steps for the duplicated samples step.
1. Prints the options.
2. Reads the ``tfam`` file (:py:func:`readTFAM`).
3. Separate the duplicated sa... | python | def main(argString=None):
"""Check for duplicated samples in a tfam/tped file.
:param argString: the options
:type argString: list
Here are the steps for the duplicated samples step.
1. Prints the options.
2. Reads the ``tfam`` file (:py:func:`readTFAM`).
3. Separate the duplicated sa... | [
"def",
"main",
"(",
"argString",
"=",
"None",
")",
":",
"# Getting and checking the options",
"args",
"=",
"parseArgs",
"(",
"argString",
")",
"checkArgs",
"(",
"args",
")",
"logger",
".",
"info",
"(",
"\"Options used:\"",
")",
"for",
"key",
",",
"value",
"i... | Check for duplicated samples in a tfam/tped file.
:param argString: the options
:type argString: list
Here are the steps for the duplicated samples step.
1. Prints the options.
2. Reads the ``tfam`` file (:py:func:`readTFAM`).
3. Separate the duplicated samples from the unique samples
... | [
"Check",
"for",
"duplicated",
"samples",
"in",
"a",
"tfam",
"/",
"tped",
"file",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L35-L173 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | addToTPEDandTFAM | def addToTPEDandTFAM(tped, tfam, prefix, toAddPrefix):
"""Append a tfile to another, creating a new one.
:param tped: the ``tped`` that will be appended to the other one.
:param tfam: the ``tfam`` that will be appended to the other one.
:param prefix: the prefix of all the files.
:param toAddPrefix... | python | def addToTPEDandTFAM(tped, tfam, prefix, toAddPrefix):
"""Append a tfile to another, creating a new one.
:param tped: the ``tped`` that will be appended to the other one.
:param tfam: the ``tfam`` that will be appended to the other one.
:param prefix: the prefix of all the files.
:param toAddPrefix... | [
"def",
"addToTPEDandTFAM",
"(",
"tped",
",",
"tfam",
",",
"prefix",
",",
"toAddPrefix",
")",
":",
"# First, writing the chosen tped",
"tpedFile",
"=",
"None",
"try",
":",
"tpedFile",
"=",
"open",
"(",
"prefix",
"+",
"\".chosen_samples.tped\"",
",",
"\"w\"",
")",... | Append a tfile to another, creating a new one.
:param tped: the ``tped`` that will be appended to the other one.
:param tfam: the ``tfam`` that will be appended to the other one.
:param prefix: the prefix of all the files.
:param toAddPrefix: the prefix of the final file.
:type tped: :py:class:`nu... | [
"Append",
"a",
"tfile",
"to",
"another",
"creating",
"a",
"new",
"one",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L176-L264 |
lemieuxl/pyGenClean | pyGenClean/DupSamples/duplicated_samples.py | createAndCleanTPED | def createAndCleanTPED(tped, tfam, samples, oldSamples, chosenSamples,
prefix, completion, completionT, concordance,
concordanceT):
"""Complete a TPED for duplicate samples.
:param tped: the ``tped`` containing the duplicated samples.
:param tfam: the ``tfam`` ... | python | def createAndCleanTPED(tped, tfam, samples, oldSamples, chosenSamples,
prefix, completion, completionT, concordance,
concordanceT):
"""Complete a TPED for duplicate samples.
:param tped: the ``tped`` containing the duplicated samples.
:param tfam: the ``tfam`` ... | [
"def",
"createAndCleanTPED",
"(",
"tped",
",",
"tfam",
",",
"samples",
",",
"oldSamples",
",",
"chosenSamples",
",",
"prefix",
",",
"completion",
",",
"completionT",
",",
"concordance",
",",
"concordanceT",
")",
":",
"zeroedOutFile",
"=",
"None",
"try",
":",
... | Complete a TPED for duplicate samples.
:param tped: the ``tped`` containing the duplicated samples.
:param tfam: the ``tfam`` containing the duplicated samples.
:param samples: the updated position of the samples in the ``tped``
containing only duplicated samples.
:param oldSamples:... | [
"Complete",
"a",
"TPED",
"for",
"duplicate",
"samples",
"."
] | train | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/DupSamples/duplicated_samples.py#L267-L431 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.