repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceExceptionWrapper.lazy_translations | def lazy_translations(cls):
"""Lazy translations."""
return {
cloudfiles.errors.NoSuchContainer: errors.NoContainerException,
cloudfiles.errors.NoSuchObject: errors.NoObjectException,
} | python | def lazy_translations(cls):
"""Lazy translations."""
return {
cloudfiles.errors.NoSuchContainer: errors.NoContainerException,
cloudfiles.errors.NoSuchObject: errors.NoObjectException,
} | [
"def",
"lazy_translations",
"(",
"cls",
")",
":",
"return",
"{",
"cloudfiles",
".",
"errors",
".",
"NoSuchContainer",
":",
"errors",
".",
"NoContainerException",
",",
"cloudfiles",
".",
"errors",
".",
"NoSuchObject",
":",
"errors",
".",
"NoObjectException",
",",... | Lazy translations. | [
"Lazy",
"translations",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L43-L48 | train | 63,400 |
ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceObject.from_info | def from_info(cls, container, info_obj):
"""Create from subdirectory or file info object."""
create_fn = cls.from_subdir if 'subdir' in info_obj \
else cls.from_file_info
return create_fn(container, info_obj) | python | def from_info(cls, container, info_obj):
"""Create from subdirectory or file info object."""
create_fn = cls.from_subdir if 'subdir' in info_obj \
else cls.from_file_info
return create_fn(container, info_obj) | [
"def",
"from_info",
"(",
"cls",
",",
"container",
",",
"info_obj",
")",
":",
"create_fn",
"=",
"cls",
".",
"from_subdir",
"if",
"'subdir'",
"in",
"info_obj",
"else",
"cls",
".",
"from_file_info",
"return",
"create_fn",
"(",
"container",
",",
"info_obj",
")"
... | Create from subdirectory or file info object. | [
"Create",
"from",
"subdirectory",
"or",
"file",
"info",
"object",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L75-L79 | train | 63,401 |
ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceObject.from_subdir | def from_subdir(cls, container, info_obj):
"""Create from subdirectory info object."""
return cls(container,
info_obj['subdir'],
obj_type=cls.type_cls.SUBDIR) | python | def from_subdir(cls, container, info_obj):
"""Create from subdirectory info object."""
return cls(container,
info_obj['subdir'],
obj_type=cls.type_cls.SUBDIR) | [
"def",
"from_subdir",
"(",
"cls",
",",
"container",
",",
"info_obj",
")",
":",
"return",
"cls",
"(",
"container",
",",
"info_obj",
"[",
"'subdir'",
"]",
",",
"obj_type",
"=",
"cls",
".",
"type_cls",
".",
"SUBDIR",
")"
] | Create from subdirectory info object. | [
"Create",
"from",
"subdirectory",
"info",
"object",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L82-L86 | train | 63,402 |
ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceObject.choose_type | def choose_type(cls, content_type):
"""Choose object type from content type."""
return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
else cls.type_cls.FILE | python | def choose_type(cls, content_type):
"""Choose object type from content type."""
return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
else cls.type_cls.FILE | [
"def",
"choose_type",
"(",
"cls",
",",
"content_type",
")",
":",
"return",
"cls",
".",
"type_cls",
".",
"SUBDIR",
"if",
"content_type",
"in",
"cls",
".",
"subdir_types",
"else",
"cls",
".",
"type_cls",
".",
"FILE"
] | Choose object type from content type. | [
"Choose",
"object",
"type",
"from",
"content",
"type",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L89-L92 | train | 63,403 |
ryan-roemer/django-cloud-browser | cloud_browser/cloud/rackspace.py | RackspaceConnection._get_connection | def _get_connection(self):
"""Return native connection object."""
kwargs = {
'username': self.account,
'api_key': self.secret_key,
}
# Only add kwarg for servicenet if True because user could set
# environment variable 'RACKSPACE_SERVICENET' separately.
... | python | def _get_connection(self):
"""Return native connection object."""
kwargs = {
'username': self.account,
'api_key': self.secret_key,
}
# Only add kwarg for servicenet if True because user could set
# environment variable 'RACKSPACE_SERVICENET' separately.
... | [
"def",
"_get_connection",
"(",
"self",
")",
":",
"kwargs",
"=",
"{",
"'username'",
":",
"self",
".",
"account",
",",
"'api_key'",
":",
"self",
".",
"secret_key",
",",
"}",
"# Only add kwarg for servicenet if True because user could set",
"# environment variable 'RACKSPA... | Return native connection object. | [
"Return",
"native",
"connection",
"object",
"."
] | b06cdd24885a6309e843ed924dbf1705b67e7f48 | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/rackspace.py#L254-L269 | train | 63,404 |
bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.delta_E | def delta_E( self ):
"""
The change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E
"""
site_delta_E = self.final_site.energy - self.initial_site.energy
if self.nearest_neighbour_energy:
site_... | python | def delta_E( self ):
"""
The change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E
"""
site_delta_E = self.final_site.energy - self.initial_site.energy
if self.nearest_neighbour_energy:
site_... | [
"def",
"delta_E",
"(",
"self",
")",
":",
"site_delta_E",
"=",
"self",
".",
"final_site",
".",
"energy",
"-",
"self",
".",
"initial_site",
".",
"energy",
"if",
"self",
".",
"nearest_neighbour_energy",
":",
"site_delta_E",
"+=",
"self",
".",
"nearest_neighbour_d... | The change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E | [
"The",
"change",
"in",
"system",
"energy",
"if",
"this",
"jump",
"were",
"accepted",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L62-L77 | train | 63,405 |
bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.nearest_neighbour_delta_E | def nearest_neighbour_delta_E( self ):
"""
Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour)
"""
delta_nn = self.final_site.nn_occupation... | python | def nearest_neighbour_delta_E( self ):
"""
Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour)
"""
delta_nn = self.final_site.nn_occupation... | [
"def",
"nearest_neighbour_delta_E",
"(",
"self",
")",
":",
"delta_nn",
"=",
"self",
".",
"final_site",
".",
"nn_occupation",
"(",
")",
"-",
"self",
".",
"initial_site",
".",
"nn_occupation",
"(",
")",
"-",
"1",
"# -1 because the hopping ion is not counted in the fin... | Nearest-neighbour interaction contribution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (nearest-neighbour) | [
"Nearest",
"-",
"neighbour",
"interaction",
"contribution",
"to",
"the",
"change",
"in",
"system",
"energy",
"if",
"this",
"jump",
"were",
"accepted",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L79-L90 | train | 63,406 |
bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.coordination_number_delta_E | def coordination_number_delta_E( self ):
"""
Coordination-number dependent energy conrtibution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (coordination-number)
"""
initial_site_neighbours = [ s... | python | def coordination_number_delta_E( self ):
"""
Coordination-number dependent energy conrtibution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (coordination-number)
"""
initial_site_neighbours = [ s... | [
"def",
"coordination_number_delta_E",
"(",
"self",
")",
":",
"initial_site_neighbours",
"=",
"[",
"s",
"for",
"s",
"in",
"self",
".",
"initial_site",
".",
"p_neighbours",
"if",
"s",
".",
"is_occupied",
"]",
"# excludes final site, since this is always unoccupied",
"fi... | Coordination-number dependent energy conrtibution to the change in system energy if this jump were accepted.
Args:
None
Returns:
(Float): delta E (coordination-number) | [
"Coordination",
"-",
"number",
"dependent",
"energy",
"conrtibution",
"to",
"the",
"change",
"in",
"system",
"energy",
"if",
"this",
"jump",
"were",
"accepted",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L92-L110 | train | 63,407 |
bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.dr | def dr( self, cell_lengths ):
"""
Particle displacement vector for this jump
Args:
cell_lengths (np.array(x,y,z)): Cell lengths for the orthogonal simulation cell.
Returns
(np.array(x,y,z)): dr
"""
half_cell_lengths = cell_lengths / 2.0
t... | python | def dr( self, cell_lengths ):
"""
Particle displacement vector for this jump
Args:
cell_lengths (np.array(x,y,z)): Cell lengths for the orthogonal simulation cell.
Returns
(np.array(x,y,z)): dr
"""
half_cell_lengths = cell_lengths / 2.0
t... | [
"def",
"dr",
"(",
"self",
",",
"cell_lengths",
")",
":",
"half_cell_lengths",
"=",
"cell_lengths",
"/",
"2.0",
"this_dr",
"=",
"self",
".",
"final_site",
".",
"r",
"-",
"self",
".",
"initial_site",
".",
"r",
"for",
"i",
"in",
"range",
"(",
"3",
")",
... | Particle displacement vector for this jump
Args:
cell_lengths (np.array(x,y,z)): Cell lengths for the orthogonal simulation cell.
Returns
(np.array(x,y,z)): dr | [
"Particle",
"displacement",
"vector",
"for",
"this",
"jump"
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L112-L129 | train | 63,408 |
bjmorgan/lattice_mc | lattice_mc/jump.py | Jump.relative_probability_from_lookup_table | def relative_probability_from_lookup_table( self, jump_lookup_table ):
"""
Relative probability of accepting this jump from a lookup-table.
Args:
jump_lookup_table (LookupTable): the lookup table to be used for this jump.
Returns:
(Float): relative probability o... | python | def relative_probability_from_lookup_table( self, jump_lookup_table ):
"""
Relative probability of accepting this jump from a lookup-table.
Args:
jump_lookup_table (LookupTable): the lookup table to be used for this jump.
Returns:
(Float): relative probability o... | [
"def",
"relative_probability_from_lookup_table",
"(",
"self",
",",
"jump_lookup_table",
")",
":",
"l1",
"=",
"self",
".",
"initial_site",
".",
"label",
"l2",
"=",
"self",
".",
"final_site",
".",
"label",
"c1",
"=",
"self",
".",
"initial_site",
".",
"nn_occupat... | Relative probability of accepting this jump from a lookup-table.
Args:
jump_lookup_table (LookupTable): the lookup table to be used for this jump.
Returns:
(Float): relative probability of accepting this jump. | [
"Relative",
"probability",
"of",
"accepting",
"this",
"jump",
"from",
"a",
"lookup",
"-",
"table",
"."
] | 7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5 | https://github.com/bjmorgan/lattice_mc/blob/7fa7be85f2f23a2d8dfd0830ecdb89d0dbf2bfd5/lattice_mc/jump.py#L131-L145 | train | 63,409 |
Kitware/tangelo | tangelo/tangelo/util.py | module_cache_get | def module_cache_get(cache, module):
"""
Import a module with an optional yaml config file, but only if we haven't
imported it already.
:param cache: object which holds information on which modules and config
files have been loaded and whether config files should be
... | python | def module_cache_get(cache, module):
"""
Import a module with an optional yaml config file, but only if we haven't
imported it already.
:param cache: object which holds information on which modules and config
files have been loaded and whether config files should be
... | [
"def",
"module_cache_get",
"(",
"cache",
",",
"module",
")",
":",
"if",
"getattr",
"(",
"cache",
",",
"\"config\"",
",",
"False",
")",
":",
"config_file",
"=",
"module",
"[",
":",
"-",
"2",
"]",
"+",
"\"yaml\"",
"if",
"config_file",
"not",
"in",
"cache... | Import a module with an optional yaml config file, but only if we haven't
imported it already.
:param cache: object which holds information on which modules and config
files have been loaded and whether config files should be
loaded.
:param module: the path of the module... | [
"Import",
"a",
"module",
"with",
"an",
"optional",
"yaml",
"config",
"file",
"but",
"only",
"if",
"we",
"haven",
"t",
"imported",
"it",
"already",
"."
] | 470034ee9b3d7a01becc1ce5fddc7adc1d5263ef | https://github.com/Kitware/tangelo/blob/470034ee9b3d7a01becc1ce5fddc7adc1d5263ef/tangelo/tangelo/util.py#L170-L214 | train | 63,410 |
bihealth/vcfpy | vcfpy/bgzf.py | BgzfWriter.close | def close(self):
"""Flush data, write 28 bytes BGZF EOF marker, and close BGZF file.
samtools will look for a magic EOF marker, just a 28 byte empty BGZF
block, and if it is missing warns the BAM file may be truncated. In
addition to samtools writing this block, so too does bgzip - so th... | python | def close(self):
"""Flush data, write 28 bytes BGZF EOF marker, and close BGZF file.
samtools will look for a magic EOF marker, just a 28 byte empty BGZF
block, and if it is missing warns the BAM file may be truncated. In
addition to samtools writing this block, so too does bgzip - so th... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_buffer",
":",
"self",
".",
"flush",
"(",
")",
"self",
".",
"_handle",
".",
"write",
"(",
"_bgzf_eof",
")",
"self",
".",
"_handle",
".",
"flush",
"(",
")",
"self",
".",
"_handle",
".",
"c... | Flush data, write 28 bytes BGZF EOF marker, and close BGZF file.
samtools will look for a magic EOF marker, just a 28 byte empty BGZF
block, and if it is missing warns the BAM file may be truncated. In
addition to samtools writing this block, so too does bgzip - so this
implementation do... | [
"Flush",
"data",
"write",
"28",
"bytes",
"BGZF",
"EOF",
"marker",
"and",
"close",
"BGZF",
"file",
".",
"samtools",
"will",
"look",
"for",
"a",
"magic",
"EOF",
"marker",
"just",
"a",
"28",
"byte",
"empty",
"BGZF",
"block",
"and",
"if",
"it",
"is",
"miss... | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/bgzf.py#L157-L168 | train | 63,411 |
eraclitux/ipcampy | ipcamweb/utils.py | ensure_secret | def ensure_secret():
"""Check if secret key to encryot sessions exists,
generate it otherwise."""
home_dir = os.environ['HOME']
file_name = home_dir + "/.ipcamweb"
if os.path.exists(file_name):
with open(file_name, "r") as s_file:
secret = s_file.readline()
else:
secr... | python | def ensure_secret():
"""Check if secret key to encryot sessions exists,
generate it otherwise."""
home_dir = os.environ['HOME']
file_name = home_dir + "/.ipcamweb"
if os.path.exists(file_name):
with open(file_name, "r") as s_file:
secret = s_file.readline()
else:
secr... | [
"def",
"ensure_secret",
"(",
")",
":",
"home_dir",
"=",
"os",
".",
"environ",
"[",
"'HOME'",
"]",
"file_name",
"=",
"home_dir",
"+",
"\"/.ipcamweb\"",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_name",
")",
":",
"with",
"open",
"(",
"file_name",
... | Check if secret key to encryot sessions exists,
generate it otherwise. | [
"Check",
"if",
"secret",
"key",
"to",
"encryot",
"sessions",
"exists",
"generate",
"it",
"otherwise",
"."
] | bffd1c4df9006705cffa5b83a090b0db90cbcbcf | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcamweb/utils.py#L6-L18 | train | 63,412 |
eraclitux/ipcampy | ipcamweb/utils.py | list_snapshots_for_a_minute | def list_snapshots_for_a_minute(path, cam_id, day, hourm):
"""Returns a list of screenshots"""
screenshoots_path = path+"/"+str(cam_id)+"/"+day+"/"+hourm
if os.path.exists(screenshoots_path):
screenshots = [scr for scr in sorted(os.listdir(screenshoots_path))]
return screenshots
else:
... | python | def list_snapshots_for_a_minute(path, cam_id, day, hourm):
"""Returns a list of screenshots"""
screenshoots_path = path+"/"+str(cam_id)+"/"+day+"/"+hourm
if os.path.exists(screenshoots_path):
screenshots = [scr for scr in sorted(os.listdir(screenshoots_path))]
return screenshots
else:
... | [
"def",
"list_snapshots_for_a_minute",
"(",
"path",
",",
"cam_id",
",",
"day",
",",
"hourm",
")",
":",
"screenshoots_path",
"=",
"path",
"+",
"\"/\"",
"+",
"str",
"(",
"cam_id",
")",
"+",
"\"/\"",
"+",
"day",
"+",
"\"/\"",
"+",
"hourm",
"if",
"os",
".",... | Returns a list of screenshots | [
"Returns",
"a",
"list",
"of",
"screenshots"
] | bffd1c4df9006705cffa5b83a090b0db90cbcbcf | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcamweb/utils.py#L44-L51 | train | 63,413 |
bihealth/vcfpy | vcfpy/record.py | Record.is_snv | def is_snv(self):
"""Return ``True`` if it is a SNV"""
return len(self.REF) == 1 and all(a.type == "SNV" for a in self.ALT) | python | def is_snv(self):
"""Return ``True`` if it is a SNV"""
return len(self.REF) == 1 and all(a.type == "SNV" for a in self.ALT) | [
"def",
"is_snv",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"REF",
")",
"==",
"1",
"and",
"all",
"(",
"a",
".",
"type",
"==",
"\"SNV\"",
"for",
"a",
"in",
"self",
".",
"ALT",
")"
] | Return ``True`` if it is a SNV | [
"Return",
"True",
"if",
"it",
"is",
"a",
"SNV"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L95-L97 | train | 63,414 |
bihealth/vcfpy | vcfpy/record.py | Record.affected_start | def affected_start(self):
"""Return affected start position in 0-based coordinates
For SNVs, MNVs, and deletions, the behaviour is the start position.
In the case of insertions, the position behind the insert position is
returned, yielding a 0-length interval together with
:py:m... | python | def affected_start(self):
"""Return affected start position in 0-based coordinates
For SNVs, MNVs, and deletions, the behaviour is the start position.
In the case of insertions, the position behind the insert position is
returned, yielding a 0-length interval together with
:py:m... | [
"def",
"affected_start",
"(",
"self",
")",
":",
"types",
"=",
"{",
"alt",
".",
"type",
"for",
"alt",
"in",
"self",
".",
"ALT",
"}",
"# set!",
"BAD_MIX",
"=",
"{",
"INS",
",",
"SV",
",",
"BND",
",",
"SYMBOLIC",
"}",
"# don't mix well with others",
"if",... | Return affected start position in 0-based coordinates
For SNVs, MNVs, and deletions, the behaviour is the start position.
In the case of insertions, the position behind the insert position is
returned, yielding a 0-length interval together with
:py:meth:`~Record.affected_end` | [
"Return",
"affected",
"start",
"position",
"in",
"0",
"-",
"based",
"coordinates"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L100-L114 | train | 63,415 |
bihealth/vcfpy | vcfpy/record.py | Record.add_filter | def add_filter(self, label):
"""Add label to FILTER if not set yet, removing ``PASS`` entry if
present
"""
if label not in self.FILTER:
if "PASS" in self.FILTER:
self.FILTER = [f for f in self.FILTER if f != "PASS"]
self.FILTER.append(label) | python | def add_filter(self, label):
"""Add label to FILTER if not set yet, removing ``PASS`` entry if
present
"""
if label not in self.FILTER:
if "PASS" in self.FILTER:
self.FILTER = [f for f in self.FILTER if f != "PASS"]
self.FILTER.append(label) | [
"def",
"add_filter",
"(",
"self",
",",
"label",
")",
":",
"if",
"label",
"not",
"in",
"self",
".",
"FILTER",
":",
"if",
"\"PASS\"",
"in",
"self",
".",
"FILTER",
":",
"self",
".",
"FILTER",
"=",
"[",
"f",
"for",
"f",
"in",
"self",
".",
"FILTER",
"... | Add label to FILTER if not set yet, removing ``PASS`` entry if
present | [
"Add",
"label",
"to",
"FILTER",
"if",
"not",
"set",
"yet",
"removing",
"PASS",
"entry",
"if",
"present"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L133-L140 | train | 63,416 |
bihealth/vcfpy | vcfpy/record.py | Record.add_format | def add_format(self, key, value=None):
"""Add an entry to format
The record's calls ``data[key]`` will be set to ``value`` if not yet
set and value is not ``None``. If key is already in FORMAT then
nothing is done.
"""
if key in self.FORMAT:
return
s... | python | def add_format(self, key, value=None):
"""Add an entry to format
The record's calls ``data[key]`` will be set to ``value`` if not yet
set and value is not ``None``. If key is already in FORMAT then
nothing is done.
"""
if key in self.FORMAT:
return
s... | [
"def",
"add_format",
"(",
"self",
",",
"key",
",",
"value",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
".",
"FORMAT",
":",
"return",
"self",
".",
"FORMAT",
".",
"append",
"(",
"key",
")",
"if",
"value",
"is",
"not",
"None",
":",
"for",
"ca... | Add an entry to format
The record's calls ``data[key]`` will be set to ``value`` if not yet
set and value is not ``None``. If key is already in FORMAT then
nothing is done. | [
"Add",
"an",
"entry",
"to",
"format"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L142-L154 | train | 63,417 |
bihealth/vcfpy | vcfpy/record.py | Call.gt_type | def gt_type(self):
"""The type of genotype, returns one of ``HOM_REF``, ``HOM_ALT``, and
``HET``.
"""
if not self.called:
return None # not called
elif all(a == 0 for a in self.gt_alleles):
return HOM_REF
elif len(set(self.gt_alleles)) == 1:
... | python | def gt_type(self):
"""The type of genotype, returns one of ``HOM_REF``, ``HOM_ALT``, and
``HET``.
"""
if not self.called:
return None # not called
elif all(a == 0 for a in self.gt_alleles):
return HOM_REF
elif len(set(self.gt_alleles)) == 1:
... | [
"def",
"gt_type",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"called",
":",
"return",
"None",
"# not called",
"elif",
"all",
"(",
"a",
"==",
"0",
"for",
"a",
"in",
"self",
".",
"gt_alleles",
")",
":",
"return",
"HOM_REF",
"elif",
"len",
"(",
... | The type of genotype, returns one of ``HOM_REF``, ``HOM_ALT``, and
``HET``. | [
"The",
"type",
"of",
"genotype",
"returns",
"one",
"of",
"HOM_REF",
"HOM_ALT",
"and",
"HET",
"."
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L268-L279 | train | 63,418 |
bihealth/vcfpy | vcfpy/record.py | Call.is_filtered | def is_filtered(self, require=None, ignore=None):
"""Return ``True`` for filtered calls
:param iterable ignore: if set, the filters to ignore, make sure to
include 'PASS', when setting, default is ``['PASS']``
:param iterable require: if set, the filters to require for returning
... | python | def is_filtered(self, require=None, ignore=None):
"""Return ``True`` for filtered calls
:param iterable ignore: if set, the filters to ignore, make sure to
include 'PASS', when setting, default is ``['PASS']``
:param iterable require: if set, the filters to require for returning
... | [
"def",
"is_filtered",
"(",
"self",
",",
"require",
"=",
"None",
",",
"ignore",
"=",
"None",
")",
":",
"ignore",
"=",
"ignore",
"or",
"[",
"\"PASS\"",
"]",
"if",
"\"FT\"",
"not",
"in",
"self",
".",
"data",
"or",
"not",
"self",
".",
"data",
"[",
"\"F... | Return ``True`` for filtered calls
:param iterable ignore: if set, the filters to ignore, make sure to
include 'PASS', when setting, default is ``['PASS']``
:param iterable require: if set, the filters to require for returning
``True`` | [
"Return",
"True",
"for",
"filtered",
"calls"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L281-L299 | train | 63,419 |
bihealth/vcfpy | vcfpy/record.py | BreakEnd.serialize | def serialize(self):
"""Return string representation for VCF"""
if self.mate_chrom is None:
remote_tag = "."
else:
if self.within_main_assembly:
mate_chrom = self.mate_chrom
else:
mate_chrom = "<{}>".format(self.mate_chrom)
... | python | def serialize(self):
"""Return string representation for VCF"""
if self.mate_chrom is None:
remote_tag = "."
else:
if self.within_main_assembly:
mate_chrom = self.mate_chrom
else:
mate_chrom = "<{}>".format(self.mate_chrom)
... | [
"def",
"serialize",
"(",
"self",
")",
":",
"if",
"self",
".",
"mate_chrom",
"is",
"None",
":",
"remote_tag",
"=",
"\".\"",
"else",
":",
"if",
"self",
".",
"within_main_assembly",
":",
"mate_chrom",
"=",
"self",
".",
"mate_chrom",
"else",
":",
"mate_chrom",... | Return string representation for VCF | [
"Return",
"string",
"representation",
"for",
"VCF"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/record.py#L431-L445 | train | 63,420 |
chriso/timeseries | timeseries/time_series.py | TimeSeries.trend_coefficients | def trend_coefficients(self, order=LINEAR):
'''Calculate trend coefficients for the specified order.'''
if not len(self.points):
raise ArithmeticError('Cannot calculate the trend of an empty series')
return LazyImport.numpy().polyfit(self.timestamps, self.values, order) | python | def trend_coefficients(self, order=LINEAR):
'''Calculate trend coefficients for the specified order.'''
if not len(self.points):
raise ArithmeticError('Cannot calculate the trend of an empty series')
return LazyImport.numpy().polyfit(self.timestamps, self.values, order) | [
"def",
"trend_coefficients",
"(",
"self",
",",
"order",
"=",
"LINEAR",
")",
":",
"if",
"not",
"len",
"(",
"self",
".",
"points",
")",
":",
"raise",
"ArithmeticError",
"(",
"'Cannot calculate the trend of an empty series'",
")",
"return",
"LazyImport",
".",
"nump... | Calculate trend coefficients for the specified order. | [
"Calculate",
"trend",
"coefficients",
"for",
"the",
"specified",
"order",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L62-L66 | train | 63,421 |
chriso/timeseries | timeseries/time_series.py | TimeSeries.moving_average | def moving_average(self, window, method=SIMPLE):
'''Calculate a moving average using the specified method and window'''
if len(self.points) < window:
raise ArithmeticError('Not enough points for moving average')
numpy = LazyImport.numpy()
if method == TimeSeries.SIMPLE:
... | python | def moving_average(self, window, method=SIMPLE):
'''Calculate a moving average using the specified method and window'''
if len(self.points) < window:
raise ArithmeticError('Not enough points for moving average')
numpy = LazyImport.numpy()
if method == TimeSeries.SIMPLE:
... | [
"def",
"moving_average",
"(",
"self",
",",
"window",
",",
"method",
"=",
"SIMPLE",
")",
":",
"if",
"len",
"(",
"self",
".",
"points",
")",
"<",
"window",
":",
"raise",
"ArithmeticError",
"(",
"'Not enough points for moving average'",
")",
"numpy",
"=",
"Lazy... | Calculate a moving average using the specified method and window | [
"Calculate",
"a",
"moving",
"average",
"using",
"the",
"specified",
"method",
"and",
"window"
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L68-L77 | train | 63,422 |
chriso/timeseries | timeseries/time_series.py | TimeSeries.forecast | def forecast(self, horizon, method=ARIMA, frequency=None):
'''Forecast points beyond the time series range using the specified
forecasting method. `horizon` is the number of points to forecast.'''
if len(self.points) <= 1:
raise ArithmeticError('Cannot run forecast when len(series) <... | python | def forecast(self, horizon, method=ARIMA, frequency=None):
'''Forecast points beyond the time series range using the specified
forecasting method. `horizon` is the number of points to forecast.'''
if len(self.points) <= 1:
raise ArithmeticError('Cannot run forecast when len(series) <... | [
"def",
"forecast",
"(",
"self",
",",
"horizon",
",",
"method",
"=",
"ARIMA",
",",
"frequency",
"=",
"None",
")",
":",
"if",
"len",
"(",
"self",
".",
"points",
")",
"<=",
"1",
":",
"raise",
"ArithmeticError",
"(",
"'Cannot run forecast when len(series) <= 1'"... | Forecast points beyond the time series range using the specified
forecasting method. `horizon` is the number of points to forecast. | [
"Forecast",
"points",
"beyond",
"the",
"time",
"series",
"range",
"using",
"the",
"specified",
"forecasting",
"method",
".",
"horizon",
"is",
"the",
"number",
"of",
"points",
"to",
"forecast",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L79-L99 | train | 63,423 |
chriso/timeseries | timeseries/time_series.py | TimeSeries.decompose | def decompose(self, frequency, window=None, periodic=False):
'''Use STL to decompose the time series into seasonal, trend, and
residual components.'''
R = LazyImport.rpy2()
if periodic:
window = 'periodic'
elif window is None:
window = frequency
ti... | python | def decompose(self, frequency, window=None, periodic=False):
'''Use STL to decompose the time series into seasonal, trend, and
residual components.'''
R = LazyImport.rpy2()
if periodic:
window = 'periodic'
elif window is None:
window = frequency
ti... | [
"def",
"decompose",
"(",
"self",
",",
"frequency",
",",
"window",
"=",
"None",
",",
"periodic",
"=",
"False",
")",
":",
"R",
"=",
"LazyImport",
".",
"rpy2",
"(",
")",
"if",
"periodic",
":",
"window",
"=",
"'periodic'",
"elif",
"window",
"is",
"None",
... | Use STL to decompose the time series into seasonal, trend, and
residual components. | [
"Use",
"STL",
"to",
"decompose",
"the",
"time",
"series",
"into",
"seasonal",
"trend",
"and",
"residual",
"components",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L101-L122 | train | 63,424 |
chriso/timeseries | timeseries/time_series.py | TimeSeries.plot | def plot(self, label=None, colour='g', style='-'): # pragma: no cover
'''Plot the time series.'''
pylab = LazyImport.pylab()
pylab.plot(self.dates, self.values, '%s%s' % (colour, style), label=label)
if label is not None:
pylab.legend()
pylab.show() | python | def plot(self, label=None, colour='g', style='-'): # pragma: no cover
'''Plot the time series.'''
pylab = LazyImport.pylab()
pylab.plot(self.dates, self.values, '%s%s' % (colour, style), label=label)
if label is not None:
pylab.legend()
pylab.show() | [
"def",
"plot",
"(",
"self",
",",
"label",
"=",
"None",
",",
"colour",
"=",
"'g'",
",",
"style",
"=",
"'-'",
")",
":",
"# pragma: no cover",
"pylab",
"=",
"LazyImport",
".",
"pylab",
"(",
")",
"pylab",
".",
"plot",
"(",
"self",
".",
"dates",
",",
"s... | Plot the time series. | [
"Plot",
"the",
"time",
"series",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/time_series.py#L124-L130 | train | 63,425 |
chriso/timeseries | timeseries/utilities.py | table_output | def table_output(data):
'''Get a table representation of a dictionary.'''
if type(data) == DictType:
data = data.items()
headings = [ item[0] for item in data ]
rows = [ item[1] for item in data ]
columns = zip(*rows)
if len(columns):
widths = [ max([ len(str(y)) for y in row ]) ... | python | def table_output(data):
'''Get a table representation of a dictionary.'''
if type(data) == DictType:
data = data.items()
headings = [ item[0] for item in data ]
rows = [ item[1] for item in data ]
columns = zip(*rows)
if len(columns):
widths = [ max([ len(str(y)) for y in row ]) ... | [
"def",
"table_output",
"(",
"data",
")",
":",
"if",
"type",
"(",
"data",
")",
"==",
"DictType",
":",
"data",
"=",
"data",
".",
"items",
"(",
")",
"headings",
"=",
"[",
"item",
"[",
"0",
"]",
"for",
"item",
"in",
"data",
"]",
"rows",
"=",
"[",
"... | Get a table representation of a dictionary. | [
"Get",
"a",
"table",
"representation",
"of",
"a",
"dictionary",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/utilities.py#L4-L22 | train | 63,426 |
chriso/timeseries | timeseries/utilities.py | to_datetime | def to_datetime(time):
'''Convert `time` to a datetime.'''
if type(time) == IntType or type(time) == LongType:
time = datetime.fromtimestamp(time // 1000)
return time | python | def to_datetime(time):
'''Convert `time` to a datetime.'''
if type(time) == IntType or type(time) == LongType:
time = datetime.fromtimestamp(time // 1000)
return time | [
"def",
"to_datetime",
"(",
"time",
")",
":",
"if",
"type",
"(",
"time",
")",
"==",
"IntType",
"or",
"type",
"(",
"time",
")",
"==",
"LongType",
":",
"time",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"time",
"//",
"1000",
")",
"return",
"time"
] | Convert `time` to a datetime. | [
"Convert",
"time",
"to",
"a",
"datetime",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/utilities.py#L24-L28 | train | 63,427 |
timmahrt/pysle | pysle/praattools.py | spellCheckTextgrid | def spellCheckTextgrid(tg, targetTierName, newTierName, isleDict,
printEntries=False):
'''
Spell check words by using the praatio spellcheck function
Incorrect items are noted in a new tier and optionally
printed to the screen
'''
def checkFunc(word):
... | python | def spellCheckTextgrid(tg, targetTierName, newTierName, isleDict,
printEntries=False):
'''
Spell check words by using the praatio spellcheck function
Incorrect items are noted in a new tier and optionally
printed to the screen
'''
def checkFunc(word):
... | [
"def",
"spellCheckTextgrid",
"(",
"tg",
",",
"targetTierName",
",",
"newTierName",
",",
"isleDict",
",",
"printEntries",
"=",
"False",
")",
":",
"def",
"checkFunc",
"(",
"word",
")",
":",
"try",
":",
"isleDict",
".",
"lookup",
"(",
"word",
")",
"except",
... | Spell check words by using the praatio spellcheck function
Incorrect items are noted in a new tier and optionally
printed to the screen | [
"Spell",
"check",
"words",
"by",
"using",
"the",
"praatio",
"spellcheck",
"function",
"Incorrect",
"items",
"are",
"noted",
"in",
"a",
"new",
"tier",
"and",
"optionally",
"printed",
"to",
"the",
"screen"
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/praattools.py#L24-L46 | train | 63,428 |
bihealth/vcfpy | vcfpy/parser.py | split_mapping | def split_mapping(pair_str):
"""Split the ``str`` in ``pair_str`` at ``'='``
Warn if key needs to be stripped
"""
orig_key, value = pair_str.split("=", 1)
key = orig_key.strip()
if key != orig_key:
warnings.warn(
"Mapping key {} has leading or trailing space".format(repr(ori... | python | def split_mapping(pair_str):
"""Split the ``str`` in ``pair_str`` at ``'='``
Warn if key needs to be stripped
"""
orig_key, value = pair_str.split("=", 1)
key = orig_key.strip()
if key != orig_key:
warnings.warn(
"Mapping key {} has leading or trailing space".format(repr(ori... | [
"def",
"split_mapping",
"(",
"pair_str",
")",
":",
"orig_key",
",",
"value",
"=",
"pair_str",
".",
"split",
"(",
"\"=\"",
",",
"1",
")",
"key",
"=",
"orig_key",
".",
"strip",
"(",
")",
"if",
"key",
"!=",
"orig_key",
":",
"warnings",
".",
"warn",
"(",... | Split the ``str`` in ``pair_str`` at ``'='``
Warn if key needs to be stripped | [
"Split",
"the",
"str",
"in",
"pair_str",
"at",
"="
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L128-L140 | train | 63,429 |
bihealth/vcfpy | vcfpy/parser.py | parse_mapping | def parse_mapping(value):
"""Parse the given VCF header line mapping
Such a mapping consists of "key=value" pairs, separated by commas and
wrapped into angular brackets ("<...>"). Strings are usually quoted,
for certain known keys, exceptions are made, depending on the tag key.
this, however, only... | python | def parse_mapping(value):
"""Parse the given VCF header line mapping
Such a mapping consists of "key=value" pairs, separated by commas and
wrapped into angular brackets ("<...>"). Strings are usually quoted,
for certain known keys, exceptions are made, depending on the tag key.
this, however, only... | [
"def",
"parse_mapping",
"(",
"value",
")",
":",
"if",
"not",
"value",
".",
"startswith",
"(",
"\"<\"",
")",
"or",
"not",
"value",
".",
"endswith",
"(",
"\">\"",
")",
":",
"raise",
"exceptions",
".",
"InvalidHeaderException",
"(",
"\"Header mapping value was no... | Parse the given VCF header line mapping
Such a mapping consists of "key=value" pairs, separated by commas and
wrapped into angular brackets ("<...>"). Strings are usually quoted,
for certain known keys, exceptions are made, depending on the tag key.
this, however, only gets important when serializing.... | [
"Parse",
"the",
"given",
"VCF",
"header",
"line",
"mapping"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L143-L174 | train | 63,430 |
bihealth/vcfpy | vcfpy/parser.py | build_header_parsers | def build_header_parsers():
"""Return mapping for parsers to use for each VCF header type
Inject the WarningHelper into the parsers.
"""
result = {
"ALT": MappingHeaderLineParser(header.AltAlleleHeaderLine),
"contig": MappingHeaderLineParser(header.ContigHeaderLine),
"FILTER": M... | python | def build_header_parsers():
"""Return mapping for parsers to use for each VCF header type
Inject the WarningHelper into the parsers.
"""
result = {
"ALT": MappingHeaderLineParser(header.AltAlleleHeaderLine),
"contig": MappingHeaderLineParser(header.ContigHeaderLine),
"FILTER": M... | [
"def",
"build_header_parsers",
"(",
")",
":",
"result",
"=",
"{",
"\"ALT\"",
":",
"MappingHeaderLineParser",
"(",
"header",
".",
"AltAlleleHeaderLine",
")",
",",
"\"contig\"",
":",
"MappingHeaderLineParser",
"(",
"header",
".",
"ContigHeaderLine",
")",
",",
"\"FIL... | Return mapping for parsers to use for each VCF header type
Inject the WarningHelper into the parsers. | [
"Return",
"mapping",
"for",
"parsers",
"to",
"use",
"for",
"each",
"VCF",
"header",
"type"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L209-L225 | train | 63,431 |
bihealth/vcfpy | vcfpy/parser.py | convert_field_value | def convert_field_value(type_, value):
"""Convert atomic field value according to the type"""
if value == ".":
return None
elif type_ in ("Character", "String"):
if "%" in value:
for k, v in record.UNESCAPE_MAPPING:
value = value.replace(k, v)
return value... | python | def convert_field_value(type_, value):
"""Convert atomic field value according to the type"""
if value == ".":
return None
elif type_ in ("Character", "String"):
if "%" in value:
for k, v in record.UNESCAPE_MAPPING:
value = value.replace(k, v)
return value... | [
"def",
"convert_field_value",
"(",
"type_",
",",
"value",
")",
":",
"if",
"value",
"==",
"\".\"",
":",
"return",
"None",
"elif",
"type_",
"in",
"(",
"\"Character\"",
",",
"\"String\"",
")",
":",
"if",
"\"%\"",
"in",
"value",
":",
"for",
"k",
",",
"v",
... | Convert atomic field value according to the type | [
"Convert",
"atomic",
"field",
"value",
"according",
"to",
"the",
"type"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L238-L255 | train | 63,432 |
bihealth/vcfpy | vcfpy/parser.py | parse_field_value | def parse_field_value(field_info, value):
"""Parse ``value`` according to ``field_info``
"""
if field_info.id == "FT":
return [x for x in value.split(";") if x != "."]
elif field_info.type == "Flag":
return True
elif field_info.number == 1:
return convert_field_value(field_in... | python | def parse_field_value(field_info, value):
"""Parse ``value`` according to ``field_info``
"""
if field_info.id == "FT":
return [x for x in value.split(";") if x != "."]
elif field_info.type == "Flag":
return True
elif field_info.number == 1:
return convert_field_value(field_in... | [
"def",
"parse_field_value",
"(",
"field_info",
",",
"value",
")",
":",
"if",
"field_info",
".",
"id",
"==",
"\"FT\"",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"value",
".",
"split",
"(",
"\";\"",
")",
"if",
"x",
"!=",
"\".\"",
"]",
"elif",
"field_i... | Parse ``value`` according to ``field_info`` | [
"Parse",
"value",
"according",
"to",
"field_info"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L258-L271 | train | 63,433 |
bihealth/vcfpy | vcfpy/parser.py | parse_breakend | def parse_breakend(alt_str):
"""Parse breakend and return tuple with results, parameters for BreakEnd
constructor
"""
arr = BREAKEND_PATTERN.split(alt_str)
mate_chrom, mate_pos = arr[1].split(":", 1)
mate_pos = int(mate_pos)
if mate_chrom[0] == "<":
mate_chrom = mate_chrom[1:-1]
... | python | def parse_breakend(alt_str):
"""Parse breakend and return tuple with results, parameters for BreakEnd
constructor
"""
arr = BREAKEND_PATTERN.split(alt_str)
mate_chrom, mate_pos = arr[1].split(":", 1)
mate_pos = int(mate_pos)
if mate_chrom[0] == "<":
mate_chrom = mate_chrom[1:-1]
... | [
"def",
"parse_breakend",
"(",
"alt_str",
")",
":",
"arr",
"=",
"BREAKEND_PATTERN",
".",
"split",
"(",
"alt_str",
")",
"mate_chrom",
",",
"mate_pos",
"=",
"arr",
"[",
"1",
"]",
".",
"split",
"(",
"\":\"",
",",
"1",
")",
"mate_pos",
"=",
"int",
"(",
"m... | Parse breakend and return tuple with results, parameters for BreakEnd
constructor | [
"Parse",
"breakend",
"and",
"return",
"tuple",
"with",
"results",
"parameters",
"for",
"BreakEnd",
"constructor"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L278-L297 | train | 63,434 |
bihealth/vcfpy | vcfpy/parser.py | process_sub_grow | def process_sub_grow(ref, alt_str):
"""Process substution where the string grows"""
if len(alt_str) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty ALT")
elif len(alt_str) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.DEL, alt_str)
els... | python | def process_sub_grow(ref, alt_str):
"""Process substution where the string grows"""
if len(alt_str) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty ALT")
elif len(alt_str) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.DEL, alt_str)
els... | [
"def",
"process_sub_grow",
"(",
"ref",
",",
"alt_str",
")",
":",
"if",
"len",
"(",
"alt_str",
")",
"==",
"0",
":",
"raise",
"exceptions",
".",
"InvalidRecordException",
"(",
"\"Invalid VCF, empty ALT\"",
")",
"elif",
"len",
"(",
"alt_str",
")",
"==",
"1",
... | Process substution where the string grows | [
"Process",
"substution",
"where",
"the",
"string",
"grows"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L300-L310 | train | 63,435 |
bihealth/vcfpy | vcfpy/parser.py | process_sub_shrink | def process_sub_shrink(ref, alt_str):
"""Process substution where the string shrink"""
if len(ref) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty REF")
elif len(ref) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.INS, alt_str)
else:
... | python | def process_sub_shrink(ref, alt_str):
"""Process substution where the string shrink"""
if len(ref) == 0:
raise exceptions.InvalidRecordException("Invalid VCF, empty REF")
elif len(ref) == 1:
if ref[0] == alt_str[0]:
return record.Substitution(record.INS, alt_str)
else:
... | [
"def",
"process_sub_shrink",
"(",
"ref",
",",
"alt_str",
")",
":",
"if",
"len",
"(",
"ref",
")",
"==",
"0",
":",
"raise",
"exceptions",
".",
"InvalidRecordException",
"(",
"\"Invalid VCF, empty REF\"",
")",
"elif",
"len",
"(",
"ref",
")",
"==",
"1",
":",
... | Process substution where the string shrink | [
"Process",
"substution",
"where",
"the",
"string",
"shrink"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L313-L323 | train | 63,436 |
bihealth/vcfpy | vcfpy/parser.py | process_alt | def process_alt(header, ref, alt_str): # pylint: disable=W0613
"""Process alternative value using Header in ``header``"""
# By its nature, this function contains a large number of case distinctions
if "]" in alt_str or "[" in alt_str:
return record.BreakEnd(*parse_breakend(alt_str))
elif alt_st... | python | def process_alt(header, ref, alt_str): # pylint: disable=W0613
"""Process alternative value using Header in ``header``"""
# By its nature, this function contains a large number of case distinctions
if "]" in alt_str or "[" in alt_str:
return record.BreakEnd(*parse_breakend(alt_str))
elif alt_st... | [
"def",
"process_alt",
"(",
"header",
",",
"ref",
",",
"alt_str",
")",
":",
"# pylint: disable=W0613",
"# By its nature, this function contains a large number of case distinctions",
"if",
"\"]\"",
"in",
"alt_str",
"or",
"\"[\"",
"in",
"alt_str",
":",
"return",
"record",
... | Process alternative value using Header in ``header`` | [
"Process",
"alternative",
"value",
"using",
"Header",
"in",
"header"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L339-L352 | train | 63,437 |
bihealth/vcfpy | vcfpy/parser.py | QuotedStringSplitter.run | def run(self, s):
"""Split string ``s`` at delimiter, correctly interpreting quotes
Further, interprets arrays wrapped in one level of ``[]``. No
recursive brackets are interpreted (as this would make the grammar
non-regular and currently this complexity is not needed). Currently,
... | python | def run(self, s):
"""Split string ``s`` at delimiter, correctly interpreting quotes
Further, interprets arrays wrapped in one level of ``[]``. No
recursive brackets are interpreted (as this would make the grammar
non-regular and currently this complexity is not needed). Currently,
... | [
"def",
"run",
"(",
"self",
",",
"s",
")",
":",
"begins",
",",
"ends",
"=",
"[",
"0",
"]",
",",
"[",
"]",
"# transition table",
"DISPATCH",
"=",
"{",
"self",
".",
"NORMAL",
":",
"self",
".",
"_handle_normal",
",",
"self",
".",
"QUOTED",
":",
"self",... | Split string ``s`` at delimiter, correctly interpreting quotes
Further, interprets arrays wrapped in one level of ``[]``. No
recursive brackets are interpreted (as this would make the grammar
non-regular and currently this complexity is not needed). Currently,
quoting inside of braces... | [
"Split",
"string",
"s",
"at",
"delimiter",
"correctly",
"interpreting",
"quotes"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L64-L89 | train | 63,438 |
bihealth/vcfpy | vcfpy/parser.py | RecordParser._handle_calls | def _handle_calls(self, alts, format_, format_str, arr):
"""Handle FORMAT and calls columns, factored out of parse_line"""
if format_str not in self._format_cache:
self._format_cache[format_str] = list(map(self.header.get_format_field_info, format_))
# per-sample calls
calls ... | python | def _handle_calls(self, alts, format_, format_str, arr):
"""Handle FORMAT and calls columns, factored out of parse_line"""
if format_str not in self._format_cache:
self._format_cache[format_str] = list(map(self.header.get_format_field_info, format_))
# per-sample calls
calls ... | [
"def",
"_handle_calls",
"(",
"self",
",",
"alts",
",",
"format_",
",",
"format_str",
",",
"arr",
")",
":",
"if",
"format_str",
"not",
"in",
"self",
".",
"_format_cache",
":",
"self",
".",
"_format_cache",
"[",
"format_str",
"]",
"=",
"list",
"(",
"map",
... | Handle FORMAT and calls columns, factored out of parse_line | [
"Handle",
"FORMAT",
"and",
"calls",
"columns",
"factored",
"out",
"of",
"parse_line"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L470-L485 | train | 63,439 |
bihealth/vcfpy | vcfpy/parser.py | RecordParser._split_line | def _split_line(self, line_str):
"""Split line and check number of columns"""
arr = line_str.rstrip().split("\t")
if len(arr) != self.expected_fields:
raise exceptions.InvalidRecordException(
(
"The line contains an invalid number of fields. Was "
... | python | def _split_line(self, line_str):
"""Split line and check number of columns"""
arr = line_str.rstrip().split("\t")
if len(arr) != self.expected_fields:
raise exceptions.InvalidRecordException(
(
"The line contains an invalid number of fields. Was "
... | [
"def",
"_split_line",
"(",
"self",
",",
"line_str",
")",
":",
"arr",
"=",
"line_str",
".",
"rstrip",
"(",
")",
".",
"split",
"(",
"\"\\t\"",
")",
"if",
"len",
"(",
"arr",
")",
"!=",
"self",
".",
"expected_fields",
":",
"raise",
"exceptions",
".",
"In... | Split line and check number of columns | [
"Split",
"line",
"and",
"check",
"number",
"of",
"columns"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L512-L522 | train | 63,440 |
bihealth/vcfpy | vcfpy/parser.py | RecordParser._parse_info | def _parse_info(self, info_str, num_alts):
"""Parse INFO column from string"""
result = OrderedDict()
if info_str == ".":
return result
# The standard is very nice to parsers, we can simply split at
# semicolon characters, although I (Manuel) don't know how strict
... | python | def _parse_info(self, info_str, num_alts):
"""Parse INFO column from string"""
result = OrderedDict()
if info_str == ".":
return result
# The standard is very nice to parsers, we can simply split at
# semicolon characters, although I (Manuel) don't know how strict
... | [
"def",
"_parse_info",
"(",
"self",
",",
"info_str",
",",
"num_alts",
")",
":",
"result",
"=",
"OrderedDict",
"(",
")",
"if",
"info_str",
"==",
"\".\"",
":",
"return",
"result",
"# The standard is very nice to parsers, we can simply split at",
"# semicolon characters, al... | Parse INFO column from string | [
"Parse",
"INFO",
"column",
"from",
"string"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L524-L540 | train | 63,441 |
bihealth/vcfpy | vcfpy/parser.py | RecordParser._parse_calls_data | def _parse_calls_data(klass, format_, infos, gt_str):
"""Parse genotype call information from arrays using format array
:param list format: List of strings with format names
:param gt_str arr: string with genotype information values
"""
data = OrderedDict()
# The standar... | python | def _parse_calls_data(klass, format_, infos, gt_str):
"""Parse genotype call information from arrays using format array
:param list format: List of strings with format names
:param gt_str arr: string with genotype information values
"""
data = OrderedDict()
# The standar... | [
"def",
"_parse_calls_data",
"(",
"klass",
",",
"format_",
",",
"infos",
",",
"gt_str",
")",
":",
"data",
"=",
"OrderedDict",
"(",
")",
"# The standard is very nice to parsers, we can simply split at",
"# colon characters, although I (Manuel) don't know how strict",
"# programs ... | Parse genotype call information from arrays using format array
:param list format: List of strings with format names
:param gt_str arr: string with genotype information values | [
"Parse",
"genotype",
"call",
"information",
"from",
"arrays",
"using",
"format",
"array"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L543-L555 | train | 63,442 |
bihealth/vcfpy | vcfpy/parser.py | FormatChecker.run | def run(self, call, num_alts):
"""Check ``FORMAT`` of a record.Call
Currently, only checks for consistent counts are implemented
"""
for key, value in call.data.items():
self._check_count(call, key, value, num_alts) | python | def run(self, call, num_alts):
"""Check ``FORMAT`` of a record.Call
Currently, only checks for consistent counts are implemented
"""
for key, value in call.data.items():
self._check_count(call, key, value, num_alts) | [
"def",
"run",
"(",
"self",
",",
"call",
",",
"num_alts",
")",
":",
"for",
"key",
",",
"value",
"in",
"call",
".",
"data",
".",
"items",
"(",
")",
":",
"self",
".",
"_check_count",
"(",
"call",
",",
"key",
",",
"value",
",",
"num_alts",
")"
] | Check ``FORMAT`` of a record.Call
Currently, only checks for consistent counts are implemented | [
"Check",
"FORMAT",
"of",
"a",
"record",
".",
"Call"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L656-L662 | train | 63,443 |
bihealth/vcfpy | vcfpy/parser.py | Parser._read_next_line | def _read_next_line(self):
"""Read next line store in self._line and return old one"""
prev_line = self._line
self._line = self.stream.readline()
return prev_line | python | def _read_next_line(self):
"""Read next line store in self._line and return old one"""
prev_line = self._line
self._line = self.stream.readline()
return prev_line | [
"def",
"_read_next_line",
"(",
"self",
")",
":",
"prev_line",
"=",
"self",
".",
"_line",
"self",
".",
"_line",
"=",
"self",
".",
"stream",
".",
"readline",
"(",
")",
"return",
"prev_line"
] | Read next line store in self._line and return old one | [
"Read",
"next",
"line",
"store",
"in",
"self",
".",
"_line",
"and",
"return",
"old",
"one"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L714-L718 | train | 63,444 |
bihealth/vcfpy | vcfpy/parser.py | Parser._check_samples_line | def _check_samples_line(klass, arr):
"""Peform additional check on samples line"""
if len(arr) <= len(REQUIRE_NO_SAMPLE_HEADER):
if tuple(arr) != REQUIRE_NO_SAMPLE_HEADER:
raise exceptions.IncorrectVCFFormat(
"Sample header line indicates no sample but doe... | python | def _check_samples_line(klass, arr):
"""Peform additional check on samples line"""
if len(arr) <= len(REQUIRE_NO_SAMPLE_HEADER):
if tuple(arr) != REQUIRE_NO_SAMPLE_HEADER:
raise exceptions.IncorrectVCFFormat(
"Sample header line indicates no sample but doe... | [
"def",
"_check_samples_line",
"(",
"klass",
",",
"arr",
")",
":",
"if",
"len",
"(",
"arr",
")",
"<=",
"len",
"(",
"REQUIRE_NO_SAMPLE_HEADER",
")",
":",
"if",
"tuple",
"(",
"arr",
")",
"!=",
"REQUIRE_NO_SAMPLE_HEADER",
":",
"raise",
"exceptions",
".",
"Inco... | Peform additional check on samples line | [
"Peform",
"additional",
"check",
"on",
"samples",
"line"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/parser.py#L777-L789 | train | 63,445 |
chriso/timeseries | timeseries/lazy_import.py | LazyImport.numpy | def numpy():
'''Lazily import the numpy module'''
if LazyImport.numpy_module is None:
try:
LazyImport.numpy_module = __import__('numpypy')
except ImportError:
try:
LazyImport.numpy_module = __import__('numpy')
ex... | python | def numpy():
'''Lazily import the numpy module'''
if LazyImport.numpy_module is None:
try:
LazyImport.numpy_module = __import__('numpypy')
except ImportError:
try:
LazyImport.numpy_module = __import__('numpy')
ex... | [
"def",
"numpy",
"(",
")",
":",
"if",
"LazyImport",
".",
"numpy_module",
"is",
"None",
":",
"try",
":",
"LazyImport",
".",
"numpy_module",
"=",
"__import__",
"(",
"'numpypy'",
")",
"except",
"ImportError",
":",
"try",
":",
"LazyImport",
".",
"numpy_module",
... | Lazily import the numpy module | [
"Lazily",
"import",
"the",
"numpy",
"module"
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/lazy_import.py#L10-L20 | train | 63,446 |
chriso/timeseries | timeseries/lazy_import.py | LazyImport.rpy2 | def rpy2():
'''Lazily import the rpy2 module'''
if LazyImport.rpy2_module is None:
try:
rpy2 = __import__('rpy2.robjects')
except ImportError:
raise ImportError('The rpy2 module is required')
LazyImport.rpy2_module = rpy2
tr... | python | def rpy2():
'''Lazily import the rpy2 module'''
if LazyImport.rpy2_module is None:
try:
rpy2 = __import__('rpy2.robjects')
except ImportError:
raise ImportError('The rpy2 module is required')
LazyImport.rpy2_module = rpy2
tr... | [
"def",
"rpy2",
"(",
")",
":",
"if",
"LazyImport",
".",
"rpy2_module",
"is",
"None",
":",
"try",
":",
"rpy2",
"=",
"__import__",
"(",
"'rpy2.robjects'",
")",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"'The rpy2 module is required'",
")",
"LazyI... | Lazily import the rpy2 module | [
"Lazily",
"import",
"the",
"rpy2",
"module"
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/lazy_import.py#L23-L38 | train | 63,447 |
eraclitux/ipcampy | ipcampy/foscam.py | map_position | def map_position(pos):
"""Map natural position to machine code postion"""
posiction_dict = dict(zip(range(1, 17), [i for i in range(30, 62) if i % 2]))
return posiction_dict[pos] | python | def map_position(pos):
"""Map natural position to machine code postion"""
posiction_dict = dict(zip(range(1, 17), [i for i in range(30, 62) if i % 2]))
return posiction_dict[pos] | [
"def",
"map_position",
"(",
"pos",
")",
":",
"posiction_dict",
"=",
"dict",
"(",
"zip",
"(",
"range",
"(",
"1",
",",
"17",
")",
",",
"[",
"i",
"for",
"i",
"in",
"range",
"(",
"30",
",",
"62",
")",
"if",
"i",
"%",
"2",
"]",
")",
")",
"return",... | Map natural position to machine code postion | [
"Map",
"natural",
"position",
"to",
"machine",
"code",
"postion"
] | bffd1c4df9006705cffa5b83a090b0db90cbcbcf | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcampy/foscam.py#L15-L19 | train | 63,448 |
eraclitux/ipcampy | ipcampy/foscam.py | FosCam.snap | def snap(self, path=None):
"""Get a snapshot and save it to disk."""
if path is None:
path = "/tmp"
else:
path = path.rstrip("/")
day_dir = datetime.datetime.now().strftime("%d%m%Y")
hour_dir = datetime.datetime.now().strftime("%H%M")
ensure_snapsh... | python | def snap(self, path=None):
"""Get a snapshot and save it to disk."""
if path is None:
path = "/tmp"
else:
path = path.rstrip("/")
day_dir = datetime.datetime.now().strftime("%d%m%Y")
hour_dir = datetime.datetime.now().strftime("%H%M")
ensure_snapsh... | [
"def",
"snap",
"(",
"self",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"\"/tmp\"",
"else",
":",
"path",
"=",
"path",
".",
"rstrip",
"(",
"\"/\"",
")",
"day_dir",
"=",
"datetime",
".",
"datetime",
".",
"now",
... | Get a snapshot and save it to disk. | [
"Get",
"a",
"snapshot",
"and",
"save",
"it",
"to",
"disk",
"."
] | bffd1c4df9006705cffa5b83a090b0db90cbcbcf | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcampy/foscam.py#L28-L52 | train | 63,449 |
timmahrt/pysle | pysle/isletool.py | getNumPhones | def getNumPhones(isleDict, word, maxFlag):
'''
Get the number of syllables and phones in this word
If maxFlag=True, use the longest pronunciation. Otherwise, take the
average length.
'''
phoneCount = 0
syllableCount = 0
syllableCountList = []
phoneCountList = []
w... | python | def getNumPhones(isleDict, word, maxFlag):
'''
Get the number of syllables and phones in this word
If maxFlag=True, use the longest pronunciation. Otherwise, take the
average length.
'''
phoneCount = 0
syllableCount = 0
syllableCountList = []
phoneCountList = []
w... | [
"def",
"getNumPhones",
"(",
"isleDict",
",",
"word",
",",
"maxFlag",
")",
":",
"phoneCount",
"=",
"0",
"syllableCount",
"=",
"0",
"syllableCountList",
"=",
"[",
"]",
"phoneCountList",
"=",
"[",
"]",
"wordList",
"=",
"isleDict",
".",
"lookup",
"(",
"word",
... | Get the number of syllables and phones in this word
If maxFlag=True, use the longest pronunciation. Otherwise, take the
average length. | [
"Get",
"the",
"number",
"of",
"syllables",
"and",
"phones",
"in",
"this",
"word",
"If",
"maxFlag",
"=",
"True",
"use",
"the",
"longest",
"pronunciation",
".",
"Otherwise",
"take",
"the",
"average",
"length",
"."
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/isletool.py#L363-L398 | train | 63,450 |
timmahrt/pysle | pysle/isletool.py | findOODWords | def findOODWords(isleDict, wordList):
'''
Returns all of the out-of-dictionary words found in a list of utterances
'''
oodList = []
for word in wordList:
try:
isleDict.lookup(word)
except WordNotInISLE:
oodList.append(word)
oodList = list(... | python | def findOODWords(isleDict, wordList):
'''
Returns all of the out-of-dictionary words found in a list of utterances
'''
oodList = []
for word in wordList:
try:
isleDict.lookup(word)
except WordNotInISLE:
oodList.append(word)
oodList = list(... | [
"def",
"findOODWords",
"(",
"isleDict",
",",
"wordList",
")",
":",
"oodList",
"=",
"[",
"]",
"for",
"word",
"in",
"wordList",
":",
"try",
":",
"isleDict",
".",
"lookup",
"(",
"word",
")",
"except",
"WordNotInISLE",
":",
"oodList",
".",
"append",
"(",
"... | Returns all of the out-of-dictionary words found in a list of utterances | [
"Returns",
"all",
"of",
"the",
"out",
"-",
"of",
"-",
"dictionary",
"words",
"found",
"in",
"a",
"list",
"of",
"utterances"
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/isletool.py#L401-L415 | train | 63,451 |
timmahrt/pysle | pysle/isletool.py | LexicalTool._buildDict | def _buildDict(self):
'''
Builds the isle textfile into a dictionary for fast searching
'''
lexDict = {}
with io.open(self.islePath, "r", encoding='utf-8') as fd:
wordList = [line.rstrip('\n') for line in fd]
for row in wordList:
word, pro... | python | def _buildDict(self):
'''
Builds the isle textfile into a dictionary for fast searching
'''
lexDict = {}
with io.open(self.islePath, "r", encoding='utf-8') as fd:
wordList = [line.rstrip('\n') for line in fd]
for row in wordList:
word, pro... | [
"def",
"_buildDict",
"(",
"self",
")",
":",
"lexDict",
"=",
"{",
"}",
"with",
"io",
".",
"open",
"(",
"self",
".",
"islePath",
",",
"\"r\"",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"fd",
":",
"wordList",
"=",
"[",
"line",
".",
"rstrip",
"(",
... | Builds the isle textfile into a dictionary for fast searching | [
"Builds",
"the",
"isle",
"textfile",
"into",
"a",
"dictionary",
"for",
"fast",
"searching"
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/isletool.py#L66-L86 | train | 63,452 |
chriso/timeseries | timeseries/data_frame.py | DataFrame.timestamps | def timestamps(self):
'''Get all timestamps from all series in the group.'''
timestamps = set()
for series in self.groups.itervalues():
timestamps |= set(series.timestamps)
return sorted(list(timestamps)) | python | def timestamps(self):
'''Get all timestamps from all series in the group.'''
timestamps = set()
for series in self.groups.itervalues():
timestamps |= set(series.timestamps)
return sorted(list(timestamps)) | [
"def",
"timestamps",
"(",
"self",
")",
":",
"timestamps",
"=",
"set",
"(",
")",
"for",
"series",
"in",
"self",
".",
"groups",
".",
"itervalues",
"(",
")",
":",
"timestamps",
"|=",
"set",
"(",
"series",
".",
"timestamps",
")",
"return",
"sorted",
"(",
... | Get all timestamps from all series in the group. | [
"Get",
"all",
"timestamps",
"from",
"all",
"series",
"in",
"the",
"group",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/data_frame.py#L13-L18 | train | 63,453 |
chriso/timeseries | timeseries/data_frame.py | DataFrame.plot | def plot(self, overlay=True, **labels): # pragma: no cover
'''Plot all time series in the group.'''
pylab = LazyImport.pylab()
colours = list('rgbymc')
colours_len = len(colours)
colours_pos = 0
plots = len(self.groups)
for name, series in self.groups.iteritems():... | python | def plot(self, overlay=True, **labels): # pragma: no cover
'''Plot all time series in the group.'''
pylab = LazyImport.pylab()
colours = list('rgbymc')
colours_len = len(colours)
colours_pos = 0
plots = len(self.groups)
for name, series in self.groups.iteritems():... | [
"def",
"plot",
"(",
"self",
",",
"overlay",
"=",
"True",
",",
"*",
"*",
"labels",
")",
":",
"# pragma: no cover",
"pylab",
"=",
"LazyImport",
".",
"pylab",
"(",
")",
"colours",
"=",
"list",
"(",
"'rgbymc'",
")",
"colours_len",
"=",
"len",
"(",
"colours... | Plot all time series in the group. | [
"Plot",
"all",
"time",
"series",
"in",
"the",
"group",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/data_frame.py#L32-L52 | train | 63,454 |
chriso/timeseries | timeseries/data_frame.py | DataFrame.rename | def rename(self, **kwargs):
'''Rename series in the group.'''
for old, new in kwargs.iteritems():
if old in self.groups:
self.groups[new] = self.groups[old]
del self.groups[old] | python | def rename(self, **kwargs):
'''Rename series in the group.'''
for old, new in kwargs.iteritems():
if old in self.groups:
self.groups[new] = self.groups[old]
del self.groups[old] | [
"def",
"rename",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"old",
",",
"new",
"in",
"kwargs",
".",
"iteritems",
"(",
")",
":",
"if",
"old",
"in",
"self",
".",
"groups",
":",
"self",
".",
"groups",
"[",
"new",
"]",
"=",
"self",
".",... | Rename series in the group. | [
"Rename",
"series",
"in",
"the",
"group",
"."
] | 8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d | https://github.com/chriso/timeseries/blob/8b81e6cfd955a7cf75a421dfdb71b3f9e53be64d/timeseries/data_frame.py#L54-L59 | train | 63,455 |
bihealth/vcfpy | vcfpy/reader.py | Reader.fetch | def fetch(self, chrom_or_region, begin=None, end=None):
"""Jump to the start position of the given chromosomal position
and limit iteration to the end position
:param str chrom_or_region: name of the chromosome to jump to if
begin and end are given and a samtools region string other... | python | def fetch(self, chrom_or_region, begin=None, end=None):
"""Jump to the start position of the given chromosomal position
and limit iteration to the end position
:param str chrom_or_region: name of the chromosome to jump to if
begin and end are given and a samtools region string other... | [
"def",
"fetch",
"(",
"self",
",",
"chrom_or_region",
",",
"begin",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"if",
"begin",
"is",
"not",
"None",
"and",
"end",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"begin and end must both be None or neither\... | Jump to the start position of the given chromosomal position
and limit iteration to the end position
:param str chrom_or_region: name of the chromosome to jump to if
begin and end are given and a samtools region string otherwise
(e.g. "chr1:123,456-123,900").
:param int ... | [
"Jump",
"to",
"the",
"start",
"position",
"of",
"the",
"given",
"chromosomal",
"position",
"and",
"limit",
"iteration",
"to",
"the",
"end",
"position"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/reader.py#L123-L146 | train | 63,456 |
bihealth/vcfpy | vcfpy/reader.py | Reader.close | def close(self):
"""Close underlying stream"""
if self.tabix_file and not self.tabix_file.closed:
self.tabix_file.close()
if self.stream:
self.stream.close() | python | def close(self):
"""Close underlying stream"""
if self.tabix_file and not self.tabix_file.closed:
self.tabix_file.close()
if self.stream:
self.stream.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"tabix_file",
"and",
"not",
"self",
".",
"tabix_file",
".",
"closed",
":",
"self",
".",
"tabix_file",
".",
"close",
"(",
")",
"if",
"self",
".",
"stream",
":",
"self",
".",
"stream",
".",
"c... | Close underlying stream | [
"Close",
"underlying",
"stream"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/reader.py#L148-L153 | train | 63,457 |
bihealth/vcfpy | vcfpy/header.py | serialize_for_header | def serialize_for_header(key, value):
"""Serialize value for the given mapping key for a VCF header line"""
if key in QUOTE_FIELDS:
return json.dumps(value)
elif isinstance(value, str):
if " " in value or "\t" in value:
return json.dumps(value)
else:
return va... | python | def serialize_for_header(key, value):
"""Serialize value for the given mapping key for a VCF header line"""
if key in QUOTE_FIELDS:
return json.dumps(value)
elif isinstance(value, str):
if " " in value or "\t" in value:
return json.dumps(value)
else:
return va... | [
"def",
"serialize_for_header",
"(",
"key",
",",
"value",
")",
":",
"if",
"key",
"in",
"QUOTE_FIELDS",
":",
"return",
"json",
".",
"dumps",
"(",
"value",
")",
"elif",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"if",
"\" \"",
"in",
"value",
"or",
... | Serialize value for the given mapping key for a VCF header line | [
"Serialize",
"value",
"for",
"the",
"given",
"mapping",
"key",
"for",
"a",
"VCF",
"header",
"line"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L212-L224 | train | 63,458 |
bihealth/vcfpy | vcfpy/header.py | mapping_to_str | def mapping_to_str(mapping):
"""Convert mapping to string"""
result = ["<"]
for i, (key, value) in enumerate(mapping.items()):
if i > 0:
result.append(",")
result += [key, "=", serialize_for_header(key, value)]
result += [">"]
return "".join(result) | python | def mapping_to_str(mapping):
"""Convert mapping to string"""
result = ["<"]
for i, (key, value) in enumerate(mapping.items()):
if i > 0:
result.append(",")
result += [key, "=", serialize_for_header(key, value)]
result += [">"]
return "".join(result) | [
"def",
"mapping_to_str",
"(",
"mapping",
")",
":",
"result",
"=",
"[",
"\"<\"",
"]",
"for",
"i",
",",
"(",
"key",
",",
"value",
")",
"in",
"enumerate",
"(",
"mapping",
".",
"items",
"(",
")",
")",
":",
"if",
"i",
">",
"0",
":",
"result",
".",
"... | Convert mapping to string | [
"Convert",
"mapping",
"to",
"string"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L482-L490 | train | 63,459 |
bihealth/vcfpy | vcfpy/header.py | Header._build_indices | def _build_indices(self):
"""Build indices for the different field types"""
result = {key: OrderedDict() for key in LINES_WITH_ID}
for line in self.lines:
if line.key in LINES_WITH_ID:
result.setdefault(line.key, OrderedDict())
if line.mapping["ID"] in... | python | def _build_indices(self):
"""Build indices for the different field types"""
result = {key: OrderedDict() for key in LINES_WITH_ID}
for line in self.lines:
if line.key in LINES_WITH_ID:
result.setdefault(line.key, OrderedDict())
if line.mapping["ID"] in... | [
"def",
"_build_indices",
"(",
"self",
")",
":",
"result",
"=",
"{",
"key",
":",
"OrderedDict",
"(",
")",
"for",
"key",
"in",
"LINES_WITH_ID",
"}",
"for",
"line",
"in",
"self",
".",
"lines",
":",
"if",
"line",
".",
"key",
"in",
"LINES_WITH_ID",
":",
"... | Build indices for the different field types | [
"Build",
"indices",
"for",
"the",
"different",
"field",
"types"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L277-L295 | train | 63,460 |
bihealth/vcfpy | vcfpy/header.py | Header.copy | def copy(self):
"""Return a copy of this header"""
return Header([line.copy() for line in self.lines], self.samples.copy()) | python | def copy(self):
"""Return a copy of this header"""
return Header([line.copy() for line in self.lines], self.samples.copy()) | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"Header",
"(",
"[",
"line",
".",
"copy",
"(",
")",
"for",
"line",
"in",
"self",
".",
"lines",
"]",
",",
"self",
".",
"samples",
".",
"copy",
"(",
")",
")"
] | Return a copy of this header | [
"Return",
"a",
"copy",
"of",
"this",
"header"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L297-L299 | train | 63,461 |
bihealth/vcfpy | vcfpy/header.py | Header.get_lines | def get_lines(self, key):
"""Return header lines having the given ``key`` as their type"""
if key in self._indices:
return self._indices[key].values()
else:
return [] | python | def get_lines(self, key):
"""Return header lines having the given ``key`` as their type"""
if key in self._indices:
return self._indices[key].values()
else:
return [] | [
"def",
"get_lines",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"_indices",
":",
"return",
"self",
".",
"_indices",
"[",
"key",
"]",
".",
"values",
"(",
")",
"else",
":",
"return",
"[",
"]"
] | Return header lines having the given ``key`` as their type | [
"Return",
"header",
"lines",
"having",
"the",
"given",
"key",
"as",
"their",
"type"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L353-L358 | train | 63,462 |
bihealth/vcfpy | vcfpy/header.py | Header.has_header_line | def has_header_line(self, key, id_):
"""Return whether there is a header line with the given ID of the
type given by ``key``
:param key: The VCF header key/line type.
:param id_: The ID value to compare fore
:return: ``True`` if there is a header line starting with ``##${key}=`... | python | def has_header_line(self, key, id_):
"""Return whether there is a header line with the given ID of the
type given by ``key``
:param key: The VCF header key/line type.
:param id_: The ID value to compare fore
:return: ``True`` if there is a header line starting with ``##${key}=`... | [
"def",
"has_header_line",
"(",
"self",
",",
"key",
",",
"id_",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_indices",
":",
"return",
"False",
"else",
":",
"return",
"id_",
"in",
"self",
".",
"_indices",
"[",
"key",
"]"
] | Return whether there is a header line with the given ID of the
type given by ``key``
:param key: The VCF header key/line type.
:param id_: The ID value to compare fore
:return: ``True`` if there is a header line starting with ``##${key}=``
in the VCF file having the mapping... | [
"Return",
"whether",
"there",
"is",
"a",
"header",
"line",
"with",
"the",
"given",
"ID",
"of",
"the",
"type",
"given",
"by",
"key"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L360-L373 | train | 63,463 |
bihealth/vcfpy | vcfpy/header.py | Header.add_line | def add_line(self, header_line):
"""Add header line, updating any necessary support indices
:return: ``False`` on conflicting line and ``True`` otherwise
"""
self.lines.append(header_line)
self._indices.setdefault(header_line.key, OrderedDict())
if not hasattr(header_lin... | python | def add_line(self, header_line):
"""Add header line, updating any necessary support indices
:return: ``False`` on conflicting line and ``True`` otherwise
"""
self.lines.append(header_line)
self._indices.setdefault(header_line.key, OrderedDict())
if not hasattr(header_lin... | [
"def",
"add_line",
"(",
"self",
",",
"header_line",
")",
":",
"self",
".",
"lines",
".",
"append",
"(",
"header_line",
")",
"self",
".",
"_indices",
".",
"setdefault",
"(",
"header_line",
".",
"key",
",",
"OrderedDict",
"(",
")",
")",
"if",
"not",
"has... | Add header line, updating any necessary support indices
:return: ``False`` on conflicting line and ``True`` otherwise | [
"Add",
"header",
"line",
"updating",
"any",
"necessary",
"support",
"indices"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L375-L395 | train | 63,464 |
bihealth/vcfpy | vcfpy/header.py | SimpleHeaderLine.copy | def copy(self):
"""Return a copy"""
mapping = OrderedDict(self.mapping.items())
return self.__class__(self.key, self.value, mapping) | python | def copy(self):
"""Return a copy"""
mapping = OrderedDict(self.mapping.items())
return self.__class__(self.key, self.value, mapping) | [
"def",
"copy",
"(",
"self",
")",
":",
"mapping",
"=",
"OrderedDict",
"(",
"self",
".",
"mapping",
".",
"items",
"(",
")",
")",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"key",
",",
"self",
".",
"value",
",",
"mapping",
")"
] | Return a copy | [
"Return",
"a",
"copy"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L513-L516 | train | 63,465 |
timmahrt/pysle | pysle/pronunciationtools.py | _adjustSyllabification | def _adjustSyllabification(adjustedPhoneList, syllableList):
'''
Inserts spaces into a syllable if needed
Originally the phone list and syllable list contained the same number
of phones. But the adjustedPhoneList may have some insertions which are
not accounted for in the syllableList.
'''... | python | def _adjustSyllabification(adjustedPhoneList, syllableList):
'''
Inserts spaces into a syllable if needed
Originally the phone list and syllable list contained the same number
of phones. But the adjustedPhoneList may have some insertions which are
not accounted for in the syllableList.
'''... | [
"def",
"_adjustSyllabification",
"(",
"adjustedPhoneList",
",",
"syllableList",
")",
":",
"i",
"=",
"0",
"retSyllableList",
"=",
"[",
"]",
"for",
"syllableNum",
",",
"syllable",
"in",
"enumerate",
"(",
"syllableList",
")",
":",
"j",
"=",
"len",
"(",
"syllabl... | Inserts spaces into a syllable if needed
Originally the phone list and syllable list contained the same number
of phones. But the adjustedPhoneList may have some insertions which are
not accounted for in the syllableList. | [
"Inserts",
"spaces",
"into",
"a",
"syllable",
"if",
"needed",
"Originally",
"the",
"phone",
"list",
"and",
"syllable",
"list",
"contained",
"the",
"same",
"number",
"of",
"phones",
".",
"But",
"the",
"adjustedPhoneList",
"may",
"have",
"some",
"insertions",
"w... | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/pronunciationtools.py#L132-L165 | train | 63,466 |
timmahrt/pysle | pysle/pronunciationtools.py | _findBestPronunciation | def _findBestPronunciation(isleWordList, aPron):
'''
Words may have multiple candidates in ISLE; returns the 'optimal' one.
'''
aP = _prepPronunciation(aPron) # Mapping to simplified phone inventory
numDiffList = []
withStress = []
i = 0
alignedSyllabificationList = []
ali... | python | def _findBestPronunciation(isleWordList, aPron):
'''
Words may have multiple candidates in ISLE; returns the 'optimal' one.
'''
aP = _prepPronunciation(aPron) # Mapping to simplified phone inventory
numDiffList = []
withStress = []
i = 0
alignedSyllabificationList = []
ali... | [
"def",
"_findBestPronunciation",
"(",
"isleWordList",
",",
"aPron",
")",
":",
"aP",
"=",
"_prepPronunciation",
"(",
"aPron",
")",
"# Mapping to simplified phone inventory",
"numDiffList",
"=",
"[",
"]",
"withStress",
"=",
"[",
"]",
"i",
"=",
"0",
"alignedSyllabifi... | Words may have multiple candidates in ISLE; returns the 'optimal' one. | [
"Words",
"may",
"have",
"multiple",
"candidates",
"in",
"ISLE",
";",
"returns",
"the",
"optimal",
"one",
"."
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/pronunciationtools.py#L168-L235 | train | 63,467 |
timmahrt/pysle | pysle/pronunciationtools.py | _syllabifyPhones | def _syllabifyPhones(phoneList, syllableList):
'''
Given a phone list and a syllable list, syllabify the phones
Typically used by findBestSyllabification which first aligns the phoneList
with a dictionary phoneList and then uses the dictionary syllabification
to syllabify the input phoneList.
... | python | def _syllabifyPhones(phoneList, syllableList):
'''
Given a phone list and a syllable list, syllabify the phones
Typically used by findBestSyllabification which first aligns the phoneList
with a dictionary phoneList and then uses the dictionary syllabification
to syllabify the input phoneList.
... | [
"def",
"_syllabifyPhones",
"(",
"phoneList",
",",
"syllableList",
")",
":",
"numPhoneList",
"=",
"[",
"len",
"(",
"syllable",
")",
"for",
"syllable",
"in",
"syllableList",
"]",
"start",
"=",
"0",
"syllabifiedList",
"=",
"[",
"]",
"for",
"end",
"in",
"numPh... | Given a phone list and a syllable list, syllabify the phones
Typically used by findBestSyllabification which first aligns the phoneList
with a dictionary phoneList and then uses the dictionary syllabification
to syllabify the input phoneList. | [
"Given",
"a",
"phone",
"list",
"and",
"a",
"syllable",
"list",
"syllabify",
"the",
"phones",
"Typically",
"used",
"by",
"findBestSyllabification",
"which",
"first",
"aligns",
"the",
"phoneList",
"with",
"a",
"dictionary",
"phoneList",
"and",
"then",
"uses",
"the... | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/pronunciationtools.py#L238-L258 | train | 63,468 |
timmahrt/pysle | pysle/pronunciationtools.py | alignPronunciations | def alignPronunciations(pronI, pronA):
'''
Align the phones in two pronunciations
'''
# First prep the two pronunctions
pronI = [char for char in pronI]
pronA = [char for char in pronA]
# Remove any elements not in the other list (but maintain order)
pronITmp = pronI
pronAT... | python | def alignPronunciations(pronI, pronA):
'''
Align the phones in two pronunciations
'''
# First prep the two pronunctions
pronI = [char for char in pronI]
pronA = [char for char in pronA]
# Remove any elements not in the other list (but maintain order)
pronITmp = pronI
pronAT... | [
"def",
"alignPronunciations",
"(",
"pronI",
",",
"pronA",
")",
":",
"# First prep the two pronunctions",
"pronI",
"=",
"[",
"char",
"for",
"char",
"in",
"pronI",
"]",
"pronA",
"=",
"[",
"char",
"for",
"char",
"in",
"pronA",
"]",
"# Remove any elements not in the... | Align the phones in two pronunciations | [
"Align",
"the",
"phones",
"in",
"two",
"pronunciations"
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/pronunciationtools.py#L261-L311 | train | 63,469 |
timmahrt/pysle | pysle/pronunciationtools.py | _findBestSyllabification | def _findBestSyllabification(inputIsleWordList, actualPronunciationList):
'''
Find the best syllabification for a word
First find the closest pronunciation to a given pronunciation. Then take
the syllabification for that pronunciation and map it onto the
input pronunciation.
'''
retList... | python | def _findBestSyllabification(inputIsleWordList, actualPronunciationList):
'''
Find the best syllabification for a word
First find the closest pronunciation to a given pronunciation. Then take
the syllabification for that pronunciation and map it onto the
input pronunciation.
'''
retList... | [
"def",
"_findBestSyllabification",
"(",
"inputIsleWordList",
",",
"actualPronunciationList",
")",
":",
"retList",
"=",
"_findBestPronunciation",
"(",
"inputIsleWordList",
",",
"actualPronunciationList",
")",
"isleWordList",
",",
"alignedAPronList",
",",
"alignedSyllableList",... | Find the best syllabification for a word
First find the closest pronunciation to a given pronunciation. Then take
the syllabification for that pronunciation and map it onto the
input pronunciation. | [
"Find",
"the",
"best",
"syllabification",
"for",
"a",
"word",
"First",
"find",
"the",
"closest",
"pronunciation",
"to",
"a",
"given",
"pronunciation",
".",
"Then",
"take",
"the",
"syllabification",
"for",
"that",
"pronunciation",
"and",
"map",
"it",
"onto",
"t... | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/pronunciationtools.py#L347-L387 | train | 63,470 |
timmahrt/pysle | pysle/pronunciationtools.py | _getSyllableNucleus | def _getSyllableNucleus(phoneList):
'''
Given the phones in a syllable, retrieves the vowel index
'''
cvList = ['V' if isletool.isVowel(phone) else 'C' for phone in phoneList]
vowelCount = cvList.count('V')
if vowelCount > 1:
raise TooManyVowelsInSyllable(phoneList, cvList)
... | python | def _getSyllableNucleus(phoneList):
'''
Given the phones in a syllable, retrieves the vowel index
'''
cvList = ['V' if isletool.isVowel(phone) else 'C' for phone in phoneList]
vowelCount = cvList.count('V')
if vowelCount > 1:
raise TooManyVowelsInSyllable(phoneList, cvList)
... | [
"def",
"_getSyllableNucleus",
"(",
"phoneList",
")",
":",
"cvList",
"=",
"[",
"'V'",
"if",
"isletool",
".",
"isVowel",
"(",
"phone",
")",
"else",
"'C'",
"for",
"phone",
"in",
"phoneList",
"]",
"vowelCount",
"=",
"cvList",
".",
"count",
"(",
"'V'",
")",
... | Given the phones in a syllable, retrieves the vowel index | [
"Given",
"the",
"phones",
"in",
"a",
"syllable",
"retrieves",
"the",
"vowel",
"index"
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/pronunciationtools.py#L390-L405 | train | 63,471 |
timmahrt/pysle | pysle/pronunciationtools.py | findClosestPronunciation | def findClosestPronunciation(inputIsleWordList, aPron):
'''
Find the closest dictionary pronunciation to a provided pronunciation
'''
retList = _findBestPronunciation(inputIsleWordList, aPron)
isleWordList = retList[0]
bestIndex = retList[3]
return isleWordList[bestIndex] | python | def findClosestPronunciation(inputIsleWordList, aPron):
'''
Find the closest dictionary pronunciation to a provided pronunciation
'''
retList = _findBestPronunciation(inputIsleWordList, aPron)
isleWordList = retList[0]
bestIndex = retList[3]
return isleWordList[bestIndex] | [
"def",
"findClosestPronunciation",
"(",
"inputIsleWordList",
",",
"aPron",
")",
":",
"retList",
"=",
"_findBestPronunciation",
"(",
"inputIsleWordList",
",",
"aPron",
")",
"isleWordList",
"=",
"retList",
"[",
"0",
"]",
"bestIndex",
"=",
"retList",
"[",
"3",
"]",... | Find the closest dictionary pronunciation to a provided pronunciation | [
"Find",
"the",
"closest",
"dictionary",
"pronunciation",
"to",
"a",
"provided",
"pronunciation"
] | da7c3d9ebdc01647be845f442b6f072a854eba3b | https://github.com/timmahrt/pysle/blob/da7c3d9ebdc01647be845f442b6f072a854eba3b/pysle/pronunciationtools.py#L408-L417 | train | 63,472 |
lexruee/pi-switch-python | send.py | create_switch | def create_switch(type, settings, pin):
"""Create a switch.
Args:
type: (str): type of the switch [A,B,C,D]
settings (str): a comma separted list
pin (int): wiringPi pin
Returns:
switch
"""
switch = None
if type == "A":
group, device = settings.split(",")
switch = p... | python | def create_switch(type, settings, pin):
"""Create a switch.
Args:
type: (str): type of the switch [A,B,C,D]
settings (str): a comma separted list
pin (int): wiringPi pin
Returns:
switch
"""
switch = None
if type == "A":
group, device = settings.split(",")
switch = p... | [
"def",
"create_switch",
"(",
"type",
",",
"settings",
",",
"pin",
")",
":",
"switch",
"=",
"None",
"if",
"type",
"==",
"\"A\"",
":",
"group",
",",
"device",
"=",
"settings",
".",
"split",
"(",
"\",\"",
")",
"switch",
"=",
"pi_switch",
".",
"RCSwitchA",... | Create a switch.
Args:
type: (str): type of the switch [A,B,C,D]
settings (str): a comma separted list
pin (int): wiringPi pin
Returns:
switch | [
"Create",
"a",
"switch",
"."
] | 5c367a6d51aa15811e997160746d1512a37e2dc6 | https://github.com/lexruee/pi-switch-python/blob/5c367a6d51aa15811e997160746d1512a37e2dc6/send.py#L32-L71 | train | 63,473 |
bihealth/vcfpy | vcfpy/writer.py | format_atomic | def format_atomic(value):
"""Format atomic value
This function also takes care of escaping the value in case one of the
reserved characters occurs in the value.
"""
# Perform escaping
if isinstance(value, str):
if any(r in value for r in record.RESERVED_CHARS):
for k, v in r... | python | def format_atomic(value):
"""Format atomic value
This function also takes care of escaping the value in case one of the
reserved characters occurs in the value.
"""
# Perform escaping
if isinstance(value, str):
if any(r in value for r in record.RESERVED_CHARS):
for k, v in r... | [
"def",
"format_atomic",
"(",
"value",
")",
":",
"# Perform escaping",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"if",
"any",
"(",
"r",
"in",
"value",
"for",
"r",
"in",
"record",
".",
"RESERVED_CHARS",
")",
":",
"for",
"k",
",",
"v",
"in... | Format atomic value
This function also takes care of escaping the value in case one of the
reserved characters occurs in the value. | [
"Format",
"atomic",
"value"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/writer.py#L14-L29 | train | 63,474 |
bihealth/vcfpy | vcfpy/writer.py | format_value | def format_value(field_info, value, section):
"""Format possibly compound value given the FieldInfo"""
if section == "FORMAT" and field_info.id == "FT":
if not value:
return "."
elif isinstance(value, list):
return ";".join(map(format_atomic, value))
elif field_info.n... | python | def format_value(field_info, value, section):
"""Format possibly compound value given the FieldInfo"""
if section == "FORMAT" and field_info.id == "FT":
if not value:
return "."
elif isinstance(value, list):
return ";".join(map(format_atomic, value))
elif field_info.n... | [
"def",
"format_value",
"(",
"field_info",
",",
"value",
",",
"section",
")",
":",
"if",
"section",
"==",
"\"FORMAT\"",
"and",
"field_info",
".",
"id",
"==",
"\"FT\"",
":",
"if",
"not",
"value",
":",
"return",
"\".\"",
"elif",
"isinstance",
"(",
"value",
... | Format possibly compound value given the FieldInfo | [
"Format",
"possibly",
"compound",
"value",
"given",
"the",
"FieldInfo"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/writer.py#L32-L48 | train | 63,475 |
bihealth/vcfpy | vcfpy/writer.py | Writer._write_header | def _write_header(self):
"""Write out the header"""
for line in self.header.lines:
print(line.serialize(), file=self.stream)
if self.header.samples.names:
print(
"\t".join(list(parser.REQUIRE_SAMPLE_HEADER) + self.header.samples.names),
fil... | python | def _write_header(self):
"""Write out the header"""
for line in self.header.lines:
print(line.serialize(), file=self.stream)
if self.header.samples.names:
print(
"\t".join(list(parser.REQUIRE_SAMPLE_HEADER) + self.header.samples.names),
fil... | [
"def",
"_write_header",
"(",
"self",
")",
":",
"for",
"line",
"in",
"self",
".",
"header",
".",
"lines",
":",
"print",
"(",
"line",
".",
"serialize",
"(",
")",
",",
"file",
"=",
"self",
".",
"stream",
")",
"if",
"self",
".",
"header",
".",
"samples... | Write out the header | [
"Write",
"out",
"the",
"header"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/writer.py#L111-L121 | train | 63,476 |
bihealth/vcfpy | vcfpy/writer.py | Writer._serialize_record | def _serialize_record(self, record):
"""Serialize whole Record"""
f = self._empty_to_dot
row = [record.CHROM, record.POS]
row.append(f(";".join(record.ID)))
row.append(f(record.REF))
if not record.ALT:
row.append(".")
else:
row.append(",".j... | python | def _serialize_record(self, record):
"""Serialize whole Record"""
f = self._empty_to_dot
row = [record.CHROM, record.POS]
row.append(f(";".join(record.ID)))
row.append(f(record.REF))
if not record.ALT:
row.append(".")
else:
row.append(",".j... | [
"def",
"_serialize_record",
"(",
"self",
",",
"record",
")",
":",
"f",
"=",
"self",
".",
"_empty_to_dot",
"row",
"=",
"[",
"record",
".",
"CHROM",
",",
"record",
".",
"POS",
"]",
"row",
".",
"append",
"(",
"f",
"(",
"\";\"",
".",
"join",
"(",
"reco... | Serialize whole Record | [
"Serialize",
"whole",
"Record"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/writer.py#L132-L151 | train | 63,477 |
bihealth/vcfpy | vcfpy/writer.py | Writer._serialize_info | def _serialize_info(self, record):
"""Return serialized version of record.INFO"""
result = []
for key, value in record.INFO.items():
info = self.header.get_info_field_info(key)
if info.type == "Flag":
result.append(key)
else:
re... | python | def _serialize_info(self, record):
"""Return serialized version of record.INFO"""
result = []
for key, value in record.INFO.items():
info = self.header.get_info_field_info(key)
if info.type == "Flag":
result.append(key)
else:
re... | [
"def",
"_serialize_info",
"(",
"self",
",",
"record",
")",
":",
"result",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"record",
".",
"INFO",
".",
"items",
"(",
")",
":",
"info",
"=",
"self",
".",
"header",
".",
"get_info_field_info",
"(",
"key",... | Return serialized version of record.INFO | [
"Return",
"serialized",
"version",
"of",
"record",
".",
"INFO"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/writer.py#L153-L162 | train | 63,478 |
bihealth/vcfpy | vcfpy/writer.py | Writer._serialize_call | def _serialize_call(self, format_, call):
"""Return serialized version of the Call using the record's FORMAT'"""
if isinstance(call, record.UnparsedCall):
return call.unparsed_data
else:
result = [
format_value(self.header.get_format_field_info(key), call.... | python | def _serialize_call(self, format_, call):
"""Return serialized version of the Call using the record's FORMAT'"""
if isinstance(call, record.UnparsedCall):
return call.unparsed_data
else:
result = [
format_value(self.header.get_format_field_info(key), call.... | [
"def",
"_serialize_call",
"(",
"self",
",",
"format_",
",",
"call",
")",
":",
"if",
"isinstance",
"(",
"call",
",",
"record",
".",
"UnparsedCall",
")",
":",
"return",
"call",
".",
"unparsed_data",
"else",
":",
"result",
"=",
"[",
"format_value",
"(",
"se... | Return serialized version of the Call using the record's FORMAT | [
"Return",
"serialized",
"version",
"of",
"the",
"Call",
"using",
"the",
"record",
"s",
"FORMAT"
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/writer.py#L164-L173 | train | 63,479 |
Pitmairen/hamlish-jinja | hamlish_jinja.py | Hamlish._create_extended_jinja_tags | def _create_extended_jinja_tags(self, nodes):
"""Loops through the nodes and looks for special jinja tags that
contains more than one tag but only one ending tag."""
jinja_a = None
jinja_b = None
ext_node = None
ext_nodes = []
for node in nodes:
if ... | python | def _create_extended_jinja_tags(self, nodes):
"""Loops through the nodes and looks for special jinja tags that
contains more than one tag but only one ending tag."""
jinja_a = None
jinja_b = None
ext_node = None
ext_nodes = []
for node in nodes:
if ... | [
"def",
"_create_extended_jinja_tags",
"(",
"self",
",",
"nodes",
")",
":",
"jinja_a",
"=",
"None",
"jinja_b",
"=",
"None",
"ext_node",
"=",
"None",
"ext_nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"nodes",
":",
"if",
"isinstance",
"(",
"node",
",",
"Empt... | Loops through the nodes and looks for special jinja tags that
contains more than one tag but only one ending tag. | [
"Loops",
"through",
"the",
"nodes",
"and",
"looks",
"for",
"special",
"jinja",
"tags",
"that",
"contains",
"more",
"than",
"one",
"tag",
"but",
"only",
"one",
"ending",
"tag",
"."
] | f8fdbddf2f444124c6fc69d1eb11603da2838093 | https://github.com/Pitmairen/hamlish-jinja/blob/f8fdbddf2f444124c6fc69d1eb11603da2838093/hamlish_jinja.py#L585-L633 | train | 63,480 |
Pitmairen/hamlish-jinja | hamlish_jinja.py | Node.has_children | def has_children(self):
"returns False if children is empty or contains only empty lines else True."
return bool([x for x in self.children if not isinstance(x, EmptyLine)]) | python | def has_children(self):
"returns False if children is empty or contains only empty lines else True."
return bool([x for x in self.children if not isinstance(x, EmptyLine)]) | [
"def",
"has_children",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"children",
"if",
"not",
"isinstance",
"(",
"x",
",",
"EmptyLine",
")",
"]",
")"
] | returns False if children is empty or contains only empty lines else True. | [
"returns",
"False",
"if",
"children",
"is",
"empty",
"or",
"contains",
"only",
"empty",
"lines",
"else",
"True",
"."
] | f8fdbddf2f444124c6fc69d1eb11603da2838093 | https://github.com/Pitmairen/hamlish-jinja/blob/f8fdbddf2f444124c6fc69d1eb11603da2838093/hamlish_jinja.py#L645-L647 | train | 63,481 |
bihealth/vcfpy | setup.py | parse_requirements | def parse_requirements(path):
"""Parse ``requirements.txt`` at ``path``."""
requirements = []
with open(path, "rt") as reqs_f:
for line in reqs_f:
line = line.strip()
if line.startswith("-r"):
fname = line.split()[1]
inner_path = os.path.join(o... | python | def parse_requirements(path):
"""Parse ``requirements.txt`` at ``path``."""
requirements = []
with open(path, "rt") as reqs_f:
for line in reqs_f:
line = line.strip()
if line.startswith("-r"):
fname = line.split()[1]
inner_path = os.path.join(o... | [
"def",
"parse_requirements",
"(",
"path",
")",
":",
"requirements",
"=",
"[",
"]",
"with",
"open",
"(",
"path",
",",
"\"rt\"",
")",
"as",
"reqs_f",
":",
"for",
"line",
"in",
"reqs_f",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
"line",
... | Parse ``requirements.txt`` at ``path``. | [
"Parse",
"requirements",
".",
"txt",
"at",
"path",
"."
] | 99e2165df30f11e0c95f3170f31bc5191d9e9e15 | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/setup.py#L13-L25 | train | 63,482 |
eraclitux/ipcampy | ipcampy/sentry.py | watch | def watch(cams, path=None, delay=10):
"""Get screenshots from all cams at defined intervall."""
while True:
for c in cams:
c.snap(path)
time.sleep(delay) | python | def watch(cams, path=None, delay=10):
"""Get screenshots from all cams at defined intervall."""
while True:
for c in cams:
c.snap(path)
time.sleep(delay) | [
"def",
"watch",
"(",
"cams",
",",
"path",
"=",
"None",
",",
"delay",
"=",
"10",
")",
":",
"while",
"True",
":",
"for",
"c",
"in",
"cams",
":",
"c",
".",
"snap",
"(",
"path",
")",
"time",
".",
"sleep",
"(",
"delay",
")"
] | Get screenshots from all cams at defined intervall. | [
"Get",
"screenshots",
"from",
"all",
"cams",
"at",
"defined",
"intervall",
"."
] | bffd1c4df9006705cffa5b83a090b0db90cbcbcf | https://github.com/eraclitux/ipcampy/blob/bffd1c4df9006705cffa5b83a090b0db90cbcbcf/ipcampy/sentry.py#L34-L39 | train | 63,483 |
TeleSign/python_telesign | telesign/score.py | ScoreClient.score | def score(self, phone_number, account_lifecycle_event, **params):
"""
Score is an API that delivers reputation scoring based on phone number intelligence, traffic patterns, machine
learning, and a global data consortium.
See https://developer.telesign.com/docs/score-api for detailed API... | python | def score(self, phone_number, account_lifecycle_event, **params):
"""
Score is an API that delivers reputation scoring based on phone number intelligence, traffic patterns, machine
learning, and a global data consortium.
See https://developer.telesign.com/docs/score-api for detailed API... | [
"def",
"score",
"(",
"self",
",",
"phone_number",
",",
"account_lifecycle_event",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"post",
"(",
"SCORE_RESOURCE",
".",
"format",
"(",
"phone_number",
"=",
"phone_number",
")",
",",
"account_lifecycle_eve... | Score is an API that delivers reputation scoring based on phone number intelligence, traffic patterns, machine
learning, and a global data consortium.
See https://developer.telesign.com/docs/score-api for detailed API documentation. | [
"Score",
"is",
"an",
"API",
"that",
"delivers",
"reputation",
"scoring",
"based",
"on",
"phone",
"number",
"intelligence",
"traffic",
"patterns",
"machine",
"learning",
"and",
"a",
"global",
"data",
"consortium",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/score.py#L16-L25 | train | 63,484 |
TeleSign/python_telesign | telesign/rest.py | RestClient.generate_telesign_headers | def generate_telesign_headers(customer_id,
api_key,
method_name,
resource,
url_encoded_fields,
date_rfc2616=None,
no... | python | def generate_telesign_headers(customer_id,
api_key,
method_name,
resource,
url_encoded_fields,
date_rfc2616=None,
no... | [
"def",
"generate_telesign_headers",
"(",
"customer_id",
",",
"api_key",
",",
"method_name",
",",
"resource",
",",
"url_encoded_fields",
",",
"date_rfc2616",
"=",
"None",
",",
"nonce",
"=",
"None",
",",
"user_agent",
"=",
"None",
",",
"content_type",
"=",
"None",... | Generates the TeleSign REST API headers used to authenticate requests.
Creates the canonicalized string_to_sign and generates the HMAC signature. This is used to authenticate requests
against the TeleSign REST API.
See https://developer.telesign.com/docs/authentication for detailed API documen... | [
"Generates",
"the",
"TeleSign",
"REST",
"API",
"headers",
"used",
"to",
"authenticate",
"requests",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/rest.py#L77-L152 | train | 63,485 |
TeleSign/python_telesign | telesign/rest.py | RestClient.post | def post(self, resource, **params):
"""
Generic TeleSign REST API POST handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the POST request with, as a dictionary.
:return: The RestClient Response o... | python | def post(self, resource, **params):
"""
Generic TeleSign REST API POST handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the POST request with, as a dictionary.
:return: The RestClient Response o... | [
"def",
"post",
"(",
"self",
",",
"resource",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"_execute",
"(",
"self",
".",
"session",
".",
"post",
",",
"'POST'",
",",
"resource",
",",
"*",
"*",
"params",
")"
] | Generic TeleSign REST API POST handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the POST request with, as a dictionary.
:return: The RestClient Response object. | [
"Generic",
"TeleSign",
"REST",
"API",
"POST",
"handler",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/rest.py#L154-L162 | train | 63,486 |
TeleSign/python_telesign | telesign/rest.py | RestClient.get | def get(self, resource, **params):
"""
Generic TeleSign REST API GET handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the GET request with, as a dictionary.
:return: The RestClient Response obje... | python | def get(self, resource, **params):
"""
Generic TeleSign REST API GET handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the GET request with, as a dictionary.
:return: The RestClient Response obje... | [
"def",
"get",
"(",
"self",
",",
"resource",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"_execute",
"(",
"self",
".",
"session",
".",
"get",
",",
"'GET'",
",",
"resource",
",",
"*",
"*",
"params",
")"
] | Generic TeleSign REST API GET handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the GET request with, as a dictionary.
:return: The RestClient Response object. | [
"Generic",
"TeleSign",
"REST",
"API",
"GET",
"handler",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/rest.py#L164-L172 | train | 63,487 |
TeleSign/python_telesign | telesign/rest.py | RestClient.put | def put(self, resource, **params):
"""
Generic TeleSign REST API PUT handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the PUT request with, as a dictionary.
:return: The RestClient Response obje... | python | def put(self, resource, **params):
"""
Generic TeleSign REST API PUT handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the PUT request with, as a dictionary.
:return: The RestClient Response obje... | [
"def",
"put",
"(",
"self",
",",
"resource",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"_execute",
"(",
"self",
".",
"session",
".",
"put",
",",
"'PUT'",
",",
"resource",
",",
"*",
"*",
"params",
")"
] | Generic TeleSign REST API PUT handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the PUT request with, as a dictionary.
:return: The RestClient Response object. | [
"Generic",
"TeleSign",
"REST",
"API",
"PUT",
"handler",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/rest.py#L174-L182 | train | 63,488 |
TeleSign/python_telesign | telesign/rest.py | RestClient.delete | def delete(self, resource, **params):
"""
Generic TeleSign REST API DELETE handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the DELETE request with, as a dictionary.
:return: The RestClient Resp... | python | def delete(self, resource, **params):
"""
Generic TeleSign REST API DELETE handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the DELETE request with, as a dictionary.
:return: The RestClient Resp... | [
"def",
"delete",
"(",
"self",
",",
"resource",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"_execute",
"(",
"self",
".",
"session",
".",
"delete",
",",
"'DELETE'",
",",
"resource",
",",
"*",
"*",
"params",
")"
] | Generic TeleSign REST API DELETE handler.
:param resource: The partial resource URI to perform the request against, as a string.
:param params: Body params to perform the DELETE request with, as a dictionary.
:return: The RestClient Response object. | [
"Generic",
"TeleSign",
"REST",
"API",
"DELETE",
"handler",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/rest.py#L184-L192 | train | 63,489 |
TeleSign/python_telesign | telesign/rest.py | RestClient._execute | def _execute(self, method_function, method_name, resource, **params):
"""
Generic TeleSign REST API request handler.
:param method_function: The Requests HTTP request function to perform the request.
:param method_name: The HTTP method name, as an upper case string.
:param resou... | python | def _execute(self, method_function, method_name, resource, **params):
"""
Generic TeleSign REST API request handler.
:param method_function: The Requests HTTP request function to perform the request.
:param method_name: The HTTP method name, as an upper case string.
:param resou... | [
"def",
"_execute",
"(",
"self",
",",
"method_function",
",",
"method_name",
",",
"resource",
",",
"*",
"*",
"params",
")",
":",
"resource_uri",
"=",
"\"{api_host}{resource}\"",
".",
"format",
"(",
"api_host",
"=",
"self",
".",
"api_host",
",",
"resource",
"=... | Generic TeleSign REST API request handler.
:param method_function: The Requests HTTP request function to perform the request.
:param method_name: The HTTP method name, as an upper case string.
:param resource: The partial resource URI to perform the request against, as a string.
:param ... | [
"Generic",
"TeleSign",
"REST",
"API",
"request",
"handler",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/rest.py#L194-L225 | train | 63,490 |
TeleSign/python_telesign | telesign/messaging.py | MessagingClient.message | def message(self, phone_number, message, message_type, **params):
"""
Send a message to the target phone_number.
See https://developer.telesign.com/docs/messaging-api for detailed API documentation.
"""
return self.post(MESSAGING_RESOURCE,
phone_number=p... | python | def message(self, phone_number, message, message_type, **params):
"""
Send a message to the target phone_number.
See https://developer.telesign.com/docs/messaging-api for detailed API documentation.
"""
return self.post(MESSAGING_RESOURCE,
phone_number=p... | [
"def",
"message",
"(",
"self",
",",
"phone_number",
",",
"message",
",",
"message_type",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"post",
"(",
"MESSAGING_RESOURCE",
",",
"phone_number",
"=",
"phone_number",
",",
"message",
"=",
"message",
... | Send a message to the target phone_number.
See https://developer.telesign.com/docs/messaging-api for detailed API documentation. | [
"Send",
"a",
"message",
"to",
"the",
"target",
"phone_number",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/messaging.py#L18-L28 | train | 63,491 |
TeleSign/python_telesign | telesign/messaging.py | MessagingClient.status | def status(self, reference_id, **params):
"""
Retrieves the current status of the message.
See https://developer.telesign.com/docs/messaging-api for detailed API documentation.
"""
return self.get(MESSAGING_STATUS_RESOURCE.format(reference_id=reference_id),
... | python | def status(self, reference_id, **params):
"""
Retrieves the current status of the message.
See https://developer.telesign.com/docs/messaging-api for detailed API documentation.
"""
return self.get(MESSAGING_STATUS_RESOURCE.format(reference_id=reference_id),
... | [
"def",
"status",
"(",
"self",
",",
"reference_id",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"get",
"(",
"MESSAGING_STATUS_RESOURCE",
".",
"format",
"(",
"reference_id",
"=",
"reference_id",
")",
",",
"*",
"*",
"params",
")"
] | Retrieves the current status of the message.
See https://developer.telesign.com/docs/messaging-api for detailed API documentation. | [
"Retrieves",
"the",
"current",
"status",
"of",
"the",
"message",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/messaging.py#L30-L37 | train | 63,492 |
TeleSign/python_telesign | telesign/phoneid.py | PhoneIdClient.phoneid | def phoneid(self, phone_number, **params):
"""
The PhoneID API provides a cleansed phone number, phone type, and telecom carrier information to determine the
best communication method - SMS or voice.
See https://developer.telesign.com/docs/phoneid-api for detailed API documentation.
... | python | def phoneid(self, phone_number, **params):
"""
The PhoneID API provides a cleansed phone number, phone type, and telecom carrier information to determine the
best communication method - SMS or voice.
See https://developer.telesign.com/docs/phoneid-api for detailed API documentation.
... | [
"def",
"phoneid",
"(",
"self",
",",
"phone_number",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"post",
"(",
"PHONEID_RESOURCE",
".",
"format",
"(",
"phone_number",
"=",
"phone_number",
")",
",",
"*",
"*",
"params",
")"
] | The PhoneID API provides a cleansed phone number, phone type, and telecom carrier information to determine the
best communication method - SMS or voice.
See https://developer.telesign.com/docs/phoneid-api for detailed API documentation. | [
"The",
"PhoneID",
"API",
"provides",
"a",
"cleansed",
"phone",
"number",
"phone",
"type",
"and",
"telecom",
"carrier",
"information",
"to",
"determine",
"the",
"best",
"communication",
"method",
"-",
"SMS",
"or",
"voice",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/phoneid.py#L19-L27 | train | 63,493 |
sptonkin/fuzzyhashlib | fuzzyhashlib/__init__.py | ssdeep.copy | def copy(self):
"""Returns a new instance which identical to this instance."""
if self._pre_computed_hash is None:
temp = ssdeep(buf="")
else:
temp = ssdeep(hash=hash)
libssdeep_wrapper.fuzzy_free(temp._state)
temp._state = libssdeep_wrapper.fuzzy_clone(se... | python | def copy(self):
"""Returns a new instance which identical to this instance."""
if self._pre_computed_hash is None:
temp = ssdeep(buf="")
else:
temp = ssdeep(hash=hash)
libssdeep_wrapper.fuzzy_free(temp._state)
temp._state = libssdeep_wrapper.fuzzy_clone(se... | [
"def",
"copy",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pre_computed_hash",
"is",
"None",
":",
"temp",
"=",
"ssdeep",
"(",
"buf",
"=",
"\"\"",
")",
"else",
":",
"temp",
"=",
"ssdeep",
"(",
"hash",
"=",
"hash",
")",
"libssdeep_wrapper",
".",
"fuzzy... | Returns a new instance which identical to this instance. | [
"Returns",
"a",
"new",
"instance",
"which",
"identical",
"to",
"this",
"instance",
"."
] | 61999dcfb0893358a330f51d88e4fa494a91bce2 | https://github.com/sptonkin/fuzzyhashlib/blob/61999dcfb0893358a330f51d88e4fa494a91bce2/fuzzyhashlib/__init__.py#L100-L110 | train | 63,494 |
TeleSign/python_telesign | telesign/voice.py | VoiceClient.call | def call(self, phone_number, message, message_type, **params):
"""
Send a voice call to the target phone_number.
See https://developer.telesign.com/docs/voice-api for detailed API documentation.
"""
return self.post(VOICE_RESOURCE,
phone_number=phone_num... | python | def call(self, phone_number, message, message_type, **params):
"""
Send a voice call to the target phone_number.
See https://developer.telesign.com/docs/voice-api for detailed API documentation.
"""
return self.post(VOICE_RESOURCE,
phone_number=phone_num... | [
"def",
"call",
"(",
"self",
",",
"phone_number",
",",
"message",
",",
"message_type",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"post",
"(",
"VOICE_RESOURCE",
",",
"phone_number",
"=",
"phone_number",
",",
"message",
"=",
"message",
",",
... | Send a voice call to the target phone_number.
See https://developer.telesign.com/docs/voice-api for detailed API documentation. | [
"Send",
"a",
"voice",
"call",
"to",
"the",
"target",
"phone_number",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/voice.py#L18-L28 | train | 63,495 |
TeleSign/python_telesign | telesign/voice.py | VoiceClient.status | def status(self, reference_id, **params):
"""
Retrieves the current status of the voice call.
See https://developer.telesign.com/docs/voice-api for detailed API documentation.
"""
return self.get(VOICE_STATUS_RESOURCE.format(reference_id=reference_id),
**... | python | def status(self, reference_id, **params):
"""
Retrieves the current status of the voice call.
See https://developer.telesign.com/docs/voice-api for detailed API documentation.
"""
return self.get(VOICE_STATUS_RESOURCE.format(reference_id=reference_id),
**... | [
"def",
"status",
"(",
"self",
",",
"reference_id",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"get",
"(",
"VOICE_STATUS_RESOURCE",
".",
"format",
"(",
"reference_id",
"=",
"reference_id",
")",
",",
"*",
"*",
"params",
")"
] | Retrieves the current status of the voice call.
See https://developer.telesign.com/docs/voice-api for detailed API documentation. | [
"Retrieves",
"the",
"current",
"status",
"of",
"the",
"voice",
"call",
"."
] | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/voice.py#L30-L37 | train | 63,496 |
TeleSign/python_telesign | telesign/appverify.py | AppVerifyClient.status | def status(self, external_id, **params):
"""
Retrieves the verification result for an App Verify transaction by external_id. To ensure a secure verification
flow you must check the status using TeleSign's servers on your backend. Do not rely on the SDK alone to
indicate a successful veri... | python | def status(self, external_id, **params):
"""
Retrieves the verification result for an App Verify transaction by external_id. To ensure a secure verification
flow you must check the status using TeleSign's servers on your backend. Do not rely on the SDK alone to
indicate a successful veri... | [
"def",
"status",
"(",
"self",
",",
"external_id",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"get",
"(",
"APPVERIFY_STATUS_RESOURCE",
".",
"format",
"(",
"external_id",
"=",
"external_id",
")",
",",
"*",
"*",
"params",
")"
] | Retrieves the verification result for an App Verify transaction by external_id. To ensure a secure verification
flow you must check the status using TeleSign's servers on your backend. Do not rely on the SDK alone to
indicate a successful verification.
See https://developer.telesign.com/docs/ap... | [
"Retrieves",
"the",
"verification",
"result",
"for",
"an",
"App",
"Verify",
"transaction",
"by",
"external_id",
".",
"To",
"ensure",
"a",
"secure",
"verification",
"flow",
"you",
"must",
"check",
"the",
"status",
"using",
"TeleSign",
"s",
"servers",
"on",
"you... | f0c2e4373dc8d685e1a7d65444b5e55955c340cb | https://github.com/TeleSign/python_telesign/blob/f0c2e4373dc8d685e1a7d65444b5e55955c340cb/telesign/appverify.py#L17-L28 | train | 63,497 |
danidee10/Staticfy | staticfy/staticfy.py | get_asset_location | def get_asset_location(element, attr):
"""
Get Asset Location.
Remove leading slash e.g '/static/images.jpg' ==> static/images.jpg
Also, if the url is also prefixed with static, it would be removed.
e.g static/image.jpg ==> image.jpg
"""
asset_location = re.match(r'^/?(static)?/?(.*)', ... | python | def get_asset_location(element, attr):
"""
Get Asset Location.
Remove leading slash e.g '/static/images.jpg' ==> static/images.jpg
Also, if the url is also prefixed with static, it would be removed.
e.g static/image.jpg ==> image.jpg
"""
asset_location = re.match(r'^/?(static)?/?(.*)', ... | [
"def",
"get_asset_location",
"(",
"element",
",",
"attr",
")",
":",
"asset_location",
"=",
"re",
".",
"match",
"(",
"r'^/?(static)?/?(.*)'",
",",
"element",
"[",
"attr",
"]",
",",
"re",
".",
"IGNORECASE",
")",
"# replace relative links i.e (../../static)",
"asset_... | Get Asset Location.
Remove leading slash e.g '/static/images.jpg' ==> static/images.jpg
Also, if the url is also prefixed with static, it would be removed.
e.g static/image.jpg ==> image.jpg | [
"Get",
"Asset",
"Location",
"."
] | ebc555b00377394b0f714e4a173d37833fec90cb | https://github.com/danidee10/Staticfy/blob/ebc555b00377394b0f714e4a173d37833fec90cb/staticfy/staticfy.py#L27-L41 | train | 63,498 |
danidee10/Staticfy | staticfy/staticfy.py | transform | def transform(matches, framework, namespace, static_endpoint):
"""
The actual transformation occurs here.
flask example: images/staticfy.jpg', ==>
"{{ url_for('static', filename='images/staticfy.jpg') }}"
"""
transformed = []
namespace = namespace + '/' if namespace else ''
for att... | python | def transform(matches, framework, namespace, static_endpoint):
"""
The actual transformation occurs here.
flask example: images/staticfy.jpg', ==>
"{{ url_for('static', filename='images/staticfy.jpg') }}"
"""
transformed = []
namespace = namespace + '/' if namespace else ''
for att... | [
"def",
"transform",
"(",
"matches",
",",
"framework",
",",
"namespace",
",",
"static_endpoint",
")",
":",
"transformed",
"=",
"[",
"]",
"namespace",
"=",
"namespace",
"+",
"'/'",
"if",
"namespace",
"else",
"''",
"for",
"attribute",
",",
"elements",
"in",
"... | The actual transformation occurs here.
flask example: images/staticfy.jpg', ==>
"{{ url_for('static', filename='images/staticfy.jpg') }}" | [
"The",
"actual",
"transformation",
"occurs",
"here",
"."
] | ebc555b00377394b0f714e4a173d37833fec90cb | https://github.com/danidee10/Staticfy/blob/ebc555b00377394b0f714e4a173d37833fec90cb/staticfy/staticfy.py#L44-L68 | train | 63,499 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.