Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
HttpRequest._process_response | (self, resp, content) | Process the response from a single chunk upload.
Args:
resp: httplib2.Response, the response object.
content: string, the content of the response.
Returns:
(status, body): (ResumableMediaStatus, object)
The body will be None until the resumable media is fully uploaded.
Raises:
... | Process the response from a single chunk upload. | def _process_response(self, resp, content):
"""Process the response from a single chunk upload.
Args:
resp: httplib2.Response, the response object.
content: string, the content of the response.
Returns:
(status, body): (ResumableMediaStatus, object)
The body will be None until t... | [
"def",
"_process_response",
"(",
"self",
",",
"resp",
",",
"content",
")",
":",
"if",
"resp",
".",
"status",
"in",
"[",
"200",
",",
"201",
"]",
":",
"self",
".",
"_in_error_state",
"=",
"False",
"return",
"None",
",",
"self",
".",
"postproc",
"(",
"r... | [
980,
2
] | [
1012,
17
] | python | en | ['en', 'en', 'en'] | True |
HttpRequest.to_json | (self) | Returns a JSON representation of the HttpRequest. | Returns a JSON representation of the HttpRequest. | def to_json(self):
"""Returns a JSON representation of the HttpRequest."""
d = copy.copy(self.__dict__)
if d['resumable'] is not None:
d['resumable'] = self.resumable.to_json()
del d['http']
del d['postproc']
del d['_sleep']
del d['_rand']
return json.dumps(d) | [
"def",
"to_json",
"(",
"self",
")",
":",
"d",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"__dict__",
")",
"if",
"d",
"[",
"'resumable'",
"]",
"is",
"not",
"None",
":",
"d",
"[",
"'resumable'",
"]",
"=",
"self",
".",
"resumable",
".",
"to_json",
... | [
1014,
2
] | [
1024,
24
] | python | en | ['en', 'en', 'en'] | True |
HttpRequest.from_json | (s, http, postproc) | Returns an HttpRequest populated with info from a JSON object. | Returns an HttpRequest populated with info from a JSON object. | def from_json(s, http, postproc):
"""Returns an HttpRequest populated with info from a JSON object."""
d = json.loads(s)
if d['resumable'] is not None:
d['resumable'] = MediaUpload.new_from_json(d['resumable'])
return HttpRequest(
http,
postproc,
uri=d['uri'],
metho... | [
"def",
"from_json",
"(",
"s",
",",
"http",
",",
"postproc",
")",
":",
"d",
"=",
"json",
".",
"loads",
"(",
"s",
")",
"if",
"d",
"[",
"'resumable'",
"]",
"is",
"not",
"None",
":",
"d",
"[",
"'resumable'",
"]",
"=",
"MediaUpload",
".",
"new_from_json... | [
1027,
2
] | [
1040,
33
] | python | en | ['en', 'en', 'en'] | True |
BatchHttpRequest.__init__ | (self, callback=None, batch_uri=None) | Constructor for a BatchHttpRequest.
Args:
callback: callable, A callback to be called for each response, of the
form callback(id, response, exception). The first parameter is the
request id, and the second is the deserialized response object. The
third is an googleapiclient.errors.Htt... | Constructor for a BatchHttpRequest. | def __init__(self, callback=None, batch_uri=None):
"""Constructor for a BatchHttpRequest.
Args:
callback: callable, A callback to be called for each response, of the
form callback(id, response, exception). The first parameter is the
request id, and the second is the deserialized response ... | [
"def",
"__init__",
"(",
"self",
",",
"callback",
"=",
"None",
",",
"batch_uri",
"=",
"None",
")",
":",
"if",
"batch_uri",
"is",
"None",
":",
"batch_uri",
"=",
"'https://www.googleapis.com/batch'",
"self",
".",
"_batch_uri",
"=",
"batch_uri",
"# Global callback t... | [
1077,
2
] | [
1114,
36
] | python | en | ['en', 'en', 'en'] | True |
BatchHttpRequest._refresh_and_apply_credentials | (self, request, http) | Refresh the credentials and apply to the request.
Args:
request: HttpRequest, the request.
http: httplib2.Http, the global http object for the batch.
| Refresh the credentials and apply to the request. | def _refresh_and_apply_credentials(self, request, http):
"""Refresh the credentials and apply to the request.
Args:
request: HttpRequest, the request.
http: httplib2.Http, the global http object for the batch.
"""
# For the credentials to refresh, but only once per refresh_token
# If th... | [
"def",
"_refresh_and_apply_credentials",
"(",
"self",
",",
"request",
",",
"http",
")",
":",
"# For the credentials to refresh, but only once per refresh_token",
"# If there is no http per the request then refresh the http passed in",
"# via execute()",
"creds",
"=",
"None",
"if",
... | [
1116,
2
] | [
1141,
34
] | python | en | ['en', 'en', 'en'] | True |
BatchHttpRequest._id_to_header | (self, id_) | Convert an id to a Content-ID header value.
Args:
id_: string, identifier of individual request.
Returns:
A Content-ID header with the id_ encoded into it. A UUID is prepended to
the value because Content-ID headers are supposed to be universally
unique.
| Convert an id to a Content-ID header value. | def _id_to_header(self, id_):
"""Convert an id to a Content-ID header value.
Args:
id_: string, identifier of individual request.
Returns:
A Content-ID header with the id_ encoded into it. A UUID is prepended to
the value because Content-ID headers are supposed to be universally
un... | [
"def",
"_id_to_header",
"(",
"self",
",",
"id_",
")",
":",
"if",
"self",
".",
"_base_id",
"is",
"None",
":",
"self",
".",
"_base_id",
"=",
"uuid",
".",
"uuid4",
"(",
")",
"return",
"'<%s+%s>'",
"%",
"(",
"self",
".",
"_base_id",
",",
"quote",
"(",
... | [
1143,
2
] | [
1157,
50
] | python | en | ['en', 'en', 'en'] | True |
BatchHttpRequest._header_to_id | (self, header) | Convert a Content-ID header value to an id.
Presumes the Content-ID header conforms to the format that _id_to_header()
returns.
Args:
header: string, Content-ID header value.
Returns:
The extracted id value.
Raises:
BatchError if the header is not in the expected format.
| Convert a Content-ID header value to an id. | def _header_to_id(self, header):
"""Convert a Content-ID header value to an id.
Presumes the Content-ID header conforms to the format that _id_to_header()
returns.
Args:
header: string, Content-ID header value.
Returns:
The extracted id value.
Raises:
BatchError if the head... | [
"def",
"_header_to_id",
"(",
"self",
",",
"header",
")",
":",
"if",
"header",
"[",
"0",
"]",
"!=",
"'<'",
"or",
"header",
"[",
"-",
"1",
"]",
"!=",
"'>'",
":",
"raise",
"BatchError",
"(",
"\"Invalid value for Content-ID: %s\"",
"%",
"header",
")",
"if",
... | [
1159,
2
] | [
1180,
23
] | python | en | ['en', 'en', 'en'] | True |
BatchHttpRequest._serialize_request | (self, request) | Convert an HttpRequest object into a string.
Args:
request: HttpRequest, the request to serialize.
Returns:
The request as a string in application/http format.
| Convert an HttpRequest object into a string. | def _serialize_request(self, request):
"""Convert an HttpRequest object into a string.
Args:
request: HttpRequest, the request to serialize.
Returns:
The request as a string in application/http format.
"""
# Construct status line
parsed = urlparse(request.uri)
request_line = ur... | [
"def",
"_serialize_request",
"(",
"self",
",",
"request",
")",
":",
"# Construct status line",
"parsed",
"=",
"urlparse",
"(",
"request",
".",
"uri",
")",
"request_line",
"=",
"urlunparse",
"(",
"(",
"''",
",",
"''",
",",
"parsed",
".",
"path",
",",
"parse... | [
1182,
2
] | [
1225,
29
] | python | en | ['en', 'lb', 'en'] | True |
BatchHttpRequest._deserialize_response | (self, payload) | Convert string into httplib2 response and content.
Args:
payload: string, headers and body as a string.
Returns:
A pair (resp, content), such as would be returned from httplib2.request.
| Convert string into httplib2 response and content. | def _deserialize_response(self, payload):
"""Convert string into httplib2 response and content.
Args:
payload: string, headers and body as a string.
Returns:
A pair (resp, content), such as would be returned from httplib2.request.
"""
# Strip off the status line
status_line, payloa... | [
"def",
"_deserialize_response",
"(",
"self",
",",
"payload",
")",
":",
"# Strip off the status line",
"status_line",
",",
"payload",
"=",
"payload",
".",
"split",
"(",
"'\\n'",
",",
"1",
")",
"protocol",
",",
"status",
",",
"reason",
"=",
"status_line",
".",
... | [
1227,
2
] | [
1253,
24
] | python | en | ['en', 'en', 'en'] | True |
BatchHttpRequest._new_id | (self) | Create a new id.
Auto incrementing number that avoids conflicts with ids already used.
Returns:
string, a new unique id.
| Create a new id. | def _new_id(self):
"""Create a new id.
Auto incrementing number that avoids conflicts with ids already used.
Returns:
string, a new unique id.
"""
self._last_auto_id += 1
while str(self._last_auto_id) in self._requests:
self._last_auto_id += 1
return str(self._last_auto_id) | [
"def",
"_new_id",
"(",
"self",
")",
":",
"self",
".",
"_last_auto_id",
"+=",
"1",
"while",
"str",
"(",
"self",
".",
"_last_auto_id",
")",
"in",
"self",
".",
"_requests",
":",
"self",
".",
"_last_auto_id",
"+=",
"1",
"return",
"str",
"(",
"self",
".",
... | [
1255,
2
] | [
1266,
34
] | python | en | ['en', 'ig', 'en'] | True |
BatchHttpRequest.add | (self, request, callback=None, request_id=None) | Add a new request.
Every callback added will be paired with a unique id, the request_id. That
unique id will be passed back to the callback when the response comes back
from the server. The default behavior is to have the library generate it's
own unique id. If the caller passes in a request_id then th... | Add a new request. | def add(self, request, callback=None, request_id=None):
"""Add a new request.
Every callback added will be paired with a unique id, the request_id. That
unique id will be passed back to the callback when the response comes back
from the server. The default behavior is to have the library generate it's
... | [
"def",
"add",
"(",
"self",
",",
"request",
",",
"callback",
"=",
"None",
",",
"request_id",
"=",
"None",
")",
":",
"if",
"request_id",
"is",
"None",
":",
"request_id",
"=",
"self",
".",
"_new_id",
"(",
")",
"if",
"request",
".",
"resumable",
"is",
"n... | [
1269,
2
] | [
1305,
34
] | python | en | ['en', 'en', 'en'] | True |
BatchHttpRequest._execute | (self, http, order, requests) | Serialize batch request, send to server, process response.
Args:
http: httplib2.Http, an http object to be used to make the request with.
order: list, list of request ids in the order they were added to the
batch.
request: list, list of request objects to send.
Raises:
httplib2... | Serialize batch request, send to server, process response. | def _execute(self, http, order, requests):
"""Serialize batch request, send to server, process response.
Args:
http: httplib2.Http, an http object to be used to make the request with.
order: list, list of request ids in the order they were added to the
batch.
request: list, list of re... | [
"def",
"_execute",
"(",
"self",
",",
"http",
",",
"order",
",",
"requests",
")",
":",
"message",
"=",
"MIMEMultipart",
"(",
"'mixed'",
")",
"# Message should not write out it's own headers.",
"setattr",
"(",
"message",
",",
"'_write_headers'",
",",
"lambda",
"self... | [
1307,
2
] | [
1375,
55
] | python | en | ['en', 'pt', 'en'] | True |
BatchHttpRequest.execute | (self, http=None) | Execute all the requests as a single batched HTTP request.
Args:
http: httplib2.Http, an http object to be used in place of the one the
HttpRequest request object was constructed with. If one isn't supplied
then use a http object from the requests in this batch.
Returns:
None
... | Execute all the requests as a single batched HTTP request. | def execute(self, http=None):
"""Execute all the requests as a single batched HTTP request.
Args:
http: httplib2.Http, an http object to be used in place of the one the
HttpRequest request object was constructed with. If one isn't supplied
then use a http object from the requests in this ... | [
"def",
"execute",
"(",
"self",
",",
"http",
"=",
"None",
")",
":",
"# If we have no requests return",
"if",
"len",
"(",
"self",
".",
"_order",
")",
"==",
"0",
":",
"return",
"None",
"# If http is not supplied use the first valid one given in the requests.",
"if",
"h... | [
1378,
2
] | [
1456,
55
] | python | en | ['en', 'en', 'en'] | True |
HttpRequestMock.__init__ | (self, resp, content, postproc) | Constructor for HttpRequestMock
Args:
resp: httplib2.Response, the response to emulate coming from the request
content: string, the response body
postproc: callable, the post processing function usually supplied by
the model class. See model.JsonModel.response() as an example.
... | Constructor for HttpRequestMock | def __init__(self, resp, content, postproc):
"""Constructor for HttpRequestMock
Args:
resp: httplib2.Response, the response to emulate coming from the request
content: string, the response body
postproc: callable, the post processing function usually supplied by
the model clas... | [
"def",
"__init__",
"(",
"self",
",",
"resp",
",",
"content",
",",
"postproc",
")",
":",
"self",
".",
"resp",
"=",
"resp",
"self",
".",
"content",
"=",
"content",
"self",
".",
"postproc",
"=",
"postproc",
"if",
"resp",
"is",
"None",
":",
"self",
".",
... | [
1465,
2
] | [
1480,
44
] | python | en | ['da', 'en', 'en'] | True |
HttpRequestMock.execute | (self, http=None) | Execute the request.
Same behavior as HttpRequest.execute(), but the response is
mocked and not really from an HTTP request/response.
| Execute the request. | def execute(self, http=None):
"""Execute the request.
Same behavior as HttpRequest.execute(), but the response is
mocked and not really from an HTTP request/response.
"""
return self.postproc(self.resp, self.content) | [
"def",
"execute",
"(",
"self",
",",
"http",
"=",
"None",
")",
":",
"return",
"self",
".",
"postproc",
"(",
"self",
".",
"resp",
",",
"self",
".",
"content",
")"
] | [
1482,
2
] | [
1488,
49
] | python | en | ['en', 'en', 'en'] | True |
RequestMockBuilder.__init__ | (self, responses, check_unexpected=False) | Constructor for RequestMockBuilder
The constructed object should be a callable object
that can replace the class HttpResponse.
responses - A dictionary that maps methodIds into tuples
of (httplib2.Response, content). The methodId
comes from the 'rpcName' field in the discov... | Constructor for RequestMockBuilder | def __init__(self, responses, check_unexpected=False):
"""Constructor for RequestMockBuilder
The constructed object should be a callable object
that can replace the class HttpResponse.
responses - A dictionary that maps methodIds into tuples
of (httplib2.Response, content). The methodI... | [
"def",
"__init__",
"(",
"self",
",",
"responses",
",",
"check_unexpected",
"=",
"False",
")",
":",
"self",
".",
"responses",
"=",
"responses",
"self",
".",
"check_unexpected",
"=",
"check_unexpected"
] | [
1518,
2
] | [
1532,
44
] | python | da | ['da', 'da', 'en'] | True |
RequestMockBuilder.__call__ | (self, http, postproc, uri, method='GET', body=None,
headers=None, methodId=None, resumable=None) | Implements the callable interface that discovery.build() expects
of requestBuilder, which is to build an object compatible with
HttpRequest.execute(). See that method for the description of the
parameters and the expected response.
| Implements the callable interface that discovery.build() expects
of requestBuilder, which is to build an object compatible with
HttpRequest.execute(). See that method for the description of the
parameters and the expected response.
| def __call__(self, http, postproc, uri, method='GET', body=None,
headers=None, methodId=None, resumable=None):
"""Implements the callable interface that discovery.build() expects
of requestBuilder, which is to build an object compatible with
HttpRequest.execute(). See that method for the desc... | [
"def",
"__call__",
"(",
"self",
",",
"http",
",",
"postproc",
",",
"uri",
",",
"method",
"=",
"'GET'",
",",
"body",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"methodId",
"=",
"None",
",",
"resumable",
"=",
"None",
")",
":",
"if",
"methodId",
"... | [
1534,
2
] | [
1561,
56
] | python | en | ['en', 'en', 'en'] | True |
HttpMock.__init__ | (self, filename=None, headers=None) |
Args:
filename: string, absolute filename to read response from
headers: dict, header to return with response
|
Args:
filename: string, absolute filename to read response from
headers: dict, header to return with response
| def __init__(self, filename=None, headers=None):
"""
Args:
filename: string, absolute filename to read response from
headers: dict, header to return with response
"""
if headers is None:
headers = {'status': '200'}
if filename:
f = open(filename, 'rb')
self.data = f.rea... | [
"def",
"__init__",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"headers",
"=",
"None",
")",
":",
"if",
"headers",
"is",
"None",
":",
"headers",
"=",
"{",
"'status'",
":",
"'200'",
"}",
"if",
"filename",
":",
"f",
"=",
"open",
"(",
"filename",
"... | [
1567,
2
] | [
1586,
23
] | python | en | ['en', 'error', 'th'] | False |
HttpMockSequence.__init__ | (self, iterable) |
Args:
iterable: iterable, a sequence of pairs of (headers, body)
|
Args:
iterable: iterable, a sequence of pairs of (headers, body)
| def __init__(self, iterable):
"""
Args:
iterable: iterable, a sequence of pairs of (headers, body)
"""
self._iterable = iterable
self.follow_redirects = True | [
"def",
"__init__",
"(",
"self",
",",
"iterable",
")",
":",
"self",
".",
"_iterable",
"=",
"iterable",
"self",
".",
"follow_redirects",
"=",
"True"
] | [
1626,
2
] | [
1632,
32
] | python | en | ['en', 'error', 'th'] | False |
Filter.__init__ | (self, source, encoding) | Creates a Filter
:arg source: the source token stream
:arg encoding: the encoding to set
| Creates a Filter | def __init__(self, source, encoding):
"""Creates a Filter
:arg source: the source token stream
:arg encoding: the encoding to set
"""
base.Filter.__init__(self, source)
self.encoding = encoding | [
"def",
"__init__",
"(",
"self",
",",
"source",
",",
"encoding",
")",
":",
"base",
".",
"Filter",
".",
"__init__",
"(",
"self",
",",
"source",
")",
"self",
".",
"encoding",
"=",
"encoding"
] | [
7,
4
] | [
16,
32
] | python | en | ['en', 'gl', 'en'] | True |
Node.__init__ | (self, children=None, connector=None, negated=False) | Construct a new Node. If no connector is given, use the default. | Construct a new Node. If no connector is given, use the default. | def __init__(self, children=None, connector=None, negated=False):
"""Construct a new Node. If no connector is given, use the default."""
self.children = children[:] if children else []
self.connector = connector or self.default
self.negated = negated | [
"def",
"__init__",
"(",
"self",
",",
"children",
"=",
"None",
",",
"connector",
"=",
"None",
",",
"negated",
"=",
"False",
")",
":",
"self",
".",
"children",
"=",
"children",
"[",
":",
"]",
"if",
"children",
"else",
"[",
"]",
"self",
".",
"connector"... | [
20,
4
] | [
24,
30
] | python | en | ['en', 'en', 'en'] | True |
Node._new_instance | (cls, children=None, connector=None, negated=False) |
Create a new instance of this class when new Nodes (or subclasses) are
needed in the internal code in this class. Normally, it just shadows
__init__(). However, subclasses with an __init__ signature that aren't
an extension of Node.__init__ might need to implement this method to
... |
Create a new instance of this class when new Nodes (or subclasses) are
needed in the internal code in this class. Normally, it just shadows
__init__(). However, subclasses with an __init__ signature that aren't
an extension of Node.__init__ might need to implement this method to
... | def _new_instance(cls, children=None, connector=None, negated=False):
"""
Create a new instance of this class when new Nodes (or subclasses) are
needed in the internal code in this class. Normally, it just shadows
__init__(). However, subclasses with an __init__ signature that aren't
... | [
"def",
"_new_instance",
"(",
"cls",
",",
"children",
"=",
"None",
",",
"connector",
"=",
"None",
",",
"negated",
"=",
"False",
")",
":",
"obj",
"=",
"Node",
"(",
"children",
",",
"connector",
",",
"negated",
")",
"obj",
".",
"__class__",
"=",
"cls",
... | [
29,
4
] | [
40,
18
] | python | en | ['en', 'error', 'th'] | False |
Node.__len__ | (self) | Return the number of children this node has. | Return the number of children this node has. | def __len__(self):
"""Return the number of children this node has."""
return len(self.children) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"children",
")"
] | [
55,
4
] | [
57,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.__bool__ | (self) | Return whether or not this node has children. | Return whether or not this node has children. | def __bool__(self):
"""Return whether or not this node has children."""
return bool(self.children) | [
"def",
"__bool__",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"children",
")"
] | [
59,
4
] | [
61,
34
] | python | en | ['en', 'en', 'en'] | True |
Node.__contains__ | (self, other) | Return True if 'other' is a direct child of this instance. | Return True if 'other' is a direct child of this instance. | def __contains__(self, other):
"""Return True if 'other' is a direct child of this instance."""
return other in self.children | [
"def",
"__contains__",
"(",
"self",
",",
"other",
")",
":",
"return",
"other",
"in",
"self",
".",
"children"
] | [
63,
4
] | [
65,
37
] | python | en | ['en', 'en', 'en'] | True |
Node.add | (self, data, conn_type, squash=True) |
Combine this tree and the data represented by data using the
connector conn_type. The combine is done by squashing the node other
away if possible.
This tree (self) will never be pushed to a child node of the
combined tree, nor will the connector or negated properties change.
... |
Combine this tree and the data represented by data using the
connector conn_type. The combine is done by squashing the node other
away if possible. | def add(self, data, conn_type, squash=True):
"""
Combine this tree and the data represented by data using the
connector conn_type. The combine is done by squashing the node other
away if possible.
This tree (self) will never be pushed to a child node of the
combined tree... | [
"def",
"add",
"(",
"self",
",",
"data",
",",
"conn_type",
",",
"squash",
"=",
"True",
")",
":",
"if",
"self",
".",
"connector",
"==",
"conn_type",
"and",
"data",
"in",
"self",
".",
"children",
":",
"return",
"data",
"if",
"not",
"squash",
":",
"self"... | [
77,
4
] | [
119,
23
] | python | en | ['en', 'error', 'th'] | False |
Node.negate | (self) | Negate the sense of the root connector. | Negate the sense of the root connector. | def negate(self):
"""Negate the sense of the root connector."""
self.negated = not self.negated | [
"def",
"negate",
"(",
"self",
")",
":",
"self",
".",
"negated",
"=",
"not",
"self",
".",
"negated"
] | [
121,
4
] | [
123,
39
] | python | en | ['en', 'en', 'en'] | True |
ItemAttributeKNN.__init__ | (self, train_file=None, test_file=None, output_file=None, metadata_file=None, similarity_file=None,
k_neighbors=30, rank_length=10, as_binary=False, as_similar_first=True, metadata_as_binary=False,
metadata_similarity_sep='\t', similarity_metric="cosine", sep='\t', output_sep='\t') |
Item Attribute KNN for Item Recommendation
This algorithm predicts a rank for each user based on the similar items that he/her consumed,
using a metadata or similarity pre-computed file
Usage::
>> ItemAttributeKNN(train, test, similarity_file=sim_matrix, as_similar_first=... |
Item Attribute KNN for Item Recommendation | def __init__(self, train_file=None, test_file=None, output_file=None, metadata_file=None, similarity_file=None,
k_neighbors=30, rank_length=10, as_binary=False, as_similar_first=True, metadata_as_binary=False,
metadata_similarity_sep='\t', similarity_metric="cosine", sep='\t', output_s... | [
"def",
"__init__",
"(",
"self",
",",
"train_file",
"=",
"None",
",",
"test_file",
"=",
"None",
",",
"output_file",
"=",
"None",
",",
"metadata_file",
"=",
"None",
",",
"similarity_file",
"=",
"None",
",",
"k_neighbors",
"=",
"30",
",",
"rank_length",
"=",
... | [
23,
4
] | [
96,
62
] | python | en | ['en', 'error', 'th'] | False |
ItemAttributeKNN.init_model | (self) |
Method to fit the model. Create and calculate a similarity matrix by metadata file or a pre-computed similarity
matrix
|
Method to fit the model. Create and calculate a similarity matrix by metadata file or a pre-computed similarity
matrix | def init_model(self):
"""
Method to fit the model. Create and calculate a similarity matrix by metadata file or a pre-computed similarity
matrix
"""
self.similar_items = defaultdict(list)
# Set the value for k
if self.k_neighbors is None:
self.k_nei... | [
"def",
"init_model",
"(",
"self",
")",
":",
"self",
".",
"similar_items",
"=",
"defaultdict",
"(",
"list",
")",
"# Set the value for k",
"if",
"self",
".",
"k_neighbors",
"is",
"None",
":",
"self",
".",
"k_neighbors",
"=",
"int",
"(",
"np",
".",
"sqrt",
... | [
98,
4
] | [
158,
109
] | python | en | ['en', 'error', 'th'] | False |
run | (argv=None) | The main function which creates the pipeline and runs it. | The main function which creates the pipeline and runs it. | def run(argv=None):
"""The main function which creates the pipeline and runs it."""
parser = argparse.ArgumentParser()
# Here we add some specific command line arguments we expect. Specifically
# we have the input file to load and the output table to write to.
parser.add_argument(
'--input... | [
"def",
"run",
"(",
"argv",
"=",
"None",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"# Here we add some specific command line arguments we expect. Specifically",
"# we have the input file to load and the output table to write to.",
"parser",
".",
"ad... | [
108,
0
] | [
164,
31
] | python | en | ['en', 'en', 'en'] | True |
DataTransformation.parse_method | (self, string_input) | This method translates a single line of comma separated values to a
dictionary which can be loaded into BigQuery.
Args:
string_input: A comma separated list of values in the form of
state_abbreviation,gender,year,name,count_of_babies,dataset_created_date
example str... | This method translates a single line of comma separated values to a
dictionary which can be loaded into BigQuery. | def parse_method(self, string_input):
"""This method translates a single line of comma separated values to a
dictionary which can be loaded into BigQuery.
Args:
string_input: A comma separated list of values in the form of
state_abbreviation,gender,year,name,count_of_babies... | [
"def",
"parse_method",
"(",
"self",
",",
"string_input",
")",
":",
"# Strip out return characters and quote characters.",
"schema",
"=",
"parse_table_schema_from_json",
"(",
"self",
".",
"schema_str",
")",
"field_map",
"=",
"[",
"f",
"for",
"f",
"in",
"schema",
".",... | [
48,
4
] | [
105,
22
] | python | en | ['en', 'en', 'en'] | True |
compute_giou_loss | (box_target, wh_weight, pred_wh, mode="diou", reduce="sum") |
Computes giou loss and in future also diou or ciou loss for ttfnet.
:param box_target: ground truth bounding boxes
:param wh_weight: weight of heatmap
:param pred_wh: prediction of 4 values (offsets to left upper and right bottom corner)
:param mode: giou or diou or ciou, defaults to "diou"
:pa... |
Computes giou loss and in future also diou or ciou loss for ttfnet.
:param box_target: ground truth bounding boxes
:param wh_weight: weight of heatmap
:param pred_wh: prediction of 4 values (offsets to left upper and right bottom corner)
:param mode: giou or diou or ciou, defaults to "diou"
:pa... | def compute_giou_loss(box_target, wh_weight, pred_wh, mode="diou", reduce="sum"):
"""
Computes giou loss and in future also diou or ciou loss for ttfnet.
:param box_target: ground truth bounding boxes
:param wh_weight: weight of heatmap
:param pred_wh: prediction of 4 values (offsets to left upper a... | [
"def",
"compute_giou_loss",
"(",
"box_target",
",",
"wh_weight",
",",
"pred_wh",
",",
"mode",
"=",
"\"diou\"",
",",
"reduce",
"=",
"\"sum\"",
")",
":",
"base_step",
"=",
"1",
"b",
"=",
"tf",
".",
"shape",
"(",
"wh_weight",
")",
"[",
"0",
"]",
"h",
"=... | [
32,
0
] | [
76,
64
] | python | en | ['en', 'error', 'th'] | False |
focal_loss | (hm_true, hm_pred) |
Computes focal loss for heatmap.
This function was taken from:
https://github.com/MioChiu/TF_CenterNet/blob/master/loss.py
:param hm_true: gt heatmap
:param hm_pred: predicted heatmap
:return: loss value
|
Computes focal loss for heatmap. | def focal_loss(hm_true, hm_pred):
"""
Computes focal loss for heatmap.
This function was taken from:
https://github.com/MioChiu/TF_CenterNet/blob/master/loss.py
:param hm_true: gt heatmap
:param hm_pred: predicted heatmap
:return: loss value
"""
pos_mask = tf.cast(tf.equal(hm_t... | [
"def",
"focal_loss",
"(",
"hm_true",
",",
"hm_pred",
")",
":",
"pos_mask",
"=",
"tf",
".",
"cast",
"(",
"tf",
".",
"equal",
"(",
"hm_true",
",",
"1.0",
")",
",",
"dtype",
"=",
"tf",
".",
"float32",
")",
"neg_mask",
"=",
"tf",
".",
"cast",
"(",
"t... | [
80,
0
] | [
108,
15
] | python | en | ['en', 'error', 'th'] | False |
reg_l1_loss | (y_true, y_pred, indices, mask) |
This function was taken from:
https://github.com/MioChiu/TF_CenterNet/blob/master/loss.py
:param y_true: (batch, max_objects, 2)
:param y_pred: (batch, heatmap_height, heatmap_width, max_objects)
:param indices: (batch, max_objects)
:param mask: (batch, max_objects)
:return: l1 loss (s... |
This function was taken from:
https://github.com/MioChiu/TF_CenterNet/blob/master/loss.py | def reg_l1_loss(y_true, y_pred, indices, mask):
"""
This function was taken from:
https://github.com/MioChiu/TF_CenterNet/blob/master/loss.py
:param y_true: (batch, max_objects, 2)
:param y_pred: (batch, heatmap_height, heatmap_width, max_objects)
:param indices: (batch, max_objects)
:p... | [
"def",
"reg_l1_loss",
"(",
"y_true",
",",
"y_pred",
",",
"indices",
",",
"mask",
")",
":",
"batch_dim",
"=",
"tf",
".",
"shape",
"(",
"y_pred",
")",
"[",
"0",
"]",
"channel_dim",
"=",
"tf",
".",
"shape",
"(",
"y_pred",
")",
"[",
"-",
"1",
"]",
"y... | [
112,
0
] | [
131,
15
] | python | en | ['en', 'error', 'th'] | False |
_giou_loss | (b1, b2, mode) |
Args:
b1: bounding box. The coordinates of the each bounding box in boxes are
encoded as [y_min, x_min, y_max, x_max].
b2: the other bounding box. The coordinates of the each bounding box
in boxes are encoded as [y_min, x_min, y_max, x_max].
mode: one of ['iou', 'cio... |
Args:
b1: bounding box. The coordinates of the each bounding box in boxes are
encoded as [y_min, x_min, y_max, x_max].
b2: the other bounding box. The coordinates of the each bounding box
in boxes are encoded as [y_min, x_min, y_max, x_max].
mode: one of ['iou', 'cio... | def _giou_loss(b1, b2, mode):
"""
Args:
b1: bounding box. The coordinates of the each bounding box in boxes are
encoded as [y_min, x_min, y_max, x_max].
b2: the other bounding box. The coordinates of the each bounding box
in boxes are encoded as [y_min, x_min, y_max, x_ma... | [
"def",
"_giou_loss",
"(",
"b1",
",",
"b2",
",",
"mode",
")",
":",
"zero",
"=",
"0.0",
"b1_ymin",
",",
"b1_xmin",
",",
"b1_ymax",
",",
"b1_xmax",
"=",
"tf",
".",
"unstack",
"(",
"b1",
",",
"4",
",",
"axis",
"=",
"-",
"1",
")",
"b2_ymin",
",",
"b... | [
134,
0
] | [
192,
80
] | python | en | ['en', 'error', 'th'] | False |
_fd | (f) | Get a filedescriptor from something which could be a file or an fd. | Get a filedescriptor from something which could be a file or an fd. | def _fd(f):
"""Get a filedescriptor from something which could be a file or an fd."""
return f.fileno() if hasattr(f, 'fileno') else f | [
"def",
"_fd",
"(",
"f",
")",
":",
"return",
"f",
".",
"fileno",
"(",
")",
"if",
"hasattr",
"(",
"f",
",",
"'fileno'",
")",
"else",
"f"
] | [
23,
0
] | [
25,
52
] | python | en | ['en', 'en', 'en'] | True |
_unique_everseen | (iterable, key=None) | List unique elements, preserving order. Remember all elements ever seen. | List unique elements, preserving order. Remember all elements ever seen. | def _unique_everseen(iterable, key=None):
"List unique elements, preserving order. Remember all elements ever seen."
# unique_everseen('AAAABBBCCDAABBB') --> A B C D
# unique_everseen('ABBCcAD', str.lower) --> A B C D
seen = set()
seen_add = seen.add
if key is None:
for element in filter... | [
"def",
"_unique_everseen",
"(",
"iterable",
",",
"key",
"=",
"None",
")",
":",
"# unique_everseen('AAAABBBCCDAABBB') --> A B C D",
"# unique_everseen('ABBCcAD', str.lower) --> A B C D",
"seen",
"=",
"set",
"(",
")",
"seen_add",
"=",
"seen",
".",
"add",
"if",
"key",
"i... | [
238,
0
] | [
253,
29
] | python | ca | ['ca', 'ca', 'en'] | True |
build_py.run | (self) | Build modules, packages, and copy data files to build directory | Build modules, packages, and copy data files to build directory | def run(self):
"""Build modules, packages, and copy data files to build directory"""
if not self.py_modules and not self.packages:
return
if self.py_modules:
self.build_modules()
if self.packages:
self.build_packages()
self.build_package_... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"py_modules",
"and",
"not",
"self",
".",
"packages",
":",
"return",
"if",
"self",
".",
"py_modules",
":",
"self",
".",
"build_modules",
"(",
")",
"if",
"self",
".",
"packages",
":",
"self... | [
42,
4
] | [
60,
78
] | python | en | ['en', 'en', 'en'] | True |
build_py.__getattr__ | (self, attr) | lazily compute data files | lazily compute data files | def __getattr__(self, attr):
"lazily compute data files"
if attr == 'data_files':
self.data_files = self._get_data_files()
return self.data_files
return orig.build_py.__getattr__(self, attr) | [
"def",
"__getattr__",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"==",
"'data_files'",
":",
"self",
".",
"data_files",
"=",
"self",
".",
"_get_data_files",
"(",
")",
"return",
"self",
".",
"data_files",
"return",
"orig",
".",
"build_py",
".",
"__g... | [
62,
4
] | [
67,
52
] | python | it | ['it', 'it', 'it'] | True |
build_py._get_data_files | (self) | Generate list of '(package,src_dir,build_dir,filenames)' tuples | Generate list of '(package,src_dir,build_dir,filenames)' tuples | def _get_data_files(self):
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
self.analyze_manifest()
return list(map(self._get_pkg_data_files, self.packages or ())) | [
"def",
"_get_data_files",
"(",
"self",
")",
":",
"self",
".",
"analyze_manifest",
"(",
")",
"return",
"list",
"(",
"map",
"(",
"self",
".",
"_get_pkg_data_files",
",",
"self",
".",
"packages",
"or",
"(",
")",
")",
")"
] | [
79,
4
] | [
82,
71
] | python | en | ['en', 'af', 'en'] | True |
build_py.find_data_files | (self, package, src_dir) | Return filenames for package's data files in 'src_dir | Return filenames for package's data files in 'src_dir | def find_data_files(self, package, src_dir):
"""Return filenames for package's data files in 'src_dir'"""
patterns = self._get_platform_patterns(
self.package_data,
package,
src_dir,
)
globs_expanded = map(glob, patterns)
# flatten the expanded... | [
"def",
"find_data_files",
"(",
"self",
",",
"package",
",",
"src_dir",
")",
":",
"patterns",
"=",
"self",
".",
"_get_platform_patterns",
"(",
"self",
".",
"package_data",
",",
"package",
",",
"src_dir",
",",
")",
"globs_expanded",
"=",
"map",
"(",
"glob",
... | [
98,
4
] | [
113,
63
] | python | en | ['en', 'no', 'en'] | True |
build_py.build_package_data | (self) | Copy data files into build directory | Copy data files into build directory | def build_package_data(self):
"""Copy data files into build directory"""
for package, src_dir, build_dir, filenames in self.data_files:
for filename in filenames:
target = os.path.join(build_dir, filename)
self.mkpath(os.path.dirname(target))
s... | [
"def",
"build_package_data",
"(",
"self",
")",
":",
"for",
"package",
",",
"src_dir",
",",
"build_dir",
",",
"filenames",
"in",
"self",
".",
"data_files",
":",
"for",
"filename",
"in",
"filenames",
":",
"target",
"=",
"os",
".",
"path",
".",
"join",
"(",... | [
115,
4
] | [
126,
53
] | python | en | ['en', 'en', 'en'] | True |
build_py.check_package | (self, package, package_dir) | Check namespace packages' __init__ for declare_namespace | Check namespace packages' __init__ for declare_namespace | def check_package(self, package, package_dir):
"""Check namespace packages' __init__ for declare_namespace"""
try:
return self.packages_checked[package]
except KeyError:
pass
init_py = orig.build_py.check_package(self, package, package_dir)
self.packages_... | [
"def",
"check_package",
"(",
"self",
",",
"package",
",",
"package_dir",
")",
":",
"try",
":",
"return",
"self",
".",
"packages_checked",
"[",
"package",
"]",
"except",
"KeyError",
":",
"pass",
"init_py",
"=",
"orig",
".",
"build_py",
".",
"check_package",
... | [
155,
4
] | [
183,
22
] | python | en | ['es', 'en', 'en'] | True |
build_py.exclude_data_files | (self, package, src_dir, files) | Filter filenames for package's data files in 'src_dir | Filter filenames for package's data files in 'src_dir | def exclude_data_files(self, package, src_dir, files):
"""Filter filenames for package's data files in 'src_dir'"""
files = list(files)
patterns = self._get_platform_patterns(
self.exclude_package_data,
package,
src_dir,
)
match_groups = (
... | [
"def",
"exclude_data_files",
"(",
"self",
",",
"package",
",",
"src_dir",
",",
"files",
")",
":",
"files",
"=",
"list",
"(",
"files",
")",
"patterns",
"=",
"self",
".",
"_get_platform_patterns",
"(",
"self",
".",
"exclude_package_data",
",",
"package",
",",
... | [
195,
4
] | [
216,
46
] | python | en | ['en', 'en', 'en'] | True |
build_py._get_platform_patterns | (spec, package, src_dir) |
yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
|
yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
| def _get_platform_patterns(spec, package, src_dir):
"""
yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
"""
raw_patterns = itertools.... | [
"def",
"_get_platform_patterns",
"(",
"spec",
",",
"package",
",",
"src_dir",
")",
":",
"raw_patterns",
"=",
"itertools",
".",
"chain",
"(",
"spec",
".",
"get",
"(",
"''",
",",
"[",
"]",
")",
",",
"spec",
".",
"get",
"(",
"package",
",",
"[",
"]",
... | [
219,
4
] | [
234,
9
] | python | en | ['en', 'error', 'th'] | False |
ExpBuffer.__init__ | (self, max_size=10000, min_size=5000) | Initializes the maximum size of the buffer.
Args:
max_size: Height of the imag
| Initializes the maximum size of the buffer.
Args:
max_size: Height of the imag
| def __init__(self, max_size=10000, min_size=5000):
""" Initializes the maximum size of the buffer.
Args:
max_size: Height of the imag
"""
self.buffer = deque()
self.max_size = max_size
self.min_size = min_size | [
"def",
"__init__",
"(",
"self",
",",
"max_size",
"=",
"10000",
",",
"min_size",
"=",
"5000",
")",
":",
"self",
".",
"buffer",
"=",
"deque",
"(",
")",
"self",
".",
"max_size",
"=",
"max_size",
"self",
".",
"min_size",
"=",
"min_size"
] | [
39,
2
] | [
46,
28
] | python | en | ['en', 'en', 'en'] | True |
ExpBuffer.add_exp | (self, exp) | Adds an experience to the buffer.
| Adds an experience to the buffer. | def add_exp(self, exp):
""" Adds an experience to the buffer.
"""
if len(self.buffer) > self.max_size:
self.buffer.popleft()
self.buffer.append(exp) | [
"def",
"add_exp",
"(",
"self",
",",
"exp",
")",
":",
"if",
"len",
"(",
"self",
".",
"buffer",
")",
">",
"self",
".",
"max_size",
":",
"self",
".",
"buffer",
".",
"popleft",
"(",
")",
"self",
".",
"buffer",
".",
"append",
"(",
"exp",
")"
] | [
48,
2
] | [
54,
27
] | python | en | ['en', 'en', 'en'] | True |
ExpBuffer.sample_experiences | (self, batch_size=128) | Samples experiences from the buffer.
Returns: Sampled array from the experience buffer
| Samples experiences from the buffer. | def sample_experiences(self, batch_size=128):
""" Samples experiences from the buffer.
Returns: Sampled array from the experience buffer
"""
sampled_buffer = random.sample(self.buffer, batch_size)
state, next_state, reward, action, done = zip(*sampled_buffer)
state, next_state = np.array(s... | [
"def",
"sample_experiences",
"(",
"self",
",",
"batch_size",
"=",
"128",
")",
":",
"sampled_buffer",
"=",
"random",
".",
"sample",
"(",
"self",
".",
"buffer",
",",
"batch_size",
")",
"state",
",",
"next_state",
",",
"reward",
",",
"action",
",",
"done",
... | [
56,
2
] | [
67,
52
] | python | en | ['en', 'en', 'en'] | True |
get_architectures | () |
get all of model architectures
|
get all of model architectures
| def get_architectures():
"""
get all of model architectures
"""
names = []
for k, v in architectures.__dict__.items():
if isinstance(v, (types.FunctionType, six.class_types)):
names.append(k)
return names | [
"def",
"get_architectures",
"(",
")",
":",
"names",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"architectures",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"(",
"types",
".",
"FunctionType",
",",
"six",
".",
"cl... | [
21,
0
] | [
29,
16
] | python | en | ['en', 'error', 'th'] | False |
similar_architectures | (name='', names=[], thresh=0.1, topk=10) |
inferred similar architectures
|
inferred similar architectures
| def similar_architectures(name='', names=[], thresh=0.1, topk=10):
"""
inferred similar architectures
"""
scores = []
for idx, n in enumerate(names):
if n.startswith('__'):
continue
score = SequenceMatcher(None, n.lower(), name.lower()).quick_ratio()
if score > th... | [
"def",
"similar_architectures",
"(",
"name",
"=",
"''",
",",
"names",
"=",
"[",
"]",
",",
"thresh",
"=",
"0.1",
",",
"topk",
"=",
"10",
")",
":",
"scores",
"=",
"[",
"]",
"for",
"idx",
",",
"n",
"in",
"enumerate",
"(",
"names",
")",
":",
"if",
... | [
32,
0
] | [
45,
24
] | python | en | ['en', 'error', 'th'] | False |
ensure_local_file | (input_file) |
Ensure the training ratings file is stored locally.
|
Ensure the training ratings file is stored locally.
| def ensure_local_file(input_file):
"""
Ensure the training ratings file is stored locally.
"""
if input_file.startswith('gs:/'):
input_path = os.path.join('/tmp/', str(uuid.uuid4()))
os.makedirs(input_path)
tmp_input_file = os.path.join(input_path, os.path.basename(input_file))
sh.gsutil("cp", "... | [
"def",
"ensure_local_file",
"(",
"input_file",
")",
":",
"if",
"input_file",
".",
"startswith",
"(",
"'gs:/'",
")",
":",
"input_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"'/tmp/'",
",",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
")",
"os... | [
22,
0
] | [
33,
21
] | python | en | ['en', 'error', 'th'] | False |
write_hptuning_metric | (args, metric) |
Write a summary containing the tuning loss metric, as required by hyperparam tuning.
|
Write a summary containing the tuning loss metric, as required by hyperparam tuning.
| def write_hptuning_metric(args, metric):
"""
Write a summary containing the tuning loss metric, as required by hyperparam tuning.
"""
summary = Summary(value=[Summary.Value(tag='training/hptuning/metric', simple_value=metric)])
# for hyperparam tuning, we write a summary log to a directory 'eval' below the j... | [
"def",
"write_hptuning_metric",
"(",
"args",
",",
"metric",
")",
":",
"summary",
"=",
"Summary",
"(",
"value",
"=",
"[",
"Summary",
".",
"Value",
"(",
"tag",
"=",
"'training/hptuning/metric'",
",",
"simple_value",
"=",
"metric",
")",
"]",
")",
"# for hyperpa... | [
36,
0
] | [
49,
24
] | python | en | ['en', 'error', 'th'] | False |
add_srs_entry | (srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
database=None) |
Take a GDAL SpatialReference system and add its information to the
`spatial_ref_sys` table of the spatial backend. Doing this enables
database-level spatial transformations for the backend. Thus, this utility
is useful for adding spatial reference systems not included by default with
the backend:
... |
Take a GDAL SpatialReference system and add its information to the
`spatial_ref_sys` table of the spatial backend. Doing this enables
database-level spatial transformations for the backend. Thus, this utility
is useful for adding spatial reference systems not included by default with
the backend: | def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
database=None):
"""
Take a GDAL SpatialReference system and add its information to the
`spatial_ref_sys` table of the spatial backend. Doing this enables
database-level spatial transformations for the backend. ... | [
"def",
"add_srs_entry",
"(",
"srs",
",",
"auth_name",
"=",
"'EPSG'",
",",
"auth_srid",
"=",
"None",
",",
"ref_sys_name",
"=",
"None",
",",
"database",
"=",
"None",
")",
":",
"database",
"=",
"database",
"or",
"DEFAULT_DB_ALIAS",
"connection",
"=",
"connectio... | [
4,
0
] | [
75,
62
] | python | en | ['en', 'error', 'th'] | False |
OneHotPreprocCore.preproc | (self, frame) |
Args:
frame (B, H, W)
Returns:
processed frame (B, C, H, W)
|
Args:
frame (B, H, W)
Returns:
processed frame (B, C, H, W)
| def preproc(self, frame):
"""
Args:
frame (B, H, W)
Returns:
processed frame (B, C, H, W)
"""
return self._image_colors_to_onehot(frame) | [
"def",
"preproc",
"(",
"self",
",",
"frame",
")",
":",
"return",
"self",
".",
"_image_colors_to_onehot",
"(",
"frame",
")"
] | [
35,
4
] | [
42,
50
] | python | en | ['en', 'error', 'th'] | False |
OneHotPreprocCore.unpreproc_after_loss | (cls, proc_frame_for_loss) |
Args:
frame (B, C, H, W)
Returns:
processed frame (B, H, W)
|
Args:
frame (B, C, H, W)
Returns:
processed frame (B, H, W)
| def unpreproc_after_loss(cls, proc_frame_for_loss):
"""
Args:
frame (B, C, H, W)
Returns:
processed frame (B, H, W)
"""
return torch.argmax(proc_frame_for_loss, axis=1) | [
"def",
"unpreproc_after_loss",
"(",
"cls",
",",
"proc_frame_for_loss",
")",
":",
"return",
"torch",
".",
"argmax",
"(",
"proc_frame_for_loss",
",",
"axis",
"=",
"1",
")"
] | [
49,
4
] | [
56,
56
] | python | en | ['en', 'error', 'th'] | False |
OneHotPtNetPreprocCore.preproc | (self, frame) |
Args:
frame (B, H, W)
Returns:
processed frame (B, C, H, W)
|
Args:
frame (B, H, W)
Returns:
processed frame (B, C, H, W)
| def preproc(self, frame):
"""
Args:
frame (B, H, W)
Returns:
processed frame (B, C, H, W)
"""
# First make it 1-hot rep, then add the XY locations
frame_onehot = self.one_hot_preproc.preproc(frame)
# Make space for the X, Y
frame_on... | [
"def",
"preproc",
"(",
"self",
",",
"frame",
")",
":",
"# First make it 1-hot rep, then add the XY locations",
"frame_onehot",
"=",
"self",
".",
"one_hot_preproc",
".",
"preproc",
"(",
"frame",
")",
"# Make space for the X, Y",
"frame_onehot_rep",
"=",
"frame_onehot",
"... | [
66,
4
] | [
82,
31
] | python | en | ['en', 'error', 'th'] | False |
OneHotPtNetPreprocCore.unpreproc_for_loss | (cls, proc_frame) | Generate a 1-hot pixel-level output to incur the loss. | Generate a 1-hot pixel-level output to incur the loss. | def unpreproc_for_loss(cls, proc_frame):
"""Generate a 1-hot pixel-level output to incur the loss."""
proc_frame_ch = torch.chunk(proc_frame, phyre.NUM_COLORS, 1)
all_feat = []
for channel in proc_frame_ch:
index = channel[:, :2, ...]
index[:, 0, ...] = 2 * (index... | [
"def",
"unpreproc_for_loss",
"(",
"cls",
",",
"proc_frame",
")",
":",
"proc_frame_ch",
"=",
"torch",
".",
"chunk",
"(",
"proc_frame",
",",
"phyre",
".",
"NUM_COLORS",
",",
"1",
")",
"all_feat",
"=",
"[",
"]",
"for",
"channel",
"in",
"proc_frame_ch",
":",
... | [
85,
4
] | [
99,
41
] | python | en | ['en', 'en', 'en'] | True |
OneHotPtNetPreprocCore.unpreproc_after_loss | (self, proc_frame_for_loss) |
Args:
proc_frame (B, C, H, W)
Returns:
frame (B, H, W)
|
Args:
proc_frame (B, C, H, W)
Returns:
frame (B, H, W)
| def unpreproc_after_loss(self, proc_frame_for_loss):
"""
Args:
proc_frame (B, C, H, W)
Returns:
frame (B, H, W)
"""
return self.one_hot_preproc.unpreproc_after_loss(proc_frame_for_loss) | [
"def",
"unpreproc_after_loss",
"(",
"self",
",",
"proc_frame_for_loss",
")",
":",
"return",
"self",
".",
"one_hot_preproc",
".",
"unpreproc_after_loss",
"(",
"proc_frame_for_loss",
")"
] | [
101,
4
] | [
108,
77
] | python | en | ['en', 'error', 'th'] | False |
VideoPreprocessor._apply_each_obj | (cls, func, frame) | Apply a function to each obj in the frame.
Args:
func
frame: B, Nobj, ...
| Apply a function to each obj in the frame.
Args:
func
frame: B, Nobj, ...
| def _apply_each_obj(cls, func, frame):
"""Apply a function to each obj in the frame.
Args:
func
frame: B, Nobj, ...
"""
frame_flat = torch.flatten(frame, 0, 1)
frame_flat_proc = func(frame_flat)
frame_proc = frame_flat_proc.view(frame.shape[:2] +
... | [
"def",
"_apply_each_obj",
"(",
"cls",
",",
"func",
",",
"frame",
")",
":",
"frame_flat",
"=",
"torch",
".",
"flatten",
"(",
"frame",
",",
"0",
",",
"1",
")",
"frame_flat_proc",
"=",
"func",
"(",
"frame_flat",
")",
"frame_proc",
"=",
"frame_flat_proc",
".... | [
119,
4
] | [
129,
25
] | python | en | ['en', 'en', 'en'] | True |
VideoPreprocessor.preproc_frame | (self, frame) | Process a frame from the vid.
Args:
frame: (B,Nobj,H,W)
Returns:
Processed frame: (B,Nobj,C,H,W)
| Process a frame from the vid.
Args:
frame: (B,Nobj,H,W)
Returns:
Processed frame: (B,Nobj,C,H,W)
| def preproc_frame(self, frame):
"""Process a frame from the vid.
Args:
frame: (B,Nobj,H,W)
Returns:
Processed frame: (B,Nobj,C,H,W)
"""
if frame is None:
return None
assert len(frame.shape) == 4
return self._apply_each_obj(self.... | [
"def",
"preproc_frame",
"(",
"self",
",",
"frame",
")",
":",
"if",
"frame",
"is",
"None",
":",
"return",
"None",
"assert",
"len",
"(",
"frame",
".",
"shape",
")",
"==",
"4",
"return",
"self",
".",
"_apply_each_obj",
"(",
"self",
".",
"preproc_core",
".... | [
131,
4
] | [
141,
69
] | python | en | ['en', 'en', 'en'] | True |
VideoPreprocessor.unpreprocess_frame_after_loss | (self, proc_frame) | Unprocess a frame from the vid, that has already been unprocessed
for loss using the unprocess_frame_for_loss function.
Note that the decoder automatically handles objects, so no obj here
Args:
processed frame: (B,Nobj,C,H,W)
Returns:
frame: (B, Nobj, H, W... | Unprocess a frame from the vid, that has already been unprocessed
for loss using the unprocess_frame_for_loss function.
Note that the decoder automatically handles objects, so no obj here
Args:
processed frame: (B,Nobj,C,H,W)
Returns:
frame: (B, Nobj, H, W... | def unpreprocess_frame_after_loss(self, proc_frame):
"""Unprocess a frame from the vid, that has already been unprocessed
for loss using the unprocess_frame_for_loss function.
Note that the decoder automatically handles objects, so no obj here
Args:
processed frame: (... | [
"def",
"unpreprocess_frame_after_loss",
"(",
"self",
",",
"proc_frame",
")",
":",
"if",
"proc_frame",
"is",
"None",
":",
"return",
"None",
"assert",
"len",
"(",
"proc_frame",
".",
"shape",
")",
"==",
"5",
"return",
"self",
".",
"_apply_each_obj",
"(",
"self"... | [
143,
4
] | [
156,
47
] | python | en | ['en', 'en', 'en'] | True |
VideoPreprocessor.unpreprocess_frame_for_loss | (self, proc_frame) | Unprocess a frame from the vid, for loss.
Args:
processed frame: (B,Nobj,C,H,W)
Returns:
frame: (B, Nobj, C, H, W)
| Unprocess a frame from the vid, for loss.
Args:
processed frame: (B,Nobj,C,H,W)
Returns:
frame: (B, Nobj, C, H, W)
| def unpreprocess_frame_for_loss(self, proc_frame):
"""Unprocess a frame from the vid, for loss.
Args:
processed frame: (B,Nobj,C,H,W)
Returns:
frame: (B, Nobj, C, H, W)
"""
if proc_frame is None:
return proc_frame
assert len(proc_frame.... | [
"def",
"unpreprocess_frame_for_loss",
"(",
"self",
",",
"proc_frame",
")",
":",
"if",
"proc_frame",
"is",
"None",
":",
"return",
"proc_frame",
"assert",
"len",
"(",
"proc_frame",
".",
"shape",
")",
"==",
"5",
"return",
"self",
".",
"_apply_each_obj",
"(",
"s... | [
158,
4
] | [
169,
47
] | python | en | ['en', 'en', 'en'] | True |
VideoPreprocessor.preprocess_vid | (self, vid) |
Args:
vid (B, T, Nobj, H, W)
Returns:
res (B, T, Nobj, C, H, W): Basically the 1-hot representation
|
Args:
vid (B, T, Nobj, H, W)
Returns:
res (B, T, Nobj, C, H, W): Basically the 1-hot representation
| def preprocess_vid(self, vid):
"""
Args:
vid (B, T, Nobj, H, W)
Returns:
res (B, T, Nobj, C, H, W): Basically the 1-hot representation
"""
assert len(vid.shape) == 5
vid_flat = torch.flatten(vid, 0, 1)
vid_flat_onehot = self.preproc_frame(v... | [
"def",
"preprocess_vid",
"(",
"self",
",",
"vid",
")",
":",
"assert",
"len",
"(",
"vid",
".",
"shape",
")",
"==",
"5",
"vid_flat",
"=",
"torch",
".",
"flatten",
"(",
"vid",
",",
"0",
",",
"1",
")",
"vid_flat_onehot",
"=",
"self",
".",
"preproc_frame"... | [
171,
4
] | [
182,
71
] | python | en | ['en', 'error', 'th'] | False |
get_capability_token | () | Respond to incoming requests. | Respond to incoming requests. | def get_capability_token():
"""Respond to incoming requests."""
# Find these values at twilio.com/console
# To set up environmental variables, see http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
capability = ClientCapabilityToken(ac... | [
"def",
"get_capability_token",
"(",
")",
":",
"# Find these values at twilio.com/console",
"# To set up environmental variables, see http://twil.io/secure",
"account_sid",
"=",
"os",
".",
"environ",
"[",
"'TWILIO_ACCOUNT_SID'",
"]",
"auth_token",
"=",
"os",
".",
"environ",
"[... | [
8,
0
] | [
24,
54
] | python | en | ['en', 'en', 'en'] | True |
JpegImageFile.load_read | (self, read_bytes) |
internal: read more image data
For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker
so libjpeg can finish decoding
|
internal: read more image data
For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker
so libjpeg can finish decoding
| def load_read(self, read_bytes):
"""
internal: read more image data
For premature EOF and LOAD_TRUNCATED_IMAGES adds EOI marker
so libjpeg can finish decoding
"""
s = self.fp.read(read_bytes)
if not s and ImageFile.LOAD_TRUNCATED_IMAGES:
# Premature E... | [
"def",
"load_read",
"(",
"self",
",",
"read_bytes",
")",
":",
"s",
"=",
"self",
".",
"fp",
".",
"read",
"(",
"read_bytes",
")",
"if",
"not",
"s",
"and",
"ImageFile",
".",
"LOAD_TRUNCATED_IMAGES",
":",
"# Premature EOF.",
"# Pretend file is finished adding EOI ma... | [
395,
4
] | [
408,
16
] | python | en | ['en', 'error', 'th'] | False |
JpegImageFile.getxmp | (self) |
Returns a dictionary containing the XMP tags.
Requires defusedxml to be installed.
:returns: XMP tags in a dictionary.
|
Returns a dictionary containing the XMP tags.
Requires defusedxml to be installed.
:returns: XMP tags in a dictionary.
| def getxmp(self):
"""
Returns a dictionary containing the XMP tags.
Requires defusedxml to be installed.
:returns: XMP tags in a dictionary.
"""
for segment, content in self.applist:
if segment == "APP1":
marker, xmp_tags = content.rsplit(b"\x... | [
"def",
"getxmp",
"(",
"self",
")",
":",
"for",
"segment",
",",
"content",
"in",
"self",
".",
"applist",
":",
"if",
"segment",
"==",
"\"APP1\"",
":",
"marker",
",",
"xmp_tags",
"=",
"content",
".",
"rsplit",
"(",
"b\"\\x00\"",
",",
"1",
")",
"if",
"ma... | [
479,
4
] | [
491,
17
] | python | en | ['en', 'error', 'th'] | False |
DashboardsServiceGrpcTransport.__init__ | (
self,
*,
host: str = "monitoring.googleapis.com",
credentials: credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
channel: grpc.Channel = None,
api_mtls_endpoint: str = None,
client_cert_source: Callable[[... | Instantiate the transport.
Args:
host (Optional[str]): The hostname to connect to.
credentials (Optional[google.auth.credentials.Credentials]): The
authorization credentials to attach to requests. These
credentials identify the application to the service;... | Instantiate the transport. | def __init__(
self,
*,
host: str = "monitoring.googleapis.com",
credentials: credentials.Credentials = None,
credentials_file: str = None,
scopes: Sequence[str] = None,
channel: grpc.Channel = None,
api_mtls_endpoint: str = None,
client_cert_source... | [
"def",
"__init__",
"(",
"self",
",",
"*",
",",
"host",
":",
"str",
"=",
"\"monitoring.googleapis.com\"",
",",
"credentials",
":",
"credentials",
".",
"Credentials",
"=",
"None",
",",
"credentials_file",
":",
"str",
"=",
"None",
",",
"scopes",
":",
"Sequence"... | [
50,
4
] | [
144,
9
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.create_channel | (
cls,
host: str = "monitoring.googleapis.com",
credentials: credentials.Credentials = None,
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs
) | Create and return a gRPC channel object.
Args:
address (Optionsl[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service.... | Create and return a gRPC channel object.
Args:
address (Optionsl[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service.... | def create_channel(
cls,
host: str = "monitoring.googleapis.com",
credentials: credentials.Credentials = None,
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs
) -> grpc.Channel:
"""... | [
"def",
"create_channel",
"(",
"cls",
",",
"host",
":",
"str",
"=",
"\"monitoring.googleapis.com\"",
",",
"credentials",
":",
"credentials",
".",
"Credentials",
"=",
"None",
",",
"credentials_file",
":",
"str",
"=",
"None",
",",
"scopes",
":",
"Optional",
"[",
... | [
147,
4
] | [
189,
9
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.grpc_channel | (self) | Create the channel designed to connect to this service.
This property caches on the instance; repeated calls return
the same channel.
| Create the channel designed to connect to this service. | def grpc_channel(self) -> grpc.Channel:
"""Create the channel designed to connect to this service.
This property caches on the instance; repeated calls return
the same channel.
"""
# Sanity check: Only create a new channel if we do not already
# have one.
if not ... | [
"def",
"grpc_channel",
"(",
"self",
")",
"->",
"grpc",
".",
"Channel",
":",
"# Sanity check: Only create a new channel if we do not already",
"# have one.",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_grpc_channel\"",
")",
":",
"self",
".",
"_grpc_channel",
"=",
"... | [
192,
4
] | [
206,
33
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.create_dashboard | (
self,
) | r"""Return a callable for the create dashboard method over gRPC.
Creates a new custom dashboard.
This method requires the ``monitoring.dashboards.create``
permission on the specified project. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Return... | r"""Return a callable for the create dashboard method over gRPC. | def create_dashboard(
self,
) -> Callable[[dashboards_service.CreateDashboardRequest], dashboard.Dashboard]:
r"""Return a callable for the create dashboard method over gRPC.
Creates a new custom dashboard.
This method requires the ``monitoring.dashboards.create``
permission... | [
"def",
"create_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"CreateDashboardRequest",
"]",
",",
"dashboard",
".",
"Dashboard",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"#... | [
209,
4
] | [
236,
46
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.list_dashboards | (
self,
) | r"""Return a callable for the list dashboards method over gRPC.
Lists the existing dashboards.
This method requires the ``monitoring.dashboards.list``
permission on the specified project. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Returns:
... | r"""Return a callable for the list dashboards method over gRPC. | def list_dashboards(
self,
) -> Callable[
[dashboards_service.ListDashboardsRequest],
dashboards_service.ListDashboardsResponse,
]:
r"""Return a callable for the list dashboards method over gRPC.
Lists the existing dashboards.
This method requires the ``monitori... | [
"def",
"list_dashboards",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"ListDashboardsRequest",
"]",
",",
"dashboards_service",
".",
"ListDashboardsResponse",
",",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make... | [
239,
4
] | [
269,
45
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.get_dashboard | (
self,
) | r"""Return a callable for the get dashboard method over gRPC.
Fetches a specific dashboard.
This method requires the ``monitoring.dashboards.get``
permission on the specified dashboard. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
Returns:
... | r"""Return a callable for the get dashboard method over gRPC. | def get_dashboard(
self,
) -> Callable[[dashboards_service.GetDashboardRequest], dashboard.Dashboard]:
r"""Return a callable for the get dashboard method over gRPC.
Fetches a specific dashboard.
This method requires the ``monitoring.dashboards.get``
permission on the specif... | [
"def",
"get_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"GetDashboardRequest",
"]",
",",
"dashboard",
".",
"Dashboard",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"# gRPC ... | [
272,
4
] | [
299,
43
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.delete_dashboard | (
self,
) | r"""Return a callable for the delete dashboard method over gRPC.
Deletes an existing custom dashboard.
This method requires the ``monitoring.dashboards.delete``
permission on the specified dashboard. For more information, see
`Google Cloud IAM <https://cloud.google.com/iam>`__.
... | r"""Return a callable for the delete dashboard method over gRPC. | def delete_dashboard(
self,
) -> Callable[[dashboards_service.DeleteDashboardRequest], empty.Empty]:
r"""Return a callable for the delete dashboard method over gRPC.
Deletes an existing custom dashboard.
This method requires the ``monitoring.dashboards.delete``
permission o... | [
"def",
"delete_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"DeleteDashboardRequest",
"]",
",",
"empty",
".",
"Empty",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"# gRPC ha... | [
302,
4
] | [
329,
46
] | python | en | ['en', 'en', 'en'] | True |
DashboardsServiceGrpcTransport.update_dashboard | (
self,
) | r"""Return a callable for the update dashboard method over gRPC.
Replaces an existing custom dashboard with a new definition.
This method requires the ``monitoring.dashboards.update``
permission on the specified dashboard. For more information, see
`Google Cloud IAM <https://cloud.goog... | r"""Return a callable for the update dashboard method over gRPC. | def update_dashboard(
self,
) -> Callable[[dashboards_service.UpdateDashboardRequest], dashboard.Dashboard]:
r"""Return a callable for the update dashboard method over gRPC.
Replaces an existing custom dashboard with a new definition.
This method requires the ``monitoring.dashboard... | [
"def",
"update_dashboard",
"(",
"self",
",",
")",
"->",
"Callable",
"[",
"[",
"dashboards_service",
".",
"UpdateDashboardRequest",
"]",
",",
"dashboard",
".",
"Dashboard",
"]",
":",
"# Generate a \"stub function\" on-the-fly which will actually make",
"# the request.",
"#... | [
332,
4
] | [
359,
46
] | python | en | ['en', 'en', 'en'] | True |
PackageIndex.__init__ | (self, url=None) |
Initialise an instance.
:param url: The URL of the index. If not specified, the URL for PyPI is
used.
|
Initialise an instance. | def __init__(self, url=None):
"""
Initialise an instance.
:param url: The URL of the index. If not specified, the URL for PyPI is
used.
"""
self.url = url or DEFAULT_INDEX
self.read_configuration()
scheme, netloc, path, params, query, frag = u... | [
"def",
"__init__",
"(",
"self",
",",
"url",
"=",
"None",
")",
":",
"self",
".",
"url",
"=",
"url",
"or",
"DEFAULT_INDEX",
"self",
".",
"read_configuration",
"(",
")",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"frag",
"="... | [
35,
4
] | [
62,
24
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex._get_pypirc_command | (self) |
Get the distutils command for interacting with PyPI configurations.
:return: the command.
|
Get the distutils command for interacting with PyPI configurations.
:return: the command.
| def _get_pypirc_command(self):
"""
Get the distutils command for interacting with PyPI configurations.
:return: the command.
"""
from .util import _get_pypirc_command as cmd
return cmd() | [
"def",
"_get_pypirc_command",
"(",
"self",
")",
":",
"from",
".",
"util",
"import",
"_get_pypirc_command",
"as",
"cmd",
"return",
"cmd",
"(",
")"
] | [
64,
4
] | [
70,
20
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.read_configuration | (self) |
Read the PyPI access configuration as supported by distutils. This populates
``username``, ``password``, ``realm`` and ``url`` attributes from the
configuration.
|
Read the PyPI access configuration as supported by distutils. This populates
``username``, ``password``, ``realm`` and ``url`` attributes from the
configuration.
| def read_configuration(self):
"""
Read the PyPI access configuration as supported by distutils. This populates
``username``, ``password``, ``realm`` and ``url`` attributes from the
configuration.
"""
from .util import _load_pypirc
cfg = _load_pypirc(self)
... | [
"def",
"read_configuration",
"(",
"self",
")",
":",
"from",
".",
"util",
"import",
"_load_pypirc",
"cfg",
"=",
"_load_pypirc",
"(",
"self",
")",
"self",
".",
"username",
"=",
"cfg",
".",
"get",
"(",
"'username'",
")",
"self",
".",
"password",
"=",
"cfg",... | [
72,
4
] | [
83,
50
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.save_configuration | (self) |
Save the PyPI access configuration. You must have set ``username`` and
``password`` attributes before calling this method.
|
Save the PyPI access configuration. You must have set ``username`` and
``password`` attributes before calling this method.
| def save_configuration(self):
"""
Save the PyPI access configuration. You must have set ``username`` and
``password`` attributes before calling this method.
"""
self.check_credentials()
from .util import _store_pypirc
_store_pypirc(self) | [
"def",
"save_configuration",
"(",
"self",
")",
":",
"self",
".",
"check_credentials",
"(",
")",
"from",
".",
"util",
"import",
"_store_pypirc",
"_store_pypirc",
"(",
"self",
")"
] | [
85,
4
] | [
92,
27
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.check_credentials | (self) |
Check that ``username`` and ``password`` have been set, and raise an
exception if not.
|
Check that ``username`` and ``password`` have been set, and raise an
exception if not.
| def check_credentials(self):
"""
Check that ``username`` and ``password`` have been set, and raise an
exception if not.
"""
if self.username is None or self.password is None:
raise DistlibException('username and password must be set')
pm = HTTPPasswordMgr()
... | [
"def",
"check_credentials",
"(",
"self",
")",
":",
"if",
"self",
".",
"username",
"is",
"None",
"or",
"self",
".",
"password",
"is",
"None",
":",
"raise",
"DistlibException",
"(",
"'username and password must be set'",
")",
"pm",
"=",
"HTTPPasswordMgr",
"(",
"... | [
94,
4
] | [
104,
56
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.register | (self, metadata) |
Register a distribution on PyPI, using the provided metadata.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the distribution to be
registered.
:return: The HTTP response received from PyPI upon su... |
Register a distribution on PyPI, using the provided metadata. | def register(self, metadata):
"""
Register a distribution on PyPI, using the provided metadata.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the distribution to be
registered.
:return: The... | [
"def",
"register",
"(",
"self",
",",
"metadata",
")",
":",
"self",
".",
"check_credentials",
"(",
")",
"metadata",
".",
"validate",
"(",
")",
"d",
"=",
"metadata",
".",
"todict",
"(",
")",
"d",
"[",
"':action'",
"]",
"=",
"'verify'",
"request",
"=",
... | [
106,
4
] | [
124,
41
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex._reader | (self, name, stream, outbuf) |
Thread runner for reading lines of from a subprocess into a buffer.
:param name: The logical name of the stream (used for logging only).
:param stream: The stream to read from. This will typically a pipe
connected to the output stream of a subprocess.
:param outb... |
Thread runner for reading lines of from a subprocess into a buffer. | def _reader(self, name, stream, outbuf):
"""
Thread runner for reading lines of from a subprocess into a buffer.
:param name: The logical name of the stream (used for logging only).
:param stream: The stream to read from. This will typically a pipe
connected to th... | [
"def",
"_reader",
"(",
"self",
",",
"name",
",",
"stream",
",",
"outbuf",
")",
":",
"while",
"True",
":",
"s",
"=",
"stream",
".",
"readline",
"(",
")",
"if",
"not",
"s",
":",
"break",
"s",
"=",
"s",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"rs... | [
126,
4
] | [
142,
22
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.get_sign_command | (self, filename, signer, sign_password,
keystore=None) |
Return a suitable command for signing a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
private key used for signing.
:para... |
Return a suitable command for signing a file. | def get_sign_command(self, filename, signer, sign_password,
keystore=None):
"""
Return a suitable command for signing a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_pas... | [
"def",
"get_sign_command",
"(",
"self",
",",
"filename",
",",
"signer",
",",
"sign_password",
",",
"keystore",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"gpg",
",",
"'--status-fd'",
",",
"'2'",
",",
"'--no-tty'",
"]",
"if",
"keystore",
"is",
... | [
144,
4
] | [
171,
22
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.run_command | (self, cmd, input_data=None) |
Run a command in a child process , passing it any input data specified.
:param cmd: The command to run.
:param input_data: If specified, this must be a byte string containing
data to be sent to the child process.
:return: A tuple consisting of the subprocess'... |
Run a command in a child process , passing it any input data specified. | def run_command(self, cmd, input_data=None):
"""
Run a command in a child process , passing it any input data specified.
:param cmd: The command to run.
:param input_data: If specified, this must be a byte string containing
data to be sent to the child process... | [
"def",
"run_command",
"(",
"self",
",",
"cmd",
",",
"input_data",
"=",
"None",
")",
":",
"kwargs",
"=",
"{",
"'stdout'",
":",
"subprocess",
".",
"PIPE",
",",
"'stderr'",
":",
"subprocess",
".",
"PIPE",
",",
"}",
"if",
"input_data",
"is",
"not",
"None",... | [
173,
4
] | [
206,
43
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.sign_file | (self, filename, signer, sign_password, keystore=None) |
Sign a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
private key used for signing.
:param keystore: The path to a directo... |
Sign a file. | def sign_file(self, filename, signer, sign_password, keystore=None):
"""
Sign a file.
:param filename: The pathname to the file to be signed.
:param signer: The identifier of the signer of the file.
:param sign_password: The passphrase for the signer's
... | [
"def",
"sign_file",
"(",
"self",
",",
"filename",
",",
"signer",
",",
"sign_password",
",",
"keystore",
"=",
"None",
")",
":",
"cmd",
",",
"sig_file",
"=",
"self",
".",
"get_sign_command",
"(",
"filename",
",",
"signer",
",",
"sign_password",
",",
"keystor... | [
208,
4
] | [
229,
23
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.upload_file | (self, metadata, filename, signer=None, sign_password=None,
filetype='sdist', pyversion='source', keystore=None) |
Upload a release file to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the file to be uploaded.
:param filename: The pathname of the file to be uploaded.
:param signer: The identifier of the signer of t... |
Upload a release file to the index. | def upload_file(self, metadata, filename, signer=None, sign_password=None,
filetype='sdist', pyversion='source', keystore=None):
"""
Upload a release file to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and versio... | [
"def",
"upload_file",
"(",
"self",
",",
"metadata",
",",
"filename",
",",
"signer",
"=",
"None",
",",
"sign_password",
"=",
"None",
",",
"filetype",
"=",
"'sdist'",
",",
"pyversion",
"=",
"'source'",
",",
"keystore",
"=",
"None",
")",
":",
"self",
".",
... | [
231,
4
] | [
286,
41
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.upload_documentation | (self, metadata, doc_dir) |
Upload documentation to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the documentation to be
uploaded.
:param doc_dir: The pathname of the directory which contains the
... |
Upload documentation to the index. | def upload_documentation(self, metadata, doc_dir):
"""
Upload documentation to the index.
:param metadata: A :class:`Metadata` instance defining at least a name
and version number for the documentation to be
uploaded.
:param doc_dir: The... | [
"def",
"upload_documentation",
"(",
"self",
",",
"metadata",
",",
"doc_dir",
")",
":",
"self",
".",
"check_credentials",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"doc_dir",
")",
":",
"raise",
"DistlibException",
"(",
"'not a directory: %r... | [
288,
4
] | [
314,
41
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.get_verify_command | (self, signature_filename, data_filename,
keystore=None) |
Return a suitable command for verifying a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_filename: The pathname to the file containing the
signed data.
:param keystore: The... |
Return a suitable command for verifying a file. | def get_verify_command(self, signature_filename, data_filename,
keystore=None):
"""
Return a suitable command for verifying a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_fil... | [
"def",
"get_verify_command",
"(",
"self",
",",
"signature_filename",
",",
"data_filename",
",",
"keystore",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"self",
".",
"gpg",
",",
"'--status-fd'",
",",
"'2'",
",",
"'--no-tty'",
"]",
"if",
"keystore",
"is",
"None"... | [
316,
4
] | [
338,
18
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.verify_signature | (self, signature_filename, data_filename,
keystore=None) |
Verify a signature for a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_filename: The pathname to the file containing the
signed data.
:param keystore: The path to a direct... |
Verify a signature for a file. | def verify_signature(self, signature_filename, data_filename,
keystore=None):
"""
Verify a signature for a file.
:param signature_filename: The pathname to the file containing the
signature.
:param data_filename: The pathname t... | [
"def",
"verify_signature",
"(",
"self",
",",
"signature_filename",
",",
"data_filename",
",",
"keystore",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"gpg",
":",
"raise",
"DistlibException",
"(",
"'verification unavailable because gpg '",
"'unavailable'",
")",
... | [
340,
4
] | [
363,
22
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.download_file | (self, url, destfile, digest=None, reporthook=None) |
This is a convenience method for downloading a file from an URL.
Normally, this will be a file from the index, though currently
no check is made for this (i.e. a file can be downloaded from
anywhere).
The method is just like the :func:`urlretrieve` function in the
stand... |
This is a convenience method for downloading a file from an URL.
Normally, this will be a file from the index, though currently
no check is made for this (i.e. a file can be downloaded from
anywhere). | def download_file(self, url, destfile, digest=None, reporthook=None):
"""
This is a convenience method for downloading a file from an URL.
Normally, this will be a file from the index, though currently
no check is made for this (i.e. a file can be downloaded from
anywhere).
... | [
"def",
"download_file",
"(",
"self",
",",
"url",
",",
"destfile",
",",
"digest",
"=",
"None",
",",
"reporthook",
"=",
"None",
")",
":",
"if",
"digest",
"is",
"None",
":",
"digester",
"=",
"None",
"logger",
".",
"debug",
"(",
"'No digest specified'",
")",... | [
365,
4
] | [
440,
55
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.send_request | (self, req) |
Send a standard library :class:`Request` to PyPI and return its
response.
:param req: The request to send.
:return: The HTTP response from PyPI (a standard library HTTPResponse).
|
Send a standard library :class:`Request` to PyPI and return its
response. | def send_request(self, req):
"""
Send a standard library :class:`Request` to PyPI and return its
response.
:param req: The request to send.
:return: The HTTP response from PyPI (a standard library HTTPResponse).
"""
handlers = []
if self.password_handler:... | [
"def",
"send_request",
"(",
"self",
",",
"req",
")",
":",
"handlers",
"=",
"[",
"]",
"if",
"self",
".",
"password_handler",
":",
"handlers",
".",
"append",
"(",
"self",
".",
"password_handler",
")",
"if",
"self",
".",
"ssl_verifier",
":",
"handlers",
"."... | [
442,
4
] | [
456,
31
] | python | en | ['en', 'error', 'th'] | False |
PackageIndex.encode_request | (self, fields, files) |
Encode fields and files for posting to an HTTP server.
:param fields: The fields to send as a list of (fieldname, value)
tuples.
:param files: The files to send as a list of (fieldname, filename,
file_bytes) tuple.
|
Encode fields and files for posting to an HTTP server. | def encode_request(self, fields, files):
"""
Encode fields and files for posting to an HTTP server.
:param fields: The fields to send as a list of (fieldname, value)
tuples.
:param files: The files to send as a list of (fieldname, filename,
f... | [
"def",
"encode_request",
"(",
"self",
",",
"fields",
",",
"files",
")",
":",
"# Adapted from packaging, which in turn was adapted from",
"# http://code.activestate.com/recipes/146306",
"parts",
"=",
"[",
"]",
"boundary",
"=",
"self",
".",
"boundary",
"for",
"k",
",",
... | [
458,
4
] | [
499,
47
] | python | en | ['en', 'error', 'th'] | False |
MavWebRTC.start_pipeline | (self) |
# Need to translate this to python
g_signal_emit_by_name (receiver_entry->webrtcbin, "get-transceivers", &transceivers);
g_assert (transceivers != NULL && transceivers->len > 0);
trans = g_array_index (transceivers, GstWebRTCRTPTransceiver *, 0);
trans->direction = GST_WEBRTC_RT... |
# Need to translate this to python
g_signal_emit_by_name (receiver_entry->webrtcbin, "get-transceivers", &transceivers);
g_assert (transceivers != NULL && transceivers->len > 0);
trans = g_array_index (transceivers, GstWebRTCRTPTransceiver *, 0);
trans->direction = GST_WEBRTC_RT... | def start_pipeline(self):
self.webrtc = self.pipeline.get_by_name('webrtc')
### Set transceiver to SENDONLY
# https://gstreamer.freedesktop.org/documentation/webrtc/index.html?gi-language=c#webrtcbin::get-transceivers
# https://gstreamer.freedesktop.org/documentation/webrtclib/webrt... | [
"def",
"start_pipeline",
"(",
"self",
")",
":",
"self",
".",
"webrtc",
"=",
"self",
".",
"pipeline",
".",
"get_by_name",
"(",
"'webrtc'",
")",
"### Set transceiver to SENDONLY",
"# https://gstreamer.freedesktop.org/documentation/webrtc/index.html?gi-language=c#webrtcbin::get-tr... | [
149,
4
] | [
175,
50
] | python | en | ['en', 'error', 'th'] | False |
get_invoke | (command: click.Command) |
Get the Cmd main method from the click command
:param command: The click Command object
:return: the do_* method for Cmd
:rtype: function
|
Get the Cmd main method from the click command
:param command: The click Command object
:return: the do_* method for Cmd
:rtype: function
| def get_invoke(command: click.Command) -> Callable[[ClickCmd, str], bool]:
"""
Get the Cmd main method from the click command
:param command: The click Command object
:return: the do_* method for Cmd
:rtype: function
"""
assert isinstance(command, click.Command)
assert command.callback
... | [
"def",
"get_invoke",
"(",
"command",
":",
"click",
".",
"Command",
")",
"->",
"Callable",
"[",
"[",
"ClickCmd",
",",
"str",
"]",
",",
"bool",
"]",
":",
"assert",
"isinstance",
"(",
"command",
",",
"click",
".",
"Command",
")",
"assert",
"command",
".",... | [
23,
0
] | [
60,
18
] | python | en | ['en', 'error', 'th'] | False |
get_help | (command: click.Command) |
Get the Cmd help function from the click command
:param command: The click Command object
:return: the help_* method for Cmd
:rtype: function
|
Get the Cmd help function from the click command
:param command: The click Command object
:return: the help_* method for Cmd
:rtype: function
| def get_help(command: click.Command) -> Callable[[ClickCmd], None]:
"""
Get the Cmd help function from the click command
:param command: The click Command object
:return: the help_* method for Cmd
:rtype: function
"""
assert isinstance(command, click.Command)
def help_(self: ClickCmd): ... | [
"def",
"get_help",
"(",
"command",
":",
"click",
".",
"Command",
")",
"->",
"Callable",
"[",
"[",
"ClickCmd",
"]",
",",
"None",
"]",
":",
"assert",
"isinstance",
"(",
"command",
",",
"click",
".",
"Command",
")",
"def",
"help_",
"(",
"self",
":",
"Cl... | [
63,
0
] | [
83,
16
] | python | en | ['en', 'error', 'th'] | False |
get_complete | (command: click.Command) |
Get the Cmd complete function for the click command
:param command: The click Command object
:return: the complete_* method for Cmd
:rtype: function
|
Get the Cmd complete function for the click command
:param command: The click Command object
:return: the complete_* method for Cmd
:rtype: function
| def get_complete(command: click.Command) -> Callable[[ClickCmd, str, str, int, int], List[str]]:
"""
Get the Cmd complete function for the click command
:param command: The click Command object
:return: the complete_* method for Cmd
:rtype: function
"""
assert isinstance(command, click.Comm... | [
"def",
"get_complete",
"(",
"command",
":",
"click",
".",
"Command",
")",
"->",
"Callable",
"[",
"[",
"ClickCmd",
",",
"str",
",",
"str",
",",
"int",
",",
"int",
"]",
",",
"List",
"[",
"str",
"]",
"]",
":",
"assert",
"isinstance",
"(",
"command",
"... | [
86,
0
] | [
114,
20
] | python | en | ['en', 'error', 'th'] | False |
safe_join | (base, *paths) |
Join one or more path components to the base path component intelligently.
Return a normalized, absolute version of the final path.
Raise ValueError if the final path isn't located inside of the base path
component.
|
Join one or more path components to the base path component intelligently.
Return a normalized, absolute version of the final path. | def safe_join(base, *paths):
"""
Join one or more path components to the base path component intelligently.
Return a normalized, absolute version of the final path.
Raise ValueError if the final path isn't located inside of the base path
component.
"""
final_path = abspath(join(base, *paths... | [
"def",
"safe_join",
"(",
"base",
",",
"*",
"paths",
")",
":",
"final_path",
"=",
"abspath",
"(",
"join",
"(",
"base",
",",
"*",
"paths",
")",
")",
"base_path",
"=",
"abspath",
"(",
"base",
")",
"# Ensure final_path starts with base_path (using normcase to ensure... | [
8,
0
] | [
31,
21
] | python | en | ['en', 'error', 'th'] | False |
symlinks_supported | () |
Return whether or not creating symlinks are supported in the host platform
and/or if they are allowed to be created (e.g. on Windows it requires admin
permissions).
|
Return whether or not creating symlinks are supported in the host platform
and/or if they are allowed to be created (e.g. on Windows it requires admin
permissions).
| def symlinks_supported():
"""
Return whether or not creating symlinks are supported in the host platform
and/or if they are allowed to be created (e.g. on Windows it requires admin
permissions).
"""
with tempfile.TemporaryDirectory() as temp_dir:
original_path = os.path.join(temp_dir, 'o... | [
"def",
"symlinks_supported",
"(",
")",
":",
"with",
"tempfile",
".",
"TemporaryDirectory",
"(",
")",
"as",
"temp_dir",
":",
"original_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"temp_dir",
",",
"'original'",
")",
"symlink_path",
"=",
"os",
".",
"path... | [
34,
0
] | [
49,
24
] | python | en | ['en', 'error', 'th'] | False |
to_path | (value) | Convert value to a pathlib.Path instance, if not already a Path. | Convert value to a pathlib.Path instance, if not already a Path. | def to_path(value):
"""Convert value to a pathlib.Path instance, if not already a Path."""
if isinstance(value, Path):
return value
elif not isinstance(value, str):
raise TypeError('Invalid path type: %s' % type(value).__name__)
return Path(value) | [
"def",
"to_path",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Path",
")",
":",
"return",
"value",
"elif",
"not",
"isinstance",
"(",
"value",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"'Invalid path type: %s'",
"%",
"type",
"(",... | [
52,
0
] | [
58,
22
] | python | en | ['en', 'en', 'en'] | True |
MiddlewareMixin._async_check | (self) |
If get_response is a coroutine function, turns us into async mode so
a thread is not consumed during a whole request.
|
If get_response is a coroutine function, turns us into async mode so
a thread is not consumed during a whole request.
| def _async_check(self):
"""
If get_response is a coroutine function, turns us into async mode so
a thread is not consumed during a whole request.
"""
if asyncio.iscoroutinefunction(self.get_response):
# Mark the class as async-capable, but do the actual switch
... | [
"def",
"_async_check",
"(",
"self",
")",
":",
"if",
"asyncio",
".",
"iscoroutinefunction",
"(",
"self",
".",
"get_response",
")",
":",
"# Mark the class as async-capable, but do the actual switch",
"# inside __call__ to avoid swapping out dunder methods",
"self",
".",
"_is_co... | [
99,
4
] | [
107,
65
] | python | en | ['en', 'error', 'th'] | False |
MiddlewareMixin.__acall__ | (self, request) |
Async version of __call__ that is swapped in when an async request
is running.
|
Async version of __call__ that is swapped in when an async request
is running.
| async def __acall__(self, request):
"""
Async version of __call__ that is swapped in when an async request
is running.
"""
response = None
if hasattr(self, 'process_request'):
response = await sync_to_async(
self.process_request,
... | [
"async",
"def",
"__acall__",
"(",
"self",
",",
"request",
")",
":",
"response",
"=",
"None",
"if",
"hasattr",
"(",
"self",
",",
"'process_request'",
")",
":",
"response",
"=",
"await",
"sync_to_async",
"(",
"self",
".",
"process_request",
",",
"thread_sensit... | [
121,
4
] | [
138,
23
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.