partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | BasePeonyClient.run_tasks | Run the tasks attached to the instance | peony/client.py | async def run_tasks(self):
""" Run the tasks attached to the instance """
tasks = self.get_tasks()
self._gathered_tasks = asyncio.gather(*tasks, loop=self.loop)
try:
await self._gathered_tasks
except CancelledError:
pass | async def run_tasks(self):
""" Run the tasks attached to the instance """
tasks = self.get_tasks()
self._gathered_tasks = asyncio.gather(*tasks, loop=self.loop)
try:
await self._gathered_tasks
except CancelledError:
pass | [
"Run",
"the",
"tasks",
"attached",
"to",
"the",
"instance"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L402-L409 | [
"async",
"def",
"run_tasks",
"(",
"self",
")",
":",
"tasks",
"=",
"self",
".",
"get_tasks",
"(",
")",
"self",
".",
"_gathered_tasks",
"=",
"asyncio",
".",
"gather",
"(",
"*",
"tasks",
",",
"loop",
"=",
"self",
".",
"loop",
")",
"try",
":",
"await",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | BasePeonyClient.close | properly close the client | peony/client.py | async def close(self):
""" properly close the client """
tasks = self._get_close_tasks()
if tasks:
await asyncio.wait(tasks)
self._session = None | async def close(self):
""" properly close the client """
tasks = self._get_close_tasks()
if tasks:
await asyncio.wait(tasks)
self._session = None | [
"properly",
"close",
"the",
"client"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L458-L465 | [
"async",
"def",
"close",
"(",
"self",
")",
":",
"tasks",
"=",
"self",
".",
"_get_close_tasks",
"(",
")",
"if",
"tasks",
":",
"await",
"asyncio",
".",
"wait",
"(",
"tasks",
")",
"self",
".",
"_session",
"=",
"None"
] | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | PeonyClient._get_twitter_configuration | create a ``twitter_configuration`` attribute with the response
of the endpoint
https://api.twitter.com/1.1/help/configuration.json | peony/client.py | async def _get_twitter_configuration(self):
"""
create a ``twitter_configuration`` attribute with the response
of the endpoint
https://api.twitter.com/1.1/help/configuration.json
"""
api = self['api', general.twitter_api_version,
".json", general.twitte... | async def _get_twitter_configuration(self):
"""
create a ``twitter_configuration`` attribute with the response
of the endpoint
https://api.twitter.com/1.1/help/configuration.json
"""
api = self['api', general.twitter_api_version,
".json", general.twitte... | [
"create",
"a",
"twitter_configuration",
"attribute",
"with",
"the",
"response",
"of",
"the",
"endpoint",
"https",
":",
"//",
"api",
".",
"twitter",
".",
"com",
"/",
"1",
".",
"1",
"/",
"help",
"/",
"configuration",
".",
"json"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L487-L496 | [
"async",
"def",
"_get_twitter_configuration",
"(",
"self",
")",
":",
"api",
"=",
"self",
"[",
"'api'",
",",
"general",
".",
"twitter_api_version",
",",
"\".json\"",
",",
"general",
".",
"twitter_base_api_url",
"]",
"return",
"await",
"api",
".",
"help",
".",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | PeonyClient._get_user | create a ``user`` attribute with the response of the endpoint
https://api.twitter.com/1.1/account/verify_credentials.json | peony/client.py | async def _get_user(self):
"""
create a ``user`` attribute with the response of the endpoint
https://api.twitter.com/1.1/account/verify_credentials.json
"""
api = self['api', general.twitter_api_version,
".json", general.twitter_base_api_url]
return aw... | async def _get_user(self):
"""
create a ``user`` attribute with the response of the endpoint
https://api.twitter.com/1.1/account/verify_credentials.json
"""
api = self['api', general.twitter_api_version,
".json", general.twitter_base_api_url]
return aw... | [
"create",
"a",
"user",
"attribute",
"with",
"the",
"response",
"of",
"the",
"endpoint",
"https",
":",
"//",
"api",
".",
"twitter",
".",
"com",
"/",
"1",
".",
"1",
"/",
"account",
"/",
"verify_credentials",
".",
"json"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L506-L514 | [
"async",
"def",
"_get_user",
"(",
"self",
")",
":",
"api",
"=",
"self",
"[",
"'api'",
",",
"general",
".",
"twitter_api_version",
",",
"\".json\"",
",",
"general",
".",
"twitter_base_api_url",
"]",
"return",
"await",
"api",
".",
"account",
".",
"verify_crede... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | PeonyClient._chunked_upload | upload media in chunks
Parameters
----------
media : file object
a file object of the media
media_size : int
size of the media
path : str, optional
filename of the media
media_type : str, optional
mime type of the media
... | peony/client.py | async def _chunked_upload(self, media, media_size,
path=None,
media_type=None,
media_category=None,
chunk_size=2**20,
**params):
"""
upload media in c... | async def _chunked_upload(self, media, media_size,
path=None,
media_type=None,
media_category=None,
chunk_size=2**20,
**params):
"""
upload media in c... | [
"upload",
"media",
"in",
"chunks"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L542-L640 | [
"async",
"def",
"_chunked_upload",
"(",
"self",
",",
"media",
",",
"media_size",
",",
"path",
"=",
"None",
",",
"media_type",
"=",
"None",
",",
"media_category",
"=",
"None",
",",
"chunk_size",
"=",
"2",
"**",
"20",
",",
"*",
"*",
"params",
")",
":",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | PeonyClient.upload_media | upload a media on twitter
Parameters
----------
file_ : str or pathlib.Path or file
Path to the file or file object
media_type : str, optional
mime type of the media
media_category : str, optional
Twitter's media category of the media, must be... | peony/client.py | async def upload_media(self, file_,
media_type=None,
media_category=None,
chunked=None,
size_limit=None,
**params):
"""
upload a media on twitter
Parameters... | async def upload_media(self, file_,
media_type=None,
media_category=None,
chunked=None,
size_limit=None,
**params):
"""
upload a media on twitter
Parameters... | [
"upload",
"a",
"media",
"on",
"twitter"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/client.py#L652-L716 | [
"async",
"def",
"upload_media",
"(",
"self",
",",
"file_",
",",
"media_type",
"=",
"None",
",",
"media_category",
"=",
"None",
",",
"chunked",
"=",
"None",
",",
"size_limit",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"if",
"isinstance",
"(",
"fil... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | split_stdout_lines | Given the standard output from NetMHC/NetMHCpan/NetMHCcons tools,
drop all {comments, lines of hyphens, empty lines} and split the
remaining lines by whitespace. | mhctools/parsing.py | def split_stdout_lines(stdout):
"""
Given the standard output from NetMHC/NetMHCpan/NetMHCcons tools,
drop all {comments, lines of hyphens, empty lines} and split the
remaining lines by whitespace.
"""
# all the NetMHC formats use lines full of dashes before any actual
# binding results
... | def split_stdout_lines(stdout):
"""
Given the standard output from NetMHC/NetMHCpan/NetMHCcons tools,
drop all {comments, lines of hyphens, empty lines} and split the
remaining lines by whitespace.
"""
# all the NetMHC formats use lines full of dashes before any actual
# binding results
... | [
"Given",
"the",
"standard",
"output",
"from",
"NetMHC",
"/",
"NetMHCpan",
"/",
"NetMHCcons",
"tools",
"drop",
"all",
"{",
"comments",
"lines",
"of",
"hyphens",
"empty",
"lines",
"}",
"and",
"split",
"the",
"remaining",
"lines",
"by",
"whitespace",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L41-L66 | [
"def",
"split_stdout_lines",
"(",
"stdout",
")",
":",
"# all the NetMHC formats use lines full of dashes before any actual",
"# binding results",
"seen_dash",
"=",
"False",
"for",
"l",
"in",
"stdout",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"l",
"=",
"l",
".",
"stri... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | clean_fields | Sometimes, NetMHC* has fields that are only populated sometimes, which results
in different count/indexing of the fields when that happens.
We handle this by looking for particular strings at particular indices, and
deleting them.
Warning: this may result in unexpected behavior sometimes. For example,... | mhctools/parsing.py | def clean_fields(fields, ignored_value_indices, transforms):
"""
Sometimes, NetMHC* has fields that are only populated sometimes, which results
in different count/indexing of the fields when that happens.
We handle this by looking for particular strings at particular indices, and
deleting them.
... | def clean_fields(fields, ignored_value_indices, transforms):
"""
Sometimes, NetMHC* has fields that are only populated sometimes, which results
in different count/indexing of the fields when that happens.
We handle this by looking for particular strings at particular indices, and
deleting them.
... | [
"Sometimes",
"NetMHC",
"*",
"has",
"fields",
"that",
"are",
"only",
"populated",
"sometimes",
"which",
"results",
"in",
"different",
"count",
"/",
"indexing",
"of",
"the",
"fields",
"when",
"that",
"happens",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L69-L98 | [
"def",
"clean_fields",
"(",
"fields",
",",
"ignored_value_indices",
",",
"transforms",
")",
":",
"cleaned_fields",
"=",
"[",
"]",
"for",
"i",
",",
"field",
"in",
"enumerate",
"(",
"fields",
")",
":",
"if",
"field",
"in",
"ignored_value_indices",
":",
"ignore... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | parse_stdout | Generic function for parsing any NetMHC* output, given expected indices
of values of interest.
Parameters
----------
ignored_value_indices : dict
Map from values to the positions we'll ignore them at. See clean_fields.
transforms : dict
Map from field index to a transform function... | mhctools/parsing.py | def parse_stdout(
stdout,
prediction_method_name,
sequence_key_mapping,
key_index,
offset_index,
peptide_index,
allele_index,
ic50_index,
rank_index,
log_ic50_index,
ignored_value_indices={},
transforms={}):
"""
Gene... | def parse_stdout(
stdout,
prediction_method_name,
sequence_key_mapping,
key_index,
offset_index,
peptide_index,
allele_index,
ic50_index,
rank_index,
log_ic50_index,
ignored_value_indices={},
transforms={}):
"""
Gene... | [
"Generic",
"function",
"for",
"parsing",
"any",
"NetMHC",
"*",
"output",
"given",
"expected",
"indices",
"of",
"values",
"of",
"interest",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L100-L157 | [
"def",
"parse_stdout",
"(",
"stdout",
",",
"prediction_method_name",
",",
"sequence_key_mapping",
",",
"key_index",
",",
"offset_index",
",",
"peptide_index",
",",
"allele_index",
",",
"ic50_index",
",",
"rank_index",
",",
"log_ic50_index",
",",
"ignored_value_indices",... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | parse_netmhc3_stdout | Parse the output format for NetMHC 3.x, which looks like:
----------------------------------------------------------------------------------------------------
pos peptide logscore affinity(nM) Bind Level Protein Name Allele
--------------------------------------------------------------------... | mhctools/parsing.py | def parse_netmhc3_stdout(
stdout,
prediction_method_name="netmhc3",
sequence_key_mapping=None):
"""
Parse the output format for NetMHC 3.x, which looks like:
----------------------------------------------------------------------------------------------------
pos peptide ... | def parse_netmhc3_stdout(
stdout,
prediction_method_name="netmhc3",
sequence_key_mapping=None):
"""
Parse the output format for NetMHC 3.x, which looks like:
----------------------------------------------------------------------------------------------------
pos peptide ... | [
"Parse",
"the",
"output",
"format",
"for",
"NetMHC",
"3",
".",
"x",
"which",
"looks",
"like",
":"
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L159-L188 | [
"def",
"parse_netmhc3_stdout",
"(",
"stdout",
",",
"prediction_method_name",
"=",
"\"netmhc3\"",
",",
"sequence_key_mapping",
"=",
"None",
")",
":",
"return",
"parse_stdout",
"(",
"stdout",
"=",
"stdout",
",",
"prediction_method_name",
"=",
"prediction_method_name",
"... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | parse_netmhc4_stdout | # Peptide length 9
# Rank Threshold for Strong binding peptides 0.500
# Rank Threshold for Weak binding peptides 2.000
-----------------------------------------------------------------------------------
pos HLA peptide Core Offset I_pos I_len D_pos D_len iCore ... | mhctools/parsing.py | def parse_netmhc4_stdout(
stdout,
prediction_method_name="netmhc4",
sequence_key_mapping=None):
"""
# Peptide length 9
# Rank Threshold for Strong binding peptides 0.500
# Rank Threshold for Weak binding peptides 2.000
-----------------------------------------------------... | def parse_netmhc4_stdout(
stdout,
prediction_method_name="netmhc4",
sequence_key_mapping=None):
"""
# Peptide length 9
# Rank Threshold for Strong binding peptides 0.500
# Rank Threshold for Weak binding peptides 2.000
-----------------------------------------------------... | [
"#",
"Peptide",
"length",
"9",
"#",
"Rank",
"Threshold",
"for",
"Strong",
"binding",
"peptides",
"0",
".",
"500",
"#",
"Rank",
"Threshold",
"for",
"Weak",
"binding",
"peptides",
"2",
".",
"000",
"------------------------------------------------------------------------... | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L190-L222 | [
"def",
"parse_netmhc4_stdout",
"(",
"stdout",
",",
"prediction_method_name",
"=",
"\"netmhc4\"",
",",
"sequence_key_mapping",
"=",
"None",
")",
":",
"return",
"parse_stdout",
"(",
"stdout",
"=",
"stdout",
",",
"prediction_method_name",
"=",
"prediction_method_name",
"... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | parse_netmhcpan28_stdout | # Affinity Threshold for Strong binding peptides 50.000',
# Affinity Threshold for Weak binding peptides 500.000',
# Rank Threshold for Strong binding peptides 0.500',
# Rank Threshold for Weak binding peptides 2.000',
----------------------------------------------------------------------------
... | mhctools/parsing.py | def parse_netmhcpan28_stdout(
stdout,
prediction_method_name="netmhcpan",
sequence_key_mapping=None):
"""
# Affinity Threshold for Strong binding peptides 50.000',
# Affinity Threshold for Weak binding peptides 500.000',
# Rank Threshold for Strong binding peptides 0.500',
... | def parse_netmhcpan28_stdout(
stdout,
prediction_method_name="netmhcpan",
sequence_key_mapping=None):
"""
# Affinity Threshold for Strong binding peptides 50.000',
# Affinity Threshold for Weak binding peptides 500.000',
# Rank Threshold for Strong binding peptides 0.500',
... | [
"#",
"Affinity",
"Threshold",
"for",
"Strong",
"binding",
"peptides",
"50",
".",
"000",
"#",
"Affinity",
"Threshold",
"for",
"Weak",
"binding",
"peptides",
"500",
".",
"000",
"#",
"Rank",
"Threshold",
"for",
"Strong",
"binding",
"peptides",
"0",
".",
"500",
... | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L224-L260 | [
"def",
"parse_netmhcpan28_stdout",
"(",
"stdout",
",",
"prediction_method_name",
"=",
"\"netmhcpan\"",
",",
"sequence_key_mapping",
"=",
"None",
")",
":",
"check_stdout_error",
"(",
"stdout",
",",
"\"NetMHCpan-2.8\"",
")",
"return",
"parse_stdout",
"(",
"stdout",
"=",... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | parse_netmhcpan3_stdout | # Rank Threshold for Strong binding peptides 0.500
# Rank Threshold for Weak binding peptides 2.000
-----------------------------------------------------------------------------------
Pos HLA Peptide Core Of Gp Gl Ip Il Icore Identity Score Aff(nM) %Rank BindLev... | mhctools/parsing.py | def parse_netmhcpan3_stdout(
stdout,
prediction_method_name="netmhcpan",
sequence_key_mapping=None):
"""
# Rank Threshold for Strong binding peptides 0.500
# Rank Threshold for Weak binding peptides 2.000
-----------------------------------------------------------------------... | def parse_netmhcpan3_stdout(
stdout,
prediction_method_name="netmhcpan",
sequence_key_mapping=None):
"""
# Rank Threshold for Strong binding peptides 0.500
# Rank Threshold for Weak binding peptides 2.000
-----------------------------------------------------------------------... | [
"#",
"Rank",
"Threshold",
"for",
"Strong",
"binding",
"peptides",
"0",
".",
"500",
"#",
"Rank",
"Threshold",
"for",
"Weak",
"binding",
"peptides",
"2",
".",
"000",
"-----------------------------------------------------------------------------------",
"Pos",
"HLA",
"Pept... | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L262-L292 | [
"def",
"parse_netmhcpan3_stdout",
"(",
"stdout",
",",
"prediction_method_name",
"=",
"\"netmhcpan\"",
",",
"sequence_key_mapping",
"=",
"None",
")",
":",
"# the offset specified in \"pos\" (at index 0) is 1-based instead of 0-based. we adjust it to be",
"# 0-based, as in all the other ... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | parse_netmhcpan4_stdout | # NetMHCpan version 4.0
# Tmpdir made /var/folders/jc/fyrvcrcs3sb8g4mkdg6nl_t80000gp/T//netMHCpanuH3SvY
# Input is in PEPTIDE format
# Make binding affinity predictions
HLA-A02:01 : Distance to training data 0.000 (using nearest neighbor HLA-A02:01)
# Rank Threshold for Strong binding peptides ... | mhctools/parsing.py | def parse_netmhcpan4_stdout(
stdout,
prediction_method_name="netmhcpan",
sequence_key_mapping=None):
"""
# NetMHCpan version 4.0
# Tmpdir made /var/folders/jc/fyrvcrcs3sb8g4mkdg6nl_t80000gp/T//netMHCpanuH3SvY
# Input is in PEPTIDE format
# Make binding affinity predictions
... | def parse_netmhcpan4_stdout(
stdout,
prediction_method_name="netmhcpan",
sequence_key_mapping=None):
"""
# NetMHCpan version 4.0
# Tmpdir made /var/folders/jc/fyrvcrcs3sb8g4mkdg6nl_t80000gp/T//netMHCpanuH3SvY
# Input is in PEPTIDE format
# Make binding affinity predictions
... | [
"#",
"NetMHCpan",
"version",
"4",
".",
"0"
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/parsing.py#L295-L326 | [
"def",
"parse_netmhcpan4_stdout",
"(",
"stdout",
",",
"prediction_method_name",
"=",
"\"netmhcpan\"",
",",
"sequence_key_mapping",
"=",
"None",
")",
":",
"# Output format is compatible with netmhcpan3, but netmhcpan 4.0 must be",
"# called with the -BA flag, so it gives affinity predic... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | _parse_iedb_response | Take the binding predictions returned by IEDB's web API
and parse them into a DataFrame
Expect response to look like:
allele seq_num start end length peptide ic50 percentile_rank
HLA-A*01:01 1 2 10 9 LYNTVATLY 2145.70 3.7
HLA-A*01:01 1 5 13 9 TVATLYCVH 2216.49 3.9
HLA-A*... | mhctools/iedb.py | def _parse_iedb_response(response):
"""Take the binding predictions returned by IEDB's web API
and parse them into a DataFrame
Expect response to look like:
allele seq_num start end length peptide ic50 percentile_rank
HLA-A*01:01 1 2 10 9 LYNTVATLY 2145.70 3.7
HLA-A*01:01 1 5 ... | def _parse_iedb_response(response):
"""Take the binding predictions returned by IEDB's web API
and parse them into a DataFrame
Expect response to look like:
allele seq_num start end length peptide ic50 percentile_rank
HLA-A*01:01 1 2 10 9 LYNTVATLY 2145.70 3.7
HLA-A*01:01 1 5 ... | [
"Take",
"the",
"binding",
"predictions",
"returned",
"by",
"IEDB",
"s",
"web",
"API",
"and",
"parse",
"them",
"into",
"a",
"DataFrame"
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/iedb.py#L70-L118 | [
"def",
"_parse_iedb_response",
"(",
"response",
")",
":",
"if",
"len",
"(",
"response",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"Empty response from IEDB!\"",
")",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"io",
".",
"BytesIO",
"(",
"response",
")"... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | _query_iedb | Call into IEDB's web API for MHC binding prediction using request dictionary
with fields:
- "method"
- "length"
- "sequence_text"
- "allele"
Parse the response into a DataFrame. | mhctools/iedb.py | def _query_iedb(request_values, url):
"""
Call into IEDB's web API for MHC binding prediction using request dictionary
with fields:
- "method"
- "length"
- "sequence_text"
- "allele"
Parse the response into a DataFrame.
"""
data = urlencode(request_values)
re... | def _query_iedb(request_values, url):
"""
Call into IEDB's web API for MHC binding prediction using request dictionary
with fields:
- "method"
- "length"
- "sequence_text"
- "allele"
Parse the response into a DataFrame.
"""
data = urlencode(request_values)
re... | [
"Call",
"into",
"IEDB",
"s",
"web",
"API",
"for",
"MHC",
"binding",
"prediction",
"using",
"request",
"dictionary",
"with",
"fields",
":",
"-",
"method",
"-",
"length",
"-",
"sequence_text",
"-",
"allele"
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/iedb.py#L120-L134 | [
"def",
"_query_iedb",
"(",
"request_values",
",",
"url",
")",
":",
"data",
"=",
"urlencode",
"(",
"request_values",
")",
"req",
"=",
"Request",
"(",
"url",
",",
"data",
".",
"encode",
"(",
"\"ascii\"",
")",
")",
"response",
"=",
"urlopen",
"(",
"req",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | IedbBasePredictor.predict_subsequences | Given a dictionary mapping unique keys to amino acid sequences,
run MHC binding predictions on all candidate epitopes extracted from
sequences and return a EpitopeCollection.
Parameters
----------
fasta_dictionary : dict or string
Mapping of protein identifiers to pr... | mhctools/iedb.py | def predict_subsequences(self, sequence_dict, peptide_lengths=None):
"""Given a dictionary mapping unique keys to amino acid sequences,
run MHC binding predictions on all candidate epitopes extracted from
sequences and return a EpitopeCollection.
Parameters
----------
fa... | def predict_subsequences(self, sequence_dict, peptide_lengths=None):
"""Given a dictionary mapping unique keys to amino acid sequences,
run MHC binding predictions on all candidate epitopes extracted from
sequences and return a EpitopeCollection.
Parameters
----------
fa... | [
"Given",
"a",
"dictionary",
"mapping",
"unique",
"keys",
"to",
"amino",
"acid",
"sequences",
"run",
"MHC",
"binding",
"predictions",
"on",
"all",
"candidate",
"epitopes",
"extracted",
"from",
"sequences",
"and",
"return",
"a",
"EpitopeCollection",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/iedb.py#L191-L241 | [
"def",
"predict_subsequences",
"(",
"self",
",",
"sequence_dict",
",",
"peptide_lengths",
"=",
"None",
")",
":",
"sequence_dict",
"=",
"check_sequence_dictionary",
"(",
"sequence_dict",
")",
"peptide_lengths",
"=",
"self",
".",
"_check_peptide_lengths",
"(",
"peptide_... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | get_args | Hackish way to get the arguments of a function
Parameters
----------
func : callable
Function to get the arguments from
skip : int, optional
Arguments to skip, defaults to 0 set it to 1 to skip the
``self`` argument of a method.
Returns
-------
tuple
Functio... | peony/utils.py | def get_args(func, skip=0):
"""
Hackish way to get the arguments of a function
Parameters
----------
func : callable
Function to get the arguments from
skip : int, optional
Arguments to skip, defaults to 0 set it to 1 to skip the
``self`` argument of a method.
R... | def get_args(func, skip=0):
"""
Hackish way to get the arguments of a function
Parameters
----------
func : callable
Function to get the arguments from
skip : int, optional
Arguments to skip, defaults to 0 set it to 1 to skip the
``self`` argument of a method.
R... | [
"Hackish",
"way",
"to",
"get",
"the",
"arguments",
"of",
"a",
"function"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/utils.py#L149-L171 | [
"def",
"get_args",
"(",
"func",
",",
"skip",
"=",
"0",
")",
":",
"code",
"=",
"getattr",
"(",
"func",
",",
"'__code__'",
",",
"None",
")",
"if",
"code",
"is",
"None",
":",
"code",
"=",
"func",
".",
"__call__",
".",
"__code__",
"return",
"code",
"."... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | log_error | log an exception and its traceback on the logger defined
Parameters
----------
msg : str, optional
A message to add to the error
exc_info : tuple
Information about the current exception
logger : logging.Logger
logger to use | peony/utils.py | def log_error(msg=None, exc_info=None, logger=None, **kwargs):
"""
log an exception and its traceback on the logger defined
Parameters
----------
msg : str, optional
A message to add to the error
exc_info : tuple
Information about the current exception
logger : logging.L... | def log_error(msg=None, exc_info=None, logger=None, **kwargs):
"""
log an exception and its traceback on the logger defined
Parameters
----------
msg : str, optional
A message to add to the error
exc_info : tuple
Information about the current exception
logger : logging.L... | [
"log",
"an",
"exception",
"and",
"its",
"traceback",
"on",
"the",
"logger",
"defined"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/utils.py#L174-L199 | [
"def",
"log_error",
"(",
"msg",
"=",
"None",
",",
"exc_info",
"=",
"None",
",",
"logger",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"logger",
"is",
"None",
":",
"logger",
"=",
"_logger",
"if",
"not",
"exc_info",
":",
"exc_info",
"=",
"s... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | get_media_metadata | Get all the file's metadata and read any kind of file object
Parameters
----------
data : bytes
first bytes of the file (the mimetype shoudl be guessed from the
file headers
path : str, optional
path to the file
Returns
-------
str
The mimetype of the media
... | peony/utils.py | async def get_media_metadata(data, path=None):
"""
Get all the file's metadata and read any kind of file object
Parameters
----------
data : bytes
first bytes of the file (the mimetype shoudl be guessed from the
file headers
path : str, optional
path to the file
... | async def get_media_metadata(data, path=None):
"""
Get all the file's metadata and read any kind of file object
Parameters
----------
data : bytes
first bytes of the file (the mimetype shoudl be guessed from the
file headers
path : str, optional
path to the file
... | [
"Get",
"all",
"the",
"file",
"s",
"metadata",
"and",
"read",
"any",
"kind",
"of",
"file",
"object"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/utils.py#L202-L232 | [
"async",
"def",
"get_media_metadata",
"(",
"data",
",",
"path",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"bytes",
")",
":",
"media_type",
"=",
"await",
"get_type",
"(",
"data",
",",
"path",
")",
"else",
":",
"raise",
"TypeError",
"(... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | get_size | Get the size of a file
Parameters
----------
media : file object
The file object of the media
Returns
-------
int
The size of the file | peony/utils.py | async def get_size(media):
"""
Get the size of a file
Parameters
----------
media : file object
The file object of the media
Returns
-------
int
The size of the file
"""
if hasattr(media, 'seek'):
await execute(media.seek(0, os.SEEK_END))
siz... | async def get_size(media):
"""
Get the size of a file
Parameters
----------
media : file object
The file object of the media
Returns
-------
int
The size of the file
"""
if hasattr(media, 'seek'):
await execute(media.seek(0, os.SEEK_END))
siz... | [
"Get",
"the",
"size",
"of",
"a",
"file"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/utils.py#L235-L262 | [
"async",
"def",
"get_size",
"(",
"media",
")",
":",
"if",
"hasattr",
"(",
"media",
",",
"'seek'",
")",
":",
"await",
"execute",
"(",
"media",
".",
"seek",
"(",
"0",
",",
"os",
".",
"SEEK_END",
")",
")",
"size",
"=",
"await",
"execute",
"(",
"media"... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | get_type | Parameters
----------
media : file object
A file object of the image
path : str, optional
The path to the file
Returns
-------
str
The mimetype of the media
str
The category of the media on Twitter | peony/utils.py | async def get_type(media, path=None):
"""
Parameters
----------
media : file object
A file object of the image
path : str, optional
The path to the file
Returns
-------
str
The mimetype of the media
str
The category of the media on Twitter
"""
... | async def get_type(media, path=None):
"""
Parameters
----------
media : file object
A file object of the image
path : str, optional
The path to the file
Returns
-------
str
The mimetype of the media
str
The category of the media on Twitter
"""
... | [
"Parameters",
"----------",
"media",
":",
"file",
"object",
"A",
"file",
"object",
"of",
"the",
"image",
"path",
":",
"str",
"optional",
"The",
"path",
"to",
"the",
"file"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/utils.py#L265-L299 | [
"async",
"def",
"get_type",
"(",
"media",
",",
"path",
"=",
"None",
")",
":",
"if",
"magic",
":",
"if",
"not",
"media",
":",
"raise",
"TypeError",
"(",
"\"Media data is empty\"",
")",
"_logger",
".",
"debug",
"(",
"\"guessing mimetype using magic\"",
")",
"m... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | set_debug | activates error messages, useful during development | peony/utils.py | def set_debug():
""" activates error messages, useful during development """
logging.basicConfig(level=logging.WARNING)
peony.logger.setLevel(logging.DEBUG) | def set_debug():
""" activates error messages, useful during development """
logging.basicConfig(level=logging.WARNING)
peony.logger.setLevel(logging.DEBUG) | [
"activates",
"error",
"messages",
"useful",
"during",
"development"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/utils.py#L328-L331 | [
"def",
"set_debug",
"(",
")",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"WARNING",
")",
"peony",
".",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")"
] | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | BindingPrediction.clone_with_updates | Returns new BindingPrediction with updated fields | mhctools/binding_prediction.py | def clone_with_updates(self, **kwargs):
"""Returns new BindingPrediction with updated fields"""
fields_dict = self.to_dict()
fields_dict.update(kwargs)
return BindingPrediction(**fields_dict) | def clone_with_updates(self, **kwargs):
"""Returns new BindingPrediction with updated fields"""
fields_dict = self.to_dict()
fields_dict.update(kwargs)
return BindingPrediction(**fields_dict) | [
"Returns",
"new",
"BindingPrediction",
"with",
"updated",
"fields"
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/binding_prediction.py#L109-L113 | [
"def",
"clone_with_updates",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"fields_dict",
"=",
"self",
".",
"to_dict",
"(",
")",
"fields_dict",
".",
"update",
"(",
"kwargs",
")",
"return",
"BindingPrediction",
"(",
"*",
"*",
"fields_dict",
")"
] | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | NetMHCpan | This function wraps NetMHCpan28 and NetMHCpan3 to automatically detect which class
to use, with the help of the miraculous and strange '--version' netmhcpan argument. | mhctools/netmhc_pan.py | def NetMHCpan(
alleles,
program_name="netMHCpan",
process_limit=-1,
default_peptide_lengths=[9],
extra_flags=[]):
"""
This function wraps NetMHCpan28 and NetMHCpan3 to automatically detect which class
to use, with the help of the miraculous and strange '--version' net... | def NetMHCpan(
alleles,
program_name="netMHCpan",
process_limit=-1,
default_peptide_lengths=[9],
extra_flags=[]):
"""
This function wraps NetMHCpan28 and NetMHCpan3 to automatically detect which class
to use, with the help of the miraculous and strange '--version' net... | [
"This",
"function",
"wraps",
"NetMHCpan28",
"and",
"NetMHCpan3",
"to",
"automatically",
"detect",
"which",
"class",
"to",
"use",
"with",
"the",
"help",
"of",
"the",
"miraculous",
"and",
"strange",
"--",
"version",
"netmhcpan",
"argument",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/netmhc_pan.py#L28-L64 | [
"def",
"NetMHCpan",
"(",
"alleles",
",",
"program_name",
"=",
"\"netMHCpan\"",
",",
"process_limit",
"=",
"-",
"1",
",",
"default_peptide_lengths",
"=",
"[",
"9",
"]",
",",
"extra_flags",
"=",
"[",
"]",
")",
":",
"# convert to str since Python3 returns a `bytes` o... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | IdIterator.get_data | Get the data from the response | peony/iterators.py | def get_data(self, response):
""" Get the data from the response """
if self._response_list:
return response
elif self._response_key is None:
if hasattr(response, "items"):
for key, data in response.items():
if (hasattr(data, "__getitem... | def get_data(self, response):
""" Get the data from the response """
if self._response_list:
return response
elif self._response_key is None:
if hasattr(response, "items"):
for key, data in response.items():
if (hasattr(data, "__getitem... | [
"Get",
"the",
"data",
"from",
"the",
"response"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/iterators.py#L72-L91 | [
"def",
"get_data",
"(",
"self",
",",
"response",
")",
":",
"if",
"self",
".",
"_response_list",
":",
"return",
"response",
"elif",
"self",
".",
"_response_key",
"is",
"None",
":",
"if",
"hasattr",
"(",
"response",
",",
"\"items\"",
")",
":",
"for",
"key"... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | SinceIdIterator.call_on_response | Try to fill the gaps and strip last tweet from the response
if its id is that of the first tweet of the last response
Parameters
----------
data : list
The response data | peony/iterators.py | async def call_on_response(self, data):
"""
Try to fill the gaps and strip last tweet from the response
if its id is that of the first tweet of the last response
Parameters
----------
data : list
The response data
"""
since_id = self.kwargs.ge... | async def call_on_response(self, data):
"""
Try to fill the gaps and strip last tweet from the response
if its id is that of the first tweet of the last response
Parameters
----------
data : list
The response data
"""
since_id = self.kwargs.ge... | [
"Try",
"to",
"fill",
"the",
"gaps",
"and",
"strip",
"last",
"tweet",
"from",
"the",
"response",
"if",
"its",
"id",
"is",
"that",
"of",
"the",
"first",
"tweet",
"of",
"the",
"last",
"response"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/iterators.py#L150-L177 | [
"async",
"def",
"call_on_response",
"(",
"self",
",",
"data",
")",
":",
"since_id",
"=",
"self",
".",
"kwargs",
".",
"get",
"(",
"self",
".",
"param",
",",
"0",
")",
"+",
"1",
"if",
"self",
".",
"fill_gaps",
":",
"if",
"data",
"[",
"-",
"1",
"]",... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | get_oauth_token | Get a temporary oauth token
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
callback_uri : str, optional
Callback uri, defaults to 'oob'
Returns
-------
dict
Temporary tokens | peony/oauth_dance.py | async def get_oauth_token(consumer_key, consumer_secret, callback_uri="oob"):
"""
Get a temporary oauth token
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
callback_uri : str, optional
Callback uri, defaults to ... | async def get_oauth_token(consumer_key, consumer_secret, callback_uri="oob"):
"""
Get a temporary oauth token
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
callback_uri : str, optional
Callback uri, defaults to ... | [
"Get",
"a",
"temporary",
"oauth",
"token"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth_dance.py#L10-L39 | [
"async",
"def",
"get_oauth_token",
"(",
"consumer_key",
",",
"consumer_secret",
",",
"callback_uri",
"=",
"\"oob\"",
")",
":",
"client",
"=",
"BasePeonyClient",
"(",
"consumer_key",
"=",
"consumer_key",
",",
"consumer_secret",
"=",
"consumer_secret",
",",
"api_versi... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | get_oauth_verifier | Open authorize page in a browser,
print the url if it didn't work
Arguments
---------
oauth_token : str
The oauth token received in :func:`get_oauth_token`
Returns
-------
str
The PIN entered by the user | peony/oauth_dance.py | async def get_oauth_verifier(oauth_token):
"""
Open authorize page in a browser,
print the url if it didn't work
Arguments
---------
oauth_token : str
The oauth token received in :func:`get_oauth_token`
Returns
-------
str
The PIN entered by the user
"""
url... | async def get_oauth_verifier(oauth_token):
"""
Open authorize page in a browser,
print the url if it didn't work
Arguments
---------
oauth_token : str
The oauth token received in :func:`get_oauth_token`
Returns
-------
str
The PIN entered by the user
"""
url... | [
"Open",
"authorize",
"page",
"in",
"a",
"browser",
"print",
"the",
"url",
"if",
"it",
"didn",
"t",
"work"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth_dance.py#L42-L69 | [
"async",
"def",
"get_oauth_verifier",
"(",
"oauth_token",
")",
":",
"url",
"=",
"\"https://api.twitter.com/oauth/authorize?oauth_token=\"",
"+",
"oauth_token",
"try",
":",
"browser",
"=",
"webbrowser",
".",
"open",
"(",
"url",
")",
"await",
"asyncio",
".",
"sleep",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | get_access_token | get the access token of the user
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
oauth_token : str
OAuth token from :func:`get_oauth_token`
oauth_token_secret : str
OAuth token secret from :func:`get_oauth_tok... | peony/oauth_dance.py | async def get_access_token(consumer_key, consumer_secret,
oauth_token, oauth_token_secret,
oauth_verifier, **kwargs):
"""
get the access token of the user
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret... | async def get_access_token(consumer_key, consumer_secret,
oauth_token, oauth_token_secret,
oauth_verifier, **kwargs):
"""
get the access token of the user
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret... | [
"get",
"the",
"access",
"token",
"of",
"the",
"user"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth_dance.py#L72-L109 | [
"async",
"def",
"get_access_token",
"(",
"consumer_key",
",",
"consumer_secret",
",",
"oauth_token",
",",
"oauth_token_secret",
",",
"oauth_verifier",
",",
"*",
"*",
"kwargs",
")",
":",
"client",
"=",
"BasePeonyClient",
"(",
"consumer_key",
"=",
"consumer_key",
",... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | async_oauth_dance | OAuth dance to get the user's access token
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
callback_uri : str
Callback uri, defaults to 'oob'
Returns
-------
dict
Access tokens | peony/oauth_dance.py | async def async_oauth_dance(consumer_key, consumer_secret, callback_uri="oob"):
"""
OAuth dance to get the user's access token
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
callback_uri : str
Callback uri, d... | async def async_oauth_dance(consumer_key, consumer_secret, callback_uri="oob"):
"""
OAuth dance to get the user's access token
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
callback_uri : str
Callback uri, d... | [
"OAuth",
"dance",
"to",
"get",
"the",
"user",
"s",
"access",
"token"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth_dance.py#L112-L149 | [
"async",
"def",
"async_oauth_dance",
"(",
"consumer_key",
",",
"consumer_secret",
",",
"callback_uri",
"=",
"\"oob\"",
")",
":",
"token",
"=",
"await",
"get_oauth_token",
"(",
"consumer_key",
",",
"consumer_secret",
",",
"callback_uri",
")",
"oauth_verifier",
"=",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | parse_token | parse the responses containing the tokens
Parameters
----------
response : str
The response containing the tokens
Returns
-------
dict
The parsed tokens | peony/oauth_dance.py | def parse_token(response):
"""
parse the responses containing the tokens
Parameters
----------
response : str
The response containing the tokens
Returns
-------
dict
The parsed tokens
"""
items = response.split("&")
items = [item.split("=") for item in items... | def parse_token(response):
"""
parse the responses containing the tokens
Parameters
----------
response : str
The response containing the tokens
Returns
-------
dict
The parsed tokens
"""
items = response.split("&")
items = [item.split("=") for item in items... | [
"parse",
"the",
"responses",
"containing",
"the",
"tokens"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth_dance.py#L152-L169 | [
"def",
"parse_token",
"(",
"response",
")",
":",
"items",
"=",
"response",
".",
"split",
"(",
"\"&\"",
")",
"items",
"=",
"[",
"item",
".",
"split",
"(",
"\"=\"",
")",
"for",
"item",
"in",
"items",
"]",
"return",
"{",
"key",
":",
"value",
"for",
"k... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | oauth_dance | OAuth dance to get the user's access token
It calls async_oauth_dance and create event loop of not given
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
oauth_callback : str
Callback uri, defaults to 'oob'
loop :... | peony/oauth_dance.py | def oauth_dance(consumer_key, consumer_secret,
oauth_callback="oob", loop=None):
"""
OAuth dance to get the user's access token
It calls async_oauth_dance and create event loop of not given
Parameters
----------
consumer_key : str
Your consumer key
consumer_secr... | def oauth_dance(consumer_key, consumer_secret,
oauth_callback="oob", loop=None):
"""
OAuth dance to get the user's access token
It calls async_oauth_dance and create event loop of not given
Parameters
----------
consumer_key : str
Your consumer key
consumer_secr... | [
"OAuth",
"dance",
"to",
"get",
"the",
"user",
"s",
"access",
"token"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth_dance.py#L172-L198 | [
"def",
"oauth_dance",
"(",
"consumer_key",
",",
"consumer_secret",
",",
"oauth_callback",
"=",
"\"oob\"",
",",
"loop",
"=",
"None",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"if",
"loop",
"is",
"None",
"else",
"loop",
"coro",
"=",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | oauth2_dance | oauth2 dance
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
loop : event loop, optional
event loop to use
Returns
-------
str
Bearer token | peony/oauth_dance.py | def oauth2_dance(consumer_key, consumer_secret, loop=None):
"""
oauth2 dance
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
loop : event loop, optional
event loop to use
Returns
-------
str
... | def oauth2_dance(consumer_key, consumer_secret, loop=None):
"""
oauth2 dance
Parameters
----------
consumer_key : str
Your consumer key
consumer_secret : str
Your consumer secret
loop : event loop, optional
event loop to use
Returns
-------
str
... | [
"oauth2",
"dance"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth_dance.py#L201-L225 | [
"def",
"oauth2_dance",
"(",
"consumer_key",
",",
"consumer_secret",
",",
"loop",
"=",
"None",
")",
":",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"if",
"loop",
"is",
"None",
"else",
"loop",
"client",
"=",
"BasePeonyClient",
"(",
"consumer_key"... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | NetChop.predict | Return netChop predictions for each position in each sequence.
Parameters
-----------
sequences : list of string
Amino acid sequences to predict cleavage for
Returns
-----------
list of list of float
The i'th list corresponds to the i'th sequence. E... | mhctools/netchop.py | def predict(self, sequences):
"""
Return netChop predictions for each position in each sequence.
Parameters
-----------
sequences : list of string
Amino acid sequences to predict cleavage for
Returns
-----------
list of list of float
... | def predict(self, sequences):
"""
Return netChop predictions for each position in each sequence.
Parameters
-----------
sequences : list of string
Amino acid sequences to predict cleavage for
Returns
-----------
list of list of float
... | [
"Return",
"netChop",
"predictions",
"for",
"each",
"position",
"in",
"each",
"sequence",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/netchop.py#L26-L59 | [
"def",
"predict",
"(",
"self",
",",
"sequences",
")",
":",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"suffix",
"=",
"\".fsa\"",
",",
"mode",
"=",
"\"w\"",
")",
"as",
"input_fd",
":",
"for",
"(",
"i",
",",
"sequence",
")",
"in",
"enumerate",
"... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | NetChop.parse_netchop | Parse netChop stdout. | mhctools/netchop.py | def parse_netchop(netchop_output):
"""
Parse netChop stdout.
"""
line_iterator = iter(netchop_output.decode().split("\n"))
scores = []
for line in line_iterator:
if "pos" in line and 'AA' in line and 'score' in line:
scores.append([])
... | def parse_netchop(netchop_output):
"""
Parse netChop stdout.
"""
line_iterator = iter(netchop_output.decode().split("\n"))
scores = []
for line in line_iterator:
if "pos" in line and 'AA' in line and 'score' in line:
scores.append([])
... | [
"Parse",
"netChop",
"stdout",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/netchop.py#L62-L78 | [
"def",
"parse_netchop",
"(",
"netchop_output",
")",
":",
"line_iterator",
"=",
"iter",
"(",
"netchop_output",
".",
"decode",
"(",
")",
".",
"split",
"(",
"\"\\n\"",
")",
")",
"scores",
"=",
"[",
"]",
"for",
"line",
"in",
"line_iterator",
":",
"if",
"\"po... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | BindingPredictionCollection.to_dataframe | Converts collection of BindingPrediction objects to DataFrame | mhctools/binding_prediction_collection.py | def to_dataframe(
self,
columns=BindingPrediction.fields + ("length",)):
"""
Converts collection of BindingPrediction objects to DataFrame
"""
return pd.DataFrame.from_records(
[tuple([getattr(x, name) for name in columns]) for x in self],
... | def to_dataframe(
self,
columns=BindingPrediction.fields + ("length",)):
"""
Converts collection of BindingPrediction objects to DataFrame
"""
return pd.DataFrame.from_records(
[tuple([getattr(x, name) for name in columns]) for x in self],
... | [
"Converts",
"collection",
"of",
"BindingPrediction",
"objects",
"to",
"DataFrame"
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/binding_prediction_collection.py#L23-L31 | [
"def",
"to_dataframe",
"(",
"self",
",",
"columns",
"=",
"BindingPrediction",
".",
"fields",
"+",
"(",
"\"length\"",
",",
")",
")",
":",
"return",
"pd",
".",
"DataFrame",
".",
"from_records",
"(",
"[",
"tuple",
"(",
"[",
"getattr",
"(",
"x",
",",
"name... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | NetMHC | This function wraps NetMHC3 and NetMHC4 to automatically detect which class
to use. Currently based on running the '-h' command and looking for
discriminating substrings between the versions. | mhctools/netmhc.py | def NetMHC(alleles,
default_peptide_lengths=[9],
program_name="netMHC"):
"""
This function wraps NetMHC3 and NetMHC4 to automatically detect which class
to use. Currently based on running the '-h' command and looking for
discriminating substrings between the versions.
"""
#... | def NetMHC(alleles,
default_peptide_lengths=[9],
program_name="netMHC"):
"""
This function wraps NetMHC3 and NetMHC4 to automatically detect which class
to use. Currently based on running the '-h' command and looking for
discriminating substrings between the versions.
"""
#... | [
"This",
"function",
"wraps",
"NetMHC3",
"and",
"NetMHC4",
"to",
"automatically",
"detect",
"which",
"class",
"to",
"use",
".",
"Currently",
"based",
"on",
"running",
"the",
"-",
"h",
"command",
"and",
"looking",
"for",
"discriminating",
"substrings",
"between",
... | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/netmhc.py#L23-L59 | [
"def",
"NetMHC",
"(",
"alleles",
",",
"default_peptide_lengths",
"=",
"[",
"9",
"]",
",",
"program_name",
"=",
"\"netMHC\"",
")",
":",
"# run NetMHC's help command and parse discriminating substrings out of",
"# the resulting str output",
"with",
"open",
"(",
"os",
".",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | MHCflurry.predict_peptides | Predict MHC affinity for peptides. | mhctools/mhcflurry.py | def predict_peptides(self, peptides):
"""
Predict MHC affinity for peptides.
"""
# importing locally to avoid slowing down CLI applications which
# don't use MHCflurry
from mhcflurry.encodable_sequences import EncodableSequences
binding_predictions = []
... | def predict_peptides(self, peptides):
"""
Predict MHC affinity for peptides.
"""
# importing locally to avoid slowing down CLI applications which
# don't use MHCflurry
from mhcflurry.encodable_sequences import EncodableSequences
binding_predictions = []
... | [
"Predict",
"MHC",
"affinity",
"for",
"peptides",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/mhcflurry.py#L75-L100 | [
"def",
"predict_peptides",
"(",
"self",
",",
"peptides",
")",
":",
"# importing locally to avoid slowing down CLI applications which",
"# don't use MHCflurry",
"from",
"mhcflurry",
".",
"encodable_sequences",
"import",
"EncodableSequences",
"binding_predictions",
"=",
"[",
"]",... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | seq_to_str | Given a sequence convert it to a comma separated string.
If, however, the argument is a single object, return its string
representation. | mhctools/common.py | def seq_to_str(obj, sep=","):
"""
Given a sequence convert it to a comma separated string.
If, however, the argument is a single object, return its string
representation.
"""
if isinstance(obj, string_classes):
return obj
elif isinstance(obj, (list, tuple)):
return sep.join([... | def seq_to_str(obj, sep=","):
"""
Given a sequence convert it to a comma separated string.
If, however, the argument is a single object, return its string
representation.
"""
if isinstance(obj, string_classes):
return obj
elif isinstance(obj, (list, tuple)):
return sep.join([... | [
"Given",
"a",
"sequence",
"convert",
"it",
"to",
"a",
"comma",
"separated",
"string",
".",
"If",
"however",
"the",
"argument",
"is",
"a",
"single",
"object",
"return",
"its",
"string",
"representation",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/common.py#L24-L35 | [
"def",
"seq_to_str",
"(",
"obj",
",",
"sep",
"=",
"\",\"",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"string_classes",
")",
":",
"return",
"obj",
"elif",
"isinstance",
"(",
"obj",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"sep",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | convert | Convert the image to all the formats specified
Parameters
----------
img : PIL.Image.Image
The image to convert
formats : list
List of all the formats to use
Returns
-------
io.BytesIO
A file object containing the converted image | examples/upload.py | def convert(img, formats):
"""
Convert the image to all the formats specified
Parameters
----------
img : PIL.Image.Image
The image to convert
formats : list
List of all the formats to use
Returns
-------
io.BytesIO
A file object containing the converted i... | def convert(img, formats):
"""
Convert the image to all the formats specified
Parameters
----------
img : PIL.Image.Image
The image to convert
formats : list
List of all the formats to use
Returns
-------
io.BytesIO
A file object containing the converted i... | [
"Convert",
"the",
"image",
"to",
"all",
"the",
"formats",
"specified",
"Parameters",
"----------",
"img",
":",
"PIL",
".",
"Image",
".",
"Image",
"The",
"image",
"to",
"convert",
"formats",
":",
"list",
"List",
"of",
"all",
"the",
"formats",
"to",
"use",
... | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/examples/upload.py#L25-L64 | [
"def",
"convert",
"(",
"img",
",",
"formats",
")",
":",
"media",
"=",
"None",
"min_size",
"=",
"0",
"for",
"kwargs",
"in",
"formats",
":",
"f",
"=",
"io",
".",
"BytesIO",
"(",
")",
"if",
"img",
".",
"mode",
"==",
"\"RGBA\"",
"and",
"kwargs",
"[",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | optimize_media | Optimize an image
Resize the picture to the ``max_size``, defaulting to the large
photo size of Twitter in :meth:`PeonyClient.upload_media` when
used with the ``optimize_media`` argument.
Parameters
----------
file_ : file object
the file object of an image
max_size : :obj:`tuple` or... | examples/upload.py | def optimize_media(file_, max_size, formats):
"""
Optimize an image
Resize the picture to the ``max_size``, defaulting to the large
photo size of Twitter in :meth:`PeonyClient.upload_media` when
used with the ``optimize_media`` argument.
Parameters
----------
file_ : file object
... | def optimize_media(file_, max_size, formats):
"""
Optimize an image
Resize the picture to the ``max_size``, defaulting to the large
photo size of Twitter in :meth:`PeonyClient.upload_media` when
used with the ``optimize_media`` argument.
Parameters
----------
file_ : file object
... | [
"Optimize",
"an",
"image",
"Resize",
"the",
"picture",
"to",
"the",
"max_size",
"defaulting",
"to",
"the",
"large",
"photo",
"size",
"of",
"Twitter",
"in",
":",
"meth",
":",
"PeonyClient",
".",
"upload_media",
"when",
"used",
"with",
"the",
"optimize_media",
... | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/examples/upload.py#L67-L109 | [
"def",
"optimize_media",
"(",
"file_",
",",
"max_size",
",",
"formats",
")",
":",
"if",
"not",
"PIL",
":",
"msg",
"=",
"(",
"\"Pillow must be installed to optimize a media\\n\"",
"\"$ pip3 install Pillow\"",
")",
"raise",
"RuntimeError",
"(",
"msg",
")",
"img",
"=... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | create_input_peptides_files | Creates one or more files containing one peptide per line,
returns names of files. | mhctools/input_file_formats.py | def create_input_peptides_files(
peptides,
max_peptides_per_file=None,
group_by_length=False):
"""
Creates one or more files containing one peptide per line,
returns names of files.
"""
if group_by_length:
peptide_lengths = {len(p) for p in peptides}
peptide_g... | def create_input_peptides_files(
peptides,
max_peptides_per_file=None,
group_by_length=False):
"""
Creates one or more files containing one peptide per line,
returns names of files.
"""
if group_by_length:
peptide_lengths = {len(p) for p in peptides}
peptide_g... | [
"Creates",
"one",
"or",
"more",
"files",
"containing",
"one",
"peptide",
"per",
"line",
"returns",
"names",
"of",
"files",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/input_file_formats.py#L26-L61 | [
"def",
"create_input_peptides_files",
"(",
"peptides",
",",
"max_peptides_per_file",
"=",
"None",
",",
"group_by_length",
"=",
"False",
")",
":",
"if",
"group_by_length",
":",
"peptide_lengths",
"=",
"{",
"len",
"(",
"p",
")",
"for",
"p",
"in",
"peptides",
"}"... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | BasePredictor._check_peptide_lengths | If peptide lengths not specified, then try using the default
lengths associated with this predictor object. If those aren't
a valid non-empty sequence of integers, then raise an exception.
Otherwise return the peptide lengths. | mhctools/base_predictor.py | def _check_peptide_lengths(self, peptide_lengths=None):
"""
If peptide lengths not specified, then try using the default
lengths associated with this predictor object. If those aren't
a valid non-empty sequence of integers, then raise an exception.
Otherwise return the peptide le... | def _check_peptide_lengths(self, peptide_lengths=None):
"""
If peptide lengths not specified, then try using the default
lengths associated with this predictor object. If those aren't
a valid non-empty sequence of integers, then raise an exception.
Otherwise return the peptide le... | [
"If",
"peptide",
"lengths",
"not",
"specified",
"then",
"try",
"using",
"the",
"default",
"lengths",
"associated",
"with",
"this",
"predictor",
"object",
".",
"If",
"those",
"aren",
"t",
"a",
"valid",
"non",
"-",
"empty",
"sequence",
"of",
"integers",
"then"... | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/base_predictor.py#L103-L133 | [
"def",
"_check_peptide_lengths",
"(",
"self",
",",
"peptide_lengths",
"=",
"None",
")",
":",
"if",
"not",
"peptide_lengths",
":",
"peptide_lengths",
"=",
"self",
".",
"default_peptide_lengths",
"if",
"not",
"peptide_lengths",
":",
"raise",
"ValueError",
"(",
"(",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | BasePredictor._check_peptide_inputs | Check peptide sequences to make sure they are valid for this predictor. | mhctools/base_predictor.py | def _check_peptide_inputs(self, peptides):
"""
Check peptide sequences to make sure they are valid for this predictor.
"""
require_iterable_of(peptides, string_types)
check_X = not self.allow_X_in_peptides
check_lower = not self.allow_lowercase_in_peptides
check_m... | def _check_peptide_inputs(self, peptides):
"""
Check peptide sequences to make sure they are valid for this predictor.
"""
require_iterable_of(peptides, string_types)
check_X = not self.allow_X_in_peptides
check_lower = not self.allow_lowercase_in_peptides
check_m... | [
"Check",
"peptide",
"sequences",
"to",
"make",
"sure",
"they",
"are",
"valid",
"for",
"this",
"predictor",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/base_predictor.py#L151-L176 | [
"def",
"_check_peptide_inputs",
"(",
"self",
",",
"peptides",
")",
":",
"require_iterable_of",
"(",
"peptides",
",",
"string_types",
")",
"check_X",
"=",
"not",
"self",
".",
"allow_X_in_peptides",
"check_lower",
"=",
"not",
"self",
".",
"allow_lowercase_in_peptides"... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | BasePredictor.predict_subsequences | Given a dictionary mapping sequence names to amino acid strings,
and an optional list of peptide lengths, returns a
BindingPredictionCollection. | mhctools/base_predictor.py | def predict_subsequences(
self,
sequence_dict,
peptide_lengths=None):
"""
Given a dictionary mapping sequence names to amino acid strings,
and an optional list of peptide lengths, returns a
BindingPredictionCollection.
"""
if isinstance... | def predict_subsequences(
self,
sequence_dict,
peptide_lengths=None):
"""
Given a dictionary mapping sequence names to amino acid strings,
and an optional list of peptide lengths, returns a
BindingPredictionCollection.
"""
if isinstance... | [
"Given",
"a",
"dictionary",
"mapping",
"sequence",
"names",
"to",
"amino",
"acid",
"strings",
"and",
"an",
"optional",
"list",
"of",
"peptide",
"lengths",
"returns",
"a",
"BindingPredictionCollection",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/base_predictor.py#L178-L222 | [
"def",
"predict_subsequences",
"(",
"self",
",",
"sequence_dict",
",",
"peptide_lengths",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"sequence_dict",
",",
"string_types",
")",
":",
"sequence_dict",
"=",
"{",
"\"seq\"",
":",
"sequence_dict",
"}",
"elif",
"... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | BasePredictor._check_hla_alleles | Given a list of HLA alleles and an optional list of valid
HLA alleles, return a set of alleles that we will pass into
the MHC binding predictor. | mhctools/base_predictor.py | def _check_hla_alleles(
alleles,
valid_alleles=None):
"""
Given a list of HLA alleles and an optional list of valid
HLA alleles, return a set of alleles that we will pass into
the MHC binding predictor.
"""
require_iterable_of(alleles, string_types... | def _check_hla_alleles(
alleles,
valid_alleles=None):
"""
Given a list of HLA alleles and an optional list of valid
HLA alleles, return a set of alleles that we will pass into
the MHC binding predictor.
"""
require_iterable_of(alleles, string_types... | [
"Given",
"a",
"list",
"of",
"HLA",
"alleles",
"and",
"an",
"optional",
"list",
"of",
"valid",
"HLA",
"alleles",
"return",
"a",
"set",
"of",
"alleles",
"that",
"we",
"will",
"pass",
"into",
"the",
"MHC",
"binding",
"predictor",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/base_predictor.py#L237-L265 | [
"def",
"_check_hla_alleles",
"(",
"alleles",
",",
"valid_alleles",
"=",
"None",
")",
":",
"require_iterable_of",
"(",
"alleles",
",",
"string_types",
",",
"\"HLA alleles\"",
")",
"# Don't run the MHC predictor twice for homozygous alleles,",
"# only run it for unique alleles",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | StreamResponse._connect | Connect to the stream
Returns
-------
asyncio.coroutine
The streaming response | peony/stream.py | async def _connect(self):
"""
Connect to the stream
Returns
-------
asyncio.coroutine
The streaming response
"""
logger.debug("connecting to the stream")
await self.client.setup
if self.session is None:
self.session = s... | async def _connect(self):
"""
Connect to the stream
Returns
-------
asyncio.coroutine
The streaming response
"""
logger.debug("connecting to the stream")
await self.client.setup
if self.session is None:
self.session = s... | [
"Connect",
"to",
"the",
"stream"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/stream.py#L75-L91 | [
"async",
"def",
"_connect",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"connecting to the stream\"",
")",
"await",
"self",
".",
"client",
".",
"setup",
"if",
"self",
".",
"session",
"is",
"None",
":",
"self",
".",
"session",
"=",
"self",
".",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | StreamResponse.connect | Create the connection
Returns
-------
self
Raises
------
exception.PeonyException
On a response status in 4xx that are not status 420 or 429
Also on statuses in 1xx or 3xx since this should not be the status
received here | peony/stream.py | async def connect(self):
"""
Create the connection
Returns
-------
self
Raises
------
exception.PeonyException
On a response status in 4xx that are not status 420 or 429
Also on statuses in 1xx or 3xx since this should not be ... | async def connect(self):
"""
Create the connection
Returns
-------
self
Raises
------
exception.PeonyException
On a response status in 4xx that are not status 420 or 429
Also on statuses in 1xx or 3xx since this should not be ... | [
"Create",
"the",
"connection"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/stream.py#L93-L126 | [
"async",
"def",
"connect",
"(",
"self",
")",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"self",
".",
"timeout",
")",
":",
"self",
".",
"response",
"=",
"await",
"self",
".",
"_connect",
"(",
")",
"if",
"self",
".",
"response",
".",
"status",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | StreamResponse.init_restart | Restart the stream on error
Parameters
----------
error : bool, optional
Whether to print the error or not | peony/stream.py | async def init_restart(self, error=None):
"""
Restart the stream on error
Parameters
----------
error : bool, optional
Whether to print the error or not
"""
if error:
utils.log_error(logger=logger)
if self.state == DISCONNECTI... | async def init_restart(self, error=None):
"""
Restart the stream on error
Parameters
----------
error : bool, optional
Whether to print the error or not
"""
if error:
utils.log_error(logger=logger)
if self.state == DISCONNECTI... | [
"Restart",
"the",
"stream",
"on",
"error"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/stream.py#L201-L251 | [
"async",
"def",
"init_restart",
"(",
"self",
",",
"error",
"=",
"None",
")",
":",
"if",
"error",
":",
"utils",
".",
"log_error",
"(",
"logger",
"=",
"logger",
")",
"if",
"self",
".",
"state",
"==",
"DISCONNECTION",
":",
"if",
"self",
".",
"_error_timeo... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | StreamResponse.restart_stream | Restart the stream on error | peony/stream.py | async def restart_stream(self):
"""
Restart the stream on error
"""
await self.response.release()
await asyncio.sleep(self._error_timeout)
await self.connect()
logger.info("Reconnected to the stream")
self._reconnecting = False
return {'stream... | async def restart_stream(self):
"""
Restart the stream on error
"""
await self.response.release()
await asyncio.sleep(self._error_timeout)
await self.connect()
logger.info("Reconnected to the stream")
self._reconnecting = False
return {'stream... | [
"Restart",
"the",
"stream",
"on",
"error"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/stream.py#L253-L263 | [
"async",
"def",
"restart_stream",
"(",
"self",
")",
":",
"await",
"self",
".",
"response",
".",
"release",
"(",
")",
"await",
"asyncio",
".",
"sleep",
"(",
"self",
".",
"_error_timeout",
")",
"await",
"self",
".",
"connect",
"(",
")",
"logger",
".",
"i... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | Handler.with_prefix | decorator to handle commands with prefixes
Parameters
----------
prefix : str
the prefix of the command
strict : bool, optional
If set to True the command must be at the beginning
of the message. Defaults to False.
Returns
-------
... | peony/commands/event_types.py | def with_prefix(self, prefix, strict=False):
"""
decorator to handle commands with prefixes
Parameters
----------
prefix : str
the prefix of the command
strict : bool, optional
If set to True the command must be at the beginning
of... | def with_prefix(self, prefix, strict=False):
"""
decorator to handle commands with prefixes
Parameters
----------
prefix : str
the prefix of the command
strict : bool, optional
If set to True the command must be at the beginning
of... | [
"decorator",
"to",
"handle",
"commands",
"with",
"prefixes"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/commands/event_types.py#L38-L60 | [
"def",
"with_prefix",
"(",
"self",
",",
"prefix",
",",
"strict",
"=",
"False",
")",
":",
"def",
"decorated",
"(",
"func",
")",
":",
"return",
"EventHandler",
"(",
"func",
"=",
"func",
",",
"event",
"=",
"self",
".",
"event",
",",
"prefix",
"=",
"pref... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | Event.envelope | returns an :class:`Event` that can be used for site streams | peony/commands/event_types.py | def envelope(self):
""" returns an :class:`Event` that can be used for site streams """
def enveloped_event(data):
return 'for_user' in data and self._func(data.get('message'))
return self.__class__(enveloped_event, self.__name__) | def envelope(self):
""" returns an :class:`Event` that can be used for site streams """
def enveloped_event(data):
return 'for_user' in data and self._func(data.get('message'))
return self.__class__(enveloped_event, self.__name__) | [
"returns",
"an",
":",
"class",
":",
"Event",
"that",
"can",
"be",
"used",
"for",
"site",
"streams"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/commands/event_types.py#L83-L89 | [
"def",
"envelope",
"(",
"self",
")",
":",
"def",
"enveloped_event",
"(",
"data",
")",
":",
"return",
"'for_user'",
"in",
"data",
"and",
"self",
".",
"_func",
"(",
"data",
".",
"get",
"(",
"'message'",
")",
")",
"return",
"self",
".",
"__class__",
"(",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | BDClient.set_tz | set the environment timezone to the timezone
set in your twitter settings | examples/birthday.py | async def set_tz(self):
"""
set the environment timezone to the timezone
set in your twitter settings
"""
settings = await self.api.account.settings.get()
tz = settings.time_zone.tzinfo_name
os.environ['TZ'] = tz
time.tzset() | async def set_tz(self):
"""
set the environment timezone to the timezone
set in your twitter settings
"""
settings = await self.api.account.settings.get()
tz = settings.time_zone.tzinfo_name
os.environ['TZ'] = tz
time.tzset() | [
"set",
"the",
"environment",
"timezone",
"to",
"the",
"timezone",
"set",
"in",
"your",
"twitter",
"settings"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/examples/birthday.py#L23-L33 | [
"async",
"def",
"set_tz",
"(",
"self",
")",
":",
"settings",
"=",
"await",
"self",
".",
"api",
".",
"account",
".",
"settings",
".",
"get",
"(",
")",
"tz",
"=",
"settings",
".",
"time_zone",
".",
"tzinfo_name",
"os",
".",
"environ",
"[",
"'TZ'",
"]",... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | run_command | Given a list whose first element is a command name, followed by arguments,
execute it and show timing info. | mhctools/process_helpers.py | def run_command(args, **kwargs):
"""
Given a list whose first element is a command name, followed by arguments,
execute it and show timing info.
"""
assert len(args) > 0
start_time = time.time()
process = AsyncProcess(args, **kwargs)
process.wait()
elapsed_time = time.time() - start_... | def run_command(args, **kwargs):
"""
Given a list whose first element is a command name, followed by arguments,
execute it and show timing info.
"""
assert len(args) > 0
start_time = time.time()
process = AsyncProcess(args, **kwargs)
process.wait()
elapsed_time = time.time() - start_... | [
"Given",
"a",
"list",
"whose",
"first",
"element",
"is",
"a",
"command",
"name",
"followed",
"by",
"arguments",
"execute",
"it",
"and",
"show",
"timing",
"info",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/process_helpers.py#L74-L84 | [
"def",
"run_command",
"(",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"args",
")",
">",
"0",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"process",
"=",
"AsyncProcess",
"(",
"args",
",",
"*",
"*",
"kwargs",
")",
"process... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | run_multiple_commands_redirect_stdout | Run multiple shell commands in parallel, write each of their
stdout output to files associated with each command.
Parameters
----------
multiple_args_dict : dict
A dictionary whose keys are files and values are args list.
Run each args list as a subprocess and write stdout to the
... | mhctools/process_helpers.py | def run_multiple_commands_redirect_stdout(
multiple_args_dict,
print_commands=True,
process_limit=-1,
polling_freq=0.5,
**kwargs):
"""
Run multiple shell commands in parallel, write each of their
stdout output to files associated with each command.
Parameters
... | def run_multiple_commands_redirect_stdout(
multiple_args_dict,
print_commands=True,
process_limit=-1,
polling_freq=0.5,
**kwargs):
"""
Run multiple shell commands in parallel, write each of their
stdout output to files associated with each command.
Parameters
... | [
"Run",
"multiple",
"shell",
"commands",
"in",
"parallel",
"write",
"each",
"of",
"their",
"stdout",
"output",
"to",
"files",
"associated",
"with",
"each",
"command",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/process_helpers.py#L86-L166 | [
"def",
"run_multiple_commands_redirect_stdout",
"(",
"multiple_args_dict",
",",
"print_commands",
"=",
"True",
",",
"process_limit",
"=",
"-",
"1",
",",
"polling_freq",
"=",
"0.5",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"multiple_args_dict",
")... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | BaseCommandlinePredictor._determine_supported_alleles | Try asking the commandline predictor (e.g. netMHCpan)
which alleles it supports. | mhctools/base_commandline_predictor.py | def _determine_supported_alleles(command, supported_allele_flag):
"""
Try asking the commandline predictor (e.g. netMHCpan)
which alleles it supports.
"""
try:
# convert to str since Python3 returns a `bytes` object
supported_alleles_output = check_output(... | def _determine_supported_alleles(command, supported_allele_flag):
"""
Try asking the commandline predictor (e.g. netMHCpan)
which alleles it supports.
"""
try:
# convert to str since Python3 returns a `bytes` object
supported_alleles_output = check_output(... | [
"Try",
"asking",
"the",
"commandline",
"predictor",
"(",
"e",
".",
"g",
".",
"netMHCpan",
")",
"which",
"alleles",
"it",
"supports",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/base_commandline_predictor.py#L189-L221 | [
"def",
"_determine_supported_alleles",
"(",
"command",
",",
"supported_allele_flag",
")",
":",
"try",
":",
"# convert to str since Python3 returns a `bytes` object",
"supported_alleles_output",
"=",
"check_output",
"(",
"[",
"command",
",",
"supported_allele_flag",
"]",
")",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | loads | Custom loads function with an object_hook and automatic decoding
Parameters
----------
json_data : str
The JSON data to decode
*args
Positional arguments, passed to :func:`json.loads`
encoding : :obj:`str`, optional
The encoding of the bytestring
**kwargs
Keyword... | peony/data_processing.py | def loads(json_data, encoding="utf-8", **kwargs):
"""
Custom loads function with an object_hook and automatic decoding
Parameters
----------
json_data : str
The JSON data to decode
*args
Positional arguments, passed to :func:`json.loads`
encoding : :obj:`str`, optional
... | def loads(json_data, encoding="utf-8", **kwargs):
"""
Custom loads function with an object_hook and automatic decoding
Parameters
----------
json_data : str
The JSON data to decode
*args
Positional arguments, passed to :func:`json.loads`
encoding : :obj:`str`, optional
... | [
"Custom",
"loads",
"function",
"with",
"an",
"object_hook",
"and",
"automatic",
"decoding"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/data_processing.py#L149-L172 | [
"def",
"loads",
"(",
"json_data",
",",
"encoding",
"=",
"\"utf-8\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"json_data",
",",
"bytes",
")",
":",
"json_data",
"=",
"json_data",
".",
"decode",
"(",
"encoding",
")",
"return",
"json",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | read | read the data of the response
Parameters
----------
response : aiohttp.ClientResponse
response
loads : callable
json loads function
encoding : :obj:`str`, optional
character encoding of the response, if set to None
aiohttp should guess the right encoding
Returns... | peony/data_processing.py | async def read(response, loads=loads, encoding=None):
"""
read the data of the response
Parameters
----------
response : aiohttp.ClientResponse
response
loads : callable
json loads function
encoding : :obj:`str`, optional
character encoding of the response, if se... | async def read(response, loads=loads, encoding=None):
"""
read the data of the response
Parameters
----------
response : aiohttp.ClientResponse
response
loads : callable
json loads function
encoding : :obj:`str`, optional
character encoding of the response, if se... | [
"read",
"the",
"data",
"of",
"the",
"response"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/data_processing.py#L175-L211 | [
"async",
"def",
"read",
"(",
"response",
",",
"loads",
"=",
"loads",
",",
"encoding",
"=",
"None",
")",
":",
"ctype",
"=",
"response",
".",
"headers",
".",
"get",
"(",
"'Content-Type'",
",",
"\"\"",
")",
".",
"lower",
"(",
")",
"try",
":",
"if",
"\... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | doc | Find the message shown when someone calls the help command
Parameters
----------
func : function
the function
Returns
-------
str
The help message for this command | peony/commands/utils.py | def doc(func):
"""
Find the message shown when someone calls the help command
Parameters
----------
func : function
the function
Returns
-------
str
The help message for this command
"""
stripped_chars = " \t"
if hasattr(func, '__doc__'):
docstr... | def doc(func):
"""
Find the message shown when someone calls the help command
Parameters
----------
func : function
the function
Returns
-------
str
The help message for this command
"""
stripped_chars = " \t"
if hasattr(func, '__doc__'):
docstr... | [
"Find",
"the",
"message",
"shown",
"when",
"someone",
"calls",
"the",
"help",
"command"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/commands/utils.py#L4-L28 | [
"def",
"doc",
"(",
"func",
")",
":",
"stripped_chars",
"=",
"\" \\t\"",
"if",
"hasattr",
"(",
"func",
",",
"'__doc__'",
")",
":",
"docstring",
"=",
"func",
".",
"__doc__",
".",
"lstrip",
"(",
"\" \\n\\t\"",
")",
"if",
"\"\\n\"",
"in",
"docstring",
":",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | permission_check | Check the permissions of the user requesting a command
Parameters
----------
data : dict
message data
command_permissions : dict
permissions of the command, contains all the roles as key and users
with these permissions as values
command : function
the command that i... | peony/commands/utils.py | def permission_check(data, command_permissions,
command=None, permissions=None):
"""
Check the permissions of the user requesting a command
Parameters
----------
data : dict
message data
command_permissions : dict
permissions of the command, contains all... | def permission_check(data, command_permissions,
command=None, permissions=None):
"""
Check the permissions of the user requesting a command
Parameters
----------
data : dict
message data
command_permissions : dict
permissions of the command, contains all... | [
"Check",
"the",
"permissions",
"of",
"the",
"user",
"requesting",
"a",
"command"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/commands/utils.py#L31-L66 | [
"def",
"permission_check",
"(",
"data",
",",
"command_permissions",
",",
"command",
"=",
"None",
",",
"permissions",
"=",
"None",
")",
":",
"if",
"permissions",
":",
"pass",
"elif",
"command",
":",
"if",
"hasattr",
"(",
"command",
",",
"'permissions'",
")",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | main | Script to make pMHC binding predictions from amino acid sequences.
Usage example:
mhctools
--sequence SFFPIQQQQQAAALLLI \
--sequence SILQQQAQAQQAQAASSSC \
--extract-subsequences \
--mhc-predictor netmhc \
--mhc-alleles HLA-A0201 H2-Db \
... | mhctools/cli/script.py | def main(args_list=None):
"""
Script to make pMHC binding predictions from amino acid sequences.
Usage example:
mhctools
--sequence SFFPIQQQQQAAALLLI \
--sequence SILQQQAQAQQAQAASSSC \
--extract-subsequences \
--mhc-predictor netmhc \
--mh... | def main(args_list=None):
"""
Script to make pMHC binding predictions from amino acid sequences.
Usage example:
mhctools
--sequence SFFPIQQQQQAAALLLI \
--sequence SILQQQAQAQQAQAASSSC \
--extract-subsequences \
--mhc-predictor netmhc \
--mh... | [
"Script",
"to",
"make",
"pMHC",
"binding",
"predictions",
"from",
"amino",
"acid",
"sequences",
"."
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/cli/script.py#L100-L120 | [
"def",
"main",
"(",
"args_list",
"=",
"None",
")",
":",
"args",
"=",
"parse_args",
"(",
"args_list",
")",
"binding_predictions",
"=",
"run_predictor",
"(",
"args",
")",
"df",
"=",
"binding_predictions",
".",
"to_dataframe",
"(",
")",
"logger",
".",
"info",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | NetMHCIIpan._prepare_drb_allele_name | Assume that we're dealing with a human DRB allele
which NetMHCIIpan treats differently because there is
little population diversity in the DR-alpha gene | mhctools/netmhcii_pan.py | def _prepare_drb_allele_name(self, parsed_beta_allele):
"""
Assume that we're dealing with a human DRB allele
which NetMHCIIpan treats differently because there is
little population diversity in the DR-alpha gene
"""
if "DRB" not in parsed_beta_allele.gene:
ra... | def _prepare_drb_allele_name(self, parsed_beta_allele):
"""
Assume that we're dealing with a human DRB allele
which NetMHCIIpan treats differently because there is
little population diversity in the DR-alpha gene
"""
if "DRB" not in parsed_beta_allele.gene:
ra... | [
"Assume",
"that",
"we",
"re",
"dealing",
"with",
"a",
"human",
"DRB",
"allele",
"which",
"NetMHCIIpan",
"treats",
"differently",
"because",
"there",
"is",
"little",
"population",
"diversity",
"in",
"the",
"DR",
"-",
"alpha",
"gene"
] | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/netmhcii_pan.py#L48-L59 | [
"def",
"_prepare_drb_allele_name",
"(",
"self",
",",
"parsed_beta_allele",
")",
":",
"if",
"\"DRB\"",
"not",
"in",
"parsed_beta_allele",
".",
"gene",
":",
"raise",
"ValueError",
"(",
"\"Unexpected allele %s\"",
"%",
"parsed_beta_allele",
")",
"return",
"\"%s_%s%s\"",
... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | NetMHCIIpan.prepare_allele_name | netMHCIIpan has some unique requirements for allele formats,
expecting the following forms:
- DRB1_0101 (for non-alpha/beta pairs)
- HLA-DQA10501-DQB10636 (for alpha and beta pairs)
Other than human class II alleles, the only other alleles that
netMHCIIpan accepts are the foll... | mhctools/netmhcii_pan.py | def prepare_allele_name(self, allele_name):
"""
netMHCIIpan has some unique requirements for allele formats,
expecting the following forms:
- DRB1_0101 (for non-alpha/beta pairs)
- HLA-DQA10501-DQB10636 (for alpha and beta pairs)
Other than human class II alleles, the ... | def prepare_allele_name(self, allele_name):
"""
netMHCIIpan has some unique requirements for allele formats,
expecting the following forms:
- DRB1_0101 (for non-alpha/beta pairs)
- HLA-DQA10501-DQB10636 (for alpha and beta pairs)
Other than human class II alleles, the ... | [
"netMHCIIpan",
"has",
"some",
"unique",
"requirements",
"for",
"allele",
"formats",
"expecting",
"the",
"following",
"forms",
":",
"-",
"DRB1_0101",
"(",
"for",
"non",
"-",
"alpha",
"/",
"beta",
"pairs",
")",
"-",
"HLA",
"-",
"DQA10501",
"-",
"DQB10636",
"... | openvax/mhctools | python | https://github.com/openvax/mhctools/blob/b329b4dccd60fae41296816b8cbfe15d6ca07e67/mhctools/netmhcii_pan.py#L61-L93 | [
"def",
"prepare_allele_name",
"(",
"self",
",",
"allele_name",
")",
":",
"parsed_alleles",
"=",
"parse_classi_or_classii_allele_name",
"(",
"allele_name",
")",
"if",
"len",
"(",
"parsed_alleles",
")",
"==",
"1",
":",
"allele",
"=",
"parsed_alleles",
"[",
"0",
"]... | b329b4dccd60fae41296816b8cbfe15d6ca07e67 |
valid | get_error | return the error if there is a corresponding exception | peony/exceptions.py | def get_error(data):
""" return the error if there is a corresponding exception """
if isinstance(data, dict):
if 'errors' in data:
error = data['errors'][0]
else:
error = data.get('error', None)
if isinstance(error, dict):
if error.get('code') in err... | def get_error(data):
""" return the error if there is a corresponding exception """
if isinstance(data, dict):
if 'errors' in data:
error = data['errors'][0]
else:
error = data.get('error', None)
if isinstance(error, dict):
if error.get('code') in err... | [
"return",
"the",
"error",
"if",
"there",
"is",
"a",
"corresponding",
"exception"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/exceptions.py#L8-L18 | [
"def",
"get_error",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"if",
"'errors'",
"in",
"data",
":",
"error",
"=",
"data",
"[",
"'errors'",
"]",
"[",
"0",
"]",
"else",
":",
"error",
"=",
"data",
".",
"get",
"(",... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | throw | Get the response data if possible and raise an exception | peony/exceptions.py | async def throw(response, loads=None, encoding=None, **kwargs):
""" Get the response data if possible and raise an exception """
if loads is None:
loads = data_processing.loads
data = await data_processing.read(response, loads=loads,
encoding=encoding)
err... | async def throw(response, loads=None, encoding=None, **kwargs):
""" Get the response data if possible and raise an exception """
if loads is None:
loads = data_processing.loads
data = await data_processing.read(response, loads=loads,
encoding=encoding)
err... | [
"Get",
"the",
"response",
"data",
"if",
"possible",
"and",
"raise",
"an",
"exception"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/exceptions.py#L21-L39 | [
"async",
"def",
"throw",
"(",
"response",
",",
"loads",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"loads",
"is",
"None",
":",
"loads",
"=",
"data_processing",
".",
"loads",
"data",
"=",
"await",
"data_processin... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | ErrorDict.code | Decorator to associate a code to an exception | peony/exceptions.py | def code(self, code):
""" Decorator to associate a code to an exception """
def decorator(exception):
self[code] = exception
return exception
return decorator | def code(self, code):
""" Decorator to associate a code to an exception """
def decorator(exception):
self[code] = exception
return exception
return decorator | [
"Decorator",
"to",
"associate",
"a",
"code",
"to",
"an",
"exception"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/exceptions.py#L101-L107 | [
"def",
"code",
"(",
"self",
",",
"code",
")",
":",
"def",
"decorator",
"(",
"exception",
")",
":",
"self",
"[",
"code",
"]",
"=",
"exception",
"return",
"exception",
"return",
"decorator"
] | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | PeonyHeaders.prepare_request | prepare all the arguments for the request
Parameters
----------
method : str
HTTP method used by the request
url : str
The url to request
headers : dict, optional
Additionnal headers
proxy : str
proxy of the request
... | peony/oauth.py | async def prepare_request(self, method, url,
headers=None,
skip_params=False,
proxy=None,
**kwargs):
"""
prepare all the arguments for the request
Parameters
---------... | async def prepare_request(self, method, url,
headers=None,
skip_params=False,
proxy=None,
**kwargs):
"""
prepare all the arguments for the request
Parameters
---------... | [
"prepare",
"all",
"the",
"arguments",
"for",
"the",
"request"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth.py#L61-L107 | [
"async",
"def",
"prepare_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"headers",
"=",
"None",
",",
"skip_params",
"=",
"False",
",",
"proxy",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"method",
".",
"lower",
"(",
")",
"==",
"\... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | PeonyHeaders._user_headers | Make sure the user doesn't override the Authorization header | peony/oauth.py | def _user_headers(self, headers=None):
""" Make sure the user doesn't override the Authorization header """
h = self.copy()
if headers is not None:
keys = set(headers.keys())
if h.get('Authorization', False):
keys -= {'Authorization'}
for key... | def _user_headers(self, headers=None):
""" Make sure the user doesn't override the Authorization header """
h = self.copy()
if headers is not None:
keys = set(headers.keys())
if h.get('Authorization', False):
keys -= {'Authorization'}
for key... | [
"Make",
"sure",
"the",
"user",
"doesn",
"t",
"override",
"the",
"Authorization",
"header"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/oauth.py#L109-L121 | [
"def",
"_user_headers",
"(",
"self",
",",
"headers",
"=",
"None",
")",
":",
"h",
"=",
"self",
".",
"copy",
"(",
")",
"if",
"headers",
"is",
"not",
"None",
":",
"keys",
"=",
"set",
"(",
"headers",
".",
"keys",
"(",
")",
")",
"if",
"h",
".",
"get... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | process_keys | Raise error for keys that are not strings
and add the prefix if it is missing | peony/commands/commands.py | def process_keys(func):
"""
Raise error for keys that are not strings
and add the prefix if it is missing
"""
@wraps(func)
def decorated(self, k, *args):
if not isinstance(k, str):
msg = "%s: key must be a string" % self.__class__.__name__
raise ValueError(msg)
... | def process_keys(func):
"""
Raise error for keys that are not strings
and add the prefix if it is missing
"""
@wraps(func)
def decorated(self, k, *args):
if not isinstance(k, str):
msg = "%s: key must be a string" % self.__class__.__name__
raise ValueError(msg)
... | [
"Raise",
"error",
"for",
"keys",
"that",
"are",
"not",
"strings",
"and",
"add",
"the",
"prefix",
"if",
"it",
"is",
"missing"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/commands/commands.py#L11-L28 | [
"def",
"process_keys",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorated",
"(",
"self",
",",
"k",
",",
"*",
"args",
")",
":",
"if",
"not",
"isinstance",
"(",
"k",
",",
"str",
")",
":",
"msg",
"=",
"\"%s: key must be a string\""... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | Functions._get | Analyze the text to get the right function
Parameters
----------
text : str
The text that could call a function | peony/commands/commands.py | def _get(self, text):
"""
Analyze the text to get the right function
Parameters
----------
text : str
The text that could call a function
"""
if self.strict:
match = self.prog.match(text)
if match:
cmd = mat... | def _get(self, text):
"""
Analyze the text to get the right function
Parameters
----------
text : str
The text that could call a function
"""
if self.strict:
match = self.prog.match(text)
if match:
cmd = mat... | [
"Analyze",
"the",
"text",
"to",
"get",
"the",
"right",
"function"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/commands/commands.py#L77-L96 | [
"def",
"_get",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"strict",
":",
"match",
"=",
"self",
".",
"prog",
".",
"match",
"(",
"text",
")",
"if",
"match",
":",
"cmd",
"=",
"match",
".",
"group",
"(",
")",
"if",
"cmd",
"in",
"self",
... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | Functions.run | run the function you want | peony/commands/commands.py | async def run(self, *args, data):
""" run the function you want """
cmd = self._get(data.text)
try:
if cmd is not None:
command = self[cmd](*args, data=data)
return await peony.utils.execute(command)
except:
fmt = "Error occurred ... | async def run(self, *args, data):
""" run the function you want """
cmd = self._get(data.text)
try:
if cmd is not None:
command = self[cmd](*args, data=data)
return await peony.utils.execute(command)
except:
fmt = "Error occurred ... | [
"run",
"the",
"function",
"you",
"want"
] | odrling/peony-twitter | python | https://github.com/odrling/peony-twitter/blob/967f98e16e1889389540f2e6acbf7cc7a1a80203/peony/commands/commands.py#L98-L109 | [
"async",
"def",
"run",
"(",
"self",
",",
"*",
"args",
",",
"data",
")",
":",
"cmd",
"=",
"self",
".",
"_get",
"(",
"data",
".",
"text",
")",
"try",
":",
"if",
"cmd",
"is",
"not",
"None",
":",
"command",
"=",
"self",
"[",
"cmd",
"]",
"(",
"*",... | 967f98e16e1889389540f2e6acbf7cc7a1a80203 |
valid | get_cartesian | Given a radius and theta, return the cartesian (x, y) coordinates. | hiveplot/hiveplot.py | def get_cartesian(r, theta):
"""
Given a radius and theta, return the cartesian (x, y) coordinates.
"""
x = r*np.sin(theta)
y = r*np.cos(theta)
return x, y | def get_cartesian(r, theta):
"""
Given a radius and theta, return the cartesian (x, y) coordinates.
"""
x = r*np.sin(theta)
y = r*np.cos(theta)
return x, y | [
"Given",
"a",
"radius",
"and",
"theta",
"return",
"the",
"cartesian",
"(",
"x",
"y",
")",
"coordinates",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L361-L368 | [
"def",
"get_cartesian",
"(",
"r",
",",
"theta",
")",
":",
"x",
"=",
"r",
"*",
"np",
".",
"sin",
"(",
"theta",
")",
"y",
"=",
"r",
"*",
"np",
".",
"cos",
"(",
"theta",
")",
"return",
"x",
",",
"y"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.simplified_edges | A generator for getting all of the edges without consuming extra
memory. | hiveplot/hiveplot.py | def simplified_edges(self):
"""
A generator for getting all of the edges without consuming extra
memory.
"""
for group, edgelist in self.edges.items():
for u, v, d in edgelist:
yield (u, v) | def simplified_edges(self):
"""
A generator for getting all of the edges without consuming extra
memory.
"""
for group, edgelist in self.edges.items():
for u, v, d in edgelist:
yield (u, v) | [
"A",
"generator",
"for",
"getting",
"all",
"of",
"the",
"edges",
"without",
"consuming",
"extra",
"memory",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L96-L103 | [
"def",
"simplified_edges",
"(",
"self",
")",
":",
"for",
"group",
",",
"edgelist",
"in",
"self",
".",
"edges",
".",
"items",
"(",
")",
":",
"for",
"u",
",",
"v",
",",
"d",
"in",
"edgelist",
":",
"yield",
"(",
"u",
",",
"v",
")"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.initialize_major_angle | Computes the major angle: 2pi radians / number of groups. | hiveplot/hiveplot.py | def initialize_major_angle(self):
"""
Computes the major angle: 2pi radians / number of groups.
"""
num_groups = len(self.nodes.keys())
self.major_angle = 2 * np.pi / num_groups | def initialize_major_angle(self):
"""
Computes the major angle: 2pi radians / number of groups.
"""
num_groups = len(self.nodes.keys())
self.major_angle = 2 * np.pi / num_groups | [
"Computes",
"the",
"major",
"angle",
":",
"2pi",
"radians",
"/",
"number",
"of",
"groups",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L105-L110 | [
"def",
"initialize_major_angle",
"(",
"self",
")",
":",
"num_groups",
"=",
"len",
"(",
"self",
".",
"nodes",
".",
"keys",
"(",
")",
")",
"self",
".",
"major_angle",
"=",
"2",
"*",
"np",
".",
"pi",
"/",
"num_groups"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.initialize_minor_angle | Computes the minor angle: 2pi radians / 3 * number of groups. | hiveplot/hiveplot.py | def initialize_minor_angle(self):
"""
Computes the minor angle: 2pi radians / 3 * number of groups.
"""
num_groups = len(self.nodes.keys())
self.minor_angle = 2 * np.pi / (6 * num_groups) | def initialize_minor_angle(self):
"""
Computes the minor angle: 2pi radians / 3 * number of groups.
"""
num_groups = len(self.nodes.keys())
self.minor_angle = 2 * np.pi / (6 * num_groups) | [
"Computes",
"the",
"minor",
"angle",
":",
"2pi",
"radians",
"/",
"3",
"*",
"number",
"of",
"groups",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L112-L118 | [
"def",
"initialize_minor_angle",
"(",
"self",
")",
":",
"num_groups",
"=",
"len",
"(",
"self",
".",
"nodes",
".",
"keys",
"(",
")",
")",
"self",
".",
"minor_angle",
"=",
"2",
"*",
"np",
".",
"pi",
"/",
"(",
"6",
"*",
"num_groups",
")"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.plot_radius | Computes the plot radius: maximum of length of each list of nodes. | hiveplot/hiveplot.py | def plot_radius(self):
"""
Computes the plot radius: maximum of length of each list of nodes.
"""
plot_rad = 0
for group, nodelist in self.nodes.items():
proposed_radius = len(nodelist) * self.scale
if proposed_radius > plot_rad:
plot_rad =... | def plot_radius(self):
"""
Computes the plot radius: maximum of length of each list of nodes.
"""
plot_rad = 0
for group, nodelist in self.nodes.items():
proposed_radius = len(nodelist) * self.scale
if proposed_radius > plot_rad:
plot_rad =... | [
"Computes",
"the",
"plot",
"radius",
":",
"maximum",
"of",
"length",
"of",
"each",
"list",
"of",
"nodes",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L130-L139 | [
"def",
"plot_radius",
"(",
"self",
")",
":",
"plot_rad",
"=",
"0",
"for",
"group",
",",
"nodelist",
"in",
"self",
".",
"nodes",
".",
"items",
"(",
")",
":",
"proposed_radius",
"=",
"len",
"(",
"nodelist",
")",
"*",
"self",
".",
"scale",
"if",
"propos... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.has_edge_within_group | Checks whether there are within-group edges or not. | hiveplot/hiveplot.py | def has_edge_within_group(self, group):
"""
Checks whether there are within-group edges or not.
"""
assert group in self.nodes.keys(),\
"{0} not one of the group of nodes".format(group)
nodelist = self.nodes[group]
for n1, n2 in self.simplified_edges():
... | def has_edge_within_group(self, group):
"""
Checks whether there are within-group edges or not.
"""
assert group in self.nodes.keys(),\
"{0} not one of the group of nodes".format(group)
nodelist = self.nodes[group]
for n1, n2 in self.simplified_edges():
... | [
"Checks",
"whether",
"there",
"are",
"within",
"-",
"group",
"edges",
"or",
"not",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L147-L156 | [
"def",
"has_edge_within_group",
"(",
"self",
",",
"group",
")",
":",
"assert",
"group",
"in",
"self",
".",
"nodes",
".",
"keys",
"(",
")",
",",
"\"{0} not one of the group of nodes\"",
".",
"format",
"(",
"group",
")",
"nodelist",
"=",
"self",
".",
"nodes",
... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.plot_axis | Renders the axis. | hiveplot/hiveplot.py | def plot_axis(self, rs, theta):
"""
Renders the axis.
"""
xs, ys = get_cartesian(rs, theta)
self.ax.plot(xs, ys, 'black', alpha=0.3) | def plot_axis(self, rs, theta):
"""
Renders the axis.
"""
xs, ys = get_cartesian(rs, theta)
self.ax.plot(xs, ys, 'black', alpha=0.3) | [
"Renders",
"the",
"axis",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L158-L163 | [
"def",
"plot_axis",
"(",
"self",
",",
"rs",
",",
"theta",
")",
":",
"xs",
",",
"ys",
"=",
"get_cartesian",
"(",
"rs",
",",
"theta",
")",
"self",
".",
"ax",
".",
"plot",
"(",
"xs",
",",
"ys",
",",
"'black'",
",",
"alpha",
"=",
"0.3",
")"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.plot_nodes | Plots nodes to screen. | hiveplot/hiveplot.py | def plot_nodes(self, nodelist, theta, group):
"""
Plots nodes to screen.
"""
for i, node in enumerate(nodelist):
r = self.internal_radius + i * self.scale
x, y = get_cartesian(r, theta)
circle = plt.Circle(xy=(x, y), radius=self.dot_radius,
... | def plot_nodes(self, nodelist, theta, group):
"""
Plots nodes to screen.
"""
for i, node in enumerate(nodelist):
r = self.internal_radius + i * self.scale
x, y = get_cartesian(r, theta)
circle = plt.Circle(xy=(x, y), radius=self.dot_radius,
... | [
"Plots",
"nodes",
"to",
"screen",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L165-L174 | [
"def",
"plot_nodes",
"(",
"self",
",",
"nodelist",
",",
"theta",
",",
"group",
")",
":",
"for",
"i",
",",
"node",
"in",
"enumerate",
"(",
"nodelist",
")",
":",
"r",
"=",
"self",
".",
"internal_radius",
"+",
"i",
"*",
"self",
".",
"scale",
"x",
",",... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.group_theta | Computes the theta along which a group's nodes are aligned. | hiveplot/hiveplot.py | def group_theta(self, group):
"""
Computes the theta along which a group's nodes are aligned.
"""
for i, g in enumerate(self.nodes.keys()):
if g == group:
break
return i * self.major_angle | def group_theta(self, group):
"""
Computes the theta along which a group's nodes are aligned.
"""
for i, g in enumerate(self.nodes.keys()):
if g == group:
break
return i * self.major_angle | [
"Computes",
"the",
"theta",
"along",
"which",
"a",
"group",
"s",
"nodes",
"are",
"aligned",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L176-L184 | [
"def",
"group_theta",
"(",
"self",
",",
"group",
")",
":",
"for",
"i",
",",
"g",
"in",
"enumerate",
"(",
"self",
".",
"nodes",
".",
"keys",
"(",
")",
")",
":",
"if",
"g",
"==",
"group",
":",
"break",
"return",
"i",
"*",
"self",
".",
"major_angle"... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.add_axes_and_nodes | Adds the axes (i.e. 2 or 3 axes, not to be confused with matplotlib
axes) and the nodes that belong to each axis. | hiveplot/hiveplot.py | def add_axes_and_nodes(self):
"""
Adds the axes (i.e. 2 or 3 axes, not to be confused with matplotlib
axes) and the nodes that belong to each axis.
"""
for i, (group, nodelist) in enumerate(self.nodes.items()):
theta = self.group_theta(group)
if self.has_... | def add_axes_and_nodes(self):
"""
Adds the axes (i.e. 2 or 3 axes, not to be confused with matplotlib
axes) and the nodes that belong to each axis.
"""
for i, (group, nodelist) in enumerate(self.nodes.items()):
theta = self.group_theta(group)
if self.has_... | [
"Adds",
"the",
"axes",
"(",
"i",
".",
"e",
".",
"2",
"or",
"3",
"axes",
"not",
"to",
"be",
"confused",
"with",
"matplotlib",
"axes",
")",
"and",
"the",
"nodes",
"that",
"belong",
"to",
"each",
"axis",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L186-L202 | [
"def",
"add_axes_and_nodes",
"(",
"self",
")",
":",
"for",
"i",
",",
"(",
"group",
",",
"nodelist",
")",
"in",
"enumerate",
"(",
"self",
".",
"nodes",
".",
"items",
"(",
")",
")",
":",
"theta",
"=",
"self",
".",
"group_theta",
"(",
"group",
")",
"i... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.find_node_group_membership | Identifies the group for which a node belongs to. | hiveplot/hiveplot.py | def find_node_group_membership(self, node):
"""
Identifies the group for which a node belongs to.
"""
for group, nodelist in self.nodes.items():
if node in nodelist:
return group | def find_node_group_membership(self, node):
"""
Identifies the group for which a node belongs to.
"""
for group, nodelist in self.nodes.items():
if node in nodelist:
return group | [
"Identifies",
"the",
"group",
"for",
"which",
"a",
"node",
"belongs",
"to",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L204-L210 | [
"def",
"find_node_group_membership",
"(",
"self",
",",
"node",
")",
":",
"for",
"group",
",",
"nodelist",
"in",
"self",
".",
"nodes",
".",
"items",
"(",
")",
":",
"if",
"node",
"in",
"nodelist",
":",
"return",
"group"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.get_idx | Finds the index of the node in the sorted list. | hiveplot/hiveplot.py | def get_idx(self, node):
"""
Finds the index of the node in the sorted list.
"""
group = self.find_node_group_membership(node)
return self.nodes[group].index(node) | def get_idx(self, node):
"""
Finds the index of the node in the sorted list.
"""
group = self.find_node_group_membership(node)
return self.nodes[group].index(node) | [
"Finds",
"the",
"index",
"of",
"the",
"node",
"in",
"the",
"sorted",
"list",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L212-L217 | [
"def",
"get_idx",
"(",
"self",
",",
"node",
")",
":",
"group",
"=",
"self",
".",
"find_node_group_membership",
"(",
"node",
")",
"return",
"self",
".",
"nodes",
"[",
"group",
"]",
".",
"index",
"(",
"node",
")"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.node_radius | Computes the radial position of the node. | hiveplot/hiveplot.py | def node_radius(self, node):
"""
Computes the radial position of the node.
"""
return self.get_idx(node) * self.scale + self.internal_radius | def node_radius(self, node):
"""
Computes the radial position of the node.
"""
return self.get_idx(node) * self.scale + self.internal_radius | [
"Computes",
"the",
"radial",
"position",
"of",
"the",
"node",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L219-L223 | [
"def",
"node_radius",
"(",
"self",
",",
"node",
")",
":",
"return",
"self",
".",
"get_idx",
"(",
"node",
")",
"*",
"self",
".",
"scale",
"+",
"self",
".",
"internal_radius"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.node_theta | Convenience function to find the node's theta angle. | hiveplot/hiveplot.py | def node_theta(self, node):
"""
Convenience function to find the node's theta angle.
"""
group = self.find_node_group_membership(node)
return self.group_theta(group) | def node_theta(self, node):
"""
Convenience function to find the node's theta angle.
"""
group = self.find_node_group_membership(node)
return self.group_theta(group) | [
"Convenience",
"function",
"to",
"find",
"the",
"node",
"s",
"theta",
"angle",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L225-L230 | [
"def",
"node_theta",
"(",
"self",
",",
"node",
")",
":",
"group",
"=",
"self",
".",
"find_node_group_membership",
"(",
"node",
")",
"return",
"self",
".",
"group_theta",
"(",
"group",
")"
] | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.draw_edge | Renders the given edge (n1, n2) to the plot. | hiveplot/hiveplot.py | def draw_edge(self, n1, n2, d, group):
"""
Renders the given edge (n1, n2) to the plot.
"""
start_radius = self.node_radius(n1)
start_theta = self.node_theta(n1)
end_radius = self.node_radius(n2)
end_theta = self.node_theta(n2)
start_theta, end_theta = s... | def draw_edge(self, n1, n2, d, group):
"""
Renders the given edge (n1, n2) to the plot.
"""
start_radius = self.node_radius(n1)
start_theta = self.node_theta(n1)
end_radius = self.node_radius(n2)
end_theta = self.node_theta(n2)
start_theta, end_theta = s... | [
"Renders",
"the",
"given",
"edge",
"(",
"n1",
"n2",
")",
"to",
"the",
"plot",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L232-L274 | [
"def",
"draw_edge",
"(",
"self",
",",
"n1",
",",
"n2",
",",
"d",
",",
"group",
")",
":",
"start_radius",
"=",
"self",
".",
"node_radius",
"(",
"n1",
")",
"start_theta",
"=",
"self",
".",
"node_theta",
"(",
"n1",
")",
"end_radius",
"=",
"self",
".",
... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.add_edges | Draws all of the edges in the graph. | hiveplot/hiveplot.py | def add_edges(self):
"""
Draws all of the edges in the graph.
"""
for group, edgelist in self.edges.items():
for (u, v, d) in edgelist:
self.draw_edge(u, v, d, group) | def add_edges(self):
"""
Draws all of the edges in the graph.
"""
for group, edgelist in self.edges.items():
for (u, v, d) in edgelist:
self.draw_edge(u, v, d, group) | [
"Draws",
"all",
"of",
"the",
"edges",
"in",
"the",
"graph",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L276-L282 | [
"def",
"add_edges",
"(",
"self",
")",
":",
"for",
"group",
",",
"edgelist",
"in",
"self",
".",
"edges",
".",
"items",
"(",
")",
":",
"for",
"(",
"u",
",",
"v",
",",
"d",
")",
"in",
"edgelist",
":",
"self",
".",
"draw_edge",
"(",
"u",
",",
"v",
... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.draw | The master function that is called that draws everything. | hiveplot/hiveplot.py | def draw(self):
"""
The master function that is called that draws everything.
"""
self.ax.set_xlim(-self.plot_radius(), self.plot_radius())
self.ax.set_ylim(-self.plot_radius(), self.plot_radius())
self.add_axes_and_nodes()
self.add_edges()
self.ax.axis(... | def draw(self):
"""
The master function that is called that draws everything.
"""
self.ax.set_xlim(-self.plot_radius(), self.plot_radius())
self.ax.set_ylim(-self.plot_radius(), self.plot_radius())
self.add_axes_and_nodes()
self.add_edges()
self.ax.axis(... | [
"The",
"master",
"function",
"that",
"is",
"called",
"that",
"draws",
"everything",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L284-L294 | [
"def",
"draw",
"(",
"self",
")",
":",
"self",
".",
"ax",
".",
"set_xlim",
"(",
"-",
"self",
".",
"plot_radius",
"(",
")",
",",
"self",
".",
"plot_radius",
"(",
")",
")",
"self",
".",
"ax",
".",
"set_ylim",
"(",
"-",
"self",
".",
"plot_radius",
"(... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.adjust_angles | This function adjusts the start and end angles to correct for
duplicated axes. | hiveplot/hiveplot.py | def adjust_angles(self, start_node, start_angle, end_node, end_angle):
"""
This function adjusts the start and end angles to correct for
duplicated axes.
"""
start_group = self.find_node_group_membership(start_node)
end_group = self.find_node_group_membership(end_node)
... | def adjust_angles(self, start_node, start_angle, end_node, end_angle):
"""
This function adjusts the start and end angles to correct for
duplicated axes.
"""
start_group = self.find_node_group_membership(start_node)
end_group = self.find_node_group_membership(end_node)
... | [
"This",
"function",
"adjusts",
"the",
"start",
"and",
"end",
"angles",
"to",
"correct",
"for",
"duplicated",
"axes",
"."
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L296-L336 | [
"def",
"adjust_angles",
"(",
"self",
",",
"start_node",
",",
"start_angle",
",",
"end_node",
",",
"end_angle",
")",
":",
"start_group",
"=",
"self",
".",
"find_node_group_membership",
"(",
"start_node",
")",
"end_group",
"=",
"self",
".",
"find_node_group_membersh... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | HivePlot.correct_angles | This function corrects for the following problems in the edges: | hiveplot/hiveplot.py | def correct_angles(self, start_angle, end_angle):
"""
This function corrects for the following problems in the edges:
"""
# Edges going the anti-clockwise direction involves angle = 0.
if start_angle == 0 and (end_angle - start_angle > np.pi):
start_angle = np.pi * 2
... | def correct_angles(self, start_angle, end_angle):
"""
This function corrects for the following problems in the edges:
"""
# Edges going the anti-clockwise direction involves angle = 0.
if start_angle == 0 and (end_angle - start_angle > np.pi):
start_angle = np.pi * 2
... | [
"This",
"function",
"corrects",
"for",
"the",
"following",
"problems",
"in",
"the",
"edges",
":"
] | ericmjl/hiveplot | python | https://github.com/ericmjl/hiveplot/blob/f465a7118b7f005c83ab054d400deb02bd9f7410/hiveplot/hiveplot.py#L338-L353 | [
"def",
"correct_angles",
"(",
"self",
",",
"start_angle",
",",
"end_angle",
")",
":",
"# Edges going the anti-clockwise direction involves angle = 0.",
"if",
"start_angle",
"==",
"0",
"and",
"(",
"end_angle",
"-",
"start_angle",
">",
"np",
".",
"pi",
")",
":",
"st... | f465a7118b7f005c83ab054d400deb02bd9f7410 |
valid | Type.mods_genre | Guesses an appropriate MODS XML genre type. | publications/models/type.py | def mods_genre(self):
"""
Guesses an appropriate MODS XML genre type.
"""
type2genre = {
'conference': 'conference publication',
'book chapter': 'bibliography',
'unpublished': 'article'
}
tp = str(self.type).lower()
return type2genre.get(tp, tp) | def mods_genre(self):
"""
Guesses an appropriate MODS XML genre type.
"""
type2genre = {
'conference': 'conference publication',
'book chapter': 'bibliography',
'unpublished': 'article'
}
tp = str(self.type).lower()
return type2genre.get(tp, tp) | [
"Guesses",
"an",
"appropriate",
"MODS",
"XML",
"genre",
"type",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/models/type.py#L66-L77 | [
"def",
"mods_genre",
"(",
"self",
")",
":",
"type2genre",
"=",
"{",
"'conference'",
":",
"'conference publication'",
",",
"'book chapter'",
":",
"'bibliography'",
",",
"'unpublished'",
":",
"'article'",
"}",
"tp",
"=",
"str",
"(",
"self",
".",
"type",
")",
"... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | Publication._produce_author_lists | Parse authors string to create lists of authors. | publications/models/publication.py | def _produce_author_lists(self):
"""
Parse authors string to create lists of authors.
"""
# post-process author names
self.authors = self.authors.replace(', and ', ', ')
self.authors = self.authors.replace(',and ', ', ')
self.authors = self.authors.replace(' and ', ', ')
self.authors = self.authors.rep... | def _produce_author_lists(self):
"""
Parse authors string to create lists of authors.
"""
# post-process author names
self.authors = self.authors.replace(', and ', ', ')
self.authors = self.authors.replace(',and ', ', ')
self.authors = self.authors.replace(' and ', ', ')
self.authors = self.authors.rep... | [
"Parse",
"authors",
"string",
"to",
"create",
"lists",
"of",
"authors",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/models/publication.py#L108-L207 | [
"def",
"_produce_author_lists",
"(",
"self",
")",
":",
"# post-process author names",
"self",
".",
"authors",
"=",
"self",
".",
"authors",
".",
"replace",
"(",
"', and '",
",",
"', '",
")",
"self",
".",
"authors",
"=",
"self",
".",
"authors",
".",
"replace",... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | get_publications | Get all publications. | publications/templatetags/publication_extras.py | def get_publications(context, template='publications/publications.html'):
"""
Get all publications.
"""
types = Type.objects.filter(hidden=False)
publications = Publication.objects.select_related()
publications = publications.filter(external=False, type__in=types)
publications = publications.order_by('-year', '... | def get_publications(context, template='publications/publications.html'):
"""
Get all publications.
"""
types = Type.objects.filter(hidden=False)
publications = Publication.objects.select_related()
publications = publications.filter(external=False, type__in=types)
publications = publications.order_by('-year', '... | [
"Get",
"all",
"publications",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/templatetags/publication_extras.py#L31-L47 | [
"def",
"get_publications",
"(",
"context",
",",
"template",
"=",
"'publications/publications.html'",
")",
":",
"types",
"=",
"Type",
".",
"objects",
".",
"filter",
"(",
"hidden",
"=",
"False",
")",
"publications",
"=",
"Publication",
".",
"objects",
".",
"sele... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | get_publication | Get a single publication. | publications/templatetags/publication_extras.py | def get_publication(context, id):
"""
Get a single publication.
"""
pbl = Publication.objects.filter(pk=int(id))
if len(pbl) < 1:
return ''
pbl[0].links = pbl[0].customlink_set.all()
pbl[0].files = pbl[0].customfile_set.all()
return render_template(
'publications/publication.html', context['request'], {... | def get_publication(context, id):
"""
Get a single publication.
"""
pbl = Publication.objects.filter(pk=int(id))
if len(pbl) < 1:
return ''
pbl[0].links = pbl[0].customlink_set.all()
pbl[0].files = pbl[0].customfile_set.all()
return render_template(
'publications/publication.html', context['request'], {... | [
"Get",
"a",
"single",
"publication",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/templatetags/publication_extras.py#L50-L64 | [
"def",
"get_publication",
"(",
"context",
",",
"id",
")",
":",
"pbl",
"=",
"Publication",
".",
"objects",
".",
"filter",
"(",
"pk",
"=",
"int",
"(",
"id",
")",
")",
"if",
"len",
"(",
"pbl",
")",
"<",
"1",
":",
"return",
"''",
"pbl",
"[",
"0",
"... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | get_publication_list | Get a publication list. | publications/templatetags/publication_extras.py | def get_publication_list(context, list, template='publications/publications.html'):
"""
Get a publication list.
"""
list = List.objects.filter(list__iexact=list)
if not list:
return ''
list = list[0]
publications = list.publication_set.all()
publications = publications.order_by('-year', '-month', '-id')
... | def get_publication_list(context, list, template='publications/publications.html'):
"""
Get a publication list.
"""
list = List.objects.filter(list__iexact=list)
if not list:
return ''
list = list[0]
publications = list.publication_set.all()
publications = publications.order_by('-year', '-month', '-id')
... | [
"Get",
"a",
"publication",
"list",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/templatetags/publication_extras.py#L67-L88 | [
"def",
"get_publication_list",
"(",
"context",
",",
"list",
",",
"template",
"=",
"'publications/publications.html'",
")",
":",
"list",
"=",
"List",
".",
"objects",
".",
"filter",
"(",
"list__iexact",
"=",
"list",
")",
"if",
"not",
"list",
":",
"return",
"''... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | tex_parse | Renders some basic TeX math to HTML. | publications/templatetags/publication_extras.py | def tex_parse(string):
"""
Renders some basic TeX math to HTML.
"""
string = string.replace('{', '').replace('}', '')
def tex_replace(match):
return \
sub(r'\^(\w)', r'<sup>\1</sup>',
sub(r'\^\{(.*?)\}', r'<sup>\1</sup>',
sub(r'\_(\w)', r'<sub>\1</sub>',
sub(r'\_\{(.*?)\}', r'<sub>\1</sub>',
sub(... | def tex_parse(string):
"""
Renders some basic TeX math to HTML.
"""
string = string.replace('{', '').replace('}', '')
def tex_replace(match):
return \
sub(r'\^(\w)', r'<sup>\1</sup>',
sub(r'\^\{(.*?)\}', r'<sup>\1</sup>',
sub(r'\_(\w)', r'<sub>\1</sub>',
sub(r'\_\{(.*?)\}', r'<sub>\1</sub>',
sub(... | [
"Renders",
"some",
"basic",
"TeX",
"math",
"to",
"HTML",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/templatetags/publication_extras.py#L91-L104 | [
"def",
"tex_parse",
"(",
"string",
")",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"'{'",
",",
"''",
")",
".",
"replace",
"(",
"'}'",
",",
"''",
")",
"def",
"tex_replace",
"(",
"match",
")",
":",
"return",
"sub",
"(",
"r'\\^(\\w)'",
",",
"r... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | parse | Takes a string in BibTex format and returns a list of BibTex entries, where
each entry is a dictionary containing the entries' key-value pairs.
@type string: string
@param string: bibliography in BibTex format
@rtype: list
@return: a list of dictionaries representing a bibliography | publications/bibtex.py | def parse(string):
"""
Takes a string in BibTex format and returns a list of BibTex entries, where
each entry is a dictionary containing the entries' key-value pairs.
@type string: string
@param string: bibliography in BibTex format
@rtype: list
@return: a list of dictionaries representing a bibliography
"""... | def parse(string):
"""
Takes a string in BibTex format and returns a list of BibTex entries, where
each entry is a dictionary containing the entries' key-value pairs.
@type string: string
@param string: bibliography in BibTex format
@rtype: list
@return: a list of dictionaries representing a bibliography
"""... | [
"Takes",
"a",
"string",
"in",
"BibTex",
"format",
"and",
"returns",
"a",
"list",
"of",
"BibTex",
"entries",
"where",
"each",
"entry",
"is",
"a",
"dictionary",
"containing",
"the",
"entries",
"key",
"-",
"value",
"pairs",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/bibtex.py#L46-L101 | [
"def",
"parse",
"(",
"string",
")",
":",
"# bibliography",
"bib",
"=",
"[",
"]",
"# make sure we are dealing with unicode strings",
"if",
"not",
"isinstance",
"(",
"string",
",",
"six",
".",
"text_type",
")",
":",
"string",
"=",
"string",
".",
"decode",
"(",
... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | OrderedModel.swap | Swap the positions of this object with a reference object. | publications/models/orderedmodel.py | def swap(self, qs):
"""
Swap the positions of this object with a reference object.
"""
try:
replacement = qs[0]
except IndexError:
# already first/last
return
if not self._valid_ordering_reference(replacement):
raise ValueEr... | def swap(self, qs):
"""
Swap the positions of this object with a reference object.
"""
try:
replacement = qs[0]
except IndexError:
# already first/last
return
if not self._valid_ordering_reference(replacement):
raise ValueEr... | [
"Swap",
"the",
"positions",
"of",
"this",
"object",
"with",
"a",
"reference",
"object",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/models/orderedmodel.py#L116-L134 | [
"def",
"swap",
"(",
"self",
",",
"qs",
")",
":",
"try",
":",
"replacement",
"=",
"qs",
"[",
"0",
"]",
"except",
"IndexError",
":",
"# already first/last",
"return",
"if",
"not",
"self",
".",
"_valid_ordering_reference",
"(",
"replacement",
")",
":",
"raise... | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
valid | OrderedModel.up | Move this object up one position. | publications/models/orderedmodel.py | def up(self):
"""
Move this object up one position.
"""
self.swap(self.get_ordering_queryset().filter(order__lt=self.order).order_by('-order')) | def up(self):
"""
Move this object up one position.
"""
self.swap(self.get_ordering_queryset().filter(order__lt=self.order).order_by('-order')) | [
"Move",
"this",
"object",
"up",
"one",
"position",
"."
] | lucastheis/django-publications | python | https://github.com/lucastheis/django-publications/blob/5a75cf88cf794937711b6850ff2acb07fe005f08/publications/models/orderedmodel.py#L136-L140 | [
"def",
"up",
"(",
"self",
")",
":",
"self",
".",
"swap",
"(",
"self",
".",
"get_ordering_queryset",
"(",
")",
".",
"filter",
"(",
"order__lt",
"=",
"self",
".",
"order",
")",
".",
"order_by",
"(",
"'-order'",
")",
")"
] | 5a75cf88cf794937711b6850ff2acb07fe005f08 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.