repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
bosth/plpygis | plpygis/geometry.py | Geometry.from_shapely | def from_shapely(sgeom, srid=None):
"""
Create a Geometry from a Shapely geometry and the specified SRID.
The Shapely geometry will not be modified.
"""
if SHAPELY:
WKBWriter.defaults["include_srid"] = True
if srid:
lgeos.GEOSSetSRID(sgeom... | python | def from_shapely(sgeom, srid=None):
"""
Create a Geometry from a Shapely geometry and the specified SRID.
The Shapely geometry will not be modified.
"""
if SHAPELY:
WKBWriter.defaults["include_srid"] = True
if srid:
lgeos.GEOSSetSRID(sgeom... | [
"def",
"from_shapely",
"(",
"sgeom",
",",
"srid",
"=",
"None",
")",
":",
"if",
"SHAPELY",
":",
"WKBWriter",
".",
"defaults",
"[",
"\"include_srid\"",
"]",
"=",
"True",
"if",
"srid",
":",
"lgeos",
".",
"GEOSSetSRID",
"(",
"sgeom",
".",
"_geom",
",",
"sr... | Create a Geometry from a Shapely geometry and the specified SRID.
The Shapely geometry will not be modified. | [
"Create",
"a",
"Geometry",
"from",
"a",
"Shapely",
"geometry",
"and",
"the",
"specified",
"SRID",
"."
] | train | https://github.com/bosth/plpygis/blob/9469cc469df4c8cd407de158903d5465cda804ea/plpygis/geometry.py#L105-L117 |
bosth/plpygis | plpygis/geometry.py | Geometry.wkb | def wkb(self):
"""
Get the geometry as an (E)WKB.
"""
return self._to_wkb(use_srid=True, dimz=self.dimz, dimm=self.dimm) | python | def wkb(self):
"""
Get the geometry as an (E)WKB.
"""
return self._to_wkb(use_srid=True, dimz=self.dimz, dimm=self.dimm) | [
"def",
"wkb",
"(",
"self",
")",
":",
"return",
"self",
".",
"_to_wkb",
"(",
"use_srid",
"=",
"True",
",",
"dimz",
"=",
"self",
".",
"dimz",
",",
"dimm",
"=",
"self",
".",
"dimm",
")"
] | Get the geometry as an (E)WKB. | [
"Get",
"the",
"geometry",
"as",
"an",
"(",
"E",
")",
"WKB",
"."
] | train | https://github.com/bosth/plpygis/blob/9469cc469df4c8cd407de158903d5465cda804ea/plpygis/geometry.py#L154-L158 |
bosth/plpygis | plpygis/geometry.py | Geometry.postgis_type | def postgis_type(self):
"""
Get the type of the geometry in PostGIS format, including additional
dimensions and SRID if they exist.
"""
dimz = "Z" if self.dimz else ""
dimm = "M" if self.dimm else ""
if self.srid:
return "geometry({}{}{},{})".format(se... | python | def postgis_type(self):
"""
Get the type of the geometry in PostGIS format, including additional
dimensions and SRID if they exist.
"""
dimz = "Z" if self.dimz else ""
dimm = "M" if self.dimm else ""
if self.srid:
return "geometry({}{}{},{})".format(se... | [
"def",
"postgis_type",
"(",
"self",
")",
":",
"dimz",
"=",
"\"Z\"",
"if",
"self",
".",
"dimz",
"else",
"\"\"",
"dimm",
"=",
"\"M\"",
"if",
"self",
".",
"dimm",
"else",
"\"\"",
"if",
"self",
".",
"srid",
":",
"return",
"\"geometry({}{}{},{})\"",
".",
"f... | Get the type of the geometry in PostGIS format, including additional
dimensions and SRID if they exist. | [
"Get",
"the",
"type",
"of",
"the",
"geometry",
"in",
"PostGIS",
"format",
"including",
"additional",
"dimensions",
"and",
"SRID",
"if",
"they",
"exist",
"."
] | train | https://github.com/bosth/plpygis/blob/9469cc469df4c8cd407de158903d5465cda804ea/plpygis/geometry.py#L177-L187 |
yjzhang/uncurl_python | uncurl/pois_ll.py | poisson_ll | def poisson_ll(data, means):
"""
Calculates the Poisson log-likelihood.
Args:
data (array): 2d numpy array of genes x cells
means (array): 2d numpy array of genes x k
Returns:
cells x k array of log-likelihood for each cell/cluster pair
"""
if sparse.issparse(data):
... | python | def poisson_ll(data, means):
"""
Calculates the Poisson log-likelihood.
Args:
data (array): 2d numpy array of genes x cells
means (array): 2d numpy array of genes x k
Returns:
cells x k array of log-likelihood for each cell/cluster pair
"""
if sparse.issparse(data):
... | [
"def",
"poisson_ll",
"(",
"data",
",",
"means",
")",
":",
"if",
"sparse",
".",
"issparse",
"(",
"data",
")",
":",
"return",
"sparse_poisson_ll",
"(",
"data",
",",
"means",
")",
"genes",
",",
"cells",
"=",
"data",
".",
"shape",
"clusters",
"=",
"means",... | Calculates the Poisson log-likelihood.
Args:
data (array): 2d numpy array of genes x cells
means (array): 2d numpy array of genes x k
Returns:
cells x k array of log-likelihood for each cell/cluster pair | [
"Calculates",
"the",
"Poisson",
"log",
"-",
"likelihood",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/pois_ll.py#L22-L43 |
yjzhang/uncurl_python | uncurl/pois_ll.py | poisson_ll_2 | def poisson_ll_2(p1, p2):
"""
Calculates Poisson LL(p1|p2).
"""
p1_1 = p1 + eps
p2_1 = p2 + eps
return np.sum(-p2_1 + p1_1*np.log(p2_1)) | python | def poisson_ll_2(p1, p2):
"""
Calculates Poisson LL(p1|p2).
"""
p1_1 = p1 + eps
p2_1 = p2 + eps
return np.sum(-p2_1 + p1_1*np.log(p2_1)) | [
"def",
"poisson_ll_2",
"(",
"p1",
",",
"p2",
")",
":",
"p1_1",
"=",
"p1",
"+",
"eps",
"p2_1",
"=",
"p2",
"+",
"eps",
"return",
"np",
".",
"sum",
"(",
"-",
"p2_1",
"+",
"p1_1",
"*",
"np",
".",
"log",
"(",
"p2_1",
")",
")"
] | Calculates Poisson LL(p1|p2). | [
"Calculates",
"Poisson",
"LL",
"(",
"p1|p2",
")",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/pois_ll.py#L45-L51 |
yjzhang/uncurl_python | uncurl/pois_ll.py | poisson_dist | def poisson_dist(p1, p2):
"""
Calculates the Poisson distance between two vectors.
p1 can be a sparse matrix, while p2 has to be a dense matrix.
"""
# ugh...
p1_ = p1 + eps
p2_ = p2 + eps
return np.dot(p1_-p2_, np.log(p1_/p2_)) | python | def poisson_dist(p1, p2):
"""
Calculates the Poisson distance between two vectors.
p1 can be a sparse matrix, while p2 has to be a dense matrix.
"""
# ugh...
p1_ = p1 + eps
p2_ = p2 + eps
return np.dot(p1_-p2_, np.log(p1_/p2_)) | [
"def",
"poisson_dist",
"(",
"p1",
",",
"p2",
")",
":",
"# ugh...",
"p1_",
"=",
"p1",
"+",
"eps",
"p2_",
"=",
"p2",
"+",
"eps",
"return",
"np",
".",
"dot",
"(",
"p1_",
"-",
"p2_",
",",
"np",
".",
"log",
"(",
"p1_",
"/",
"p2_",
")",
")"
] | Calculates the Poisson distance between two vectors.
p1 can be a sparse matrix, while p2 has to be a dense matrix. | [
"Calculates",
"the",
"Poisson",
"distance",
"between",
"two",
"vectors",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/pois_ll.py#L53-L62 |
moonso/loqusdb | loqusdb/commands/delete.py | delete | def delete(ctx, family_file, family_type, case_id):
"""Delete the variants of a case."""
if not (family_file or case_id):
LOG.error("Please provide a family file")
ctx.abort()
adapter = ctx.obj['adapter']
# Get a ped_parser.Family object from family file
family = None
family_id... | python | def delete(ctx, family_file, family_type, case_id):
"""Delete the variants of a case."""
if not (family_file or case_id):
LOG.error("Please provide a family file")
ctx.abort()
adapter = ctx.obj['adapter']
# Get a ped_parser.Family object from family file
family = None
family_id... | [
"def",
"delete",
"(",
"ctx",
",",
"family_file",
",",
"family_type",
",",
"case_id",
")",
":",
"if",
"not",
"(",
"family_file",
"or",
"case_id",
")",
":",
"LOG",
".",
"error",
"(",
"\"Please provide a family file\"",
")",
"ctx",
".",
"abort",
"(",
")",
"... | Delete the variants of a case. | [
"Delete",
"the",
"variants",
"of",
"a",
"case",
"."
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/delete.py#L28-L68 |
markperdue/pyvesync | src/pyvesync/vesyncoutlet.py | VeSyncOutlet.update_energy | def update_energy(self, bypass_check: bool = False):
"""Builds weekly, monthly and yearly dictionaries"""
if bypass_check or (not bypass_check and self.update_time_check):
self.get_weekly_energy()
if 'week' in self.energy:
self.get_monthly_energy()
... | python | def update_energy(self, bypass_check: bool = False):
"""Builds weekly, monthly and yearly dictionaries"""
if bypass_check or (not bypass_check and self.update_time_check):
self.get_weekly_energy()
if 'week' in self.energy:
self.get_monthly_energy()
... | [
"def",
"update_energy",
"(",
"self",
",",
"bypass_check",
":",
"bool",
"=",
"False",
")",
":",
"if",
"bypass_check",
"or",
"(",
"not",
"bypass_check",
"and",
"self",
".",
"update_time_check",
")",
":",
"self",
".",
"get_weekly_energy",
"(",
")",
"if",
"'we... | Builds weekly, monthly and yearly dictionaries | [
"Builds",
"weekly",
"monthly",
"and",
"yearly",
"dictionaries"
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesyncoutlet.py#L61-L69 |
markperdue/pyvesync | src/pyvesync/vesyncoutlet.py | VeSyncOutlet15A.turn_on_nightlight | def turn_on_nightlight(self):
"""Turn on nightlight"""
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
body['mode'] = 'auto'
response, _ = helpers.call_api(
'/15a/v1/device/nightlightstatus',
'put',
headers=helpe... | python | def turn_on_nightlight(self):
"""Turn on nightlight"""
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
body['mode'] = 'auto'
response, _ = helpers.call_api(
'/15a/v1/device/nightlightstatus',
'put',
headers=helpe... | [
"def",
"turn_on_nightlight",
"(",
"self",
")",
":",
"body",
"=",
"helpers",
".",
"req_body",
"(",
"self",
".",
"manager",
",",
"'devicestatus'",
")",
"body",
"[",
"'uuid'",
"]",
"=",
"self",
".",
"uuid",
"body",
"[",
"'mode'",
"]",
"=",
"'auto'",
"resp... | Turn on nightlight | [
"Turn",
"on",
"nightlight"
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesyncoutlet.py#L441-L454 |
fbergmann/libSEDML | examples/python/echo_sedml.py | main | def main (args):
"""Usage: echo_sedml input-filename output-filename
"""
if len(args) != 3:
print(main.__doc__)
sys.exit(1)
d = libsedml.readSedML(args[1]);
if ( d.getErrorLog().getNumFailsWithSeverity(libsedml.LIBSEDML_SEV_ERROR) > 0):
print (d.getErrorLog().toString());
else:
libsedml.wri... | python | def main (args):
"""Usage: echo_sedml input-filename output-filename
"""
if len(args) != 3:
print(main.__doc__)
sys.exit(1)
d = libsedml.readSedML(args[1]);
if ( d.getErrorLog().getNumFailsWithSeverity(libsedml.LIBSEDML_SEV_ERROR) > 0):
print (d.getErrorLog().toString());
else:
libsedml.wri... | [
"def",
"main",
"(",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"!=",
"3",
":",
"print",
"(",
"main",
".",
"__doc__",
")",
"sys",
".",
"exit",
"(",
"1",
")",
"d",
"=",
"libsedml",
".",
"readSedML",
"(",
"args",
"[",
"1",
"]",
")",
"if",
... | Usage: echo_sedml input-filename output-filename | [
"Usage",
":",
"echo_sedml",
"input",
"-",
"filename",
"output",
"-",
"filename"
] | train | https://github.com/fbergmann/libSEDML/blob/2611274d993cb92c663f8f0296896a6e441f75fd/examples/python/echo_sedml.py#L40-L53 |
bachya/py17track | example.py | main | async def main() -> None:
"""Create the aiohttp session and run the example."""
logging.basicConfig(level=logging.INFO)
async with ClientSession() as websession:
try:
client = Client(websession)
await client.profile.login('<EMAIL>', '<PASSWORD>')
_LOGGER.info('A... | python | async def main() -> None:
"""Create the aiohttp session and run the example."""
logging.basicConfig(level=logging.INFO)
async with ClientSession() as websession:
try:
client = Client(websession)
await client.profile.login('<EMAIL>', '<PASSWORD>')
_LOGGER.info('A... | [
"async",
"def",
"main",
"(",
")",
"->",
"None",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
")",
"async",
"with",
"ClientSession",
"(",
")",
"as",
"websession",
":",
"try",
":",
"client",
"=",
"Client",
"(",
"websessi... | Create the aiohttp session and run the example. | [
"Create",
"the",
"aiohttp",
"session",
"and",
"run",
"the",
"example",
"."
] | train | https://github.com/bachya/py17track/blob/e6e64f2a79571433df7ee702cb4ebc4127b7ad6d/example.py#L13-L30 |
johncosta/django-like-button | like_button/templatetags/like_button.py | my_import | def my_import(name):
""" dynamic importing """
module, attr = name.rsplit('.', 1)
mod = __import__(module, fromlist=[attr])
klass = getattr(mod, attr)
return klass() | python | def my_import(name):
""" dynamic importing """
module, attr = name.rsplit('.', 1)
mod = __import__(module, fromlist=[attr])
klass = getattr(mod, attr)
return klass() | [
"def",
"my_import",
"(",
"name",
")",
":",
"module",
",",
"attr",
"=",
"name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"mod",
"=",
"__import__",
"(",
"module",
",",
"fromlist",
"=",
"[",
"attr",
"]",
")",
"klass",
"=",
"getattr",
"(",
"mod",
",... | dynamic importing | [
"dynamic",
"importing"
] | train | https://github.com/johncosta/django-like-button/blob/c93a1be9c041d76e8de9a26f424ad4f836ab97bd/like_button/templatetags/like_button.py#L20-L25 |
johncosta/django-like-button | like_button/templatetags/like_button.py | like_button_js_tag | def like_button_js_tag(context):
""" This tag will check to see if they have the FACEBOOK_LIKE_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then... | python | def like_button_js_tag(context):
""" This tag will check to see if they have the FACEBOOK_LIKE_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then... | [
"def",
"like_button_js_tag",
"(",
"context",
")",
":",
"if",
"FACEBOOK_APP_ID",
"is",
"None",
":",
"log",
".",
"warning",
"(",
"\"FACEBOOK_APP_ID isn't setup correctly in your settings\"",
")",
"# make sure FACEBOOK_APP_ID is setup correct and user is authenticated",
"if",
"FAC... | This tag will check to see if they have the FACEBOOK_LIKE_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then not
install the javascript since... | [
"This",
"tag",
"will",
"check",
"to",
"see",
"if",
"they",
"have",
"the",
"FACEBOOK_LIKE_APP_ID",
"setup",
"correctly",
"in",
"the",
"django",
"settings",
"if",
"so",
"then",
"it",
"will",
"pass",
"the",
"data",
"along",
"to",
"the",
"intercom_tag",
"templat... | train | https://github.com/johncosta/django-like-button/blob/c93a1be9c041d76e8de9a26f424ad4f836ab97bd/like_button/templatetags/like_button.py#L34-L55 |
johncosta/django-like-button | like_button/templatetags/like_button.py | like_button_tag | def like_button_tag(context):
""" This tag will check to see if they have the FACEBOOK_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then not
... | python | def like_button_tag(context):
""" This tag will check to see if they have the FACEBOOK_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then not
... | [
"def",
"like_button_tag",
"(",
"context",
")",
":",
"if",
"FACEBOOK_APP_ID",
"is",
"None",
":",
"log",
".",
"warning",
"(",
"\"FACEBOOK_APP_ID isn't setup correctly in your settings\"",
")",
"# make sure INTERCOM_APPID is setup correct and user is authenticated",
"if",
"FACEBOO... | This tag will check to see if they have the FACEBOOK_APP_ID setup
correctly in the django settings, if so then it will pass the data
along to the intercom_tag template to be displayed.
If something isn't perfect we will return False, which will then not
install the javascript since it i... | [
"This",
"tag",
"will",
"check",
"to",
"see",
"if",
"they",
"have",
"the",
"FACEBOOK_APP_ID",
"setup",
"correctly",
"in",
"the",
"django",
"settings",
"if",
"so",
"then",
"it",
"will",
"pass",
"the",
"data",
"along",
"to",
"the",
"intercom_tag",
"template",
... | train | https://github.com/johncosta/django-like-button/blob/c93a1be9c041d76e8de9a26f424ad4f836ab97bd/like_button/templatetags/like_button.py#L59-L94 |
moonso/loqusdb | loqusdb/plugins/mongo/structural_variant.py | SVMixin.add_structural_variant | def add_structural_variant(self, variant, max_window = 3000):
"""Add a variant to the structural variants collection
The process of adding an SV variant differs quite a bit from the
more straight forward case of SNV/INDEL.
Variants are represented in the database by cl... | python | def add_structural_variant(self, variant, max_window = 3000):
"""Add a variant to the structural variants collection
The process of adding an SV variant differs quite a bit from the
more straight forward case of SNV/INDEL.
Variants are represented in the database by cl... | [
"def",
"add_structural_variant",
"(",
"self",
",",
"variant",
",",
"max_window",
"=",
"3000",
")",
":",
"# This will return the cluster most similar to variant or None",
"cluster",
"=",
"self",
".",
"get_structural_variant",
"(",
"variant",
")",
"# If there was no matcing c... | Add a variant to the structural variants collection
The process of adding an SV variant differs quite a bit from the
more straight forward case of SNV/INDEL.
Variants are represented in the database by clusters that are two intervals,
one interval for start(pos) and on... | [
"Add",
"a",
"variant",
"to",
"the",
"structural",
"variants",
"collection",
"The",
"process",
"of",
"adding",
"an",
"SV",
"variant",
"differs",
"quite",
"a",
"bit",
"from",
"the",
"more",
"straight",
"forward",
"case",
"of",
"SNV",
"/",
"INDEL",
".",
"Vari... | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/structural_variant.py#L14-L143 |
moonso/loqusdb | loqusdb/plugins/mongo/structural_variant.py | SVMixin.get_structural_variant | def get_structural_variant(self, variant):
"""Check if there are any overlapping sv clusters
Search the sv variants with chrom start end_chrom end and sv_type
Args:
variant (dict): A variant dictionary
Returns:
variant (dict): A variant dictionary
"""
... | python | def get_structural_variant(self, variant):
"""Check if there are any overlapping sv clusters
Search the sv variants with chrom start end_chrom end and sv_type
Args:
variant (dict): A variant dictionary
Returns:
variant (dict): A variant dictionary
"""
... | [
"def",
"get_structural_variant",
"(",
"self",
",",
"variant",
")",
":",
"# Create a query for the database",
"# This will include more variants than we want",
"# The rest of the calculations will be done in python",
"query",
"=",
"{",
"'chrom'",
":",
"variant",
"[",
"'chrom'",
... | Check if there are any overlapping sv clusters
Search the sv variants with chrom start end_chrom end and sv_type
Args:
variant (dict): A variant dictionary
Returns:
variant (dict): A variant dictionary | [
"Check",
"if",
"there",
"are",
"any",
"overlapping",
"sv",
"clusters"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/structural_variant.py#L145-L202 |
moonso/loqusdb | loqusdb/plugins/mongo/structural_variant.py | SVMixin.get_sv_variants | def get_sv_variants(self, chromosome=None, end_chromosome=None, sv_type=None,
pos=None, end=None):
"""Return all structural variants in the database
Args:
chromosome (str)
end_chromosome (str)
sv_type (str)
pos (int): Left positio... | python | def get_sv_variants(self, chromosome=None, end_chromosome=None, sv_type=None,
pos=None, end=None):
"""Return all structural variants in the database
Args:
chromosome (str)
end_chromosome (str)
sv_type (str)
pos (int): Left positio... | [
"def",
"get_sv_variants",
"(",
"self",
",",
"chromosome",
"=",
"None",
",",
"end_chromosome",
"=",
"None",
",",
"sv_type",
"=",
"None",
",",
"pos",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"query",
"=",
"{",
"}",
"if",
"chromosome",
":",
"quer... | Return all structural variants in the database
Args:
chromosome (str)
end_chromosome (str)
sv_type (str)
pos (int): Left position of SV
end (int): Right position of SV
Returns:
variants (Iterable(Variant)) | [
"Return",
"all",
"structural",
"variants",
"in",
"the",
"database"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/structural_variant.py#L204-L240 |
moonso/loqusdb | loqusdb/plugins/mongo/structural_variant.py | SVMixin.get_clusters | def get_clusters(self, variant_id):
"""Search what clusters a variant belongs to
Args:
variant_id(str): From ID column in vcf
Returns:
clusters()
"""
query = {'variant_id':variant_id}
identities = self.db.identity.find(query)
... | python | def get_clusters(self, variant_id):
"""Search what clusters a variant belongs to
Args:
variant_id(str): From ID column in vcf
Returns:
clusters()
"""
query = {'variant_id':variant_id}
identities = self.db.identity.find(query)
... | [
"def",
"get_clusters",
"(",
"self",
",",
"variant_id",
")",
":",
"query",
"=",
"{",
"'variant_id'",
":",
"variant_id",
"}",
"identities",
"=",
"self",
".",
"db",
".",
"identity",
".",
"find",
"(",
"query",
")",
"return",
"identities"
] | Search what clusters a variant belongs to
Args:
variant_id(str): From ID column in vcf
Returns:
clusters() | [
"Search",
"what",
"clusters",
"a",
"variant",
"belongs",
"to",
"Args",
":",
"variant_id",
"(",
"str",
")",
":",
"From",
"ID",
"column",
"in",
"vcf",
"Returns",
":",
"clusters",
"()"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/structural_variant.py#L242-L253 |
yjzhang/uncurl_python | uncurl/run_se.py | run_state_estimation | def run_state_estimation(data, clusters, dist='Poiss', reps=1, **kwargs):
"""
Runs state estimation for multiple initializations, returning the result with the highest log-likelihood. All the arguments are passed to the underlying state estimation functions (poisson_estimate_state, nb_estimate_state, zip_estima... | python | def run_state_estimation(data, clusters, dist='Poiss', reps=1, **kwargs):
"""
Runs state estimation for multiple initializations, returning the result with the highest log-likelihood. All the arguments are passed to the underlying state estimation functions (poisson_estimate_state, nb_estimate_state, zip_estima... | [
"def",
"run_state_estimation",
"(",
"data",
",",
"clusters",
",",
"dist",
"=",
"'Poiss'",
",",
"reps",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"clusters",
"=",
"int",
"(",
"clusters",
")",
"func",
"=",
"poisson_estimate_state",
"dist",
"=",
"dist",
... | Runs state estimation for multiple initializations, returning the result with the highest log-likelihood. All the arguments are passed to the underlying state estimation functions (poisson_estimate_state, nb_estimate_state, zip_estimate_state).
Args:
data (array): genes x cells
clusters (int): numb... | [
"Runs",
"state",
"estimation",
"for",
"multiple",
"initializations",
"returning",
"the",
"result",
"with",
"the",
"highest",
"log",
"-",
"likelihood",
".",
"All",
"the",
"arguments",
"are",
"passed",
"to",
"the",
"underlying",
"state",
"estimation",
"functions",
... | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/run_se.py#L11-L64 |
markperdue/pyvesync | src/pyvesync/vesyncfan.py | VeSyncAir131.get_details | def get_details(self):
"""Build details dictionary"""
body = helpers.req_body(self.manager, 'devicedetail')
head = helpers.req_headers(self.manager)
r, _ = helpers.call_api('/131airpurifier/v1/device/deviceDetail',
method='post', headers=head, json=body)
... | python | def get_details(self):
"""Build details dictionary"""
body = helpers.req_body(self.manager, 'devicedetail')
head = helpers.req_headers(self.manager)
r, _ = helpers.call_api('/131airpurifier/v1/device/deviceDetail',
method='post', headers=head, json=body)
... | [
"def",
"get_details",
"(",
"self",
")",
":",
"body",
"=",
"helpers",
".",
"req_body",
"(",
"self",
".",
"manager",
",",
"'devicedetail'",
")",
"head",
"=",
"helpers",
".",
"req_headers",
"(",
"self",
".",
"manager",
")",
"r",
",",
"_",
"=",
"helpers",
... | Build details dictionary | [
"Build",
"details",
"dictionary"
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesyncfan.py#L17-L32 |
markperdue/pyvesync | src/pyvesync/vesyncfan.py | VeSyncAir131.turn_on | def turn_on(self):
"""Turn Air Purifier on"""
if self.device_status != 'on':
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
body['status'] = 'on'
head = helpers.req_headers(self.manager)
r, _ = helpers.call_api(... | python | def turn_on(self):
"""Turn Air Purifier on"""
if self.device_status != 'on':
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
body['status'] = 'on'
head = helpers.req_headers(self.manager)
r, _ = helpers.call_api(... | [
"def",
"turn_on",
"(",
"self",
")",
":",
"if",
"self",
".",
"device_status",
"!=",
"'on'",
":",
"body",
"=",
"helpers",
".",
"req_body",
"(",
"self",
".",
"manager",
",",
"'devicestatus'",
")",
"body",
"[",
"'uuid'",
"]",
"=",
"self",
".",
"uuid",
"b... | Turn Air Purifier on | [
"Turn",
"Air",
"Purifier",
"on"
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesyncfan.py#L44-L59 |
markperdue/pyvesync | src/pyvesync/vesyncfan.py | VeSyncAir131.fan_speed | def fan_speed(self, speed: int = None) -> bool:
"""Adjust Fan Speed by Specifying 1,2,3 as argument or cycle
through speeds increasing by one"""
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
head = helpers.req_headers(self.manager)
if ... | python | def fan_speed(self, speed: int = None) -> bool:
"""Adjust Fan Speed by Specifying 1,2,3 as argument or cycle
through speeds increasing by one"""
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
head = helpers.req_headers(self.manager)
if ... | [
"def",
"fan_speed",
"(",
"self",
",",
"speed",
":",
"int",
"=",
"None",
")",
"->",
"bool",
":",
"body",
"=",
"helpers",
".",
"req_body",
"(",
"self",
".",
"manager",
",",
"'devicestatus'",
")",
"body",
"[",
"'uuid'",
"]",
"=",
"self",
".",
"uuid",
... | Adjust Fan Speed by Specifying 1,2,3 as argument or cycle
through speeds increasing by one | [
"Adjust",
"Fan",
"Speed",
"by",
"Specifying",
"1",
"2",
"3",
"as",
"argument",
"or",
"cycle",
"through",
"speeds",
"increasing",
"by",
"one"
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesyncfan.py#L90-L118 |
markperdue/pyvesync | src/pyvesync/vesyncfan.py | VeSyncAir131.mode_toggle | def mode_toggle(self, mode: str) -> bool:
"""Set mode to manual, auto or sleep"""
head = helpers.req_headers(self.manager)
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
if mode != body['mode'] and mode in ['sleep', 'auto', 'manual']:
b... | python | def mode_toggle(self, mode: str) -> bool:
"""Set mode to manual, auto or sleep"""
head = helpers.req_headers(self.manager)
body = helpers.req_body(self.manager, 'devicestatus')
body['uuid'] = self.uuid
if mode != body['mode'] and mode in ['sleep', 'auto', 'manual']:
b... | [
"def",
"mode_toggle",
"(",
"self",
",",
"mode",
":",
"str",
")",
"->",
"bool",
":",
"head",
"=",
"helpers",
".",
"req_headers",
"(",
"self",
".",
"manager",
")",
"body",
"=",
"helpers",
".",
"req_body",
"(",
"self",
".",
"manager",
",",
"'devicestatus'... | Set mode to manual, auto or sleep | [
"Set",
"mode",
"to",
"manual",
"auto",
"or",
"sleep"
] | train | https://github.com/markperdue/pyvesync/blob/7552dd1a6dd5ebc452acf78e33fd8f6e721e8cfc/src/pyvesync/vesyncfan.py#L120-L137 |
yjzhang/uncurl_python | uncurl/lineage.py | fourier_series | def fourier_series(x, *a):
"""
Arbitrary dimensionality fourier series.
The first parameter is a_0, and the second parameter is the interval/scale
parameter.
The parameters are altering sin and cos paramters.
n = (len(a)-2)/2
"""
output = 0
output += a[0]/2
w = a[1]
for n ... | python | def fourier_series(x, *a):
"""
Arbitrary dimensionality fourier series.
The first parameter is a_0, and the second parameter is the interval/scale
parameter.
The parameters are altering sin and cos paramters.
n = (len(a)-2)/2
"""
output = 0
output += a[0]/2
w = a[1]
for n ... | [
"def",
"fourier_series",
"(",
"x",
",",
"*",
"a",
")",
":",
"output",
"=",
"0",
"output",
"+=",
"a",
"[",
"0",
"]",
"/",
"2",
"w",
"=",
"a",
"[",
"1",
"]",
"for",
"n",
"in",
"range",
"(",
"2",
",",
"len",
"(",
"a",
")",
",",
"2",
")",
"... | Arbitrary dimensionality fourier series.
The first parameter is a_0, and the second parameter is the interval/scale
parameter.
The parameters are altering sin and cos paramters.
n = (len(a)-2)/2 | [
"Arbitrary",
"dimensionality",
"fourier",
"series",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/lineage.py#L10-L30 |
yjzhang/uncurl_python | uncurl/lineage.py | graph_distances | def graph_distances(start, edges, distances):
"""
Given an undirected adjacency list and a pairwise distance matrix between
all nodes: calculates distances along graph from start node.
Args:
start (int): start node
edges (list): adjacency list of tuples
distances (array): 2d arr... | python | def graph_distances(start, edges, distances):
"""
Given an undirected adjacency list and a pairwise distance matrix between
all nodes: calculates distances along graph from start node.
Args:
start (int): start node
edges (list): adjacency list of tuples
distances (array): 2d arr... | [
"def",
"graph_distances",
"(",
"start",
",",
"edges",
",",
"distances",
")",
":",
"# convert adjacency list to adjacency dict",
"adj",
"=",
"{",
"x",
":",
"[",
"]",
"for",
"x",
"in",
"range",
"(",
"len",
"(",
"distances",
")",
")",
"}",
"for",
"n1",
",",... | Given an undirected adjacency list and a pairwise distance matrix between
all nodes: calculates distances along graph from start node.
Args:
start (int): start node
edges (list): adjacency list of tuples
distances (array): 2d array of distances between nodes
Returns:
dict o... | [
"Given",
"an",
"undirected",
"adjacency",
"list",
"and",
"a",
"pairwise",
"distance",
"matrix",
"between",
"all",
"nodes",
":",
"calculates",
"distances",
"along",
"graph",
"from",
"start",
"node",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/lineage.py#L32-L62 |
yjzhang/uncurl_python | uncurl/lineage.py | poly_curve | def poly_curve(x, *a):
"""
Arbitrary dimension polynomial.
"""
output = 0.0
for n in range(0, len(a)):
output += a[n]*x**n
return output | python | def poly_curve(x, *a):
"""
Arbitrary dimension polynomial.
"""
output = 0.0
for n in range(0, len(a)):
output += a[n]*x**n
return output | [
"def",
"poly_curve",
"(",
"x",
",",
"*",
"a",
")",
":",
"output",
"=",
"0.0",
"for",
"n",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"a",
")",
")",
":",
"output",
"+=",
"a",
"[",
"n",
"]",
"*",
"x",
"**",
"n",
"return",
"output"
] | Arbitrary dimension polynomial. | [
"Arbitrary",
"dimension",
"polynomial",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/lineage.py#L65-L72 |
yjzhang/uncurl_python | uncurl/lineage.py | run_lineage | def run_lineage(means, weights, curve_function='poly', curve_dimensions=6):
"""
Lineage graph produced by minimum spanning tree
Args:
means (array): genes x clusters - output of state estimation
weights (array): clusters x cells - output of state estimation
curve_function (string): ... | python | def run_lineage(means, weights, curve_function='poly', curve_dimensions=6):
"""
Lineage graph produced by minimum spanning tree
Args:
means (array): genes x clusters - output of state estimation
weights (array): clusters x cells - output of state estimation
curve_function (string): ... | [
"def",
"run_lineage",
"(",
"means",
",",
"weights",
",",
"curve_function",
"=",
"'poly'",
",",
"curve_dimensions",
"=",
"6",
")",
":",
"if",
"curve_function",
"==",
"'poly'",
":",
"func",
"=",
"poly_curve",
"elif",
"curve_function",
"==",
"'fourier'",
":",
"... | Lineage graph produced by minimum spanning tree
Args:
means (array): genes x clusters - output of state estimation
weights (array): clusters x cells - output of state estimation
curve_function (string): either 'poly' or 'fourier'. Default: 'poly'
curve_dimensions (int): number of pa... | [
"Lineage",
"graph",
"produced",
"by",
"minimum",
"spanning",
"tree"
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/lineage.py#L75-L193 |
yjzhang/uncurl_python | uncurl/lineage.py | pseudotime | def pseudotime(starting_node, edges, fitted_vals):
"""
Args:
starting_node (int): index of the starting node
edges (list): list of tuples (node1, node2)
fitted_vals (array): output of lineage (2 x cells)
Returns:
A 1d array containing the pseudotime value of each cell.
"... | python | def pseudotime(starting_node, edges, fitted_vals):
"""
Args:
starting_node (int): index of the starting node
edges (list): list of tuples (node1, node2)
fitted_vals (array): output of lineage (2 x cells)
Returns:
A 1d array containing the pseudotime value of each cell.
"... | [
"def",
"pseudotime",
"(",
"starting_node",
",",
"edges",
",",
"fitted_vals",
")",
":",
"# TODO",
"# 1. calculate a distance matrix...",
"distances",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"sum",
"(",
"(",
"x",
"-",
"y",
")",
"**",
"2",
")",
"for",
"x",
... | Args:
starting_node (int): index of the starting node
edges (list): list of tuples (node1, node2)
fitted_vals (array): output of lineage (2 x cells)
Returns:
A 1d array containing the pseudotime value of each cell. | [
"Args",
":",
"starting_node",
"(",
"int",
")",
":",
"index",
"of",
"the",
"starting",
"node",
"edges",
"(",
"list",
")",
":",
"list",
"of",
"tuples",
"(",
"node1",
"node2",
")",
"fitted_vals",
"(",
"array",
")",
":",
"output",
"of",
"lineage",
"(",
"... | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/lineage.py#L195-L213 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country._add_countriesdata | def _add_countriesdata(cls, iso3, country):
# type: (str, hxl.Row) -> None
"""
Set up countries data from data in form provided by UNStats and World Bank
Args:
iso3 (str): ISO3 code for country
country (hxl.Row): Country information
Returns:
... | python | def _add_countriesdata(cls, iso3, country):
# type: (str, hxl.Row) -> None
"""
Set up countries data from data in form provided by UNStats and World Bank
Args:
iso3 (str): ISO3 code for country
country (hxl.Row): Country information
Returns:
... | [
"def",
"_add_countriesdata",
"(",
"cls",
",",
"iso3",
",",
"country",
")",
":",
"# type: (str, hxl.Row) -> None",
"countryname",
"=",
"country",
".",
"get",
"(",
"'#country+name+preferred'",
")",
"cls",
".",
"_countriesdata",
"[",
"'countrynames2iso3'",
"]",
"[",
... | Set up countries data from data in form provided by UNStats and World Bank
Args:
iso3 (str): ISO3 code for country
country (hxl.Row): Country information
Returns:
None | [
"Set",
"up",
"countries",
"data",
"from",
"data",
"in",
"form",
"provided",
"by",
"UNStats",
"and",
"World",
"Bank"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L45-L104 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.set_countriesdata | def set_countriesdata(cls, countries):
# type: (str) -> None
"""
Set up countries data from data in form provided by UNStats and World Bank
Args:
countries (str): Countries data in HTML format provided by UNStats
Returns:
None
"""
cls._co... | python | def set_countriesdata(cls, countries):
# type: (str) -> None
"""
Set up countries data from data in form provided by UNStats and World Bank
Args:
countries (str): Countries data in HTML format provided by UNStats
Returns:
None
"""
cls._co... | [
"def",
"set_countriesdata",
"(",
"cls",
",",
"countries",
")",
":",
"# type: (str) -> None",
"cls",
".",
"_countriesdata",
"=",
"dict",
"(",
")",
"cls",
".",
"_countriesdata",
"[",
"'countries'",
"]",
"=",
"dict",
"(",
")",
"cls",
".",
"_countriesdata",
"[",... | Set up countries data from data in form provided by UNStats and World Bank
Args:
countries (str): Countries data in HTML format provided by UNStats
Returns:
None | [
"Set",
"up",
"countries",
"data",
"from",
"data",
"in",
"form",
"provided",
"by",
"UNStats",
"and",
"World",
"Bank"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L107-L141 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.countriesdata | def countriesdata(cls, use_live=True):
# type: (bool) -> List[Dict[Dict]]
"""
Read countries data from OCHA countries feed (falling back to file)
Args:
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
Returns:
... | python | def countriesdata(cls, use_live=True):
# type: (bool) -> List[Dict[Dict]]
"""
Read countries data from OCHA countries feed (falling back to file)
Args:
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
Returns:
... | [
"def",
"countriesdata",
"(",
"cls",
",",
"use_live",
"=",
"True",
")",
":",
"# type: (bool) -> List[Dict[Dict]]",
"if",
"cls",
".",
"_countriesdata",
"is",
"None",
":",
"countries",
"=",
"None",
"if",
"use_live",
":",
"try",
":",
"countries",
"=",
"hxl",
"."... | Read countries data from OCHA countries feed (falling back to file)
Args:
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
Returns:
List[Dict[Dict]]: Countries dictionaries | [
"Read",
"countries",
"data",
"from",
"OCHA",
"countries",
"feed",
"(",
"falling",
"back",
"to",
"file",
")"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L144-L167 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.set_ocha_url | def set_ocha_url(cls, url=None):
# type: (str) -> None
"""
Set World Bank url from which to retrieve countries data
Args:
url (str): World Bank url from which to retrieve countries data. Defaults to internal value.
Returns:
None
"""
if ur... | python | def set_ocha_url(cls, url=None):
# type: (str) -> None
"""
Set World Bank url from which to retrieve countries data
Args:
url (str): World Bank url from which to retrieve countries data. Defaults to internal value.
Returns:
None
"""
if ur... | [
"def",
"set_ocha_url",
"(",
"cls",
",",
"url",
"=",
"None",
")",
":",
"# type: (str) -> None",
"if",
"url",
"is",
"None",
":",
"url",
"=",
"cls",
".",
"_ochaurl_int",
"cls",
".",
"_ochaurl",
"=",
"url"
] | Set World Bank url from which to retrieve countries data
Args:
url (str): World Bank url from which to retrieve countries data. Defaults to internal value.
Returns:
None | [
"Set",
"World",
"Bank",
"url",
"from",
"which",
"to",
"retrieve",
"countries",
"data"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L170-L183 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_country_info_from_iso3 | def get_country_info_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country information from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country information
use_live (bool):... | python | def get_country_info_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country information from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country information
use_live (bool):... | [
"def",
"get_country_info_from_iso3",
"(",
"cls",
",",
"iso3",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]",
"countriesdata",
"=",
"cls",
".",
"countriesdata",
"(",
"use... | Get country information from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country information
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if cou... | [
"Get",
"country",
"information",
"from",
"ISO3",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L186-L205 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_country_name_from_iso3 | def get_country_name_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country name
use_live (bool): Try to get use late... | python | def get_country_name_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country name
use_live (bool): Try to get use late... | [
"def",
"get_country_name_from_iso3",
"(",
"cls",
",",
"iso3",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]",
"countryinfo",
"=",
"cls",
".",
"get_country_info_from_iso3",
"(",
... | Get country name from ISO3 code
Args:
iso3 (str): ISO3 code for which to get country name
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if country not found... | [
"Get",
"country",
"name",
"from",
"ISO3",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L208-L223 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_iso2_from_iso3 | def get_iso2_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get ISO2 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get ISO2 code
use_live (bool): Try to get use latest data from web ra... | python | def get_iso2_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get ISO2 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get ISO2 code
use_live (bool): Try to get use latest data from web ra... | [
"def",
"get_iso2_from_iso3",
"(",
"cls",
",",
"iso3",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]",
"countriesdata",
"=",
"cls",
".",
"countriesdata",
"(",
"use_live",
"=",... | Get ISO2 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get ISO2 code
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if country not found. Defaults ... | [
"Get",
"ISO2",
"from",
"ISO3",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L226-L245 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_country_info_from_iso2 | def get_country_info_from_iso2(cls, iso2, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country information
use_live (bool): Try to... | python | def get_country_info_from_iso2(cls, iso2, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country information
use_live (bool): Try to... | [
"def",
"get_country_info_from_iso2",
"(",
"cls",
",",
"iso2",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]",
"iso3",
"=",
"cls",
".",
"get_iso3_from_iso2",
"(",
"iso2",
... | Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country information
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if country no... | [
"Get",
"country",
"name",
"from",
"ISO2",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L270-L285 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_country_name_from_iso2 | def get_country_name_from_iso2(cls, iso2, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country name
use_live (bool): Try to get use late... | python | def get_country_name_from_iso2(cls, iso2, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country name
use_live (bool): Try to get use late... | [
"def",
"get_country_name_from_iso2",
"(",
"cls",
",",
"iso2",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]",
"iso3",
"=",
"cls",
".",
"get_iso3_from_iso2",
"(",
"iso2",
",",... | Get country name from ISO2 code
Args:
iso2 (str): ISO2 code for which to get country name
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if country not found... | [
"Get",
"country",
"name",
"from",
"ISO2",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L288-L303 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_m49_from_iso3 | def get_m49_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[int]
"""Get M49 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get M49 code
use_live (bool): Try to get use latest data from web rathe... | python | def get_m49_from_iso3(cls, iso3, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[int]
"""Get M49 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get M49 code
use_live (bool): Try to get use latest data from web rathe... | [
"def",
"get_m49_from_iso3",
"(",
"cls",
",",
"iso3",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[int]",
"countriesdata",
"=",
"cls",
".",
"countriesdata",
"(",
"use_live",
"=",
... | Get M49 from ISO3 code
Args:
iso3 (str): ISO3 code for which to get M49 code
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if country not found. Defaults to... | [
"Get",
"M49",
"from",
"ISO3",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L306-L325 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_country_info_from_m49 | def get_country_info_from_m49(cls, m49, use_live=True, exception=None):
# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country information
use_live (bool): Try... | python | def get_country_info_from_m49(cls, m49, use_live=True, exception=None):
# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]
"""Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country information
use_live (bool): Try... | [
"def",
"get_country_info_from_m49",
"(",
"cls",
",",
"m49",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[Dict[str]]",
"iso3",
"=",
"cls",
".",
"get_iso3_from_m49",
"(",
"m49",
",... | Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country information
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if count... | [
"Get",
"country",
"name",
"from",
"M49",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L350-L365 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_country_name_from_m49 | def get_country_name_from_m49(cls, m49, use_live=True, exception=None):
# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country name
use_live (bool): Try to get use l... | python | def get_country_name_from_m49(cls, m49, use_live=True, exception=None):
# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country name
use_live (bool): Try to get use l... | [
"def",
"get_country_name_from_m49",
"(",
"cls",
",",
"m49",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (int, bool, Optional[ExceptionUpperBound]) -> Optional[str]",
"iso3",
"=",
"cls",
".",
"get_iso3_from_m49",
"(",
"m49",
",",
"... | Get country name from M49 code
Args:
m49 (int): M49 numeric code for which to get country name
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception to raise if country not ... | [
"Get",
"country",
"name",
"from",
"M49",
"code"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L368-L383 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.expand_countryname_abbrevs | def expand_countryname_abbrevs(cls, country):
# type: (str) -> List[str]
"""Expands abbreviation(s) in country name in various ways (eg. FED -> FEDERATED, FEDERAL etc.)
Args:
country (str): Country with abbreviation(s)to expand
Returns:
List[str]: Uppercase coun... | python | def expand_countryname_abbrevs(cls, country):
# type: (str) -> List[str]
"""Expands abbreviation(s) in country name in various ways (eg. FED -> FEDERATED, FEDERAL etc.)
Args:
country (str): Country with abbreviation(s)to expand
Returns:
List[str]: Uppercase coun... | [
"def",
"expand_countryname_abbrevs",
"(",
"cls",
",",
"country",
")",
":",
"# type: (str) -> List[str]",
"def",
"replace_ensure_space",
"(",
"word",
",",
"replace",
",",
"replacement",
")",
":",
"return",
"word",
".",
"replace",
"(",
"replace",
",",
"'%s '",
"%"... | Expands abbreviation(s) in country name in various ways (eg. FED -> FEDERATED, FEDERAL etc.)
Args:
country (str): Country with abbreviation(s)to expand
Returns:
List[str]: Uppercase country name with abbreviation(s) expanded in various ways | [
"Expands",
"abbreviation",
"(",
"s",
")",
"in",
"country",
"name",
"in",
"various",
"ways",
"(",
"eg",
".",
"FED",
"-",
">",
"FEDERATED",
"FEDERAL",
"etc",
".",
")"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L386-L406 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.simplify_countryname | def simplify_countryname(cls, country):
# type: (str) -> (str, List[str])
"""Simplifies country name by removing descriptive text eg. DEMOCRATIC, REPUBLIC OF etc.
Args:
country (str): Country name to simplify
Returns:
Tuple[str, List[str]]: Uppercase simplified ... | python | def simplify_countryname(cls, country):
# type: (str) -> (str, List[str])
"""Simplifies country name by removing descriptive text eg. DEMOCRATIC, REPUBLIC OF etc.
Args:
country (str): Country name to simplify
Returns:
Tuple[str, List[str]]: Uppercase simplified ... | [
"def",
"simplify_countryname",
"(",
"cls",
",",
"country",
")",
":",
"# type: (str) -> (str, List[str])",
"countryupper",
"=",
"country",
".",
"upper",
"(",
")",
"words",
"=",
"get_words_in_sentence",
"(",
"countryupper",
")",
"index",
"=",
"countryupper",
".",
"f... | Simplifies country name by removing descriptive text eg. DEMOCRATIC, REPUBLIC OF etc.
Args:
country (str): Country name to simplify
Returns:
Tuple[str, List[str]]: Uppercase simplified country name and list of removed words | [
"Simplifies",
"country",
"name",
"by",
"removing",
"descriptive",
"text",
"eg",
".",
"DEMOCRATIC",
"REPUBLIC",
"OF",
"etc",
"."
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L409-L446 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_iso3_country_code | def get_iso3_country_code(cls, country, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get ISO3 code for cls. Only exact matches or None are returned.
Args:
country (str): Country for which to get ISO3 code
use_live... | python | def get_iso3_country_code(cls, country, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]
"""Get ISO3 code for cls. Only exact matches or None are returned.
Args:
country (str): Country for which to get ISO3 code
use_live... | [
"def",
"get_iso3_country_code",
"(",
"cls",
",",
"country",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Optional[str]",
"countriesdata",
"=",
"cls",
".",
"countriesdata",
"(",
"use_live",
... | Get ISO3 code for cls. Only exact matches or None are returned.
Args:
country (str): Country for which to get ISO3 code
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception... | [
"Get",
"ISO3",
"code",
"for",
"cls",
".",
"Only",
"exact",
"matches",
"or",
"None",
"are",
"returned",
"."
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L449-L483 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_iso3_country_code_fuzzy | def get_iso3_country_code_fuzzy(cls, country, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Tuple[[Optional[str], bool]]
"""Get ISO3 code for cls. A tuple is returned with the first value being the ISO3 code and the second
showing if the match is exact or ... | python | def get_iso3_country_code_fuzzy(cls, country, use_live=True, exception=None):
# type: (str, bool, Optional[ExceptionUpperBound]) -> Tuple[[Optional[str], bool]]
"""Get ISO3 code for cls. A tuple is returned with the first value being the ISO3 code and the second
showing if the match is exact or ... | [
"def",
"get_iso3_country_code_fuzzy",
"(",
"cls",
",",
"country",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (str, bool, Optional[ExceptionUpperBound]) -> Tuple[[Optional[str], bool]]",
"countriesdata",
"=",
"cls",
".",
"countriesdata",
... | Get ISO3 code for cls. A tuple is returned with the first value being the ISO3 code and the second
showing if the match is exact or not.
Args:
country (str): Country for which to get ISO3 code
use_live (bool): Try to get use latest data from web rather than file in package. Defa... | [
"Get",
"ISO3",
"code",
"for",
"cls",
".",
"A",
"tuple",
"is",
"returned",
"with",
"the",
"first",
"value",
"being",
"the",
"ISO3",
"code",
"and",
"the",
"second",
"showing",
"if",
"the",
"match",
"is",
"exact",
"or",
"not",
"."
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L486-L556 |
OCHA-DAP/hdx-python-country | src/hdx/location/country.py | Country.get_countries_in_region | def get_countries_in_region(cls, region, use_live=True, exception=None):
# type: (Union[int,str], bool, Optional[ExceptionUpperBound]) -> List[str]
"""Get countries (ISO3 codes) in region
Args:
region (Union[int,str]): Three digit UNStats M49 region code or region name
u... | python | def get_countries_in_region(cls, region, use_live=True, exception=None):
# type: (Union[int,str], bool, Optional[ExceptionUpperBound]) -> List[str]
"""Get countries (ISO3 codes) in region
Args:
region (Union[int,str]): Three digit UNStats M49 region code or region name
u... | [
"def",
"get_countries_in_region",
"(",
"cls",
",",
"region",
",",
"use_live",
"=",
"True",
",",
"exception",
"=",
"None",
")",
":",
"# type: (Union[int,str], bool, Optional[ExceptionUpperBound]) -> List[str]",
"countriesdata",
"=",
"cls",
".",
"countriesdata",
"(",
"use... | Get countries (ISO3 codes) in region
Args:
region (Union[int,str]): Three digit UNStats M49 region code or region name
use_live (bool): Try to get use latest data from web rather than file in package. Defaults to True.
exception (Optional[ExceptionUpperBound]): An exception ... | [
"Get",
"countries",
"(",
"ISO3",
"codes",
")",
"in",
"region"
] | train | https://github.com/OCHA-DAP/hdx-python-country/blob/e86a0b5f182a5d010c4cd7faa36a213cfbcc01f6/src/hdx/location/country.py#L559-L583 |
moonso/loqusdb | loqusdb/commands/load_profile.py | load_profile | def load_profile(ctx, variant_file, update, stats, profile_threshold):
"""
Command for profiling of samples. User may upload variants used in profiling
from a vcf, update the profiles for all samples, and get some stats
from the profiles in the database.
Profiling is used to monito... | python | def load_profile(ctx, variant_file, update, stats, profile_threshold):
"""
Command for profiling of samples. User may upload variants used in profiling
from a vcf, update the profiles for all samples, and get some stats
from the profiles in the database.
Profiling is used to monito... | [
"def",
"load_profile",
"(",
"ctx",
",",
"variant_file",
",",
"update",
",",
"stats",
",",
"profile_threshold",
")",
":",
"adapter",
"=",
"ctx",
".",
"obj",
"[",
"'adapter'",
"]",
"if",
"variant_file",
":",
"load_profile_variants",
"(",
"adapter",
",",
"varia... | Command for profiling of samples. User may upload variants used in profiling
from a vcf, update the profiles for all samples, and get some stats
from the profiles in the database.
Profiling is used to monitor duplicates in the database. The profile is
based on the variants in the 'profi... | [
"Command",
"for",
"profiling",
"of",
"samples",
".",
"User",
"may",
"upload",
"variants",
"used",
"in",
"profiling",
"from",
"a",
"vcf",
"update",
"the",
"profiles",
"for",
"all",
"samples",
"and",
"get",
"some",
"stats",
"from",
"the",
"profiles",
"in",
"... | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/load_profile.py#L36-L59 |
moonso/loqusdb | loqusdb/plugins/mongo/profile_variant.py | ProfileVariantMixin.add_profile_variants | def add_profile_variants(self, profile_variants):
"""Add several variants to the profile_variant collection in the
database
Args:
profile_variants(list(models.ProfileVariant))
"""
results = self.db.profile_variant.insert_many(profile_variants)
return res... | python | def add_profile_variants(self, profile_variants):
"""Add several variants to the profile_variant collection in the
database
Args:
profile_variants(list(models.ProfileVariant))
"""
results = self.db.profile_variant.insert_many(profile_variants)
return res... | [
"def",
"add_profile_variants",
"(",
"self",
",",
"profile_variants",
")",
":",
"results",
"=",
"self",
".",
"db",
".",
"profile_variant",
".",
"insert_many",
"(",
"profile_variants",
")",
"return",
"results"
] | Add several variants to the profile_variant collection in the
database
Args:
profile_variants(list(models.ProfileVariant)) | [
"Add",
"several",
"variants",
"to",
"the",
"profile_variant",
"collection",
"in",
"the",
"database"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/profile_variant.py#L7-L20 |
yjzhang/uncurl_python | uncurl/zip_clustering.py | zip_fit_params | def zip_fit_params(data):
"""
Returns the ZIP parameters that best fit a given data set.
Args:
data (array): 2d array of genes x cells belonging to a given cluster
Returns:
L (array): 1d array of means
M (array): 1d array of zero-inflation parameter
"""
genes, cells = d... | python | def zip_fit_params(data):
"""
Returns the ZIP parameters that best fit a given data set.
Args:
data (array): 2d array of genes x cells belonging to a given cluster
Returns:
L (array): 1d array of means
M (array): 1d array of zero-inflation parameter
"""
genes, cells = d... | [
"def",
"zip_fit_params",
"(",
"data",
")",
":",
"genes",
",",
"cells",
"=",
"data",
".",
"shape",
"m",
"=",
"data",
".",
"mean",
"(",
"1",
")",
"v",
"=",
"data",
".",
"var",
"(",
"1",
")",
"M",
"=",
"(",
"v",
"-",
"m",
")",
"/",
"(",
"m",
... | Returns the ZIP parameters that best fit a given data set.
Args:
data (array): 2d array of genes x cells belonging to a given cluster
Returns:
L (array): 1d array of means
M (array): 1d array of zero-inflation parameter | [
"Returns",
"the",
"ZIP",
"parameters",
"that",
"best",
"fit",
"a",
"given",
"data",
"set",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/zip_clustering.py#L11-L33 |
yjzhang/uncurl_python | uncurl/zip_clustering.py | zip_cluster | def zip_cluster(data, k, init=None, max_iters=100):
"""
Performs hard EM clustering using the zero-inflated Poisson distribution.
Args:
data (array): A 2d array- genes x cells
k (int): Number of clusters
init (array, optional): Initial centers - genes x k array. Default: None, use k... | python | def zip_cluster(data, k, init=None, max_iters=100):
"""
Performs hard EM clustering using the zero-inflated Poisson distribution.
Args:
data (array): A 2d array- genes x cells
k (int): Number of clusters
init (array, optional): Initial centers - genes x k array. Default: None, use k... | [
"def",
"zip_cluster",
"(",
"data",
",",
"k",
",",
"init",
"=",
"None",
",",
"max_iters",
"=",
"100",
")",
":",
"genes",
",",
"cells",
"=",
"data",
".",
"shape",
"init",
",",
"new_assignments",
"=",
"kmeans_pp",
"(",
"data",
"+",
"eps",
",",
"k",
",... | Performs hard EM clustering using the zero-inflated Poisson distribution.
Args:
data (array): A 2d array- genes x cells
k (int): Number of clusters
init (array, optional): Initial centers - genes x k array. Default: None, use kmeans++
max_iters (int, optional): Maximum number of ite... | [
"Performs",
"hard",
"EM",
"clustering",
"using",
"the",
"zero",
"-",
"inflated",
"Poisson",
"distribution",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/zip_clustering.py#L46-L76 |
yjzhang/uncurl_python | uncurl/dimensionality_reduction.py | diffusion_mds | def diffusion_mds(means, weights, d, diffusion_rounds=10):
"""
Dimensionality reduction using MDS, while running diffusion on W.
Args:
means (array): genes x clusters
weights (array): clusters x cells
d (int): desired dimensionality
Returns:
W_reduced (array): array of ... | python | def diffusion_mds(means, weights, d, diffusion_rounds=10):
"""
Dimensionality reduction using MDS, while running diffusion on W.
Args:
means (array): genes x clusters
weights (array): clusters x cells
d (int): desired dimensionality
Returns:
W_reduced (array): array of ... | [
"def",
"diffusion_mds",
"(",
"means",
",",
"weights",
",",
"d",
",",
"diffusion_rounds",
"=",
"10",
")",
":",
"for",
"i",
"in",
"range",
"(",
"diffusion_rounds",
")",
":",
"weights",
"=",
"weights",
"*",
"weights",
"weights",
"=",
"weights",
"/",
"weight... | Dimensionality reduction using MDS, while running diffusion on W.
Args:
means (array): genes x clusters
weights (array): clusters x cells
d (int): desired dimensionality
Returns:
W_reduced (array): array of shape (d, cells) | [
"Dimensionality",
"reduction",
"using",
"MDS",
"while",
"running",
"diffusion",
"on",
"W",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/dimensionality_reduction.py#L9-L28 |
yjzhang/uncurl_python | uncurl/dimensionality_reduction.py | mds | def mds(means, weights, d):
"""
Dimensionality reduction using MDS.
Args:
means (array): genes x clusters
weights (array): clusters x cells
d (int): desired dimensionality
Returns:
W_reduced (array): array of shape (d, cells)
"""
X = dim_reduce(means, weights, d... | python | def mds(means, weights, d):
"""
Dimensionality reduction using MDS.
Args:
means (array): genes x clusters
weights (array): clusters x cells
d (int): desired dimensionality
Returns:
W_reduced (array): array of shape (d, cells)
"""
X = dim_reduce(means, weights, d... | [
"def",
"mds",
"(",
"means",
",",
"weights",
",",
"d",
")",
":",
"X",
"=",
"dim_reduce",
"(",
"means",
",",
"weights",
",",
"d",
")",
"if",
"X",
".",
"shape",
"[",
"0",
"]",
"==",
"2",
":",
"return",
"X",
".",
"dot",
"(",
"weights",
")",
"else... | Dimensionality reduction using MDS.
Args:
means (array): genes x clusters
weights (array): clusters x cells
d (int): desired dimensionality
Returns:
W_reduced (array): array of shape (d, cells) | [
"Dimensionality",
"reduction",
"using",
"MDS",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/dimensionality_reduction.py#L31-L47 |
yjzhang/uncurl_python | uncurl/dimensionality_reduction.py | dim_reduce_data | def dim_reduce_data(data, d):
"""
Does a MDS on the data directly, not on the means.
Args:
data (array): genes x cells
d (int): desired dimensionality
Returns:
X, a cells x d matrix
"""
genes, cells = data.shape
distances = np.zeros((cells, cells))
for i in rang... | python | def dim_reduce_data(data, d):
"""
Does a MDS on the data directly, not on the means.
Args:
data (array): genes x cells
d (int): desired dimensionality
Returns:
X, a cells x d matrix
"""
genes, cells = data.shape
distances = np.zeros((cells, cells))
for i in rang... | [
"def",
"dim_reduce_data",
"(",
"data",
",",
"d",
")",
":",
"genes",
",",
"cells",
"=",
"data",
".",
"shape",
"distances",
"=",
"np",
".",
"zeros",
"(",
"(",
"cells",
",",
"cells",
")",
")",
"for",
"i",
"in",
"range",
"(",
"cells",
")",
":",
"for"... | Does a MDS on the data directly, not on the means.
Args:
data (array): genes x cells
d (int): desired dimensionality
Returns:
X, a cells x d matrix | [
"Does",
"a",
"MDS",
"on",
"the",
"data",
"directly",
"not",
"on",
"the",
"means",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/dimensionality_reduction.py#L64-L91 |
moonso/loqusdb | loqusdb/plugins/mongo/case.py | CaseMixin.case | def case(self, case):
"""Get a case from the database
Search the cases with the case id
Args:
case (dict): A case dictionary
Returns:
mongo_case (dict): A mongo case dictionary
"""
LOG.debug("Getting case {0} from database".f... | python | def case(self, case):
"""Get a case from the database
Search the cases with the case id
Args:
case (dict): A case dictionary
Returns:
mongo_case (dict): A mongo case dictionary
"""
LOG.debug("Getting case {0} from database".f... | [
"def",
"case",
"(",
"self",
",",
"case",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Getting case {0} from database\"",
".",
"format",
"(",
"case",
".",
"get",
"(",
"'case_id'",
")",
")",
")",
"case_id",
"=",
"case",
"[",
"'case_id'",
"]",
"return",
"self",
... | Get a case from the database
Search the cases with the case id
Args:
case (dict): A case dictionary
Returns:
mongo_case (dict): A mongo case dictionary | [
"Get",
"a",
"case",
"from",
"the",
"database"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/case.py#L11-L24 |
moonso/loqusdb | loqusdb/plugins/mongo/case.py | CaseMixin.nr_cases | def nr_cases(self, snv_cases=None, sv_cases=None):
"""Return the number of cases in the database
Args:
snv_cases(bool): If only snv cases should be searched
sv_cases(bool): If only snv cases should be searched
Returns:
cases (Iterable(Case)): A iterable with... | python | def nr_cases(self, snv_cases=None, sv_cases=None):
"""Return the number of cases in the database
Args:
snv_cases(bool): If only snv cases should be searched
sv_cases(bool): If only snv cases should be searched
Returns:
cases (Iterable(Case)): A iterable with... | [
"def",
"nr_cases",
"(",
"self",
",",
"snv_cases",
"=",
"None",
",",
"sv_cases",
"=",
"None",
")",
":",
"query",
"=",
"{",
"}",
"if",
"snv_cases",
":",
"query",
"=",
"{",
"'vcf_path'",
":",
"{",
"'$exists'",
":",
"True",
"}",
"}",
"if",
"sv_cases",
... | Return the number of cases in the database
Args:
snv_cases(bool): If only snv cases should be searched
sv_cases(bool): If only snv cases should be searched
Returns:
cases (Iterable(Case)): A iterable with mongo cases | [
"Return",
"the",
"number",
"of",
"cases",
"in",
"the",
"database"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/case.py#L35-L54 |
moonso/loqusdb | loqusdb/plugins/mongo/case.py | CaseMixin.add_case | def add_case(self, case, update=False):
"""Add a case to the case collection
If the case exists and update is False raise error.
Args:
db (MongoClient): A connection to the mongodb
case (dict): A case dictionary
update(bool): If existing case should be updat... | python | def add_case(self, case, update=False):
"""Add a case to the case collection
If the case exists and update is False raise error.
Args:
db (MongoClient): A connection to the mongodb
case (dict): A case dictionary
update(bool): If existing case should be updat... | [
"def",
"add_case",
"(",
"self",
",",
"case",
",",
"update",
"=",
"False",
")",
":",
"existing_case",
"=",
"self",
".",
"case",
"(",
"case",
")",
"if",
"existing_case",
"and",
"not",
"update",
":",
"raise",
"CaseError",
"(",
"\"Case {} already exists\"",
".... | Add a case to the case collection
If the case exists and update is False raise error.
Args:
db (MongoClient): A connection to the mongodb
case (dict): A case dictionary
update(bool): If existing case should be updated
Returns:
mongo_case_id(Obje... | [
"Add",
"a",
"case",
"to",
"the",
"case",
"collection"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/case.py#L57-L82 |
moonso/loqusdb | loqusdb/plugins/mongo/case.py | CaseMixin.delete_case | def delete_case(self, case):
"""Delete case from the database
Delete a case from the database
Args:
case (dict): A case dictionary
"""
mongo_case = self.case(case)
if not mongo_case:
raise CaseError("Tried to delete case {0} but cou... | python | def delete_case(self, case):
"""Delete case from the database
Delete a case from the database
Args:
case (dict): A case dictionary
"""
mongo_case = self.case(case)
if not mongo_case:
raise CaseError("Tried to delete case {0} but cou... | [
"def",
"delete_case",
"(",
"self",
",",
"case",
")",
":",
"mongo_case",
"=",
"self",
".",
"case",
"(",
"case",
")",
"if",
"not",
"mongo_case",
":",
"raise",
"CaseError",
"(",
"\"Tried to delete case {0} but could not find case\"",
".",
"format",
"(",
"case",
"... | Delete case from the database
Delete a case from the database
Args:
case (dict): A case dictionary | [
"Delete",
"case",
"from",
"the",
"database"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/plugins/mongo/case.py#L84-L104 |
MainRo/cyclotron-py | cyclotron/rx.py | make_sink_proxies | def make_sink_proxies(drivers):
''' Build a list of sink proxies. sink proxies are a two-level ordered
dictionary. The first level contains the lst of drivers, and the second
level contains the list of sink proxies for each driver:
drv1-->sink1
| |->sink2
|
drv2-->sink1
|->sink2... | python | def make_sink_proxies(drivers):
''' Build a list of sink proxies. sink proxies are a two-level ordered
dictionary. The first level contains the lst of drivers, and the second
level contains the list of sink proxies for each driver:
drv1-->sink1
| |->sink2
|
drv2-->sink1
|->sink2... | [
"def",
"make_sink_proxies",
"(",
"drivers",
")",
":",
"sink_proxies",
"=",
"OrderedDict",
"(",
")",
"if",
"drivers",
"is",
"not",
"None",
":",
"for",
"driver_name",
"in",
"drivers",
".",
"_fields",
":",
"driver",
"=",
"getattr",
"(",
"drivers",
",",
"drive... | Build a list of sink proxies. sink proxies are a two-level ordered
dictionary. The first level contains the lst of drivers, and the second
level contains the list of sink proxies for each driver:
drv1-->sink1
| |->sink2
|
drv2-->sink1
|->sink2 | [
"Build",
"a",
"list",
"of",
"sink",
"proxies",
".",
"sink",
"proxies",
"are",
"a",
"two",
"-",
"level",
"ordered",
"dictionary",
".",
"The",
"first",
"level",
"contains",
"the",
"lst",
"of",
"drivers",
"and",
"the",
"second",
"level",
"contains",
"the",
... | train | https://github.com/MainRo/cyclotron-py/blob/4530f65173aa4b9e27c3d4a2f5d33900fc19f754/cyclotron/rx.py#L8-L30 |
moonso/loqusdb | loqusdb/build_models/profile_variant.py | build_profile_variant | def build_profile_variant(variant):
"""Returns a ProfileVariant object
Args:
variant (cyvcf2.Variant)
Returns:
variant (models.ProfileVariant)
"""
chrom = variant.CHROM
if chrom.startswith(('chr', 'CHR', 'Chr')):
chrom = chrom[3:]
pos = int(variant.POS)
varia... | python | def build_profile_variant(variant):
"""Returns a ProfileVariant object
Args:
variant (cyvcf2.Variant)
Returns:
variant (models.ProfileVariant)
"""
chrom = variant.CHROM
if chrom.startswith(('chr', 'CHR', 'Chr')):
chrom = chrom[3:]
pos = int(variant.POS)
varia... | [
"def",
"build_profile_variant",
"(",
"variant",
")",
":",
"chrom",
"=",
"variant",
".",
"CHROM",
"if",
"chrom",
".",
"startswith",
"(",
"(",
"'chr'",
",",
"'CHR'",
",",
"'Chr'",
")",
")",
":",
"chrom",
"=",
"chrom",
"[",
"3",
":",
"]",
"pos",
"=",
... | Returns a ProfileVariant object
Args:
variant (cyvcf2.Variant)
Returns:
variant (models.ProfileVariant) | [
"Returns",
"a",
"ProfileVariant",
"object"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/build_models/profile_variant.py#L24-L57 |
moonso/loqusdb | loqusdb/utils/vcf.py | add_headers | def add_headers(vcf_obj, nr_cases=None, sv=False):
"""Add loqus specific information to a VCF header
Args:
vcf_obj(cyvcf2.VCF)
"""
vcf_obj.add_info_to_header(
{
'ID':"Obs",
'Number': '1',
'Type': 'Integer',
'Description': "The number of o... | python | def add_headers(vcf_obj, nr_cases=None, sv=False):
"""Add loqus specific information to a VCF header
Args:
vcf_obj(cyvcf2.VCF)
"""
vcf_obj.add_info_to_header(
{
'ID':"Obs",
'Number': '1',
'Type': 'Integer',
'Description': "The number of o... | [
"def",
"add_headers",
"(",
"vcf_obj",
",",
"nr_cases",
"=",
"None",
",",
"sv",
"=",
"False",
")",
":",
"vcf_obj",
".",
"add_info_to_header",
"(",
"{",
"'ID'",
":",
"\"Obs\"",
",",
"'Number'",
":",
"'1'",
",",
"'Type'",
":",
"'Integer'",
",",
"'Descriptio... | Add loqus specific information to a VCF header
Args:
vcf_obj(cyvcf2.VCF) | [
"Add",
"loqus",
"specific",
"information",
"to",
"a",
"VCF",
"header"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/vcf.py#L12-L45 |
moonso/loqusdb | loqusdb/utils/vcf.py | get_file_handle | def get_file_handle(file_path):
"""Return cyvcf2 VCF object
Args:
file_path(str)
Returns:
vcf_obj(cyvcf2.VCF)
"""
LOG.debug("Check if file end is correct")
if not os.path.exists(file_path):
raise IOError("No such file:{0}".format(file_path))
if not os.path.splitex... | python | def get_file_handle(file_path):
"""Return cyvcf2 VCF object
Args:
file_path(str)
Returns:
vcf_obj(cyvcf2.VCF)
"""
LOG.debug("Check if file end is correct")
if not os.path.exists(file_path):
raise IOError("No such file:{0}".format(file_path))
if not os.path.splitex... | [
"def",
"get_file_handle",
"(",
"file_path",
")",
":",
"LOG",
".",
"debug",
"(",
"\"Check if file end is correct\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"file_path",
")",
":",
"raise",
"IOError",
"(",
"\"No such file:{0}\"",
".",
"format",
... | Return cyvcf2 VCF object
Args:
file_path(str)
Returns:
vcf_obj(cyvcf2.VCF) | [
"Return",
"cyvcf2",
"VCF",
"object"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/vcf.py#L49-L68 |
moonso/loqusdb | loqusdb/utils/vcf.py | check_vcf | def check_vcf(vcf_path, expected_type='snv'):
"""Check if there are any problems with the vcf file
Args:
vcf_path(str)
expected_type(str): 'sv' or 'snv'
Returns:
vcf_info(dict): dict like
{
'nr_variants':<INT>,
'variant_type': <STR> in ['snv', 'sv'],... | python | def check_vcf(vcf_path, expected_type='snv'):
"""Check if there are any problems with the vcf file
Args:
vcf_path(str)
expected_type(str): 'sv' or 'snv'
Returns:
vcf_info(dict): dict like
{
'nr_variants':<INT>,
'variant_type': <STR> in ['snv', 'sv'],... | [
"def",
"check_vcf",
"(",
"vcf_path",
",",
"expected_type",
"=",
"'snv'",
")",
":",
"LOG",
".",
"info",
"(",
"\"Check if vcf is on correct format...\"",
")",
"vcf",
"=",
"VCF",
"(",
"vcf_path",
")",
"individuals",
"=",
"vcf",
".",
"samples",
"variant_type",
"="... | Check if there are any problems with the vcf file
Args:
vcf_path(str)
expected_type(str): 'sv' or 'snv'
Returns:
vcf_info(dict): dict like
{
'nr_variants':<INT>,
'variant_type': <STR> in ['snv', 'sv'],
'individuals': <LIST> individual positio... | [
"Check",
"if",
"there",
"are",
"any",
"problems",
"with",
"the",
"vcf",
"file"
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/utils/vcf.py#L89-L180 |
xi/ldif3 | ldif3.py | is_dn | def is_dn(s):
"""Return True if s is a LDAP DN."""
if s == '':
return True
rm = DN_REGEX.match(s)
return rm is not None and rm.group(0) == s | python | def is_dn(s):
"""Return True if s is a LDAP DN."""
if s == '':
return True
rm = DN_REGEX.match(s)
return rm is not None and rm.group(0) == s | [
"def",
"is_dn",
"(",
"s",
")",
":",
"if",
"s",
"==",
"''",
":",
"return",
"True",
"rm",
"=",
"DN_REGEX",
".",
"match",
"(",
"s",
")",
"return",
"rm",
"is",
"not",
"None",
"and",
"rm",
".",
"group",
"(",
"0",
")",
"==",
"s"
] | Return True if s is a LDAP DN. | [
"Return",
"True",
"if",
"s",
"is",
"a",
"LDAP",
"DN",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L43-L48 |
xi/ldif3 | ldif3.py | LDIFWriter._fold_line | def _fold_line(self, line):
"""Write string line as one or more folded lines."""
if len(line) <= self._cols:
self._output_file.write(line)
self._output_file.write(self._line_sep)
else:
pos = self._cols
self._output_file.write(line[0:self._cols])
... | python | def _fold_line(self, line):
"""Write string line as one or more folded lines."""
if len(line) <= self._cols:
self._output_file.write(line)
self._output_file.write(self._line_sep)
else:
pos = self._cols
self._output_file.write(line[0:self._cols])
... | [
"def",
"_fold_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"len",
"(",
"line",
")",
"<=",
"self",
".",
"_cols",
":",
"self",
".",
"_output_file",
".",
"write",
"(",
"line",
")",
"self",
".",
"_output_file",
".",
"write",
"(",
"self",
".",
"_lin... | Write string line as one or more folded lines. | [
"Write",
"string",
"line",
"as",
"one",
"or",
"more",
"folded",
"lines",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L100-L114 |
xi/ldif3 | ldif3.py | LDIFWriter._needs_base64_encoding | def _needs_base64_encoding(self, attr_type, attr_value):
"""Return True if attr_value has to be base-64 encoded.
This is the case because of special chars or because attr_type is in
self._base64_attrs
"""
return attr_type.lower() in self._base64_attrs or \
isinstance... | python | def _needs_base64_encoding(self, attr_type, attr_value):
"""Return True if attr_value has to be base-64 encoded.
This is the case because of special chars or because attr_type is in
self._base64_attrs
"""
return attr_type.lower() in self._base64_attrs or \
isinstance... | [
"def",
"_needs_base64_encoding",
"(",
"self",
",",
"attr_type",
",",
"attr_value",
")",
":",
"return",
"attr_type",
".",
"lower",
"(",
")",
"in",
"self",
".",
"_base64_attrs",
"or",
"isinstance",
"(",
"attr_value",
",",
"bytes",
")",
"or",
"UNSAFE_STRING_RE",
... | Return True if attr_value has to be base-64 encoded.
This is the case because of special chars or because attr_type is in
self._base64_attrs | [
"Return",
"True",
"if",
"attr_value",
"has",
"to",
"be",
"base",
"-",
"64",
"encoded",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L116-L124 |
xi/ldif3 | ldif3.py | LDIFWriter._unparse_attr | def _unparse_attr(self, attr_type, attr_value):
"""Write a single attribute type/value pair."""
if self._needs_base64_encoding(attr_type, attr_value):
if not isinstance(attr_value, bytes):
attr_value = attr_value.encode(self._encoding)
encoded = base64.encodestrin... | python | def _unparse_attr(self, attr_type, attr_value):
"""Write a single attribute type/value pair."""
if self._needs_base64_encoding(attr_type, attr_value):
if not isinstance(attr_value, bytes):
attr_value = attr_value.encode(self._encoding)
encoded = base64.encodestrin... | [
"def",
"_unparse_attr",
"(",
"self",
",",
"attr_type",
",",
"attr_value",
")",
":",
"if",
"self",
".",
"_needs_base64_encoding",
"(",
"attr_type",
",",
"attr_value",
")",
":",
"if",
"not",
"isinstance",
"(",
"attr_value",
",",
"bytes",
")",
":",
"attr_value"... | Write a single attribute type/value pair. | [
"Write",
"a",
"single",
"attribute",
"type",
"/",
"value",
"pair",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L126-L137 |
xi/ldif3 | ldif3.py | LDIFWriter._unparse_entry_record | def _unparse_entry_record(self, entry):
"""
:type entry: Dict[string, List[string]]
:param entry: Dictionary holding an entry
"""
for attr_type in sorted(entry.keys()):
for attr_value in entry[attr_type]:
self._unparse_attr(attr_type, attr_value) | python | def _unparse_entry_record(self, entry):
"""
:type entry: Dict[string, List[string]]
:param entry: Dictionary holding an entry
"""
for attr_type in sorted(entry.keys()):
for attr_value in entry[attr_type]:
self._unparse_attr(attr_type, attr_value) | [
"def",
"_unparse_entry_record",
"(",
"self",
",",
"entry",
")",
":",
"for",
"attr_type",
"in",
"sorted",
"(",
"entry",
".",
"keys",
"(",
")",
")",
":",
"for",
"attr_value",
"in",
"entry",
"[",
"attr_type",
"]",
":",
"self",
".",
"_unparse_attr",
"(",
"... | :type entry: Dict[string, List[string]]
:param entry: Dictionary holding an entry | [
":",
"type",
"entry",
":",
"Dict",
"[",
"string",
"List",
"[",
"string",
"]]",
":",
"param",
"entry",
":",
"Dictionary",
"holding",
"an",
"entry"
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L139-L146 |
xi/ldif3 | ldif3.py | LDIFWriter._unparse_changetype | def _unparse_changetype(self, mod_len):
"""Detect and write the changetype."""
if mod_len == 2:
changetype = 'add'
elif mod_len == 3:
changetype = 'modify'
else:
raise ValueError("modlist item of wrong length")
self._unparse_attr('changetype',... | python | def _unparse_changetype(self, mod_len):
"""Detect and write the changetype."""
if mod_len == 2:
changetype = 'add'
elif mod_len == 3:
changetype = 'modify'
else:
raise ValueError("modlist item of wrong length")
self._unparse_attr('changetype',... | [
"def",
"_unparse_changetype",
"(",
"self",
",",
"mod_len",
")",
":",
"if",
"mod_len",
"==",
"2",
":",
"changetype",
"=",
"'add'",
"elif",
"mod_len",
"==",
"3",
":",
"changetype",
"=",
"'modify'",
"else",
":",
"raise",
"ValueError",
"(",
"\"modlist item of wr... | Detect and write the changetype. | [
"Detect",
"and",
"write",
"the",
"changetype",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L148-L157 |
xi/ldif3 | ldif3.py | LDIFWriter._unparse_change_record | def _unparse_change_record(self, modlist):
"""
:type modlist: List[Tuple]
:param modlist: List of additions (2-tuple) or modifications (3-tuple)
"""
mod_len = len(modlist[0])
self._unparse_changetype(mod_len)
for mod in modlist:
if len(mod) != mod_len... | python | def _unparse_change_record(self, modlist):
"""
:type modlist: List[Tuple]
:param modlist: List of additions (2-tuple) or modifications (3-tuple)
"""
mod_len = len(modlist[0])
self._unparse_changetype(mod_len)
for mod in modlist:
if len(mod) != mod_len... | [
"def",
"_unparse_change_record",
"(",
"self",
",",
"modlist",
")",
":",
"mod_len",
"=",
"len",
"(",
"modlist",
"[",
"0",
"]",
")",
"self",
".",
"_unparse_changetype",
"(",
"mod_len",
")",
"for",
"mod",
"in",
"modlist",
":",
"if",
"len",
"(",
"mod",
")"... | :type modlist: List[Tuple]
:param modlist: List of additions (2-tuple) or modifications (3-tuple) | [
":",
"type",
"modlist",
":",
"List",
"[",
"Tuple",
"]",
":",
"param",
"modlist",
":",
"List",
"of",
"additions",
"(",
"2",
"-",
"tuple",
")",
"or",
"modifications",
"(",
"3",
"-",
"tuple",
")"
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L159-L181 |
xi/ldif3 | ldif3.py | LDIFWriter.unparse | def unparse(self, dn, record):
"""Write an entry or change record to the output file.
:type dn: string
:param dn: distinguished name
:type record: Union[Dict[string, List[string]], List[Tuple]]
:param record: Either a dictionary holding an entry or a list of
additi... | python | def unparse(self, dn, record):
"""Write an entry or change record to the output file.
:type dn: string
:param dn: distinguished name
:type record: Union[Dict[string, List[string]], List[Tuple]]
:param record: Either a dictionary holding an entry or a list of
additi... | [
"def",
"unparse",
"(",
"self",
",",
"dn",
",",
"record",
")",
":",
"self",
".",
"_unparse_attr",
"(",
"'dn'",
",",
"dn",
")",
"if",
"isinstance",
"(",
"record",
",",
"dict",
")",
":",
"self",
".",
"_unparse_entry_record",
"(",
"record",
")",
"elif",
... | Write an entry or change record to the output file.
:type dn: string
:param dn: distinguished name
:type record: Union[Dict[string, List[string]], List[Tuple]]
:param record: Either a dictionary holding an entry or a list of
additions (2-tuple) or modifications (3-tuple). | [
"Write",
"an",
"entry",
"or",
"change",
"record",
"to",
"the",
"output",
"file",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L183-L201 |
xi/ldif3 | ldif3.py | LDIFParser._strip_line_sep | def _strip_line_sep(self, s):
"""Strip trailing line separators from s, but no other whitespaces."""
if s[-2:] == b'\r\n':
return s[:-2]
elif s[-1:] == b'\n':
return s[:-1]
else:
return s | python | def _strip_line_sep(self, s):
"""Strip trailing line separators from s, but no other whitespaces."""
if s[-2:] == b'\r\n':
return s[:-2]
elif s[-1:] == b'\n':
return s[:-1]
else:
return s | [
"def",
"_strip_line_sep",
"(",
"self",
",",
"s",
")",
":",
"if",
"s",
"[",
"-",
"2",
":",
"]",
"==",
"b'\\r\\n'",
":",
"return",
"s",
"[",
":",
"-",
"2",
"]",
"elif",
"s",
"[",
"-",
"1",
":",
"]",
"==",
"b'\\n'",
":",
"return",
"s",
"[",
":... | Strip trailing line separators from s, but no other whitespaces. | [
"Strip",
"trailing",
"line",
"separators",
"from",
"s",
"but",
"no",
"other",
"whitespaces",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L233-L240 |
xi/ldif3 | ldif3.py | LDIFParser._iter_unfolded_lines | def _iter_unfolded_lines(self):
"""Iter input unfoled lines. Skip comments."""
line = self._input_file.readline()
while line:
self.line_counter += 1
self.byte_counter += len(line)
line = self._strip_line_sep(line)
nextline = self._input_file.read... | python | def _iter_unfolded_lines(self):
"""Iter input unfoled lines. Skip comments."""
line = self._input_file.readline()
while line:
self.line_counter += 1
self.byte_counter += len(line)
line = self._strip_line_sep(line)
nextline = self._input_file.read... | [
"def",
"_iter_unfolded_lines",
"(",
"self",
")",
":",
"line",
"=",
"self",
".",
"_input_file",
".",
"readline",
"(",
")",
"while",
"line",
":",
"self",
".",
"line_counter",
"+=",
"1",
"self",
".",
"byte_counter",
"+=",
"len",
"(",
"line",
")",
"line",
... | Iter input unfoled lines. Skip comments. | [
"Iter",
"input",
"unfoled",
"lines",
".",
"Skip",
"comments",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L261-L277 |
xi/ldif3 | ldif3.py | LDIFParser._iter_blocks | def _iter_blocks(self):
"""Iter input lines in blocks separated by blank lines."""
lines = []
for line in self._iter_unfolded_lines():
if line:
lines.append(line)
elif lines:
self.records_read += 1
yield lines
... | python | def _iter_blocks(self):
"""Iter input lines in blocks separated by blank lines."""
lines = []
for line in self._iter_unfolded_lines():
if line:
lines.append(line)
elif lines:
self.records_read += 1
yield lines
... | [
"def",
"_iter_blocks",
"(",
"self",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"line",
"in",
"self",
".",
"_iter_unfolded_lines",
"(",
")",
":",
"if",
"line",
":",
"lines",
".",
"append",
"(",
"line",
")",
"elif",
"lines",
":",
"self",
".",
"records_re... | Iter input lines in blocks separated by blank lines. | [
"Iter",
"input",
"lines",
"in",
"blocks",
"separated",
"by",
"blank",
"lines",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L279-L291 |
xi/ldif3 | ldif3.py | LDIFParser._parse_attr | def _parse_attr(self, line):
"""Parse a single attribute type/value pair."""
colon_pos = line.index(b':')
attr_type = line[0:colon_pos].decode('ascii')
if line[colon_pos:].startswith(b'::'):
attr_value = base64.decodestring(line[colon_pos + 2:])
elif line[colon_pos:]... | python | def _parse_attr(self, line):
"""Parse a single attribute type/value pair."""
colon_pos = line.index(b':')
attr_type = line[0:colon_pos].decode('ascii')
if line[colon_pos:].startswith(b'::'):
attr_value = base64.decodestring(line[colon_pos + 2:])
elif line[colon_pos:]... | [
"def",
"_parse_attr",
"(",
"self",
",",
"line",
")",
":",
"colon_pos",
"=",
"line",
".",
"index",
"(",
"b':'",
")",
"attr_type",
"=",
"line",
"[",
"0",
":",
"colon_pos",
"]",
".",
"decode",
"(",
"'ascii'",
")",
"if",
"line",
"[",
"colon_pos",
":",
... | Parse a single attribute type/value pair. | [
"Parse",
"a",
"single",
"attribute",
"type",
"/",
"value",
"pair",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L309-L326 |
xi/ldif3 | ldif3.py | LDIFParser._check_dn | def _check_dn(self, dn, attr_value):
"""Check dn attribute for issues."""
if dn is not None:
self._error('Two lines starting with dn: in one record.')
if not is_dn(attr_value):
self._error('No valid string-representation of '
'distinguished name %s.' % att... | python | def _check_dn(self, dn, attr_value):
"""Check dn attribute for issues."""
if dn is not None:
self._error('Two lines starting with dn: in one record.')
if not is_dn(attr_value):
self._error('No valid string-representation of '
'distinguished name %s.' % att... | [
"def",
"_check_dn",
"(",
"self",
",",
"dn",
",",
"attr_value",
")",
":",
"if",
"dn",
"is",
"not",
"None",
":",
"self",
".",
"_error",
"(",
"'Two lines starting with dn: in one record.'",
")",
"if",
"not",
"is_dn",
"(",
"attr_value",
")",
":",
"self",
".",
... | Check dn attribute for issues. | [
"Check",
"dn",
"attribute",
"for",
"issues",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L334-L340 |
xi/ldif3 | ldif3.py | LDIFParser._check_changetype | def _check_changetype(self, dn, changetype, attr_value):
"""Check changetype attribute for issues."""
if dn is None:
self._error('Read changetype: before getting valid dn: line.')
if changetype is not None:
self._error('Two lines starting with changetype: in one record.')... | python | def _check_changetype(self, dn, changetype, attr_value):
"""Check changetype attribute for issues."""
if dn is None:
self._error('Read changetype: before getting valid dn: line.')
if changetype is not None:
self._error('Two lines starting with changetype: in one record.')... | [
"def",
"_check_changetype",
"(",
"self",
",",
"dn",
",",
"changetype",
",",
"attr_value",
")",
":",
"if",
"dn",
"is",
"None",
":",
"self",
".",
"_error",
"(",
"'Read changetype: before getting valid dn: line.'",
")",
"if",
"changetype",
"is",
"not",
"None",
":... | Check changetype attribute for issues. | [
"Check",
"changetype",
"attribute",
"for",
"issues",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L342-L349 |
xi/ldif3 | ldif3.py | LDIFParser._parse_entry_record | def _parse_entry_record(self, lines):
"""Parse a single entry record from a list of lines."""
dn = None
entry = OrderedDict()
for line in lines:
attr_type, attr_value = self._parse_attr(line)
if attr_type == 'dn':
self._check_dn(dn, attr_value)
... | python | def _parse_entry_record(self, lines):
"""Parse a single entry record from a list of lines."""
dn = None
entry = OrderedDict()
for line in lines:
attr_type, attr_value = self._parse_attr(line)
if attr_type == 'dn':
self._check_dn(dn, attr_value)
... | [
"def",
"_parse_entry_record",
"(",
"self",
",",
"lines",
")",
":",
"dn",
"=",
"None",
"entry",
"=",
"OrderedDict",
"(",
")",
"for",
"line",
"in",
"lines",
":",
"attr_type",
",",
"attr_value",
"=",
"self",
".",
"_parse_attr",
"(",
"line",
")",
"if",
"at... | Parse a single entry record from a list of lines. | [
"Parse",
"a",
"single",
"entry",
"record",
"from",
"a",
"list",
"of",
"lines",
"."
] | train | https://github.com/xi/ldif3/blob/debc4222bb48492de0d3edcc3c71fdae5bc612a4/ldif3.py#L351-L375 |
yjzhang/uncurl_python | uncurl/zip_state_estimation.py | _create_w_objective | def _create_w_objective(m, X, Z=None):
"""
Creates an objective function and its derivative for W, given M and X (data)
Args:
m (array): genes x clusters
X (array): genes x cells
Z (array): zero-inflation parameters - genes x 1
"""
genes, clusters = m.shape
cells = X.sha... | python | def _create_w_objective(m, X, Z=None):
"""
Creates an objective function and its derivative for W, given M and X (data)
Args:
m (array): genes x clusters
X (array): genes x cells
Z (array): zero-inflation parameters - genes x 1
"""
genes, clusters = m.shape
cells = X.sha... | [
"def",
"_create_w_objective",
"(",
"m",
",",
"X",
",",
"Z",
"=",
"None",
")",
":",
"genes",
",",
"clusters",
"=",
"m",
".",
"shape",
"cells",
"=",
"X",
".",
"shape",
"[",
"1",
"]",
"nonzeros",
"=",
"(",
"X",
"!=",
"0",
")",
"def",
"objective",
... | Creates an objective function and its derivative for W, given M and X (data)
Args:
m (array): genes x clusters
X (array): genes x cells
Z (array): zero-inflation parameters - genes x 1 | [
"Creates",
"an",
"objective",
"function",
"and",
"its",
"derivative",
"for",
"W",
"given",
"M",
"and",
"X",
"(",
"data",
")"
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/zip_state_estimation.py#L13-L38 |
yjzhang/uncurl_python | uncurl/zip_state_estimation.py | zip_estimate_state | def zip_estimate_state(data, clusters, init_means=None, init_weights=None, max_iters=10, tol=1e-4, disp=True, inner_max_iters=400, normalize=True):
"""
Uses a Zero-inflated Poisson Mixture model to estimate cell states and
cell state mixing weights.
Args:
data (array): genes x cells
clu... | python | def zip_estimate_state(data, clusters, init_means=None, init_weights=None, max_iters=10, tol=1e-4, disp=True, inner_max_iters=400, normalize=True):
"""
Uses a Zero-inflated Poisson Mixture model to estimate cell states and
cell state mixing weights.
Args:
data (array): genes x cells
clu... | [
"def",
"zip_estimate_state",
"(",
"data",
",",
"clusters",
",",
"init_means",
"=",
"None",
",",
"init_weights",
"=",
"None",
",",
"max_iters",
"=",
"10",
",",
"tol",
"=",
"1e-4",
",",
"disp",
"=",
"True",
",",
"inner_max_iters",
"=",
"400",
",",
"normali... | Uses a Zero-inflated Poisson Mixture model to estimate cell states and
cell state mixing weights.
Args:
data (array): genes x cells
clusters (int): number of mixture components
init_means (array, optional): initial centers - genes x clusters. Default: kmeans++ initializations
in... | [
"Uses",
"a",
"Zero",
"-",
"inflated",
"Poisson",
"Mixture",
"model",
"to",
"estimate",
"cell",
"states",
"and",
"cell",
"state",
"mixing",
"weights",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/zip_state_estimation.py#L64-L127 |
yjzhang/uncurl_python | uncurl/clustering.py | kmeans_pp | def kmeans_pp(data, k, centers=None):
"""
Generates kmeans++ initial centers.
Args:
data (array): A 2d array- genes x cells
k (int): Number of clusters
centers (array, optional): if provided, these are one or more known cluster centers. 2d array of genes x number of centers (<=k).
... | python | def kmeans_pp(data, k, centers=None):
"""
Generates kmeans++ initial centers.
Args:
data (array): A 2d array- genes x cells
k (int): Number of clusters
centers (array, optional): if provided, these are one or more known cluster centers. 2d array of genes x number of centers (<=k).
... | [
"def",
"kmeans_pp",
"(",
"data",
",",
"k",
",",
"centers",
"=",
"None",
")",
":",
"# TODO: what if there is missing data for a given gene?",
"# missing data could be if all the entires are -1.",
"genes",
",",
"cells",
"=",
"data",
".",
"shape",
"if",
"sparse",
".",
"i... | Generates kmeans++ initial centers.
Args:
data (array): A 2d array- genes x cells
k (int): Number of clusters
centers (array, optional): if provided, these are one or more known cluster centers. 2d array of genes x number of centers (<=k).
Returns:
centers - a genes x k array o... | [
"Generates",
"kmeans",
"++",
"initial",
"centers",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/clustering.py#L10-L71 |
yjzhang/uncurl_python | uncurl/clustering.py | poisson_cluster | def poisson_cluster(data, k, init=None, max_iters=100):
"""
Performs Poisson hard EM on the given data.
Args:
data (array): A 2d array- genes x cells. Can be dense or sparse; for best performance, sparse matrices should be in CSC format.
k (int): Number of clusters
init (array, opti... | python | def poisson_cluster(data, k, init=None, max_iters=100):
"""
Performs Poisson hard EM on the given data.
Args:
data (array): A 2d array- genes x cells. Can be dense or sparse; for best performance, sparse matrices should be in CSC format.
k (int): Number of clusters
init (array, opti... | [
"def",
"poisson_cluster",
"(",
"data",
",",
"k",
",",
"init",
"=",
"None",
",",
"max_iters",
"=",
"100",
")",
":",
"# TODO: be able to use a combination of fixed and unknown starting points",
"# e.g., have init values only for certain genes, have a row of all",
"# zeros indicatin... | Performs Poisson hard EM on the given data.
Args:
data (array): A 2d array- genes x cells. Can be dense or sparse; for best performance, sparse matrices should be in CSC format.
k (int): Number of clusters
init (array, optional): Initial centers - genes x k array. Default: None, use kmeans+... | [
"Performs",
"Poisson",
"hard",
"EM",
"on",
"the",
"given",
"data",
"."
] | train | https://github.com/yjzhang/uncurl_python/blob/55c58ca5670f87699d3bd5752fdfa4baa07724dd/uncurl/clustering.py#L73-L119 |
moonso/loqusdb | loqusdb/commands/view.py | cases | def cases(ctx, case_id, to_json):
"""Display cases in the database."""
adapter = ctx.obj['adapter']
cases = []
if case_id:
case_obj = adapter.case({'case_id':case_id})
if not case_obj:
LOG.info("Case {0} does not exist in database".format(case_id))
return
... | python | def cases(ctx, case_id, to_json):
"""Display cases in the database."""
adapter = ctx.obj['adapter']
cases = []
if case_id:
case_obj = adapter.case({'case_id':case_id})
if not case_obj:
LOG.info("Case {0} does not exist in database".format(case_id))
return
... | [
"def",
"cases",
"(",
"ctx",
",",
"case_id",
",",
"to_json",
")",
":",
"adapter",
"=",
"ctx",
".",
"obj",
"[",
"'adapter'",
"]",
"cases",
"=",
"[",
"]",
"if",
"case_id",
":",
"case_obj",
"=",
"adapter",
".",
"case",
"(",
"{",
"'case_id'",
":",
"case... | Display cases in the database. | [
"Display",
"cases",
"in",
"the",
"database",
"."
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/view.py#L19-L45 |
moonso/loqusdb | loqusdb/commands/view.py | variants | def variants(ctx, variant_id, chromosome, end_chromosome, start, end, variant_type,
sv_type):
"""Display variants in the database."""
if sv_type:
variant_type = 'sv'
adapter = ctx.obj['adapter']
if (start or end):
if not (chromosome and start and end):
LOG.warn... | python | def variants(ctx, variant_id, chromosome, end_chromosome, start, end, variant_type,
sv_type):
"""Display variants in the database."""
if sv_type:
variant_type = 'sv'
adapter = ctx.obj['adapter']
if (start or end):
if not (chromosome and start and end):
LOG.warn... | [
"def",
"variants",
"(",
"ctx",
",",
"variant_id",
",",
"chromosome",
",",
"end_chromosome",
",",
"start",
",",
"end",
",",
"variant_type",
",",
"sv_type",
")",
":",
"if",
"sv_type",
":",
"variant_type",
"=",
"'sv'",
"adapter",
"=",
"ctx",
".",
"obj",
"["... | Display variants in the database. | [
"Display",
"variants",
"in",
"the",
"database",
"."
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/view.py#L77-L119 |
moonso/loqusdb | loqusdb/commands/view.py | index | def index(ctx, view):
"""Index the database."""
adapter = ctx.obj['adapter']
if view:
click.echo(adapter.indexes())
return
adapter.ensure_indexes() | python | def index(ctx, view):
"""Index the database."""
adapter = ctx.obj['adapter']
if view:
click.echo(adapter.indexes())
return
adapter.ensure_indexes() | [
"def",
"index",
"(",
"ctx",
",",
"view",
")",
":",
"adapter",
"=",
"ctx",
".",
"obj",
"[",
"'adapter'",
"]",
"if",
"view",
":",
"click",
".",
"echo",
"(",
"adapter",
".",
"indexes",
"(",
")",
")",
"return",
"adapter",
".",
"ensure_indexes",
"(",
")... | Index the database. | [
"Index",
"the",
"database",
"."
] | train | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/view.py#L127-L133 |
limix/numpy-sugar | numpy_sugar/linalg/dot.py | dotd | def dotd(A, B, out=None):
r"""Diagonal of :math:`\mathrm A\mathrm B^\intercal`.
If ``A`` is :math:`n\times p` and ``B`` is :math:`p\times n`, it is done in
:math:`O(pn)`.
Args:
A (array_like): Left matrix.
B (array_like): Right matrix.
out (:class:`numpy.ndarray`, optional): co... | python | def dotd(A, B, out=None):
r"""Diagonal of :math:`\mathrm A\mathrm B^\intercal`.
If ``A`` is :math:`n\times p` and ``B`` is :math:`p\times n`, it is done in
:math:`O(pn)`.
Args:
A (array_like): Left matrix.
B (array_like): Right matrix.
out (:class:`numpy.ndarray`, optional): co... | [
"def",
"dotd",
"(",
"A",
",",
"B",
",",
"out",
"=",
"None",
")",
":",
"A",
"=",
"asarray",
"(",
"A",
",",
"float",
")",
"B",
"=",
"asarray",
"(",
"B",
",",
"float",
")",
"if",
"A",
".",
"ndim",
"==",
"1",
"and",
"B",
".",
"ndim",
"==",
"1... | r"""Diagonal of :math:`\mathrm A\mathrm B^\intercal`.
If ``A`` is :math:`n\times p` and ``B`` is :math:`p\times n`, it is done in
:math:`O(pn)`.
Args:
A (array_like): Left matrix.
B (array_like): Right matrix.
out (:class:`numpy.ndarray`, optional): copy result to.
Returns:
... | [
"r",
"Diagonal",
"of",
":",
"math",
":",
"\\",
"mathrm",
"A",
"\\",
"mathrm",
"B^",
"\\",
"intercal",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/dot.py#L4-L26 |
limix/numpy-sugar | numpy_sugar/linalg/dot.py | ddot | def ddot(L, R, left=None, out=None):
r"""Dot product of a matrix and a diagonal one.
Args:
L (array_like): Left matrix.
R (array_like): Right matrix.
out (:class:`numpy.ndarray`, optional): copy result to.
Returns:
:class:`numpy.ndarray`: Resulting matrix.
"""
L = a... | python | def ddot(L, R, left=None, out=None):
r"""Dot product of a matrix and a diagonal one.
Args:
L (array_like): Left matrix.
R (array_like): Right matrix.
out (:class:`numpy.ndarray`, optional): copy result to.
Returns:
:class:`numpy.ndarray`: Resulting matrix.
"""
L = a... | [
"def",
"ddot",
"(",
"L",
",",
"R",
",",
"left",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"L",
"=",
"asarray",
"(",
"L",
",",
"float",
")",
"R",
"=",
"asarray",
"(",
"R",
",",
"float",
")",
"if",
"left",
"is",
"None",
":",
"ok",
"=",
... | r"""Dot product of a matrix and a diagonal one.
Args:
L (array_like): Left matrix.
R (array_like): Right matrix.
out (:class:`numpy.ndarray`, optional): copy result to.
Returns:
:class:`numpy.ndarray`: Resulting matrix. | [
"r",
"Dot",
"product",
"of",
"a",
"matrix",
"and",
"a",
"diagonal",
"one",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/dot.py#L29-L57 |
limix/numpy-sugar | numpy_sugar/linalg/dot.py | cdot | def cdot(L, out=None):
r"""Product of a Cholesky matrix with itself transposed.
Args:
L (array_like): Cholesky matrix.
out (:class:`numpy.ndarray`, optional): copy result to.
Returns:
:class:`numpy.ndarray`: :math:`\mathrm L\mathrm L^\intercal`.
"""
L = asarray(L, float)
... | python | def cdot(L, out=None):
r"""Product of a Cholesky matrix with itself transposed.
Args:
L (array_like): Cholesky matrix.
out (:class:`numpy.ndarray`, optional): copy result to.
Returns:
:class:`numpy.ndarray`: :math:`\mathrm L\mathrm L^\intercal`.
"""
L = asarray(L, float)
... | [
"def",
"cdot",
"(",
"L",
",",
"out",
"=",
"None",
")",
":",
"L",
"=",
"asarray",
"(",
"L",
",",
"float",
")",
"layout_error",
"=",
"\"Wrong matrix layout.\"",
"if",
"L",
".",
"ndim",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"layout_error",
")",
"i... | r"""Product of a Cholesky matrix with itself transposed.
Args:
L (array_like): Cholesky matrix.
out (:class:`numpy.ndarray`, optional): copy result to.
Returns:
:class:`numpy.ndarray`: :math:`\mathrm L\mathrm L^\intercal`. | [
"r",
"Product",
"of",
"a",
"Cholesky",
"matrix",
"with",
"itself",
"transposed",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/dot.py#L60-L83 |
limix/numpy-sugar | numpy_sugar/_rankdata.py | nanrankdata | def nanrankdata(a, axis=-1, inplace=False):
""" Rank data for arrays contaning NaN values.
Parameters
----------
X : array_like
Array of values.
axis : int, optional
Axis value. Defaults to `1`.
inplace : bool, optional
Defaults to `False`.
Returns
-------
... | python | def nanrankdata(a, axis=-1, inplace=False):
""" Rank data for arrays contaning NaN values.
Parameters
----------
X : array_like
Array of values.
axis : int, optional
Axis value. Defaults to `1`.
inplace : bool, optional
Defaults to `False`.
Returns
-------
... | [
"def",
"nanrankdata",
"(",
"a",
",",
"axis",
"=",
"-",
"1",
",",
"inplace",
"=",
"False",
")",
":",
"from",
"scipy",
".",
"stats",
"import",
"rankdata",
"if",
"hasattr",
"(",
"a",
",",
"\"dtype\"",
")",
"and",
"issubdtype",
"(",
"a",
".",
"dtype",
... | Rank data for arrays contaning NaN values.
Parameters
----------
X : array_like
Array of values.
axis : int, optional
Axis value. Defaults to `1`.
inplace : bool, optional
Defaults to `False`.
Returns
-------
array_like
Ranked array.
Examples
-... | [
"Rank",
"data",
"for",
"arrays",
"contaning",
"NaN",
"values",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/_rankdata.py#L4-L64 |
limix/numpy-sugar | numpy_sugar/linalg/det.py | plogdet | def plogdet(K):
r"""Log of the pseudo-determinant.
It assumes that ``K`` is a positive semi-definite matrix.
Args:
K (array_like): matrix.
Returns:
float: log of the pseudo-determinant.
"""
egvals = eigvalsh(K)
return npsum(log(egvals[egvals > epsilon])) | python | def plogdet(K):
r"""Log of the pseudo-determinant.
It assumes that ``K`` is a positive semi-definite matrix.
Args:
K (array_like): matrix.
Returns:
float: log of the pseudo-determinant.
"""
egvals = eigvalsh(K)
return npsum(log(egvals[egvals > epsilon])) | [
"def",
"plogdet",
"(",
"K",
")",
":",
"egvals",
"=",
"eigvalsh",
"(",
"K",
")",
"return",
"npsum",
"(",
"log",
"(",
"egvals",
"[",
"egvals",
">",
"epsilon",
"]",
")",
")"
] | r"""Log of the pseudo-determinant.
It assumes that ``K`` is a positive semi-definite matrix.
Args:
K (array_like): matrix.
Returns:
float: log of the pseudo-determinant. | [
"r",
"Log",
"of",
"the",
"pseudo",
"-",
"determinant",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/det.py#L8-L20 |
limix/numpy-sugar | numpy_sugar/linalg/qs.py | economic_qs | def economic_qs(K, epsilon=sqrt(finfo(float).eps)):
r"""Economic eigen decomposition for symmetric matrices.
A symmetric matrix ``K`` can be decomposed in
:math:`\mathrm Q_0 \mathrm S_0 \mathrm Q_0^\intercal + \mathrm Q_1\
\mathrm S_1 \mathrm Q_1^ \intercal`, where :math:`\mathrm S_1` is a zero
mat... | python | def economic_qs(K, epsilon=sqrt(finfo(float).eps)):
r"""Economic eigen decomposition for symmetric matrices.
A symmetric matrix ``K`` can be decomposed in
:math:`\mathrm Q_0 \mathrm S_0 \mathrm Q_0^\intercal + \mathrm Q_1\
\mathrm S_1 \mathrm Q_1^ \intercal`, where :math:`\mathrm S_1` is a zero
mat... | [
"def",
"economic_qs",
"(",
"K",
",",
"epsilon",
"=",
"sqrt",
"(",
"finfo",
"(",
"float",
")",
".",
"eps",
")",
")",
":",
"(",
"S",
",",
"Q",
")",
"=",
"eigh",
"(",
"K",
")",
"nok",
"=",
"abs",
"(",
"max",
"(",
"Q",
"[",
"0",
"]",
".",
"mi... | r"""Economic eigen decomposition for symmetric matrices.
A symmetric matrix ``K`` can be decomposed in
:math:`\mathrm Q_0 \mathrm S_0 \mathrm Q_0^\intercal + \mathrm Q_1\
\mathrm S_1 \mathrm Q_1^ \intercal`, where :math:`\mathrm S_1` is a zero
matrix with size determined by ``K``'s rank deficiency.
... | [
"r",
"Economic",
"eigen",
"decomposition",
"for",
"symmetric",
"matrices",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/qs.py#L5-L36 |
limix/numpy-sugar | numpy_sugar/linalg/qs.py | economic_qs_linear | def economic_qs_linear(G):
r"""Economic eigen decomposition for symmetric matrices ``dot(G, G.T)``.
It is theoretically equivalent to ``economic_qs(dot(G, G.T))``.
Refer to :func:`numpy_sugar.economic_qs` for further information.
Args:
G (array_like): Matrix.
Returns:
tuple: ``((Q... | python | def economic_qs_linear(G):
r"""Economic eigen decomposition for symmetric matrices ``dot(G, G.T)``.
It is theoretically equivalent to ``economic_qs(dot(G, G.T))``.
Refer to :func:`numpy_sugar.economic_qs` for further information.
Args:
G (array_like): Matrix.
Returns:
tuple: ``((Q... | [
"def",
"economic_qs_linear",
"(",
"G",
")",
":",
"import",
"dask",
".",
"array",
"as",
"da",
"if",
"not",
"isinstance",
"(",
"G",
",",
"da",
".",
"Array",
")",
":",
"G",
"=",
"asarray",
"(",
"G",
",",
"float",
")",
"if",
"G",
".",
"shape",
"[",
... | r"""Economic eigen decomposition for symmetric matrices ``dot(G, G.T)``.
It is theoretically equivalent to ``economic_qs(dot(G, G.T))``.
Refer to :func:`numpy_sugar.economic_qs` for further information.
Args:
G (array_like): Matrix.
Returns:
tuple: ``((Q0, Q1), S0)``. | [
"r",
"Economic",
"eigen",
"decomposition",
"for",
"symmetric",
"matrices",
"dot",
"(",
"G",
"G",
".",
"T",
")",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/qs.py#L39-L63 |
limix/numpy-sugar | numpy_sugar/_array.py | cartesian | def cartesian(shape):
r"""Cartesian indexing.
Returns a sequence of n-tuples indexing each element of a hypothetical
matrix of the given shape.
Args:
shape (tuple): tuple of dimensions.
Returns:
array_like: indices.
Example
-------
.. doctest::
>>> from nump... | python | def cartesian(shape):
r"""Cartesian indexing.
Returns a sequence of n-tuples indexing each element of a hypothetical
matrix of the given shape.
Args:
shape (tuple): tuple of dimensions.
Returns:
array_like: indices.
Example
-------
.. doctest::
>>> from nump... | [
"def",
"cartesian",
"(",
"shape",
")",
":",
"n",
"=",
"len",
"(",
"shape",
")",
"idx",
"=",
"[",
"slice",
"(",
"0",
",",
"s",
")",
"for",
"s",
"in",
"shape",
"]",
"g",
"=",
"rollaxis",
"(",
"mgrid",
"[",
"idx",
"]",
",",
"0",
",",
"n",
"+",... | r"""Cartesian indexing.
Returns a sequence of n-tuples indexing each element of a hypothetical
matrix of the given shape.
Args:
shape (tuple): tuple of dimensions.
Returns:
array_like: indices.
Example
-------
.. doctest::
>>> from numpy_sugar import cartesian
... | [
"r",
"Cartesian",
"indexing",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/_array.py#L96-L129 |
limix/numpy-sugar | numpy_sugar/_array.py | unique | def unique(ar):
r"""Find the unique elements of an array.
It uses ``dask.array.unique`` if necessary.
Args:
ar (array_like): Input array.
Returns:
array_like: the sorted unique elements.
"""
import dask.array as da
if isinstance(ar, da.core.Array):
return da.uniq... | python | def unique(ar):
r"""Find the unique elements of an array.
It uses ``dask.array.unique`` if necessary.
Args:
ar (array_like): Input array.
Returns:
array_like: the sorted unique elements.
"""
import dask.array as da
if isinstance(ar, da.core.Array):
return da.uniq... | [
"def",
"unique",
"(",
"ar",
")",
":",
"import",
"dask",
".",
"array",
"as",
"da",
"if",
"isinstance",
"(",
"ar",
",",
"da",
".",
"core",
".",
"Array",
")",
":",
"return",
"da",
".",
"unique",
"(",
"ar",
")",
"return",
"_unique",
"(",
"ar",
")"
] | r"""Find the unique elements of an array.
It uses ``dask.array.unique`` if necessary.
Args:
ar (array_like): Input array.
Returns:
array_like: the sorted unique elements. | [
"r",
"Find",
"the",
"unique",
"elements",
"of",
"an",
"array",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/_array.py#L132-L149 |
limix/numpy-sugar | numpy_sugar/linalg/lu.py | lu_slogdet | def lu_slogdet(LU):
r"""Natural logarithm of a LU decomposition.
Args:
LU (tuple): LU decomposition.
Returns:
tuple: sign and log-determinant.
"""
LU = (asarray(LU[0], float), asarray(LU[1], float))
adet = _sum(log(_abs(LU[0].diagonal())))
s = prod(sign(LU[0].diagonal()))
... | python | def lu_slogdet(LU):
r"""Natural logarithm of a LU decomposition.
Args:
LU (tuple): LU decomposition.
Returns:
tuple: sign and log-determinant.
"""
LU = (asarray(LU[0], float), asarray(LU[1], float))
adet = _sum(log(_abs(LU[0].diagonal())))
s = prod(sign(LU[0].diagonal()))
... | [
"def",
"lu_slogdet",
"(",
"LU",
")",
":",
"LU",
"=",
"(",
"asarray",
"(",
"LU",
"[",
"0",
"]",
",",
"float",
")",
",",
"asarray",
"(",
"LU",
"[",
"1",
"]",
",",
"float",
")",
")",
"adet",
"=",
"_sum",
"(",
"log",
"(",
"_abs",
"(",
"LU",
"["... | r"""Natural logarithm of a LU decomposition.
Args:
LU (tuple): LU decomposition.
Returns:
tuple: sign and log-determinant. | [
"r",
"Natural",
"logarithm",
"of",
"a",
"LU",
"decomposition",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/lu.py#L6-L26 |
limix/numpy-sugar | numpy_sugar/linalg/lu.py | lu_solve | def lu_solve(LU, b):
r"""Solve for LU decomposition.
Solve the linear equations :math:`\mathrm A \mathbf x = \mathbf b`,
given the LU factorization of :math:`\mathrm A`.
Args:
LU (array_like): LU decomposition.
b (array_like): Right-hand side.
Returns:
:class:`numpy.ndarra... | python | def lu_solve(LU, b):
r"""Solve for LU decomposition.
Solve the linear equations :math:`\mathrm A \mathbf x = \mathbf b`,
given the LU factorization of :math:`\mathrm A`.
Args:
LU (array_like): LU decomposition.
b (array_like): Right-hand side.
Returns:
:class:`numpy.ndarra... | [
"def",
"lu_solve",
"(",
"LU",
",",
"b",
")",
":",
"from",
"scipy",
".",
"linalg",
"import",
"lu_solve",
"as",
"sp_lu_solve",
"LU",
"=",
"(",
"asarray",
"(",
"LU",
"[",
"0",
"]",
",",
"float",
")",
",",
"asarray",
"(",
"LU",
"[",
"1",
"]",
",",
... | r"""Solve for LU decomposition.
Solve the linear equations :math:`\mathrm A \mathbf x = \mathbf b`,
given the LU factorization of :math:`\mathrm A`.
Args:
LU (array_like): LU decomposition.
b (array_like): Right-hand side.
Returns:
:class:`numpy.ndarray`: The solution to the s... | [
"r",
"Solve",
"for",
"LU",
"decomposition",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/lu.py#L29-L52 |
limix/numpy-sugar | numpy_sugar/linalg/lstsq.py | lstsq | def lstsq(A, b):
r"""Return the least-squares solution to a linear matrix equation.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Least-squares solution.
"""
A = asarray(A, float)
b = asarray(b, float)
i... | python | def lstsq(A, b):
r"""Return the least-squares solution to a linear matrix equation.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Least-squares solution.
"""
A = asarray(A, float)
b = asarray(b, float)
i... | [
"def",
"lstsq",
"(",
"A",
",",
"b",
")",
":",
"A",
"=",
"asarray",
"(",
"A",
",",
"float",
")",
"b",
"=",
"asarray",
"(",
"b",
",",
"float",
")",
"if",
"A",
".",
"ndim",
"==",
"1",
":",
"A",
"=",
"A",
"[",
":",
",",
"newaxis",
"]",
"if",
... | r"""Return the least-squares solution to a linear matrix equation.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Least-squares solution. | [
"r",
"Return",
"the",
"least",
"-",
"squares",
"solution",
"to",
"a",
"linear",
"matrix",
"equation",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/lstsq.py#L6-L26 |
limix/numpy-sugar | numpy_sugar/ma/dot.py | dotd | def dotd(A, B):
r"""Diagonal of :math:`\mathrm A\mathrm B^\intercal`.
If ``A`` is :math:`n\times p` and ``B`` is :math:`p\times n`, it is done in
:math:`O(pn)`.
Args:
A (array_like): Left matrix.
B (array_like): Right matrix.
Returns:
:class:`numpy.ndarray`: Resulting diag... | python | def dotd(A, B):
r"""Diagonal of :math:`\mathrm A\mathrm B^\intercal`.
If ``A`` is :math:`n\times p` and ``B`` is :math:`p\times n`, it is done in
:math:`O(pn)`.
Args:
A (array_like): Left matrix.
B (array_like): Right matrix.
Returns:
:class:`numpy.ndarray`: Resulting diag... | [
"def",
"dotd",
"(",
"A",
",",
"B",
")",
":",
"A",
"=",
"asarray",
"(",
"A",
",",
"float",
")",
"B",
"=",
"asarray",
"(",
"B",
",",
"float",
")",
"if",
"A",
".",
"ndim",
"==",
"1",
"and",
"B",
".",
"ndim",
"==",
"1",
":",
"return",
"dot",
... | r"""Diagonal of :math:`\mathrm A\mathrm B^\intercal`.
If ``A`` is :math:`n\times p` and ``B`` is :math:`p\times n`, it is done in
:math:`O(pn)`.
Args:
A (array_like): Left matrix.
B (array_like): Right matrix.
Returns:
:class:`numpy.ndarray`: Resulting diagonal. | [
"r",
"Diagonal",
"of",
":",
"math",
":",
"\\",
"mathrm",
"A",
"\\",
"mathrm",
"B^",
"\\",
"intercal",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/ma/dot.py#L4-L25 |
limix/numpy-sugar | numpy_sugar/linalg/svd.py | economic_svd | def economic_svd(G, epsilon=sqrt(finfo(float).eps)):
r"""Economic Singular Value Decomposition.
Args:
G (array_like): Matrix to be factorized.
epsilon (float): Threshold on the square root of the eigen values.
Default is ``sqrt(finfo(float).eps)``.
Returns:
... | python | def economic_svd(G, epsilon=sqrt(finfo(float).eps)):
r"""Economic Singular Value Decomposition.
Args:
G (array_like): Matrix to be factorized.
epsilon (float): Threshold on the square root of the eigen values.
Default is ``sqrt(finfo(float).eps)``.
Returns:
... | [
"def",
"economic_svd",
"(",
"G",
",",
"epsilon",
"=",
"sqrt",
"(",
"finfo",
"(",
"float",
")",
".",
"eps",
")",
")",
":",
"from",
"scipy",
".",
"linalg",
"import",
"svd",
"G",
"=",
"asarray",
"(",
"G",
",",
"float",
")",
"(",
"U",
",",
"S",
","... | r"""Economic Singular Value Decomposition.
Args:
G (array_like): Matrix to be factorized.
epsilon (float): Threshold on the square root of the eigen values.
Default is ``sqrt(finfo(float).eps)``.
Returns:
:class:`numpy.ndarray`: Unitary matrix.
:class:`... | [
"r",
"Economic",
"Singular",
"Value",
"Decomposition",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/svd.py#L4-L30 |
limix/numpy-sugar | numpy_sugar/linalg/solve.py | hsolve | def hsolve(A, y):
r"""Solver for the linear equations of two variables and equations only.
It uses Householder reductions to solve ``Ax = y`` in a robust manner.
Parameters
----------
A : array_like
Coefficient matrix.
y : array_like
Ordinate values.
Returns
-------
... | python | def hsolve(A, y):
r"""Solver for the linear equations of two variables and equations only.
It uses Householder reductions to solve ``Ax = y`` in a robust manner.
Parameters
----------
A : array_like
Coefficient matrix.
y : array_like
Ordinate values.
Returns
-------
... | [
"def",
"hsolve",
"(",
"A",
",",
"y",
")",
":",
"n",
"=",
"_norm",
"(",
"A",
"[",
"0",
",",
"0",
"]",
",",
"A",
"[",
"1",
",",
"0",
"]",
")",
"u0",
"=",
"A",
"[",
"0",
",",
"0",
"]",
"-",
"n",
"u1",
"=",
"A",
"[",
"1",
",",
"0",
"]... | r"""Solver for the linear equations of two variables and equations only.
It uses Householder reductions to solve ``Ax = y`` in a robust manner.
Parameters
----------
A : array_like
Coefficient matrix.
y : array_like
Ordinate values.
Returns
-------
:class:`numpy.ndarra... | [
"r",
"Solver",
"for",
"the",
"linear",
"equations",
"of",
"two",
"variables",
"and",
"equations",
"only",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/solve.py#L31-L98 |
limix/numpy-sugar | numpy_sugar/linalg/solve.py | solve | def solve(A, b):
r"""Solve for the linear equations :math:`\mathrm A \mathbf x = \mathbf b`.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Solution ``x``.
"""
A = asarray(A, float)
b = asarray(b, float)
i... | python | def solve(A, b):
r"""Solve for the linear equations :math:`\mathrm A \mathbf x = \mathbf b`.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Solution ``x``.
"""
A = asarray(A, float)
b = asarray(b, float)
i... | [
"def",
"solve",
"(",
"A",
",",
"b",
")",
":",
"A",
"=",
"asarray",
"(",
"A",
",",
"float",
")",
"b",
"=",
"asarray",
"(",
"b",
",",
"float",
")",
"if",
"A",
".",
"shape",
"[",
"0",
"]",
"==",
"1",
":",
"with",
"errstate",
"(",
"divide",
"="... | r"""Solve for the linear equations :math:`\mathrm A \mathbf x = \mathbf b`.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Solution ``x``. | [
"r",
"Solve",
"for",
"the",
"linear",
"equations",
":",
"math",
":",
"\\",
"mathrm",
"A",
"\\",
"mathbf",
"x",
"=",
"\\",
"mathbf",
"b",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/solve.py#L101-L136 |
limix/numpy-sugar | numpy_sugar/linalg/solve.py | rsolve | def rsolve(A, b, epsilon=_epsilon):
r"""Robust solve for the linear equations.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Solution ``x``.
"""
A = asarray(A, float)
b = asarray(b, float)
if A.shape[0] =... | python | def rsolve(A, b, epsilon=_epsilon):
r"""Robust solve for the linear equations.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Solution ``x``.
"""
A = asarray(A, float)
b = asarray(b, float)
if A.shape[0] =... | [
"def",
"rsolve",
"(",
"A",
",",
"b",
",",
"epsilon",
"=",
"_epsilon",
")",
":",
"A",
"=",
"asarray",
"(",
"A",
",",
"float",
")",
"b",
"=",
"asarray",
"(",
"b",
",",
"float",
")",
"if",
"A",
".",
"shape",
"[",
"0",
"]",
"==",
"0",
":",
"ret... | r"""Robust solve for the linear equations.
Args:
A (array_like): Coefficient matrix.
b (array_like): Ordinate values.
Returns:
:class:`numpy.ndarray`: Solution ``x``. | [
"r",
"Robust",
"solve",
"for",
"the",
"linear",
"equations",
"."
] | train | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/linalg/solve.py#L139-L163 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.