id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
49,700 | codeinn/vcs | vcs/backends/git/repository.py | GitRepository.clone | def clone(self, url, update_after_clone=True, bare=False):
"""
Tries to clone changes from external location.
:param update_after_clone: If set to ``False``, git won't checkout
working directory
:param bare: If set to ``True``, repository would be cloned into
*bare* ... | python | def clone(self, url, update_after_clone=True, bare=False):
"""
Tries to clone changes from external location.
:param update_after_clone: If set to ``False``, git won't checkout
working directory
:param bare: If set to ``True``, repository would be cloned into
*bare* ... | [
"def",
"clone",
"(",
"self",
",",
"url",
",",
"update_after_clone",
"=",
"True",
",",
"bare",
"=",
"False",
")",
":",
"url",
"=",
"self",
".",
"_get_url",
"(",
"url",
")",
"cmd",
"=",
"[",
"'clone'",
"]",
"if",
"bare",
":",
"cmd",
".",
"append",
... | Tries to clone changes from external location.
:param update_after_clone: If set to ``False``, git won't checkout
working directory
:param bare: If set to ``True``, repository would be cloned into
*bare* git repository (no working directory at all). | [
"Tries",
"to",
"clone",
"changes",
"from",
"external",
"location",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/repository.py#L583-L601 |
49,701 | codeinn/vcs | vcs/utils/annotate.py | AnnotateHtmlFormatter.annotate_from_changeset | def annotate_from_changeset(self, changeset):
"""
Returns full html line for single changeset per annotated line.
"""
if self.annotate_from_changeset_func:
return self.annotate_from_changeset_func(changeset)
else:
return ''.join((changeset.id, '\n')) | python | def annotate_from_changeset(self, changeset):
"""
Returns full html line for single changeset per annotated line.
"""
if self.annotate_from_changeset_func:
return self.annotate_from_changeset_func(changeset)
else:
return ''.join((changeset.id, '\n')) | [
"def",
"annotate_from_changeset",
"(",
"self",
",",
"changeset",
")",
":",
"if",
"self",
".",
"annotate_from_changeset_func",
":",
"return",
"self",
".",
"annotate_from_changeset_func",
"(",
"changeset",
")",
"else",
":",
"return",
"''",
".",
"join",
"(",
"(",
... | Returns full html line for single changeset per annotated line. | [
"Returns",
"full",
"html",
"line",
"for",
"single",
"changeset",
"per",
"annotated",
"line",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/annotate.py#L75-L82 |
49,702 | codeinn/vcs | vcs/utils/lockfiles.py | LockFile._obtain_lock_or_raise | def _obtain_lock_or_raise(self):
"""Create a lock file as flag for other instances, mark our instance as lock-holder
:raise IOError: if a lock was already present or a lock file could not be written"""
if self._has_lock():
return
lock_file = self._lock_file_path()
if... | python | def _obtain_lock_or_raise(self):
"""Create a lock file as flag for other instances, mark our instance as lock-holder
:raise IOError: if a lock was already present or a lock file could not be written"""
if self._has_lock():
return
lock_file = self._lock_file_path()
if... | [
"def",
"_obtain_lock_or_raise",
"(",
"self",
")",
":",
"if",
"self",
".",
"_has_lock",
"(",
")",
":",
"return",
"lock_file",
"=",
"self",
".",
"_lock_file_path",
"(",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"lock_file",
")",
":",
"raise",
"IO... | Create a lock file as flag for other instances, mark our instance as lock-holder
:raise IOError: if a lock was already present or a lock file could not be written | [
"Create",
"a",
"lock",
"file",
"as",
"flag",
"for",
"other",
"instances",
"mark",
"our",
"instance",
"as",
"lock",
"-",
"holder"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/lockfiles.py#L32-L48 |
49,703 | deontologician/restnavigator | restnavigator/utils.py | objectify_uri | def objectify_uri(relative_uri):
'''Converts uris from path syntax to a json-like object syntax.
In addition, url escaped characters are unescaped, but non-ascii
characters a romanized using the unidecode library.
Examples:
"/blog/3/comments" becomes "blog[3].comments"
"car/engine/piston"... | python | def objectify_uri(relative_uri):
'''Converts uris from path syntax to a json-like object syntax.
In addition, url escaped characters are unescaped, but non-ascii
characters a romanized using the unidecode library.
Examples:
"/blog/3/comments" becomes "blog[3].comments"
"car/engine/piston"... | [
"def",
"objectify_uri",
"(",
"relative_uri",
")",
":",
"def",
"path_clean",
"(",
"chunk",
")",
":",
"if",
"not",
"chunk",
":",
"return",
"chunk",
"if",
"re",
".",
"match",
"(",
"r'\\d+$'",
",",
"chunk",
")",
":",
"return",
"'[{0}]'",
".",
"format",
"("... | Converts uris from path syntax to a json-like object syntax.
In addition, url escaped characters are unescaped, but non-ascii
characters a romanized using the unidecode library.
Examples:
"/blog/3/comments" becomes "blog[3].comments"
"car/engine/piston" becomes "car.engine.piston" | [
"Converts",
"uris",
"from",
"path",
"syntax",
"to",
"a",
"json",
"-",
"like",
"object",
"syntax",
".",
"In",
"addition",
"url",
"escaped",
"characters",
"are",
"unescaped",
"but",
"non",
"-",
"ascii",
"characters",
"a",
"romanized",
"using",
"the",
"unidecod... | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/utils.py#L145-L168 |
49,704 | deontologician/restnavigator | restnavigator/utils.py | parse_media_type | def parse_media_type(media_type):
'''Returns type, subtype, parameter tuple from an http media_type.
Can be applied to the 'Accept' or 'Content-Type' http header fields.
'''
media_type, sep, parameter = str(media_type).partition(';')
media_type, sep, subtype = media_type.partition('/')
return tu... | python | def parse_media_type(media_type):
'''Returns type, subtype, parameter tuple from an http media_type.
Can be applied to the 'Accept' or 'Content-Type' http header fields.
'''
media_type, sep, parameter = str(media_type).partition(';')
media_type, sep, subtype = media_type.partition('/')
return tu... | [
"def",
"parse_media_type",
"(",
"media_type",
")",
":",
"media_type",
",",
"sep",
",",
"parameter",
"=",
"str",
"(",
"media_type",
")",
".",
"partition",
"(",
"';'",
")",
"media_type",
",",
"sep",
",",
"subtype",
"=",
"media_type",
".",
"partition",
"(",
... | Returns type, subtype, parameter tuple from an http media_type.
Can be applied to the 'Accept' or 'Content-Type' http header fields. | [
"Returns",
"type",
"subtype",
"parameter",
"tuple",
"from",
"an",
"http",
"media_type",
".",
"Can",
"be",
"applied",
"to",
"the",
"Accept",
"or",
"Content",
"-",
"Type",
"http",
"header",
"fields",
"."
] | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/utils.py#L171-L177 |
49,705 | deontologician/restnavigator | restnavigator/utils.py | getpath | def getpath(d, json_path, default=None, sep='.'):
'''Gets a value nested in dictionaries containing dictionaries.
Returns the default if any key in the path doesn't exist.
'''
for key in json_path.split(sep):
try:
d = d[key]
except (KeyError, TypeError):
return de... | python | def getpath(d, json_path, default=None, sep='.'):
'''Gets a value nested in dictionaries containing dictionaries.
Returns the default if any key in the path doesn't exist.
'''
for key in json_path.split(sep):
try:
d = d[key]
except (KeyError, TypeError):
return de... | [
"def",
"getpath",
"(",
"d",
",",
"json_path",
",",
"default",
"=",
"None",
",",
"sep",
"=",
"'.'",
")",
":",
"for",
"key",
"in",
"json_path",
".",
"split",
"(",
"sep",
")",
":",
"try",
":",
"d",
"=",
"d",
"[",
"key",
"]",
"except",
"(",
"KeyErr... | Gets a value nested in dictionaries containing dictionaries.
Returns the default if any key in the path doesn't exist. | [
"Gets",
"a",
"value",
"nested",
"in",
"dictionaries",
"containing",
"dictionaries",
".",
"Returns",
"the",
"default",
"if",
"any",
"key",
"in",
"the",
"path",
"doesn",
"t",
"exist",
"."
] | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/utils.py#L257-L266 |
49,706 | deontologician/restnavigator | restnavigator/utils.py | getstate | def getstate(d):
'''Deep copies a dict, and returns it without the keys _links and
_embedded
'''
if not isinstance(d, dict):
raise TypeError("Can only get the state of a dictionary")
cpd = copy.deepcopy(d)
cpd.pop('_links', None)
cpd.pop('_embedded', None)
return cpd | python | def getstate(d):
'''Deep copies a dict, and returns it without the keys _links and
_embedded
'''
if not isinstance(d, dict):
raise TypeError("Can only get the state of a dictionary")
cpd = copy.deepcopy(d)
cpd.pop('_links', None)
cpd.pop('_embedded', None)
return cpd | [
"def",
"getstate",
"(",
"d",
")",
":",
"if",
"not",
"isinstance",
"(",
"d",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"\"Can only get the state of a dictionary\"",
")",
"cpd",
"=",
"copy",
".",
"deepcopy",
"(",
"d",
")",
"cpd",
".",
"pop",
"(",
... | Deep copies a dict, and returns it without the keys _links and
_embedded | [
"Deep",
"copies",
"a",
"dict",
"and",
"returns",
"it",
"without",
"the",
"keys",
"_links",
"and",
"_embedded"
] | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/utils.py#L269-L278 |
49,707 | deontologician/restnavigator | restnavigator/utils.py | LinkList.append_with | def append_with(self, obj, **properties):
'''Add an item to the dictionary with the given metadata properties'''
for prop, val in properties.items():
val = self.serialize(val)
self._meta.setdefault(prop, {}).setdefault(val, []).append(obj)
self.append(obj) | python | def append_with(self, obj, **properties):
'''Add an item to the dictionary with the given metadata properties'''
for prop, val in properties.items():
val = self.serialize(val)
self._meta.setdefault(prop, {}).setdefault(val, []).append(obj)
self.append(obj) | [
"def",
"append_with",
"(",
"self",
",",
"obj",
",",
"*",
"*",
"properties",
")",
":",
"for",
"prop",
",",
"val",
"in",
"properties",
".",
"items",
"(",
")",
":",
"val",
"=",
"self",
".",
"serialize",
"(",
"val",
")",
"self",
".",
"_meta",
".",
"s... | Add an item to the dictionary with the given metadata properties | [
"Add",
"an",
"item",
"to",
"the",
"dictionary",
"with",
"the",
"given",
"metadata",
"properties"
] | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/utils.py#L198-L203 |
49,708 | deontologician/restnavigator | restnavigator/utils.py | LinkList.get_by | def get_by(self, prop, val, raise_exc=False):
'''Retrieve an item from the dictionary with the given metadata
properties. If there is no such item, None will be returned, if there
are multiple such items, the first will be returned.'''
try:
val = self.serialize(val)
... | python | def get_by(self, prop, val, raise_exc=False):
'''Retrieve an item from the dictionary with the given metadata
properties. If there is no such item, None will be returned, if there
are multiple such items, the first will be returned.'''
try:
val = self.serialize(val)
... | [
"def",
"get_by",
"(",
"self",
",",
"prop",
",",
"val",
",",
"raise_exc",
"=",
"False",
")",
":",
"try",
":",
"val",
"=",
"self",
".",
"serialize",
"(",
"val",
")",
"return",
"self",
".",
"_meta",
"[",
"prop",
"]",
"[",
"val",
"]",
"[",
"0",
"]"... | Retrieve an item from the dictionary with the given metadata
properties. If there is no such item, None will be returned, if there
are multiple such items, the first will be returned. | [
"Retrieve",
"an",
"item",
"from",
"the",
"dictionary",
"with",
"the",
"given",
"metadata",
"properties",
".",
"If",
"there",
"is",
"no",
"such",
"item",
"None",
"will",
"be",
"returned",
"if",
"there",
"are",
"multiple",
"such",
"items",
"the",
"first",
"w... | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/utils.py#L205-L216 |
49,709 | deontologician/restnavigator | restnavigator/utils.py | LinkList.getall_by | def getall_by(self, prop, val):
'''Retrieves all items from the dictionary with the given metadata'''
try:
val = self.serialize(val)
return self._meta[prop][val][:] # return a copy of the list
except KeyError:
return [] | python | def getall_by(self, prop, val):
'''Retrieves all items from the dictionary with the given metadata'''
try:
val = self.serialize(val)
return self._meta[prop][val][:] # return a copy of the list
except KeyError:
return [] | [
"def",
"getall_by",
"(",
"self",
",",
"prop",
",",
"val",
")",
":",
"try",
":",
"val",
"=",
"self",
".",
"serialize",
"(",
"val",
")",
"return",
"self",
".",
"_meta",
"[",
"prop",
"]",
"[",
"val",
"]",
"[",
":",
"]",
"# return a copy of the list",
... | Retrieves all items from the dictionary with the given metadata | [
"Retrieves",
"all",
"items",
"from",
"the",
"dictionary",
"with",
"the",
"given",
"metadata"
] | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/utils.py#L218-L224 |
49,710 | dead-beef/markovchain | markovchain/storage/json.py | JsonStorage.do_replace_state_separator | def do_replace_state_separator(data, old, new):
"""Replace state separator.
Parameters
----------
data : `dict` of `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Data.
old : `str`
Old separator.
new : `str`
New separa... | python | def do_replace_state_separator(data, old, new):
"""Replace state separator.
Parameters
----------
data : `dict` of `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Data.
old : `str`
Old separator.
new : `str`
New separa... | [
"def",
"do_replace_state_separator",
"(",
"data",
",",
"old",
",",
"new",
")",
":",
"for",
"key",
",",
"dataset",
"in",
"data",
".",
"items",
"(",
")",
":",
"data",
"[",
"key",
"]",
"=",
"dict",
"(",
"(",
"k",
".",
"replace",
"(",
"old",
",",
"ne... | Replace state separator.
Parameters
----------
data : `dict` of `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Data.
old : `str`
Old separator.
new : `str`
New separator. | [
"Replace",
"state",
"separator",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/json.py#L50-L66 |
49,711 | dead-beef/markovchain | markovchain/storage/json.py | JsonStorage.do_get_dataset | def do_get_dataset(data, key, create=False):
"""Get a dataset.
Parameters
----------
data : `None` or `dict` of `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Data.
key : `str`
Dataset key.
create : `bool`, optional
C... | python | def do_get_dataset(data, key, create=False):
"""Get a dataset.
Parameters
----------
data : `None` or `dict` of `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Data.
key : `str`
Dataset key.
create : `bool`, optional
C... | [
"def",
"do_get_dataset",
"(",
"data",
",",
"key",
",",
"create",
"=",
"False",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"None",
"try",
":",
"return",
"data",
"[",
"key",
"]",
"except",
"KeyError",
":",
"if",
"create",
":",
"dataset",
"=",... | Get a dataset.
Parameters
----------
data : `None` or `dict` of `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Data.
key : `str`
Dataset key.
create : `bool`, optional
Create a dataset if it does not exist.
Returns
... | [
"Get",
"a",
"dataset",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/json.py#L69-L95 |
49,712 | dead-beef/markovchain | markovchain/storage/json.py | JsonStorage.add_link | def add_link(dataset, source, target, count=1):
"""Add a link.
Parameters
----------
dataset : `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Dataset.
source : `iterable` of `str`
Link source.
target : `str`
Link targ... | python | def add_link(dataset, source, target, count=1):
"""Add a link.
Parameters
----------
dataset : `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Dataset.
source : `iterable` of `str`
Link source.
target : `str`
Link targ... | [
"def",
"add_link",
"(",
"dataset",
",",
"source",
",",
"target",
",",
"count",
"=",
"1",
")",
":",
"try",
":",
"node",
"=",
"dataset",
"[",
"source",
"]",
"values",
",",
"links",
"=",
"node",
"if",
"isinstance",
"(",
"links",
",",
"list",
")",
":",... | Add a link.
Parameters
----------
dataset : `dict` of ([`int`, `str`] or [`list` of `int`, `list` of `str`])
Dataset.
source : `iterable` of `str`
Link source.
target : `str`
Link target.
count : `int`, optional
Link count ... | [
"Add",
"a",
"link",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/json.py#L98-L128 |
49,713 | bitlabstudio/django-conversation | conversation/templatetags/conversation_tags.py | chain_user_names | def chain_user_names(users, exclude_user, truncate=35):
"""Tag to return a truncated chain of user names."""
if not users or not isinstance(exclude_user, get_user_model()):
return ''
return truncatechars(
', '.join(u'{}'.format(u) for u in users.exclude(pk=exclude_user.pk)),
truncate... | python | def chain_user_names(users, exclude_user, truncate=35):
"""Tag to return a truncated chain of user names."""
if not users or not isinstance(exclude_user, get_user_model()):
return ''
return truncatechars(
', '.join(u'{}'.format(u) for u in users.exclude(pk=exclude_user.pk)),
truncate... | [
"def",
"chain_user_names",
"(",
"users",
",",
"exclude_user",
",",
"truncate",
"=",
"35",
")",
":",
"if",
"not",
"users",
"or",
"not",
"isinstance",
"(",
"exclude_user",
",",
"get_user_model",
"(",
")",
")",
":",
"return",
"''",
"return",
"truncatechars",
... | Tag to return a truncated chain of user names. | [
"Tag",
"to",
"return",
"a",
"truncated",
"chain",
"of",
"user",
"names",
"."
] | 2cba8093cee93076102673c260924ea121784c58 | https://github.com/bitlabstudio/django-conversation/blob/2cba8093cee93076102673c260924ea121784c58/conversation/templatetags/conversation_tags.py#L12-L18 |
49,714 | mozilla/Marketplace.Python | marketplace/client.py | Client.url | def url(self, key):
"""Creates a full URL to the API using urls dict
"""
return urlunparse((self.protocol, '%s:%s' % (self.domain, self.port),
'%s/api/v1%s' % (self.prefix, URLS[key]),
'', '', '')) | python | def url(self, key):
"""Creates a full URL to the API using urls dict
"""
return urlunparse((self.protocol, '%s:%s' % (self.domain, self.port),
'%s/api/v1%s' % (self.prefix, URLS[key]),
'', '', '')) | [
"def",
"url",
"(",
"self",
",",
"key",
")",
":",
"return",
"urlunparse",
"(",
"(",
"self",
".",
"protocol",
",",
"'%s:%s'",
"%",
"(",
"self",
".",
"domain",
",",
"self",
".",
"port",
")",
",",
"'%s/api/v1%s'",
"%",
"(",
"self",
".",
"prefix",
",",
... | Creates a full URL to the API using urls dict | [
"Creates",
"a",
"full",
"URL",
"to",
"the",
"API",
"using",
"urls",
"dict"
] | 88176b12201f766b6b96bccc1e4c3e82f0676283 | https://github.com/mozilla/Marketplace.Python/blob/88176b12201f766b6b96bccc1e4c3e82f0676283/marketplace/client.py#L57-L62 |
49,715 | mozilla/Marketplace.Python | marketplace/client.py | Client.is_manifest_valid | def is_manifest_valid(self, manifest_id):
"""Check validation shortcut
:param: manifest_id (string) id received in :method:`validate_manifest`
:returns:
* True if manifest was valid
* None if manifest wasn't checked yet
* validation dict if not valid
... | python | def is_manifest_valid(self, manifest_id):
"""Check validation shortcut
:param: manifest_id (string) id received in :method:`validate_manifest`
:returns:
* True if manifest was valid
* None if manifest wasn't checked yet
* validation dict if not valid
... | [
"def",
"is_manifest_valid",
"(",
"self",
",",
"manifest_id",
")",
":",
"response",
"=",
"self",
".",
"get_manifest_validation_result",
"(",
"manifest_id",
")",
"if",
"response",
".",
"status_code",
"!=",
"200",
":",
"raise",
"Exception",
"(",
"response",
".",
... | Check validation shortcut
:param: manifest_id (string) id received in :method:`validate_manifest`
:returns:
* True if manifest was valid
* None if manifest wasn't checked yet
* validation dict if not valid | [
"Check",
"validation",
"shortcut"
] | 88176b12201f766b6b96bccc1e4c3e82f0676283 | https://github.com/mozilla/Marketplace.Python/blob/88176b12201f766b6b96bccc1e4c3e82f0676283/marketplace/client.py#L89-L106 |
49,716 | mozilla/Marketplace.Python | marketplace/client.py | Client.update | def update(self, app_id, data):
"""Update app identified by app_id with data
:params:
* app_id (int) id in the marketplace received with :method:`create`
* data (dict) some keys are required:
* *name*: the title of the app. Maximum length 127
ch... | python | def update(self, app_id, data):
"""Update app identified by app_id with data
:params:
* app_id (int) id in the marketplace received with :method:`create`
* data (dict) some keys are required:
* *name*: the title of the app. Maximum length 127
ch... | [
"def",
"update",
"(",
"self",
",",
"app_id",
",",
"data",
")",
":",
"assert",
"(",
"'name'",
"in",
"data",
"and",
"data",
"[",
"'name'",
"]",
"and",
"'summary'",
"in",
"data",
"and",
"'categories'",
"in",
"data",
"and",
"data",
"[",
"'categories'",
"]"... | Update app identified by app_id with data
:params:
* app_id (int) id in the marketplace received with :method:`create`
* data (dict) some keys are required:
* *name*: the title of the app. Maximum length 127
characters.
* *summary*: the ... | [
"Update",
"app",
"identified",
"by",
"app_id",
"with",
"data"
] | 88176b12201f766b6b96bccc1e4c3e82f0676283 | https://github.com/mozilla/Marketplace.Python/blob/88176b12201f766b6b96bccc1e4c3e82f0676283/marketplace/client.py#L129-L163 |
49,717 | mozilla/Marketplace.Python | marketplace/client.py | Client.create_screenshot | def create_screenshot(self, app_id, filename, position=1):
"""Add a screenshot to the web app identified by by ``app_id``.
Screenshots are ordered by ``position``.
:returns: HttpResponse:
* status_code (int) 201 is successful
* content (dict) containing screenshot data
... | python | def create_screenshot(self, app_id, filename, position=1):
"""Add a screenshot to the web app identified by by ``app_id``.
Screenshots are ordered by ``position``.
:returns: HttpResponse:
* status_code (int) 201 is successful
* content (dict) containing screenshot data
... | [
"def",
"create_screenshot",
"(",
"self",
",",
"app_id",
",",
"filename",
",",
"position",
"=",
"1",
")",
":",
"# prepare file for upload",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"s_file",
":",
"s_content",
"=",
"s_file",
".",
"read",
"(",... | Add a screenshot to the web app identified by by ``app_id``.
Screenshots are ordered by ``position``.
:returns: HttpResponse:
* status_code (int) 201 is successful
* content (dict) containing screenshot data | [
"Add",
"a",
"screenshot",
"to",
"the",
"web",
"app",
"identified",
"by",
"by",
"app_id",
".",
"Screenshots",
"are",
"ordered",
"by",
"position",
"."
] | 88176b12201f766b6b96bccc1e4c3e82f0676283 | https://github.com/mozilla/Marketplace.Python/blob/88176b12201f766b6b96bccc1e4c3e82f0676283/marketplace/client.py#L183-L204 |
49,718 | mozilla/Marketplace.Python | marketplace/client.py | Client.add_content_ratings | def add_content_ratings(self, app_id, submission_id, security_code):
"""Add content ratings to the web app identified by by ``app_id``,
using the specified submission id and security code.
:returns: HttpResponse:
* status_code (int) 201 is successful
"""
url = self.u... | python | def add_content_ratings(self, app_id, submission_id, security_code):
"""Add content ratings to the web app identified by by ``app_id``,
using the specified submission id and security code.
:returns: HttpResponse:
* status_code (int) 201 is successful
"""
url = self.u... | [
"def",
"add_content_ratings",
"(",
"self",
",",
"app_id",
",",
"submission_id",
",",
"security_code",
")",
":",
"url",
"=",
"self",
".",
"url",
"(",
"'content_ratings'",
")",
"%",
"app_id",
"return",
"self",
".",
"conn",
".",
"fetch",
"(",
"'POST'",
",",
... | Add content ratings to the web app identified by by ``app_id``,
using the specified submission id and security code.
:returns: HttpResponse:
* status_code (int) 201 is successful | [
"Add",
"content",
"ratings",
"to",
"the",
"web",
"app",
"identified",
"by",
"by",
"app_id",
"using",
"the",
"specified",
"submission",
"id",
"and",
"security",
"code",
"."
] | 88176b12201f766b6b96bccc1e4c3e82f0676283 | https://github.com/mozilla/Marketplace.Python/blob/88176b12201f766b6b96bccc1e4c3e82f0676283/marketplace/client.py#L224-L235 |
49,719 | dead-beef/markovchain | markovchain/text/scanner.py | RegExpScanner.save | def save(self):
"""Convert the scanner to JSON.
Returns
-------
`dict`
JSON data.
"""
data = super().save()
data['expr'] = self.expr.pattern
data['default_end'] = self.default_end
return data | python | def save(self):
"""Convert the scanner to JSON.
Returns
-------
`dict`
JSON data.
"""
data = super().save()
data['expr'] = self.expr.pattern
data['default_end'] = self.default_end
return data | [
"def",
"save",
"(",
"self",
")",
":",
"data",
"=",
"super",
"(",
")",
".",
"save",
"(",
")",
"data",
"[",
"'expr'",
"]",
"=",
"self",
".",
"expr",
".",
"pattern",
"data",
"[",
"'default_end'",
"]",
"=",
"self",
".",
"default_end",
"return",
"data"
... | Convert the scanner to JSON.
Returns
-------
`dict`
JSON data. | [
"Convert",
"the",
"scanner",
"to",
"JSON",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/scanner.py#L282-L293 |
49,720 | codeinn/vcs | vcs/backends/hg/repository.py | MercurialRepository._get_branches | def _get_branches(self, closed=False):
"""
Get's branches for this repository
Returns only not closed branches by default
:param closed: return also closed branches for mercurial
"""
if self._empty:
return {}
def _branchtags(localrepo):
... | python | def _get_branches(self, closed=False):
"""
Get's branches for this repository
Returns only not closed branches by default
:param closed: return also closed branches for mercurial
"""
if self._empty:
return {}
def _branchtags(localrepo):
... | [
"def",
"_get_branches",
"(",
"self",
",",
"closed",
"=",
"False",
")",
":",
"if",
"self",
".",
"_empty",
":",
"return",
"{",
"}",
"def",
"_branchtags",
"(",
"localrepo",
")",
":",
"\"\"\"\n Patched version of mercurial branchtags to not return the closed\n ... | Get's branches for this repository
Returns only not closed branches by default
:param closed: return also closed branches for mercurial | [
"Get",
"s",
"branches",
"for",
"this",
"repository",
"Returns",
"only",
"not",
"closed",
"branches",
"by",
"default"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/repository.py#L106-L142 |
49,721 | codeinn/vcs | vcs/backends/hg/repository.py | MercurialRepository._get_repo | def _get_repo(self, create, src_url=None, update_after_clone=False):
"""
Function will check for mercurial repository in given path and return
a localrepo object. If there is no repository in that path it will
raise an exception unless ``create`` parameter is set to True - in
tha... | python | def _get_repo(self, create, src_url=None, update_after_clone=False):
"""
Function will check for mercurial repository in given path and return
a localrepo object. If there is no repository in that path it will
raise an exception unless ``create`` parameter is set to True - in
tha... | [
"def",
"_get_repo",
"(",
"self",
",",
"create",
",",
"src_url",
"=",
"None",
",",
"update_after_clone",
"=",
"False",
")",
":",
"try",
":",
"if",
"src_url",
":",
"url",
"=",
"str",
"(",
"self",
".",
"_get_url",
"(",
"src_url",
")",
")",
"opts",
"=",
... | Function will check for mercurial repository in given path and return
a localrepo object. If there is no repository in that path it will
raise an exception unless ``create`` parameter is set to True - in
that case repository would be created and returned.
If ``src_url`` is given, would t... | [
"Function",
"will",
"check",
"for",
"mercurial",
"repository",
"in",
"given",
"path",
"and",
"return",
"a",
"localrepo",
"object",
".",
"If",
"there",
"is",
"no",
"repository",
"in",
"that",
"path",
"it",
"will",
"raise",
"an",
"exception",
"unless",
"create... | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/repository.py#L326-L361 |
49,722 | codeinn/vcs | vcs/backends/hg/repository.py | MercurialRepository._get_revision | def _get_revision(self, revision):
"""
Get's an ID revision given as str. This will always return a fill
40 char revision number
:param revision: str or int or None
"""
if self._empty:
raise EmptyRepositoryError("There are no changesets yet")
if rev... | python | def _get_revision(self, revision):
"""
Get's an ID revision given as str. This will always return a fill
40 char revision number
:param revision: str or int or None
"""
if self._empty:
raise EmptyRepositoryError("There are no changesets yet")
if rev... | [
"def",
"_get_revision",
"(",
"self",
",",
"revision",
")",
":",
"if",
"self",
".",
"_empty",
":",
"raise",
"EmptyRepositoryError",
"(",
"\"There are no changesets yet\"",
")",
"if",
"revision",
"in",
"[",
"-",
"1",
",",
"'tip'",
",",
"None",
"]",
":",
"rev... | Get's an ID revision given as str. This will always return a fill
40 char revision number
:param revision: str or int or None | [
"Get",
"s",
"an",
"ID",
"revision",
"given",
"as",
"str",
".",
"This",
"will",
"always",
"return",
"a",
"fill",
"40",
"char",
"revision",
"number"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/repository.py#L401-L421 |
49,723 | codeinn/vcs | vcs/backends/hg/repository.py | MercurialRepository.get_changeset | def get_changeset(self, revision=None):
"""
Returns ``MercurialChangeset`` object representing repository's
changeset at the given ``revision``.
"""
revision = self._get_revision(revision)
changeset = MercurialChangeset(repository=self, revision=revision)
return c... | python | def get_changeset(self, revision=None):
"""
Returns ``MercurialChangeset`` object representing repository's
changeset at the given ``revision``.
"""
revision = self._get_revision(revision)
changeset = MercurialChangeset(repository=self, revision=revision)
return c... | [
"def",
"get_changeset",
"(",
"self",
",",
"revision",
"=",
"None",
")",
":",
"revision",
"=",
"self",
".",
"_get_revision",
"(",
"revision",
")",
"changeset",
"=",
"MercurialChangeset",
"(",
"repository",
"=",
"self",
",",
"revision",
"=",
"revision",
")",
... | Returns ``MercurialChangeset`` object representing repository's
changeset at the given ``revision``. | [
"Returns",
"MercurialChangeset",
"object",
"representing",
"repository",
"s",
"changeset",
"at",
"the",
"given",
"revision",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/repository.py#L449-L456 |
49,724 | dead-beef/markovchain | markovchain/text/markov.py | MarkovText.format | def format(self, parts):
"""Format generated text.
Parameters
----------
parts : `iterable` of `str`
Text parts.
"""
text = self.storage.state_separator.join(parts)
return self.formatter(text) | python | def format(self, parts):
"""Format generated text.
Parameters
----------
parts : `iterable` of `str`
Text parts.
"""
text = self.storage.state_separator.join(parts)
return self.formatter(text) | [
"def",
"format",
"(",
"self",
",",
"parts",
")",
":",
"text",
"=",
"self",
".",
"storage",
".",
"state_separator",
".",
"join",
"(",
"parts",
")",
"return",
"self",
".",
"formatter",
"(",
"text",
")"
] | Format generated text.
Parameters
----------
parts : `iterable` of `str`
Text parts. | [
"Format",
"generated",
"text",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/markov.py#L56-L65 |
49,725 | dead-beef/markovchain | markovchain/text/markov.py | MarkovText.generate_replies | def generate_replies(self, max_length, state_size, reply_to, dataset):
"""Generate replies.
Parameters
----------
max_length : `int` or `None`
Maximum sentence length.
state_size : `int`
State size.
reply_to : `str`
Input string.
... | python | def generate_replies(self, max_length, state_size, reply_to, dataset):
"""Generate replies.
Parameters
----------
max_length : `int` or `None`
Maximum sentence length.
state_size : `int`
State size.
reply_to : `str`
Input string.
... | [
"def",
"generate_replies",
"(",
"self",
",",
"max_length",
",",
"state_size",
",",
"reply_to",
",",
"dataset",
")",
":",
"state_sets",
"=",
"self",
".",
"get_reply_states",
"(",
"reply_to",
",",
"dataset",
"+",
"state_size_dataset",
"(",
"state_size",
")",
")"... | Generate replies.
Parameters
----------
max_length : `int` or `None`
Maximum sentence length.
state_size : `int`
State size.
reply_to : `str`
Input string.
dataset: `str`
Dataset key prefix.
Returns
-------... | [
"Generate",
"replies",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/text/markov.py#L155-L199 |
49,726 | codeinn/vcs | vcs/backends/base.py | BaseRepository.size | def size(self):
"""
Returns combined size in bytes for all repository files
"""
size = 0
try:
tip = self.get_changeset()
for topnode, dirs, files in tip.walk('/'):
for f in files:
size += tip.get_file_size(f.path)
... | python | def size(self):
"""
Returns combined size in bytes for all repository files
"""
size = 0
try:
tip = self.get_changeset()
for topnode, dirs, files in tip.walk('/'):
for f in files:
size += tip.get_file_size(f.path)
... | [
"def",
"size",
"(",
"self",
")",
":",
"size",
"=",
"0",
"try",
":",
"tip",
"=",
"self",
".",
"get_changeset",
"(",
")",
"for",
"topnode",
",",
"dirs",
",",
"files",
"in",
"tip",
".",
"walk",
"(",
"'/'",
")",
":",
"for",
"f",
"in",
"files",
":",... | Returns combined size in bytes for all repository files | [
"Returns",
"combined",
"size",
"in",
"bytes",
"for",
"all",
"repository",
"files"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/base.py#L101-L118 |
49,727 | codeinn/vcs | vcs/backends/base.py | BaseRepository.get_changesets | def get_changesets(self, start=None, end=None, start_date=None,
end_date=None, branch_name=None, reverse=False):
"""
Returns iterator of ``MercurialChangeset`` objects from start to end
not inclusive This should behave just like a list, ie. end is not
inclusive
... | python | def get_changesets(self, start=None, end=None, start_date=None,
end_date=None, branch_name=None, reverse=False):
"""
Returns iterator of ``MercurialChangeset`` objects from start to end
not inclusive This should behave just like a list, ie. end is not
inclusive
... | [
"def",
"get_changesets",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
",",
"start_date",
"=",
"None",
",",
"end_date",
"=",
"None",
",",
"branch_name",
"=",
"None",
",",
"reverse",
"=",
"False",
")",
":",
"raise",
"NotImplementedError... | Returns iterator of ``MercurialChangeset`` objects from start to end
not inclusive This should behave just like a list, ie. end is not
inclusive
:param start: None or str
:param end: None or str
:param start_date:
:param end_date:
:param branch_name:
:par... | [
"Returns",
"iterator",
"of",
"MercurialChangeset",
"objects",
"from",
"start",
"to",
"end",
"not",
"inclusive",
"This",
"should",
"behave",
"just",
"like",
"a",
"list",
"ie",
".",
"end",
"is",
"not",
"inclusive"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/base.py#L151-L165 |
49,728 | codeinn/vcs | vcs/backends/base.py | BaseChangeset.get_chunked_archive | def get_chunked_archive(self, **kwargs):
"""
Returns iterable archive. Tiny wrapper around ``fill_archive`` method.
:param chunk_size: extra parameter which controls size of returned
chunks. Default:8k.
"""
chunk_size = kwargs.pop('chunk_size', 8192)
stream ... | python | def get_chunked_archive(self, **kwargs):
"""
Returns iterable archive. Tiny wrapper around ``fill_archive`` method.
:param chunk_size: extra parameter which controls size of returned
chunks. Default:8k.
"""
chunk_size = kwargs.pop('chunk_size', 8192)
stream ... | [
"def",
"get_chunked_archive",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"chunk_size",
"=",
"kwargs",
".",
"pop",
"(",
"'chunk_size'",
",",
"8192",
")",
"stream",
"=",
"kwargs",
".",
"get",
"(",
"'stream'",
")",
"self",
".",
"fill_archive",
"(",
"... | Returns iterable archive. Tiny wrapper around ``fill_archive`` method.
:param chunk_size: extra parameter which controls size of returned
chunks. Default:8k. | [
"Returns",
"iterable",
"archive",
".",
"Tiny",
"wrapper",
"around",
"fill_archive",
"method",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/base.py#L537-L552 |
49,729 | codeinn/vcs | vcs/backends/base.py | BaseChangeset.as_dict | def as_dict(self):
"""
Returns dictionary with changeset's attributes and their values.
"""
data = get_dict_for_attrs(self, ['id', 'raw_id', 'short_id',
'revision', 'date', 'message'])
data['author'] = {'name': self.author_name, 'email': self.author_email}
dat... | python | def as_dict(self):
"""
Returns dictionary with changeset's attributes and their values.
"""
data = get_dict_for_attrs(self, ['id', 'raw_id', 'short_id',
'revision', 'date', 'message'])
data['author'] = {'name': self.author_name, 'email': self.author_email}
dat... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"data",
"=",
"get_dict_for_attrs",
"(",
"self",
",",
"[",
"'id'",
",",
"'raw_id'",
",",
"'short_id'",
",",
"'revision'",
",",
"'date'",
",",
"'message'",
"]",
")",
"data",
"[",
"'author'",
"]",
"=",
"{",
"'name'... | Returns dictionary with changeset's attributes and their values. | [
"Returns",
"dictionary",
"with",
"changeset",
"s",
"attributes",
"and",
"their",
"values",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/base.py#L627-L637 |
49,730 | codeinn/vcs | vcs/backends/base.py | BaseInMemoryChangeset.get_ipaths | def get_ipaths(self):
"""
Returns generator of paths from nodes marked as added, changed or
removed.
"""
for node in itertools.chain(self.added, self.changed, self.removed):
yield node.path | python | def get_ipaths(self):
"""
Returns generator of paths from nodes marked as added, changed or
removed.
"""
for node in itertools.chain(self.added, self.changed, self.removed):
yield node.path | [
"def",
"get_ipaths",
"(",
"self",
")",
":",
"for",
"node",
"in",
"itertools",
".",
"chain",
"(",
"self",
".",
"added",
",",
"self",
".",
"changed",
",",
"self",
".",
"removed",
")",
":",
"yield",
"node",
".",
"path"
] | Returns generator of paths from nodes marked as added, changed or
removed. | [
"Returns",
"generator",
"of",
"paths",
"from",
"nodes",
"marked",
"as",
"added",
"changed",
"or",
"removed",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/base.py#L831-L837 |
49,731 | codeinn/vcs | vcs/backends/base.py | BaseInMemoryChangeset.check_integrity | def check_integrity(self, parents=None):
"""
Checks in-memory changeset's integrity. Also, sets parents if not
already set.
:raises CommitError: if any error occurs (i.e.
``NodeDoesNotExistError``).
"""
if not self.parents:
parents = parents or []
... | python | def check_integrity(self, parents=None):
"""
Checks in-memory changeset's integrity. Also, sets parents if not
already set.
:raises CommitError: if any error occurs (i.e.
``NodeDoesNotExistError``).
"""
if not self.parents:
parents = parents or []
... | [
"def",
"check_integrity",
"(",
"self",
",",
"parents",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"parents",
":",
"parents",
"=",
"parents",
"or",
"[",
"]",
"if",
"len",
"(",
"parents",
")",
"==",
"0",
":",
"try",
":",
"parents",
"=",
"[",
... | Checks in-memory changeset's integrity. Also, sets parents if not
already set.
:raises CommitError: if any error occurs (i.e.
``NodeDoesNotExistError``). | [
"Checks",
"in",
"-",
"memory",
"changeset",
"s",
"integrity",
".",
"Also",
"sets",
"parents",
"if",
"not",
"already",
"set",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/base.py#L845-L917 |
49,732 | codeinn/vcs | vcs/backends/git/changeset.py | GitChangeset.get_file_content | def get_file_content(self, path):
"""
Returns content of the file at given ``path``.
"""
id = self._get_id_for_path(path)
blob = self.repository._repo[id]
return blob.as_pretty_string() | python | def get_file_content(self, path):
"""
Returns content of the file at given ``path``.
"""
id = self._get_id_for_path(path)
blob = self.repository._repo[id]
return blob.as_pretty_string() | [
"def",
"get_file_content",
"(",
"self",
",",
"path",
")",
":",
"id",
"=",
"self",
".",
"_get_id_for_path",
"(",
"path",
")",
"blob",
"=",
"self",
".",
"repository",
".",
"_repo",
"[",
"id",
"]",
"return",
"blob",
".",
"as_pretty_string",
"(",
")"
] | Returns content of the file at given ``path``. | [
"Returns",
"content",
"of",
"the",
"file",
"at",
"given",
"path",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/changeset.py#L259-L265 |
49,733 | codeinn/vcs | vcs/backends/git/changeset.py | GitChangeset.get_file_size | def get_file_size(self, path):
"""
Returns size of the file at given ``path``.
"""
id = self._get_id_for_path(path)
blob = self.repository._repo[id]
return blob.raw_length() | python | def get_file_size(self, path):
"""
Returns size of the file at given ``path``.
"""
id = self._get_id_for_path(path)
blob = self.repository._repo[id]
return blob.raw_length() | [
"def",
"get_file_size",
"(",
"self",
",",
"path",
")",
":",
"id",
"=",
"self",
".",
"_get_id_for_path",
"(",
"path",
")",
"blob",
"=",
"self",
".",
"repository",
".",
"_repo",
"[",
"id",
"]",
"return",
"blob",
".",
"raw_length",
"(",
")"
] | Returns size of the file at given ``path``. | [
"Returns",
"size",
"of",
"the",
"file",
"at",
"given",
"path",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/changeset.py#L267-L273 |
49,734 | codeinn/vcs | vcs/backends/git/changeset.py | GitChangeset.affected_files | def affected_files(self):
"""
Get's a fast accessible file changes for given changeset
"""
added, modified, deleted = self._changes_cache
return list(added.union(modified).union(deleted)) | python | def affected_files(self):
"""
Get's a fast accessible file changes for given changeset
"""
added, modified, deleted = self._changes_cache
return list(added.union(modified).union(deleted)) | [
"def",
"affected_files",
"(",
"self",
")",
":",
"added",
",",
"modified",
",",
"deleted",
"=",
"self",
".",
"_changes_cache",
"return",
"list",
"(",
"added",
".",
"union",
"(",
"modified",
")",
".",
"union",
"(",
"deleted",
")",
")"
] | Get's a fast accessible file changes for given changeset | [
"Get",
"s",
"a",
"fast",
"accessible",
"file",
"changes",
"for",
"given",
"changeset"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/changeset.py#L469-L474 |
49,735 | codeinn/vcs | vcs/backends/git/changeset.py | GitChangeset._get_paths_for_status | def _get_paths_for_status(self, status):
"""
Returns sorted list of paths for given ``status``.
:param status: one of: *added*, *modified* or *deleted*
"""
added, modified, deleted = self._changes_cache
return sorted({
'added': list(added),
'modif... | python | def _get_paths_for_status(self, status):
"""
Returns sorted list of paths for given ``status``.
:param status: one of: *added*, *modified* or *deleted*
"""
added, modified, deleted = self._changes_cache
return sorted({
'added': list(added),
'modif... | [
"def",
"_get_paths_for_status",
"(",
"self",
",",
"status",
")",
":",
"added",
",",
"modified",
",",
"deleted",
"=",
"self",
".",
"_changes_cache",
"return",
"sorted",
"(",
"{",
"'added'",
":",
"list",
"(",
"added",
")",
",",
"'modified'",
":",
"list",
"... | Returns sorted list of paths for given ``status``.
:param status: one of: *added*, *modified* or *deleted* | [
"Returns",
"sorted",
"list",
"of",
"paths",
"for",
"given",
"status",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/changeset.py#L511-L522 |
49,736 | codeinn/vcs | vcs/backends/git/changeset.py | GitChangeset.added | def added(self):
"""
Returns list of added ``FileNode`` objects.
"""
if not self.parents:
return list(self._get_file_nodes())
return AddedFileNodesGenerator([n for n in
self._get_paths_for_status('added')], self) | python | def added(self):
"""
Returns list of added ``FileNode`` objects.
"""
if not self.parents:
return list(self._get_file_nodes())
return AddedFileNodesGenerator([n for n in
self._get_paths_for_status('added')], self) | [
"def",
"added",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parents",
":",
"return",
"list",
"(",
"self",
".",
"_get_file_nodes",
"(",
")",
")",
"return",
"AddedFileNodesGenerator",
"(",
"[",
"n",
"for",
"n",
"in",
"self",
".",
"_get_paths_for_stat... | Returns list of added ``FileNode`` objects. | [
"Returns",
"list",
"of",
"added",
"FileNode",
"objects",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/changeset.py#L525-L532 |
49,737 | codeinn/vcs | vcs/backends/git/changeset.py | GitChangeset.changed | def changed(self):
"""
Returns list of modified ``FileNode`` objects.
"""
if not self.parents:
return []
return ChangedFileNodesGenerator([n for n in
self._get_paths_for_status('modified')], self) | python | def changed(self):
"""
Returns list of modified ``FileNode`` objects.
"""
if not self.parents:
return []
return ChangedFileNodesGenerator([n for n in
self._get_paths_for_status('modified')], self) | [
"def",
"changed",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parents",
":",
"return",
"[",
"]",
"return",
"ChangedFileNodesGenerator",
"(",
"[",
"n",
"for",
"n",
"in",
"self",
".",
"_get_paths_for_status",
"(",
"'modified'",
")",
"]",
",",
"self",... | Returns list of modified ``FileNode`` objects. | [
"Returns",
"list",
"of",
"modified",
"FileNode",
"objects",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/changeset.py#L535-L542 |
49,738 | codeinn/vcs | vcs/backends/git/changeset.py | GitChangeset.removed | def removed(self):
"""
Returns list of removed ``FileNode`` objects.
"""
if not self.parents:
return []
return RemovedFileNodesGenerator([n for n in
self._get_paths_for_status('deleted')], self) | python | def removed(self):
"""
Returns list of removed ``FileNode`` objects.
"""
if not self.parents:
return []
return RemovedFileNodesGenerator([n for n in
self._get_paths_for_status('deleted')], self) | [
"def",
"removed",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"parents",
":",
"return",
"[",
"]",
"return",
"RemovedFileNodesGenerator",
"(",
"[",
"n",
"for",
"n",
"in",
"self",
".",
"_get_paths_for_status",
"(",
"'deleted'",
")",
"]",
",",
"self",
... | Returns list of removed ``FileNode`` objects. | [
"Returns",
"list",
"of",
"removed",
"FileNode",
"objects",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/git/changeset.py#L545-L552 |
49,739 | NICTA/revrand | revrand/optimize/sgd.py | sgd | def sgd(fun, x0, data, args=(), bounds=None, batch_size=10, maxiter=5000,
updater=None, eval_obj=False, random_state=None):
"""
Stochastic Gradient Descent.
Parameters
----------
fun : callable
the function to *minimize*, this must have the signature ``[obj,]``
grad = fun(x,... | python | def sgd(fun, x0, data, args=(), bounds=None, batch_size=10, maxiter=5000,
updater=None, eval_obj=False, random_state=None):
"""
Stochastic Gradient Descent.
Parameters
----------
fun : callable
the function to *minimize*, this must have the signature ``[obj,]``
grad = fun(x,... | [
"def",
"sgd",
"(",
"fun",
",",
"x0",
",",
"data",
",",
"args",
"=",
"(",
")",
",",
"bounds",
"=",
"None",
",",
"batch_size",
"=",
"10",
",",
"maxiter",
"=",
"5000",
",",
"updater",
"=",
"None",
",",
"eval_obj",
"=",
"False",
",",
"random_state",
... | Stochastic Gradient Descent.
Parameters
----------
fun : callable
the function to *minimize*, this must have the signature ``[obj,]``
grad = fun(x, data, ...)`, where the ``eval_obj`` argument tells
``sgd`` if an objective function value is going to be returned by
``fun``.
... | [
"Stochastic",
"Gradient",
"Descent",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/optimize/sgd.py#L311-L425 |
49,740 | NICTA/revrand | revrand/optimize/sgd.py | gen_batch | def gen_batch(data, batch_size, maxiter=np.inf, random_state=None):
"""
Create random batches for Stochastic gradients.
Batch index generator for SGD that will yeild random batches for a
a defined number of iterations, which can be infinite. This generator makes
consecutive passes through the data,... | python | def gen_batch(data, batch_size, maxiter=np.inf, random_state=None):
"""
Create random batches for Stochastic gradients.
Batch index generator for SGD that will yeild random batches for a
a defined number of iterations, which can be infinite. This generator makes
consecutive passes through the data,... | [
"def",
"gen_batch",
"(",
"data",
",",
"batch_size",
",",
"maxiter",
"=",
"np",
".",
"inf",
",",
"random_state",
"=",
"None",
")",
":",
"perms",
"=",
"endless_permutations",
"(",
"_len_data",
"(",
"data",
")",
",",
"random_state",
")",
"it",
"=",
"0",
"... | Create random batches for Stochastic gradients.
Batch index generator for SGD that will yeild random batches for a
a defined number of iterations, which can be infinite. This generator makes
consecutive passes through the data, drawing without replacement on each
pass.
Parameters
----------
... | [
"Create",
"random",
"batches",
"for",
"Stochastic",
"gradients",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/optimize/sgd.py#L428-L459 |
49,741 | NICTA/revrand | revrand/optimize/sgd.py | normalize_bound | def normalize_bound(bound):
"""
Replace ``None`` with + or - inf in bound tuples.
Examples
--------
>>> normalize_bound((2.6, 7.2))
(2.6, 7.2)
>>> normalize_bound((None, 7.2))
(-inf, 7.2)
>>> normalize_bound((2.6, None))
(2.6, inf)
>>> normalize_bound((None, None))
(-... | python | def normalize_bound(bound):
"""
Replace ``None`` with + or - inf in bound tuples.
Examples
--------
>>> normalize_bound((2.6, 7.2))
(2.6, 7.2)
>>> normalize_bound((None, 7.2))
(-inf, 7.2)
>>> normalize_bound((2.6, None))
(2.6, inf)
>>> normalize_bound((None, None))
(-... | [
"def",
"normalize_bound",
"(",
"bound",
")",
":",
"min_",
",",
"max_",
"=",
"bound",
"if",
"min_",
"is",
"None",
":",
"min_",
"=",
"-",
"float",
"(",
"'inf'",
")",
"if",
"max_",
"is",
"None",
":",
"max_",
"=",
"float",
"(",
"'inf'",
")",
"return",
... | Replace ``None`` with + or - inf in bound tuples.
Examples
--------
>>> normalize_bound((2.6, 7.2))
(2.6, 7.2)
>>> normalize_bound((None, 7.2))
(-inf, 7.2)
>>> normalize_bound((2.6, None))
(2.6, inf)
>>> normalize_bound((None, None))
(-inf, inf)
This operation is idempot... | [
"Replace",
"None",
"with",
"+",
"or",
"-",
"inf",
"in",
"bound",
"tuples",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/optimize/sgd.py#L462-L493 |
49,742 | NICTA/revrand | revrand/optimize/sgd.py | Adam.reset | def reset(self):
"""Reset the state of this updater for a new optimisation problem."""
self.__init__(self.alpha, self.beta1, self.beta2, self.epsilon) | python | def reset(self):
"""Reset the state of this updater for a new optimisation problem."""
self.__init__(self.alpha, self.beta1, self.beta2, self.epsilon) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"__init__",
"(",
"self",
".",
"alpha",
",",
"self",
".",
"beta1",
",",
"self",
".",
"beta2",
",",
"self",
".",
"epsilon",
")"
] | Reset the state of this updater for a new optimisation problem. | [
"Reset",
"the",
"state",
"of",
"this",
"updater",
"for",
"a",
"new",
"optimisation",
"problem",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/optimize/sgd.py#L292-L294 |
49,743 | codeinn/vcs | vcs/utils/__init__.py | aslist | def aslist(obj, sep=None, strip=True):
"""
Returns given string separated by sep as list
:param obj:
:param sep:
:param strip:
"""
if isinstance(obj, (basestring)):
lst = obj.split(sep)
if strip:
lst = [v.strip() for v in lst]
return lst
elif isinstan... | python | def aslist(obj, sep=None, strip=True):
"""
Returns given string separated by sep as list
:param obj:
:param sep:
:param strip:
"""
if isinstance(obj, (basestring)):
lst = obj.split(sep)
if strip:
lst = [v.strip() for v in lst]
return lst
elif isinstan... | [
"def",
"aslist",
"(",
"obj",
",",
"sep",
"=",
"None",
",",
"strip",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"basestring",
")",
")",
":",
"lst",
"=",
"obj",
".",
"split",
"(",
"sep",
")",
"if",
"strip",
":",
"lst",
"=",
... | Returns given string separated by sep as list
:param obj:
:param sep:
:param strip: | [
"Returns",
"given",
"string",
"separated",
"by",
"sep",
"as",
"list"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/__init__.py#L19-L37 |
49,744 | codeinn/vcs | vcs/utils/__init__.py | safe_unicode | def safe_unicode(str_, from_encoding=None):
"""
safe unicode function. Does few trick to turn str_ into unicode
In case of UnicodeDecode error we try to return it with encoding detected
by chardet library if it fails fallback to unicode with errors replaced
:param str_: string to decode
:rtype... | python | def safe_unicode(str_, from_encoding=None):
"""
safe unicode function. Does few trick to turn str_ into unicode
In case of UnicodeDecode error we try to return it with encoding detected
by chardet library if it fails fallback to unicode with errors replaced
:param str_: string to decode
:rtype... | [
"def",
"safe_unicode",
"(",
"str_",
",",
"from_encoding",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"str_",
",",
"unicode",
")",
":",
"return",
"str_",
"if",
"not",
"from_encoding",
":",
"from",
"vcs",
".",
"conf",
"import",
"settings",
"from_encodin... | safe unicode function. Does few trick to turn str_ into unicode
In case of UnicodeDecode error we try to return it with encoding detected
by chardet library if it fails fallback to unicode with errors replaced
:param str_: string to decode
:rtype: unicode
:returns: unicode object | [
"safe",
"unicode",
"function",
".",
"Does",
"few",
"trick",
"to",
"turn",
"str_",
"into",
"unicode"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/__init__.py#L68-L107 |
49,745 | codeinn/vcs | vcs/utils/__init__.py | safe_str | def safe_str(unicode_, to_encoding=None):
"""
safe str function. Does few trick to turn unicode_ into string
In case of UnicodeEncodeError we try to return it with encoding detected
by chardet library if it fails fallback to string with errors replaced
:param unicode_: unicode to encode
:rtype... | python | def safe_str(unicode_, to_encoding=None):
"""
safe str function. Does few trick to turn unicode_ into string
In case of UnicodeEncodeError we try to return it with encoding detected
by chardet library if it fails fallback to string with errors replaced
:param unicode_: unicode to encode
:rtype... | [
"def",
"safe_str",
"(",
"unicode_",
",",
"to_encoding",
"=",
"None",
")",
":",
"# if it's not basestr cast to str",
"if",
"not",
"isinstance",
"(",
"unicode_",
",",
"basestring",
")",
":",
"return",
"str",
"(",
"unicode_",
")",
"if",
"isinstance",
"(",
"unicod... | safe str function. Does few trick to turn unicode_ into string
In case of UnicodeEncodeError we try to return it with encoding detected
by chardet library if it fails fallback to string with errors replaced
:param unicode_: unicode to encode
:rtype: str
:returns: str object | [
"safe",
"str",
"function",
".",
"Does",
"few",
"trick",
"to",
"turn",
"unicode_",
"into",
"string"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/__init__.py#L110-L152 |
49,746 | codeinn/vcs | vcs/utils/__init__.py | author_name | def author_name(author):
"""
get name of author, or else username.
It'll try to find an email in the author string and just cut it off
to get the username
"""
if not '@' in author:
return author
else:
return author.replace(author_email(author), '').replace('<', '')\
... | python | def author_name(author):
"""
get name of author, or else username.
It'll try to find an email in the author string and just cut it off
to get the username
"""
if not '@' in author:
return author
else:
return author.replace(author_email(author), '').replace('<', '')\
... | [
"def",
"author_name",
"(",
"author",
")",
":",
"if",
"not",
"'@'",
"in",
"author",
":",
"return",
"author",
"else",
":",
"return",
"author",
".",
"replace",
"(",
"author_email",
"(",
"author",
")",
",",
"''",
")",
".",
"replace",
"(",
"'<'",
",",
"''... | get name of author, or else username.
It'll try to find an email in the author string and just cut it off
to get the username | [
"get",
"name",
"of",
"author",
"or",
"else",
"username",
".",
"It",
"ll",
"try",
"to",
"find",
"an",
"email",
"in",
"the",
"author",
"string",
"and",
"just",
"cut",
"it",
"off",
"to",
"get",
"the",
"username"
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/__init__.py#L179-L190 |
49,747 | NICTA/revrand | revrand/slm.py | StandardLinearModel.fit | def fit(self, X, y):
"""
Learn the hyperparameters of a Bayesian linear regressor.
Parameters
----------
X : ndarray
(N, d) array input dataset (N samples, d dimensions).
y : ndarray
(N,) array targets (N samples)
Returns
-------
... | python | def fit(self, X, y):
"""
Learn the hyperparameters of a Bayesian linear regressor.
Parameters
----------
X : ndarray
(N, d) array input dataset (N samples, d dimensions).
y : ndarray
(N,) array targets (N samples)
Returns
-------
... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"y",
")",
":",
"X",
",",
"y",
"=",
"check_X_y",
"(",
"X",
",",
"y",
")",
"self",
".",
"obj_",
"=",
"-",
"np",
".",
"inf",
"# Make list of parameters and decorate optimiser to undestand this",
"params",
"=",
"[",
... | Learn the hyperparameters of a Bayesian linear regressor.
Parameters
----------
X : ndarray
(N, d) array input dataset (N samples, d dimensions).
y : ndarray
(N,) array targets (N samples)
Returns
-------
self
Notes
-----... | [
"Learn",
"the",
"hyperparameters",
"of",
"a",
"Bayesian",
"linear",
"regressor",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/slm.py#L74-L140 |
49,748 | NICTA/revrand | revrand/slm.py | StandardLinearModel.predict_moments | def predict_moments(self, X):
"""
Full predictive distribution from Bayesian linear regression.
Parameters
----------
X : ndarray
(N*,d) array query input dataset (N* samples, d dimensions).
Returns
-------
Ey : ndarray
The expect... | python | def predict_moments(self, X):
"""
Full predictive distribution from Bayesian linear regression.
Parameters
----------
X : ndarray
(N*,d) array query input dataset (N* samples, d dimensions).
Returns
-------
Ey : ndarray
The expect... | [
"def",
"predict_moments",
"(",
"self",
",",
"X",
")",
":",
"check_is_fitted",
"(",
"self",
",",
"[",
"'var_'",
",",
"'regularizer_'",
",",
"'weights_'",
",",
"'covariance_'",
",",
"'hypers_'",
"]",
")",
"X",
"=",
"check_array",
"(",
"X",
")",
"Phi",
"=",... | Full predictive distribution from Bayesian linear regression.
Parameters
----------
X : ndarray
(N*,d) array query input dataset (N* samples, d dimensions).
Returns
-------
Ey : ndarray
The expected value of y* for the query inputs, X* of shape (... | [
"Full",
"predictive",
"distribution",
"from",
"Bayesian",
"linear",
"regression",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/slm.py#L219-L244 |
49,749 | deontologician/restnavigator | scripts/generate_registry.py | emit_iana_rels | def emit_iana_rels(rels_url):
'''Fetches the IANA link relation registry'''
text = requests.get(rels_url).text.encode('ascii', 'ignore')
xml = objectify.fromstring(text)
iana_rels = {str(rec.value): str(rec.description)
for rec in xml.registry.record}
keys = sorted(iana_rels)
pr... | python | def emit_iana_rels(rels_url):
'''Fetches the IANA link relation registry'''
text = requests.get(rels_url).text.encode('ascii', 'ignore')
xml = objectify.fromstring(text)
iana_rels = {str(rec.value): str(rec.description)
for rec in xml.registry.record}
keys = sorted(iana_rels)
pr... | [
"def",
"emit_iana_rels",
"(",
"rels_url",
")",
":",
"text",
"=",
"requests",
".",
"get",
"(",
"rels_url",
")",
".",
"text",
".",
"encode",
"(",
"'ascii'",
",",
"'ignore'",
")",
"xml",
"=",
"objectify",
".",
"fromstring",
"(",
"text",
")",
"iana_rels",
... | Fetches the IANA link relation registry | [
"Fetches",
"the",
"IANA",
"link",
"relation",
"registry"
] | 453b9de4e70e602009d3e3ffafcf77d23c8b07c5 | https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/scripts/generate_registry.py#L61-L82 |
49,750 | codeinn/vcs | vcs/utils/paths.py | get_dirs_for_path | def get_dirs_for_path(*paths):
"""
Returns list of directories, including intermediate.
"""
for path in paths:
head = path
while head:
head, tail = os.path.split(head)
if head:
yield head
else:
# We don't need to yield e... | python | def get_dirs_for_path(*paths):
"""
Returns list of directories, including intermediate.
"""
for path in paths:
head = path
while head:
head, tail = os.path.split(head)
if head:
yield head
else:
# We don't need to yield e... | [
"def",
"get_dirs_for_path",
"(",
"*",
"paths",
")",
":",
"for",
"path",
"in",
"paths",
":",
"head",
"=",
"path",
"while",
"head",
":",
"head",
",",
"tail",
"=",
"os",
".",
"path",
".",
"split",
"(",
"head",
")",
"if",
"head",
":",
"yield",
"head",
... | Returns list of directories, including intermediate. | [
"Returns",
"list",
"of",
"directories",
"including",
"intermediate",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/utils/paths.py#L6-L18 |
49,751 | dead-beef/markovchain | markovchain/storage/sqlite.py | SqliteStorage.get_tables | def get_tables(self):
"""Get all table names.
Returns
-------
`set` of `str`
"""
self.cursor.execute(
'SELECT name FROM sqlite_master WHERE type="table"'
)
return set(x[0] for x in self.cursor.fetchall()) | python | def get_tables(self):
"""Get all table names.
Returns
-------
`set` of `str`
"""
self.cursor.execute(
'SELECT name FROM sqlite_master WHERE type="table"'
)
return set(x[0] for x in self.cursor.fetchall()) | [
"def",
"get_tables",
"(",
"self",
")",
":",
"self",
".",
"cursor",
".",
"execute",
"(",
"'SELECT name FROM sqlite_master WHERE type=\"table\"'",
")",
"return",
"set",
"(",
"x",
"[",
"0",
"]",
"for",
"x",
"in",
"self",
".",
"cursor",
".",
"fetchall",
"(",
"... | Get all table names.
Returns
-------
`set` of `str` | [
"Get",
"all",
"table",
"names",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/sqlite.py#L126-L136 |
49,752 | dead-beef/markovchain | markovchain/storage/sqlite.py | SqliteStorage.get_node | def get_node(self, value):
"""Get node ID by value.
If a node with the specified value does not exist,
create it and return its ID.
Parameters
----------
value : `str`
Node value.
Returns
-------
`int`
Node ID.
""... | python | def get_node(self, value):
"""Get node ID by value.
If a node with the specified value does not exist,
create it and return its ID.
Parameters
----------
value : `str`
Node value.
Returns
-------
`int`
Node ID.
""... | [
"def",
"get_node",
"(",
"self",
",",
"value",
")",
":",
"while",
"True",
":",
"self",
".",
"cursor",
".",
"execute",
"(",
"'SELECT id FROM nodes WHERE value=?'",
",",
"(",
"value",
",",
")",
")",
"node",
"=",
"self",
".",
"cursor",
".",
"fetchone",
"(",
... | Get node ID by value.
If a node with the specified value does not exist,
create it and return its ID.
Parameters
----------
value : `str`
Node value.
Returns
-------
`int`
Node ID. | [
"Get",
"node",
"ID",
"by",
"value",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/sqlite.py#L138-L165 |
49,753 | dead-beef/markovchain | markovchain/storage/sqlite.py | SqliteStorage.update_main_table | def update_main_table(self):
"""Write generator settings to database.
"""
data = (json.dumps(self.settings),)
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS main (
settings TEXT NOT NULL DEFAULT "{}"
)
''')
self.cursor.execute('... | python | def update_main_table(self):
"""Write generator settings to database.
"""
data = (json.dumps(self.settings),)
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS main (
settings TEXT NOT NULL DEFAULT "{}"
)
''')
self.cursor.execute('... | [
"def",
"update_main_table",
"(",
"self",
")",
":",
"data",
"=",
"(",
"json",
".",
"dumps",
"(",
"self",
".",
"settings",
")",
",",
")",
"self",
".",
"cursor",
".",
"execute",
"(",
"'''\n CREATE TABLE IF NOT EXISTS main (\n settings TEXT NOT... | Write generator settings to database. | [
"Write",
"generator",
"settings",
"to",
"database",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/sqlite.py#L167-L180 |
49,754 | dead-beef/markovchain | markovchain/storage/sqlite.py | SqliteStorage.create_node_tables | def create_node_tables(self):
"""Create node and link tables if they don't exist.
"""
self.cursor.execute('PRAGMA foreign_keys=1')
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS datasets (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
key ... | python | def create_node_tables(self):
"""Create node and link tables if they don't exist.
"""
self.cursor.execute('PRAGMA foreign_keys=1')
self.cursor.execute('''
CREATE TABLE IF NOT EXISTS datasets (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
key ... | [
"def",
"create_node_tables",
"(",
"self",
")",
":",
"self",
".",
"cursor",
".",
"execute",
"(",
"'PRAGMA foreign_keys=1'",
")",
"self",
".",
"cursor",
".",
"execute",
"(",
"'''\n CREATE TABLE IF NOT EXISTS datasets (\n id INTEGER NOT NULL PRIMARY KEY... | Create node and link tables if they don't exist. | [
"Create",
"node",
"and",
"link",
"tables",
"if",
"they",
"don",
"t",
"exist",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/storage/sqlite.py#L182-L216 |
49,755 | codeinn/vcs | vcs/cli.py | ExecutionManager.get_argv_for_command | def get_argv_for_command(self):
"""
Returns stripped arguments that would be passed into the command.
"""
argv = [a for a in self.argv]
argv.insert(0, self.prog_name)
return argv | python | def get_argv_for_command(self):
"""
Returns stripped arguments that would be passed into the command.
"""
argv = [a for a in self.argv]
argv.insert(0, self.prog_name)
return argv | [
"def",
"get_argv_for_command",
"(",
"self",
")",
":",
"argv",
"=",
"[",
"a",
"for",
"a",
"in",
"self",
".",
"argv",
"]",
"argv",
".",
"insert",
"(",
"0",
",",
"self",
".",
"prog_name",
")",
"return",
"argv"
] | Returns stripped arguments that would be passed into the command. | [
"Returns",
"stripped",
"arguments",
"that",
"would",
"be",
"passed",
"into",
"the",
"command",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L71-L77 |
49,756 | codeinn/vcs | vcs/cli.py | ExecutionManager.execute | def execute(self):
"""
Executes whole process of parsing and running command.
"""
self.autocomplete()
if len(self.argv):
cmd = self.argv[0]
cmd_argv = self.get_argv_for_command()
self.run_command(cmd, cmd_argv)
else:
self.sh... | python | def execute(self):
"""
Executes whole process of parsing and running command.
"""
self.autocomplete()
if len(self.argv):
cmd = self.argv[0]
cmd_argv = self.get_argv_for_command()
self.run_command(cmd, cmd_argv)
else:
self.sh... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"autocomplete",
"(",
")",
"if",
"len",
"(",
"self",
".",
"argv",
")",
":",
"cmd",
"=",
"self",
".",
"argv",
"[",
"0",
"]",
"cmd_argv",
"=",
"self",
".",
"get_argv_for_command",
"(",
")",
"self",... | Executes whole process of parsing and running command. | [
"Executes",
"whole",
"process",
"of",
"parsing",
"and",
"running",
"command",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L79-L89 |
49,757 | codeinn/vcs | vcs/cli.py | ExecutionManager.get_command_class | def get_command_class(self, cmd):
"""
Returns command class from the registry for a given ``cmd``.
:param cmd: command to run (key at the registry)
"""
try:
cmdpath = self.registry[cmd]
except KeyError:
raise CommandError("No such command %r" % cm... | python | def get_command_class(self, cmd):
"""
Returns command class from the registry for a given ``cmd``.
:param cmd: command to run (key at the registry)
"""
try:
cmdpath = self.registry[cmd]
except KeyError:
raise CommandError("No such command %r" % cm... | [
"def",
"get_command_class",
"(",
"self",
",",
"cmd",
")",
":",
"try",
":",
"cmdpath",
"=",
"self",
".",
"registry",
"[",
"cmd",
"]",
"except",
"KeyError",
":",
"raise",
"CommandError",
"(",
"\"No such command %r\"",
"%",
"cmd",
")",
"if",
"isinstance",
"("... | Returns command class from the registry for a given ``cmd``.
:param cmd: command to run (key at the registry) | [
"Returns",
"command",
"class",
"from",
"the",
"registry",
"for",
"a",
"given",
"cmd",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L108-L122 |
49,758 | codeinn/vcs | vcs/cli.py | ExecutionManager.run_command | def run_command(self, cmd, argv):
"""
Runs command.
:param cmd: command to run (key at the registry)
:param argv: arguments passed to the command
"""
try:
Command = self.get_command_class(cmd)
except CommandError, e:
self.stderr.write(str(... | python | def run_command(self, cmd, argv):
"""
Runs command.
:param cmd: command to run (key at the registry)
:param argv: arguments passed to the command
"""
try:
Command = self.get_command_class(cmd)
except CommandError, e:
self.stderr.write(str(... | [
"def",
"run_command",
"(",
"self",
",",
"cmd",
",",
"argv",
")",
":",
"try",
":",
"Command",
"=",
"self",
".",
"get_command_class",
"(",
"cmd",
")",
"except",
"CommandError",
",",
"e",
":",
"self",
".",
"stderr",
".",
"write",
"(",
"str",
"(",
"e",
... | Runs command.
:param cmd: command to run (key at the registry)
:param argv: arguments passed to the command | [
"Runs",
"command",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L133-L147 |
49,759 | codeinn/vcs | vcs/cli.py | ExecutionManager.show_help | def show_help(self):
"""
Prints help text about available commands.
"""
output = [
'Usage %s subcommand [options] [args]' % self.prog_name,
'',
'Available commands:',
'',
]
for cmd in self.get_commands():
output.... | python | def show_help(self):
"""
Prints help text about available commands.
"""
output = [
'Usage %s subcommand [options] [args]' % self.prog_name,
'',
'Available commands:',
'',
]
for cmd in self.get_commands():
output.... | [
"def",
"show_help",
"(",
"self",
")",
":",
"output",
"=",
"[",
"'Usage %s subcommand [options] [args]'",
"%",
"self",
".",
"prog_name",
",",
"''",
",",
"'Available commands:'",
",",
"''",
",",
"]",
"for",
"cmd",
"in",
"self",
".",
"get_commands",
"(",
")",
... | Prints help text about available commands. | [
"Prints",
"help",
"text",
"about",
"available",
"commands",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L149-L162 |
49,760 | codeinn/vcs | vcs/cli.py | BaseCommand.get_parser | def get_parser(self, prog_name, subcommand):
"""
Returns parser for given ``prog_name`` and ``subcommand``.
:param prog_name: vcs main script name
:param subcommand: command name
"""
parser = OptionParser(
prog=prog_name,
usage=self.usage(subcomma... | python | def get_parser(self, prog_name, subcommand):
"""
Returns parser for given ``prog_name`` and ``subcommand``.
:param prog_name: vcs main script name
:param subcommand: command name
"""
parser = OptionParser(
prog=prog_name,
usage=self.usage(subcomma... | [
"def",
"get_parser",
"(",
"self",
",",
"prog_name",
",",
"subcommand",
")",
":",
"parser",
"=",
"OptionParser",
"(",
"prog",
"=",
"prog_name",
",",
"usage",
"=",
"self",
".",
"usage",
"(",
"subcommand",
")",
",",
"version",
"=",
"self",
".",
"get_version... | Returns parser for given ``prog_name`` and ``subcommand``.
:param prog_name: vcs main script name
:param subcommand: command name | [
"Returns",
"parser",
"for",
"given",
"prog_name",
"and",
"subcommand",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L203-L215 |
49,761 | codeinn/vcs | vcs/cli.py | BaseCommand.print_help | def print_help(self, prog_name, subcommand):
"""
Prints parser's help.
:param prog_name: vcs main script name
:param subcommand: command name
"""
parser = self.get_parser(prog_name, subcommand)
parser.print_help() | python | def print_help(self, prog_name, subcommand):
"""
Prints parser's help.
:param prog_name: vcs main script name
:param subcommand: command name
"""
parser = self.get_parser(prog_name, subcommand)
parser.print_help() | [
"def",
"print_help",
"(",
"self",
",",
"prog_name",
",",
"subcommand",
")",
":",
"parser",
"=",
"self",
".",
"get_parser",
"(",
"prog_name",
",",
"subcommand",
")",
"parser",
".",
"print_help",
"(",
")"
] | Prints parser's help.
:param prog_name: vcs main script name
:param subcommand: command name | [
"Prints",
"parser",
"s",
"help",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L217-L225 |
49,762 | codeinn/vcs | vcs/cli.py | BaseCommand.run_from_argv | def run_from_argv(self, argv):
"""
Runs command for given arguments.
:param argv: arguments
"""
parser = self.get_parser(argv[0], argv[1])
options, args = parser.parse_args(argv[2:])
self.execute(*args, **options.__dict__) | python | def run_from_argv(self, argv):
"""
Runs command for given arguments.
:param argv: arguments
"""
parser = self.get_parser(argv[0], argv[1])
options, args = parser.parse_args(argv[2:])
self.execute(*args, **options.__dict__) | [
"def",
"run_from_argv",
"(",
"self",
",",
"argv",
")",
":",
"parser",
"=",
"self",
".",
"get_parser",
"(",
"argv",
"[",
"0",
"]",
",",
"argv",
"[",
"1",
"]",
")",
"options",
",",
"args",
"=",
"parser",
".",
"parse_args",
"(",
"argv",
"[",
"2",
":... | Runs command for given arguments.
:param argv: arguments | [
"Runs",
"command",
"for",
"given",
"arguments",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L227-L235 |
49,763 | codeinn/vcs | vcs/cli.py | BaseCommand.execute | def execute(self, *args, **options):
"""
Executes whole process of parsing arguments, running command and
trying to catch errors.
"""
try:
self.handle(*args, **options)
except CommandError, e:
if options['debug']:
try:
... | python | def execute(self, *args, **options):
"""
Executes whole process of parsing arguments, running command and
trying to catch errors.
"""
try:
self.handle(*args, **options)
except CommandError, e:
if options['debug']:
try:
... | [
"def",
"execute",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"try",
":",
"self",
".",
"handle",
"(",
"*",
"args",
",",
"*",
"*",
"options",
")",
"except",
"CommandError",
",",
"e",
":",
"if",
"options",
"[",
"'debug'",
"]"... | Executes whole process of parsing arguments, running command and
trying to catch errors. | [
"Executes",
"whole",
"process",
"of",
"parsing",
"arguments",
"running",
"command",
"and",
"trying",
"to",
"catch",
"errors",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L237-L275 |
49,764 | codeinn/vcs | vcs/cli.py | RepositoryCommand.handle | def handle(self, *args, **options):
"""
Runs ``pre_process``, ``handle_repo`` and ``post_process`` methods, in
that order.
"""
self.pre_process(self.repo)
self.handle_repo(self.repo, *args, **options)
self.post_process(self.repo, **options) | python | def handle(self, *args, **options):
"""
Runs ``pre_process``, ``handle_repo`` and ``post_process`` methods, in
that order.
"""
self.pre_process(self.repo)
self.handle_repo(self.repo, *args, **options)
self.post_process(self.repo, **options) | [
"def",
"handle",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"pre_process",
"(",
"self",
".",
"repo",
")",
"self",
".",
"handle_repo",
"(",
"self",
".",
"repo",
",",
"*",
"args",
",",
"*",
"*",
"options",
")",
... | Runs ``pre_process``, ``handle_repo`` and ``post_process`` methods, in
that order. | [
"Runs",
"pre_process",
"handle_repo",
"and",
"post_process",
"methods",
"in",
"that",
"order",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L319-L326 |
49,765 | codeinn/vcs | vcs/cli.py | ChangesetCommand.get_changesets | def get_changesets(self, repo, **options):
"""
Returns generator of changesets from given ``repo`` for given
``options``.
:param repo: repository instance. Same as ``self.repo``.
**Available options**
* ``start_date``: only changesets not older than this parameter woul... | python | def get_changesets(self, repo, **options):
"""
Returns generator of changesets from given ``repo`` for given
``options``.
:param repo: repository instance. Same as ``self.repo``.
**Available options**
* ``start_date``: only changesets not older than this parameter woul... | [
"def",
"get_changesets",
"(",
"self",
",",
"repo",
",",
"*",
"*",
"options",
")",
":",
"branch_name",
"=",
"None",
"if",
"not",
"options",
".",
"get",
"(",
"'all'",
",",
"None",
")",
":",
"branch_name",
"=",
"options",
".",
"get",
"(",
"'branch'",
")... | Returns generator of changesets from given ``repo`` for given
``options``.
:param repo: repository instance. Same as ``self.repo``.
**Available options**
* ``start_date``: only changesets not older than this parameter would be
generated
* ``end_date``: only changeset... | [
"Returns",
"generator",
"of",
"changesets",
"from",
"given",
"repo",
"for",
"given",
"options",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L384-L434 |
49,766 | codeinn/vcs | vcs/cli.py | ChangesetCommand.get_progressbar | def get_progressbar(self, total, **options):
"""
Returns progress bar instance for a given ``total`` number of clicks
it should do.
"""
progressbar = ColoredProgressBar(total)
progressbar.steps_label = 'Commit'
progressbar.elements += ['eta', 'time']
retur... | python | def get_progressbar(self, total, **options):
"""
Returns progress bar instance for a given ``total`` number of clicks
it should do.
"""
progressbar = ColoredProgressBar(total)
progressbar.steps_label = 'Commit'
progressbar.elements += ['eta', 'time']
retur... | [
"def",
"get_progressbar",
"(",
"self",
",",
"total",
",",
"*",
"*",
"options",
")",
":",
"progressbar",
"=",
"ColoredProgressBar",
"(",
"total",
")",
"progressbar",
".",
"steps_label",
"=",
"'Commit'",
"progressbar",
".",
"elements",
"+=",
"[",
"'eta'",
",",... | Returns progress bar instance for a given ``total`` number of clicks
it should do. | [
"Returns",
"progress",
"bar",
"instance",
"for",
"a",
"given",
"total",
"number",
"of",
"clicks",
"it",
"should",
"do",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L461-L469 |
49,767 | codeinn/vcs | vcs/cli.py | SingleChangesetCommand.get_changeset | def get_changeset(self, **options):
"""
Returns changeset for given ``options``.
"""
cid = options.get('changeset_id', None)
return self.repo.get_changeset(cid) | python | def get_changeset(self, **options):
"""
Returns changeset for given ``options``.
"""
cid = options.get('changeset_id', None)
return self.repo.get_changeset(cid) | [
"def",
"get_changeset",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"cid",
"=",
"options",
".",
"get",
"(",
"'changeset_id'",
",",
"None",
")",
"return",
"self",
".",
"repo",
".",
"get_changeset",
"(",
"cid",
")"
] | Returns changeset for given ``options``. | [
"Returns",
"changeset",
"for",
"given",
"options",
"."
] | e6cd94188e9c36d273411bf3adc0584ac6ab92a0 | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/cli.py#L496-L501 |
49,768 | dead-beef/markovchain | markovchain/cli/util.py | pprint | def pprint(data, indent=0, end='\n'):
"""Pretty print JSON data.
Parameters
----------
data
JSON data.
indent : `int`, optional
Indent level in characters (default: 0).
end : `str`, optional
String to print after the data (default: '\\\\n').
"""
if isinstance(dat... | python | def pprint(data, indent=0, end='\n'):
"""Pretty print JSON data.
Parameters
----------
data
JSON data.
indent : `int`, optional
Indent level in characters (default: 0).
end : `str`, optional
String to print after the data (default: '\\\\n').
"""
if isinstance(dat... | [
"def",
"pprint",
"(",
"data",
",",
"indent",
"=",
"0",
",",
"end",
"=",
"'\\n'",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"print",
"(",
"'{'",
")",
"new_indent",
"=",
"indent",
"+",
"4",
"space",
"=",
"' '",
"*",
"new_ind... | Pretty print JSON data.
Parameters
----------
data
JSON data.
indent : `int`, optional
Indent level in characters (default: 0).
end : `str`, optional
String to print after the data (default: '\\\\n'). | [
"Pretty",
"print",
"JSON",
"data",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L81-L116 |
49,769 | dead-beef/markovchain | markovchain/cli/util.py | load | def load(cls, fname, args):
"""Load a generator.
Parameters
----------
cls : `type`
Generator class.
fname : `str`
Input file path.
args : `argparse.Namespace`
Command arguments.
Returns
-------
`cls`
"""
if args.type == JSON:
if fname.endsw... | python | def load(cls, fname, args):
"""Load a generator.
Parameters
----------
cls : `type`
Generator class.
fname : `str`
Input file path.
args : `argparse.Namespace`
Command arguments.
Returns
-------
`cls`
"""
if args.type == JSON:
if fname.endsw... | [
"def",
"load",
"(",
"cls",
",",
"fname",
",",
"args",
")",
":",
"if",
"args",
".",
"type",
"==",
"JSON",
":",
"if",
"fname",
".",
"endswith",
"(",
"'.bz2'",
")",
":",
"open_",
"=",
"bz2",
".",
"open",
"else",
":",
"open_",
"=",
"open",
"if",
"a... | Load a generator.
Parameters
----------
cls : `type`
Generator class.
fname : `str`
Input file path.
args : `argparse.Namespace`
Command arguments.
Returns
-------
`cls` | [
"Load",
"a",
"generator",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L118-L152 |
49,770 | dead-beef/markovchain | markovchain/cli/util.py | save | def save(markov, fname, args):
"""Save a generator.
Parameters
----------
markov : `markovchain.Markov`
Generator to save.
fname : `str`
Output file path.
args : `argparse.Namespace`
Command arguments.
"""
if isinstance(markov.storage, JsonStorage):
if fn... | python | def save(markov, fname, args):
"""Save a generator.
Parameters
----------
markov : `markovchain.Markov`
Generator to save.
fname : `str`
Output file path.
args : `argparse.Namespace`
Command arguments.
"""
if isinstance(markov.storage, JsonStorage):
if fn... | [
"def",
"save",
"(",
"markov",
",",
"fname",
",",
"args",
")",
":",
"if",
"isinstance",
"(",
"markov",
".",
"storage",
",",
"JsonStorage",
")",
":",
"if",
"fname",
"is",
"None",
":",
"markov",
".",
"save",
"(",
"sys",
".",
"stdout",
")",
"else",
":"... | Save a generator.
Parameters
----------
markov : `markovchain.Markov`
Generator to save.
fname : `str`
Output file path.
args : `argparse.Namespace`
Command arguments. | [
"Save",
"a",
"generator",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L154-L179 |
49,771 | dead-beef/markovchain | markovchain/cli/util.py | save_image | def save_image(img, fname):
"""Save an image.
Parameters
----------
img : `PIL.Image`
Image to save.
fname : `str`
File path.
"""
_, ext = os.path.splitext(fname)
ext = ext[1:] or 'png'
with open(fname, 'wb') as fp:
img.save(fp, ext) | python | def save_image(img, fname):
"""Save an image.
Parameters
----------
img : `PIL.Image`
Image to save.
fname : `str`
File path.
"""
_, ext = os.path.splitext(fname)
ext = ext[1:] or 'png'
with open(fname, 'wb') as fp:
img.save(fp, ext) | [
"def",
"save_image",
"(",
"img",
",",
"fname",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"fname",
")",
"ext",
"=",
"ext",
"[",
"1",
":",
"]",
"or",
"'png'",
"with",
"open",
"(",
"fname",
",",
"'wb'",
")",
"as",
... | Save an image.
Parameters
----------
img : `PIL.Image`
Image to save.
fname : `str`
File path. | [
"Save",
"an",
"image",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L181-L194 |
49,772 | dead-beef/markovchain | markovchain/cli/util.py | set_args | def set_args(args):
"""Set computed command arguments.
Parameters
----------
args : `argparse.Namespace`
Command arguments.
base : `iterable` of `type`
Generator mixins.
Raises
------
ValueError
If output file is stdout and progress bars are enabled.
"""
... | python | def set_args(args):
"""Set computed command arguments.
Parameters
----------
args : `argparse.Namespace`
Command arguments.
base : `iterable` of `type`
Generator mixins.
Raises
------
ValueError
If output file is stdout and progress bars are enabled.
"""
... | [
"def",
"set_args",
"(",
"args",
")",
":",
"try",
":",
"if",
"args",
".",
"output",
"is",
"sys",
".",
"stdout",
"and",
"args",
".",
"progress",
":",
"raise",
"ValueError",
"(",
"'args.output is stdout and args.progress'",
")",
"except",
"AttributeError",
":",
... | Set computed command arguments.
Parameters
----------
args : `argparse.Namespace`
Command arguments.
base : `iterable` of `type`
Generator mixins.
Raises
------
ValueError
If output file is stdout and progress bars are enabled. | [
"Set",
"computed",
"command",
"arguments",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L196-L240 |
49,773 | dead-beef/markovchain | markovchain/cli/util.py | check_output_format | def check_output_format(fmt, nfiles):
"""Validate file format string.
Parameters
----------
fmt : `str`
File format string.
nfiles : `int`
Number of files.
Raises
------
ValueError
If nfiles < 0 or format string is invalid.
"""
if nfiles < 0:
rai... | python | def check_output_format(fmt, nfiles):
"""Validate file format string.
Parameters
----------
fmt : `str`
File format string.
nfiles : `int`
Number of files.
Raises
------
ValueError
If nfiles < 0 or format string is invalid.
"""
if nfiles < 0:
rai... | [
"def",
"check_output_format",
"(",
"fmt",
",",
"nfiles",
")",
":",
"if",
"nfiles",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'Invalid file count: '",
"+",
"str",
"(",
"nfiles",
")",
")",
"if",
"nfiles",
"==",
"1",
":",
"return",
"try",
":",
"fmt",
"%... | Validate file format string.
Parameters
----------
fmt : `str`
File format string.
nfiles : `int`
Number of files.
Raises
------
ValueError
If nfiles < 0 or format string is invalid. | [
"Validate",
"file",
"format",
"string",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L242-L266 |
49,774 | dead-beef/markovchain | markovchain/cli/util.py | infiles | def infiles(fnames, progress, leave=True):
"""Get input file paths.
Parameters
----------
fnames : `list` of `str`
File paths.
progress : `bool`
Show progress bar.
leave : `bool`, optional
Leave progress bar (default: True).
Returns
-------
`generator` of `s... | python | def infiles(fnames, progress, leave=True):
"""Get input file paths.
Parameters
----------
fnames : `list` of `str`
File paths.
progress : `bool`
Show progress bar.
leave : `bool`, optional
Leave progress bar (default: True).
Returns
-------
`generator` of `s... | [
"def",
"infiles",
"(",
"fnames",
",",
"progress",
",",
"leave",
"=",
"True",
")",
":",
"if",
"progress",
":",
"if",
"fnames",
":",
"fnames",
"=",
"tqdm",
"(",
"fnames",
",",
"desc",
"=",
"'Loading'",
",",
"unit",
"=",
"'file'",
",",
"bar_format",
"="... | Get input file paths.
Parameters
----------
fnames : `list` of `str`
File paths.
progress : `bool`
Show progress bar.
leave : `bool`, optional
Leave progress bar (default: True).
Returns
-------
`generator` of `str`
Input file paths. | [
"Get",
"input",
"file",
"paths",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L269-L297 |
49,775 | dead-beef/markovchain | markovchain/cli/util.py | cmd_settings | def cmd_settings(args):
"""Print generator settings.
Parameters
----------
args : `argparse.Namespace`
Command arguments.
"""
if args.type == SQLITE:
storage = SqliteStorage
else:
storage = JsonStorage
storage = storage.load(args.state)
data = storage.setting... | python | def cmd_settings(args):
"""Print generator settings.
Parameters
----------
args : `argparse.Namespace`
Command arguments.
"""
if args.type == SQLITE:
storage = SqliteStorage
else:
storage = JsonStorage
storage = storage.load(args.state)
data = storage.setting... | [
"def",
"cmd_settings",
"(",
"args",
")",
":",
"if",
"args",
".",
"type",
"==",
"SQLITE",
":",
"storage",
"=",
"SqliteStorage",
"else",
":",
"storage",
"=",
"JsonStorage",
"storage",
"=",
"storage",
".",
"load",
"(",
"args",
".",
"state",
")",
"data",
"... | Print generator settings.
Parameters
----------
args : `argparse.Namespace`
Command arguments. | [
"Print",
"generator",
"settings",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L342-L360 |
49,776 | dead-beef/markovchain | markovchain/cli/util.py | NoProgressBar.print_warning | def print_warning(cls):
"""Print a missing progress bar warning if it was not printed.
"""
if not cls.warning:
cls.warning = True
print('Can\'t create progress bar:', str(TQDM_IMPORT_ERROR),
file=sys.stderr) | python | def print_warning(cls):
"""Print a missing progress bar warning if it was not printed.
"""
if not cls.warning:
cls.warning = True
print('Can\'t create progress bar:', str(TQDM_IMPORT_ERROR),
file=sys.stderr) | [
"def",
"print_warning",
"(",
"cls",
")",
":",
"if",
"not",
"cls",
".",
"warning",
":",
"cls",
".",
"warning",
"=",
"True",
"print",
"(",
"'Can\\'t create progress bar:'",
",",
"str",
"(",
"TQDM_IMPORT_ERROR",
")",
",",
"file",
"=",
"sys",
".",
"stderr",
... | Print a missing progress bar warning if it was not printed. | [
"Print",
"a",
"missing",
"progress",
"bar",
"warning",
"if",
"it",
"was",
"not",
"printed",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L42-L48 |
49,777 | dead-beef/markovchain | markovchain/base.py | Markov.data | def data(self, data, part=False, dataset=''):
"""Parse data and update links.
Parameters
----------
data
Data to parse.
part : `bool`, optional
True if data is partial (default: `False`).
dataset : `str`, optional
Dataset key prefix (d... | python | def data(self, data, part=False, dataset=''):
"""Parse data and update links.
Parameters
----------
data
Data to parse.
part : `bool`, optional
True if data is partial (default: `False`).
dataset : `str`, optional
Dataset key prefix (d... | [
"def",
"data",
"(",
"self",
",",
"data",
",",
"part",
"=",
"False",
",",
"dataset",
"=",
"''",
")",
":",
"links",
"=",
"self",
".",
"parser",
"(",
"self",
".",
"scanner",
"(",
"data",
",",
"part",
")",
",",
"part",
",",
"dataset",
")",
"self",
... | Parse data and update links.
Parameters
----------
data
Data to parse.
part : `bool`, optional
True if data is partial (default: `False`).
dataset : `str`, optional
Dataset key prefix (default: ''). | [
"Parse",
"data",
"and",
"update",
"links",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/base.py#L56-L69 |
49,778 | dead-beef/markovchain | markovchain/base.py | Markov.get_settings_json | def get_settings_json(self):
"""Convert generator settings to JSON.
Returns
-------
`dict`
JSON data.
"""
return {
'scanner': None if self.scanner is None else self.scanner.save(),
'parser': None if self.parser is None else self.parser... | python | def get_settings_json(self):
"""Convert generator settings to JSON.
Returns
-------
`dict`
JSON data.
"""
return {
'scanner': None if self.scanner is None else self.scanner.save(),
'parser': None if self.parser is None else self.parser... | [
"def",
"get_settings_json",
"(",
"self",
")",
":",
"return",
"{",
"'scanner'",
":",
"None",
"if",
"self",
".",
"scanner",
"is",
"None",
"else",
"self",
".",
"scanner",
".",
"save",
"(",
")",
",",
"'parser'",
":",
"None",
"if",
"self",
".",
"parser",
... | Convert generator settings to JSON.
Returns
-------
`dict`
JSON data. | [
"Convert",
"generator",
"settings",
"to",
"JSON",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/base.py#L102-L113 |
49,779 | dead-beef/markovchain | markovchain/base.py | Markov.from_storage | def from_storage(cls, storage):
"""Load from storage.
Parameters
----------
storage : `markovchain.storage.Storage`
Returns
-------
`markovchain.Markov`
"""
args = dict(storage.settings.get('markov', {}))
args['storage'] = storage
... | python | def from_storage(cls, storage):
"""Load from storage.
Parameters
----------
storage : `markovchain.storage.Storage`
Returns
-------
`markovchain.Markov`
"""
args = dict(storage.settings.get('markov', {}))
args['storage'] = storage
... | [
"def",
"from_storage",
"(",
"cls",
",",
"storage",
")",
":",
"args",
"=",
"dict",
"(",
"storage",
".",
"settings",
".",
"get",
"(",
"'markov'",
",",
"{",
"}",
")",
")",
"args",
"[",
"'storage'",
"]",
"=",
"storage",
"return",
"cls",
"(",
"*",
"*",
... | Load from storage.
Parameters
----------
storage : `markovchain.storage.Storage`
Returns
-------
`markovchain.Markov` | [
"Load",
"from",
"storage",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/base.py#L132-L145 |
49,780 | dead-beef/markovchain | markovchain/base.py | Markov.from_file | def from_file(cls, fp, storage=None):
"""Load from file.
Parameters
----------
fp : `str` or `file`
File or path.
storage : `type`, optional
Storage class (default: cls.DEFAULT_STORAGE)
Returns
-------
`markovchain.Markov`
... | python | def from_file(cls, fp, storage=None):
"""Load from file.
Parameters
----------
fp : `str` or `file`
File or path.
storage : `type`, optional
Storage class (default: cls.DEFAULT_STORAGE)
Returns
-------
`markovchain.Markov`
... | [
"def",
"from_file",
"(",
"cls",
",",
"fp",
",",
"storage",
"=",
"None",
")",
":",
"if",
"storage",
"is",
"None",
":",
"storage",
"=",
"cls",
".",
"DEFAULT_STORAGE",
"return",
"cls",
".",
"from_storage",
"(",
"storage",
".",
"load",
"(",
"fp",
")",
")... | Load from file.
Parameters
----------
fp : `str` or `file`
File or path.
storage : `type`, optional
Storage class (default: cls.DEFAULT_STORAGE)
Returns
-------
`markovchain.Markov` | [
"Load",
"from",
"file",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/base.py#L148-L164 |
49,781 | dead-beef/markovchain | markovchain/base.py | Markov.from_settings | def from_settings(cls, settings=None, storage=None):
"""Create from settings.
Parameters
----------
settings : `dict`, optional
Settings (default: None).
storage : `type`, optional
Storage class (default: cls.DEFAULT_STORAGE)
Returns
----... | python | def from_settings(cls, settings=None, storage=None):
"""Create from settings.
Parameters
----------
settings : `dict`, optional
Settings (default: None).
storage : `type`, optional
Storage class (default: cls.DEFAULT_STORAGE)
Returns
----... | [
"def",
"from_settings",
"(",
"cls",
",",
"settings",
"=",
"None",
",",
"storage",
"=",
"None",
")",
":",
"if",
"storage",
"is",
"None",
":",
"storage",
"=",
"cls",
".",
"DEFAULT_STORAGE",
"return",
"cls",
".",
"from_storage",
"(",
"storage",
"(",
"settin... | Create from settings.
Parameters
----------
settings : `dict`, optional
Settings (default: None).
storage : `type`, optional
Storage class (default: cls.DEFAULT_STORAGE)
Returns
-------
`markovchain.Markov` | [
"Create",
"from",
"settings",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/base.py#L167-L183 |
49,782 | dead-beef/markovchain | markovchain/image/scanner.py | ImageScanner.input | def input(self, img):
"""Resize input image if necessary.
Parameters
----------
img : `PIL.Image`
Input image.
Raises
------
ValueError
If input image is too small.
Returns
-------
`PIL.Image`
Resized ... | python | def input(self, img):
"""Resize input image if necessary.
Parameters
----------
img : `PIL.Image`
Input image.
Raises
------
ValueError
If input image is too small.
Returns
-------
`PIL.Image`
Resized ... | [
"def",
"input",
"(",
"self",
",",
"img",
")",
":",
"img_width",
",",
"img_height",
"=",
"img",
".",
"size",
"if",
"self",
".",
"resize",
":",
"width",
",",
"height",
"=",
"self",
".",
"resize",
"scale",
"=",
"min",
"(",
"width",
"/",
"img_width",
"... | Resize input image if necessary.
Parameters
----------
img : `PIL.Image`
Input image.
Raises
------
ValueError
If input image is too small.
Returns
-------
`PIL.Image`
Resized image or input image. | [
"Resize",
"input",
"image",
"if",
"necessary",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/image/scanner.py#L130-L161 |
49,783 | dead-beef/markovchain | markovchain/image/scanner.py | ImageScanner.level | def level(self, img, level):
"""Get image level.
Parameters
----------
img : `PIL.Image`
Input image.
level : `int`
Level number.
Returns
-------
`PIL.Image`
Converted image.
"""
if level < self.levels ... | python | def level(self, img, level):
"""Get image level.
Parameters
----------
img : `PIL.Image`
Input image.
level : `int`
Level number.
Returns
-------
`PIL.Image`
Converted image.
"""
if level < self.levels ... | [
"def",
"level",
"(",
"self",
",",
"img",
",",
"level",
")",
":",
"if",
"level",
"<",
"self",
".",
"levels",
"-",
"1",
":",
"width",
",",
"height",
"=",
"img",
".",
"size",
"scale",
"=",
"reduce",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
"*",
"... | Get image level.
Parameters
----------
img : `PIL.Image`
Input image.
level : `int`
Level number.
Returns
-------
`PIL.Image`
Converted image. | [
"Get",
"image",
"level",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/image/scanner.py#L163-L183 |
49,784 | dead-beef/markovchain | markovchain/image/scanner.py | ImageScanner._scan_level | def _scan_level(self, level, prev, img):
"""Scan a level.
Parameters
----------
level : `int`
Level number.
prev : `PIL.Image` or None
Previous level image or None if level == 0.
img : `PIL.Image`
Current level image.
Returns
... | python | def _scan_level(self, level, prev, img):
"""Scan a level.
Parameters
----------
level : `int`
Level number.
prev : `PIL.Image` or None
Previous level image or None if level == 0.
img : `PIL.Image`
Current level image.
Returns
... | [
"def",
"_scan_level",
"(",
"self",
",",
"level",
",",
"prev",
",",
"img",
")",
":",
"if",
"level",
"==",
"0",
":",
"width",
",",
"height",
"=",
"img",
".",
"size",
"else",
":",
"width",
",",
"height",
"=",
"prev",
".",
"size",
"tr",
"=",
"self",
... | Scan a level.
Parameters
----------
level : `int`
Level number.
prev : `PIL.Image` or None
Previous level image or None if level == 0.
img : `PIL.Image`
Current level image.
Returns
-------
`generator` of (`str` or `ma... | [
"Scan",
"a",
"level",
"."
] | 9bd10b2f01089341c4a875a0fa569d50caba22c7 | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/image/scanner.py#L185-L231 |
49,785 | NICTA/revrand | revrand/metrics.py | smse | def smse(y_true, y_pred):
"""
Standardised mean squared error.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
Returns
-------
float:
SMSE of predictions vs truth (scalar)
Example
-------
... | python | def smse(y_true, y_pred):
"""
Standardised mean squared error.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
Returns
-------
float:
SMSE of predictions vs truth (scalar)
Example
-------
... | [
"def",
"smse",
"(",
"y_true",
",",
"y_pred",
")",
":",
"N",
"=",
"y_true",
".",
"shape",
"[",
"0",
"]",
"return",
"(",
"(",
"y_true",
"-",
"y_pred",
")",
"**",
"2",
")",
".",
"sum",
"(",
")",
"/",
"(",
"N",
"*",
"y_true",
".",
"var",
"(",
"... | Standardised mean squared error.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
Returns
-------
float:
SMSE of predictions vs truth (scalar)
Example
-------
>>> y_true = np.random.randn(100)
... | [
"Standardised",
"mean",
"squared",
"error",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/metrics.py#L9-L35 |
49,786 | NICTA/revrand | revrand/metrics.py | mll | def mll(y_true, y_pred, y_var):
"""
Mean log loss under a Gaussian distribution.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
y_var: float or ndarray
predicted variances
Returns
-------
float:
... | python | def mll(y_true, y_pred, y_var):
"""
Mean log loss under a Gaussian distribution.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
y_var: float or ndarray
predicted variances
Returns
-------
float:
... | [
"def",
"mll",
"(",
"y_true",
",",
"y_pred",
",",
"y_var",
")",
":",
"return",
"-",
"norm",
".",
"logpdf",
"(",
"y_true",
",",
"loc",
"=",
"y_pred",
",",
"scale",
"=",
"np",
".",
"sqrt",
"(",
"y_var",
")",
")",
".",
"mean",
"(",
")"
] | Mean log loss under a Gaussian distribution.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
y_var: float or ndarray
predicted variances
Returns
-------
float:
The mean negative log loss (negative ... | [
"Mean",
"log",
"loss",
"under",
"a",
"Gaussian",
"distribution",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/metrics.py#L38-L66 |
49,787 | NICTA/revrand | revrand/metrics.py | msll | def msll(y_true, y_pred, y_var, y_train):
"""
Mean standardised log loss under a Gaussian distribution.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
y_var: float or ndarray
predicted variances
y_train: n... | python | def msll(y_true, y_pred, y_var, y_train):
"""
Mean standardised log loss under a Gaussian distribution.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
y_var: float or ndarray
predicted variances
y_train: n... | [
"def",
"msll",
"(",
"y_true",
",",
"y_pred",
",",
"y_var",
",",
"y_train",
")",
":",
"var",
"=",
"y_train",
".",
"var",
"(",
")",
"mu",
"=",
"y_train",
".",
"mean",
"(",
")",
"ll_naive",
"=",
"norm",
".",
"logpdf",
"(",
"y_true",
",",
"loc",
"=",... | Mean standardised log loss under a Gaussian distribution.
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
y_var: float or ndarray
predicted variances
y_train: ndarray
vector of *training* targets by which t... | [
"Mean",
"standardised",
"log",
"loss",
"under",
"a",
"Gaussian",
"distribution",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/metrics.py#L69-L104 |
49,788 | NICTA/revrand | revrand/metrics.py | lins_ccc | def lins_ccc(y_true, y_pred):
"""
Lin's Concordance Correlation Coefficient.
See https://en.wikipedia.org/wiki/Concordance_correlation_coefficient
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
Returns
-----... | python | def lins_ccc(y_true, y_pred):
"""
Lin's Concordance Correlation Coefficient.
See https://en.wikipedia.org/wiki/Concordance_correlation_coefficient
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
Returns
-----... | [
"def",
"lins_ccc",
"(",
"y_true",
",",
"y_pred",
")",
":",
"t",
"=",
"y_true",
".",
"mean",
"(",
")",
"p",
"=",
"y_pred",
".",
"mean",
"(",
")",
"St",
"=",
"y_true",
".",
"var",
"(",
")",
"Sp",
"=",
"y_pred",
".",
"var",
"(",
")",
"Spt",
"=",... | Lin's Concordance Correlation Coefficient.
See https://en.wikipedia.org/wiki/Concordance_correlation_coefficient
Parameters
----------
y_true: ndarray
vector of true targets
y_pred: ndarray
vector of predicted targets
Returns
-------
float:
1.0 for a perfect ma... | [
"Lin",
"s",
"Concordance",
"Correlation",
"Coefficient",
"."
] | 4c1881b6c1772d2b988518e49dde954f165acfb6 | https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/metrics.py#L107-L141 |
49,789 | priestc/giotto | giotto/controllers/__init__.py | GiottoController.get_response | def get_response(self):
"""
High level function for getting a response. This is what the concrete
controller should call. Returns a controller specific response.
"""
last_good_request = self.request
middleware_result = None
try:
last_good_request, midd... | python | def get_response(self):
"""
High level function for getting a response. This is what the concrete
controller should call. Returns a controller specific response.
"""
last_good_request = self.request
middleware_result = None
try:
last_good_request, midd... | [
"def",
"get_response",
"(",
"self",
")",
":",
"last_good_request",
"=",
"self",
".",
"request",
"middleware_result",
"=",
"None",
"try",
":",
"last_good_request",
",",
"middleware_result",
"=",
"self",
".",
"program",
".",
"execute_input_middleware_stream",
"(",
"... | High level function for getting a response. This is what the concrete
controller should call. Returns a controller specific response. | [
"High",
"level",
"function",
"for",
"getting",
"a",
"response",
".",
"This",
"is",
"what",
"the",
"concrete",
"controller",
"should",
"call",
".",
"Returns",
"a",
"controller",
"specific",
"response",
"."
] | d4c26380caefa7745bb27135e315de830f7254d3 | https://github.com/priestc/giotto/blob/d4c26380caefa7745bb27135e315de830f7254d3/giotto/controllers/__init__.py#L41-L68 |
49,790 | priestc/giotto | giotto/controllers/__init__.py | GiottoController.get_data_response | def get_data_response(self):
"""
Execute the model and view, and handle the cache.
Returns controller-agnostic response data.
"""
if self.middleware_interrupt_exc:
## the middleware raised an exception, re-raise it here so
## get_concrete_response (defined... | python | def get_data_response(self):
"""
Execute the model and view, and handle the cache.
Returns controller-agnostic response data.
"""
if self.middleware_interrupt_exc:
## the middleware raised an exception, re-raise it here so
## get_concrete_response (defined... | [
"def",
"get_data_response",
"(",
"self",
")",
":",
"if",
"self",
".",
"middleware_interrupt_exc",
":",
"## the middleware raised an exception, re-raise it here so",
"## get_concrete_response (defined in subclasses) can catch it.",
"raise",
"self",
".",
"middleware_interrupt_exc",
"... | Execute the model and view, and handle the cache.
Returns controller-agnostic response data. | [
"Execute",
"the",
"model",
"and",
"view",
"and",
"handle",
"the",
"cache",
".",
"Returns",
"controller",
"-",
"agnostic",
"response",
"data",
"."
] | d4c26380caefa7745bb27135e315de830f7254d3 | https://github.com/priestc/giotto/blob/d4c26380caefa7745bb27135e315de830f7254d3/giotto/controllers/__init__.py#L70-L108 |
49,791 | priestc/giotto | giotto/controllers/__init__.py | GiottoController.get_data_for_model | def get_data_for_model(self, args, kwargs):
"""
In comes args and kwargs expected for the model. Out comes the data from
this invocation that will go to the model.
In other words, this function does the "data negotiation" between the
controller and the model.
"""
... | python | def get_data_for_model(self, args, kwargs):
"""
In comes args and kwargs expected for the model. Out comes the data from
this invocation that will go to the model.
In other words, this function does the "data negotiation" between the
controller and the model.
"""
... | [
"def",
"get_data_for_model",
"(",
"self",
",",
"args",
",",
"kwargs",
")",
":",
"kwargs_from_invocation",
"=",
"self",
".",
"get_raw_data",
"(",
")",
"args_from_invocation",
"=",
"deque",
"(",
"self",
".",
"path_args",
")",
"defaults",
"=",
"kwargs",
"values",... | In comes args and kwargs expected for the model. Out comes the data from
this invocation that will go to the model.
In other words, this function does the "data negotiation" between the
controller and the model. | [
"In",
"comes",
"args",
"and",
"kwargs",
"expected",
"for",
"the",
"model",
".",
"Out",
"comes",
"the",
"data",
"from",
"this",
"invocation",
"that",
"will",
"go",
"to",
"the",
"model",
".",
"In",
"other",
"words",
"this",
"function",
"does",
"the",
"data... | d4c26380caefa7745bb27135e315de830f7254d3 | https://github.com/priestc/giotto/blob/d4c26380caefa7745bb27135e315de830f7254d3/giotto/controllers/__init__.py#L110-L167 |
49,792 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | _isInner | def _isInner(node):
"""
Determine whether the given node is, at any point in its syntactic
parentage, defined within a function.
@param node: The node to inspect.
@type node: L{logilab.astng.bases.NodeNG}
@return: a boolean indicating if the given node is defined as an inner
class or i... | python | def _isInner(node):
"""
Determine whether the given node is, at any point in its syntactic
parentage, defined within a function.
@param node: The node to inspect.
@type node: L{logilab.astng.bases.NodeNG}
@return: a boolean indicating if the given node is defined as an inner
class or i... | [
"def",
"_isInner",
"(",
"node",
")",
":",
"while",
"node",
":",
"node",
"=",
"node",
".",
"parent",
"if",
"isinstance",
"(",
"node",
",",
"scoped_nodes",
".",
"FunctionDef",
")",
":",
"return",
"True",
"return",
"False"
] | Determine whether the given node is, at any point in its syntactic
parentage, defined within a function.
@param node: The node to inspect.
@type node: L{logilab.astng.bases.NodeNG}
@return: a boolean indicating if the given node is defined as an inner
class or inner function. | [
"Determine",
"whether",
"the",
"given",
"node",
"is",
"at",
"any",
"point",
"in",
"its",
"syntactic",
"parentage",
"defined",
"within",
"a",
"function",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L20-L35 |
49,793 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | _getDecoratorsName | def _getDecoratorsName(node):
"""
Return a list with names of decorators attached to this node.
@param node: current node of pylint
"""
# For setter properties pylint fails so we use a custom code.
decorators = []
if not node.decorators:
return decorators
for decorator in node.... | python | def _getDecoratorsName(node):
"""
Return a list with names of decorators attached to this node.
@param node: current node of pylint
"""
# For setter properties pylint fails so we use a custom code.
decorators = []
if not node.decorators:
return decorators
for decorator in node.... | [
"def",
"_getDecoratorsName",
"(",
"node",
")",
":",
"# For setter properties pylint fails so we use a custom code.",
"decorators",
"=",
"[",
"]",
"if",
"not",
"node",
".",
"decorators",
":",
"return",
"decorators",
"for",
"decorator",
"in",
"node",
".",
"decorators",
... | Return a list with names of decorators attached to this node.
@param node: current node of pylint | [
"Return",
"a",
"list",
"with",
"names",
"of",
"decorators",
"attached",
"to",
"this",
"node",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L39-L52 |
49,794 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | _isSetter | def _isSetter(node_type, node):
"""
Determine whether the given node is a setter property.
@param node_type: The type of the node to inspect.
@param node: The L{logilab.astng.bases.NodeNG} to inspect.
@return: a boolean indicating if the given node is a setter.
"""
if node_type not in ['fu... | python | def _isSetter(node_type, node):
"""
Determine whether the given node is a setter property.
@param node_type: The type of the node to inspect.
@param node: The L{logilab.astng.bases.NodeNG} to inspect.
@return: a boolean indicating if the given node is a setter.
"""
if node_type not in ['fu... | [
"def",
"_isSetter",
"(",
"node_type",
",",
"node",
")",
":",
"if",
"node_type",
"not",
"in",
"[",
"'function'",
",",
"'method'",
"]",
":",
"return",
"False",
"for",
"name",
"in",
"_getDecoratorsName",
"(",
"node",
")",
":",
"if",
"'.setter'",
"in",
"name... | Determine whether the given node is a setter property.
@param node_type: The type of the node to inspect.
@param node: The L{logilab.astng.bases.NodeNG} to inspect.
@return: a boolean indicating if the given node is a setter. | [
"Determine",
"whether",
"the",
"given",
"node",
"is",
"a",
"setter",
"property",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L55-L70 |
49,795 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | DocstringChecker._check_docstring | def _check_docstring(self, node_type, node, report_missing=True,
confidence=None):
"""
Check whether the opening and the closing of docstring
on a line by themselves.
Then check for epytext markups for function or method.
@param node_type: type of node
... | python | def _check_docstring(self, node_type, node, report_missing=True,
confidence=None):
"""
Check whether the opening and the closing of docstring
on a line by themselves.
Then check for epytext markups for function or method.
@param node_type: type of node
... | [
"def",
"_check_docstring",
"(",
"self",
",",
"node_type",
",",
"node",
",",
"report_missing",
"=",
"True",
",",
"confidence",
"=",
"None",
")",
":",
"docstring",
"=",
"node",
".",
"doc",
"if",
"docstring",
"is",
"None",
":",
"# The node does not have a docstri... | Check whether the opening and the closing of docstring
on a line by themselves.
Then check for epytext markups for function or method.
@param node_type: type of node
@param node: current node of pylint | [
"Check",
"whether",
"the",
"opening",
"and",
"the",
"closing",
"of",
"docstring",
"on",
"a",
"line",
"by",
"themselves",
".",
"Then",
"check",
"for",
"epytext",
"markups",
"for",
"function",
"or",
"method",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L173-L205 |
49,796 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | DocstringChecker._hasReturnValue | def _hasReturnValue(self, node):
"""
Determine whether the given method or function has a return statement.
@param node: the node currently checks
"""
returnFound = False
for subnode in node.body:
if type(subnode) == node_classes.Return and subnode.value:
... | python | def _hasReturnValue(self, node):
"""
Determine whether the given method or function has a return statement.
@param node: the node currently checks
"""
returnFound = False
for subnode in node.body:
if type(subnode) == node_classes.Return and subnode.value:
... | [
"def",
"_hasReturnValue",
"(",
"self",
",",
"node",
")",
":",
"returnFound",
"=",
"False",
"for",
"subnode",
"in",
"node",
".",
"body",
":",
"if",
"type",
"(",
"subnode",
")",
"==",
"node_classes",
".",
"Return",
"and",
"subnode",
".",
"value",
":",
"r... | Determine whether the given method or function has a return statement.
@param node: the node currently checks | [
"Determine",
"whether",
"the",
"given",
"method",
"or",
"function",
"has",
"a",
"return",
"statement",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L255-L266 |
49,797 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | DocstringChecker._checkEpytext | def _checkEpytext(self, node_type, node, linenoDocstring):
"""
Check epytext of docstring.
@param node_type: type of node
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring
"""
if node_type not in ['function', 'method']:
... | python | def _checkEpytext(self, node_type, node, linenoDocstring):
"""
Check epytext of docstring.
@param node_type: type of node
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring
"""
if node_type not in ['function', 'method']:
... | [
"def",
"_checkEpytext",
"(",
"self",
",",
"node_type",
",",
"node",
",",
"linenoDocstring",
")",
":",
"if",
"node_type",
"not",
"in",
"[",
"'function'",
",",
"'method'",
"]",
":",
"return",
"# Check for arguments.",
"# If current node is method,",
"# then first argu... | Check epytext of docstring.
@param node_type: type of node
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring | [
"Check",
"epytext",
"of",
"docstring",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L269-L307 |
49,798 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | DocstringChecker._checkReturnValueEpytext | def _checkReturnValueEpytext(self, node, linenoDocstring):
"""
Check if return value is documented.
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring
"""
# Getter properties don't need to document their return value,
# but then n... | python | def _checkReturnValueEpytext(self, node, linenoDocstring):
"""
Check if return value is documented.
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring
"""
# Getter properties don't need to document their return value,
# but then n... | [
"def",
"_checkReturnValueEpytext",
"(",
"self",
",",
"node",
",",
"linenoDocstring",
")",
":",
"# Getter properties don't need to document their return value,",
"# but then need to have a return value.",
"if",
"'property'",
"in",
"_getDecoratorsName",
"(",
"node",
")",
":",
"... | Check if return value is documented.
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring | [
"Check",
"if",
"return",
"value",
"is",
"documented",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L310-L332 |
49,799 | twisted/twistedchecker | twistedchecker/checkers/docstring.py | DocstringChecker._checkBlankLineBeforeEpytext | def _checkBlankLineBeforeEpytext(self, node_type, node, linenoDocstring):
"""
Check whether there is a blank line before epytext.
@param node_type: type of node
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring
"""
# Check whethe... | python | def _checkBlankLineBeforeEpytext(self, node_type, node, linenoDocstring):
"""
Check whether there is a blank line before epytext.
@param node_type: type of node
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring
"""
# Check whethe... | [
"def",
"_checkBlankLineBeforeEpytext",
"(",
"self",
",",
"node_type",
",",
"node",
",",
"linenoDocstring",
")",
":",
"# Check whether there is a blank line before epytext markups.",
"patternEpytext",
"=",
"(",
"r\"\\n *@(param|type|return|returns|rtype|ivar|cvar\"",
"r\"|raises|rai... | Check whether there is a blank line before epytext.
@param node_type: type of node
@param node: current node of pylint
@param linenoDocstring: linenumber of docstring | [
"Check",
"whether",
"there",
"is",
"a",
"blank",
"line",
"before",
"epytext",
"."
] | 80060e1c07cf5d67d747dbec8ec0e5ee913e8929 | https://github.com/twisted/twistedchecker/blob/80060e1c07cf5d67d747dbec8ec0e5ee913e8929/twistedchecker/checkers/docstring.py#L335-L353 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.