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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Model.make_label_placeholder | (self) | Create and return a placeholder representing class labels.
This method should respect context managers (e.g. "with tf.device")
and should not just return a reference to a single pre-created
placeholder.
| Create and return a placeholder representing class labels. | def make_label_placeholder(self):
"""Create and return a placeholder representing class labels.
This method should respect context managers (e.g. "with tf.device")
and should not just return a reference to a single pre-created
placeholder.
"""
raise NotImplementedError(... | [
"def",
"make_label_placeholder",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"str",
"(",
"type",
"(",
"self",
")",
")",
"+",
"\" does not implement \"",
"\"make_label_placeholder\"",
")"
] | [
198,
4
] | [
208,
9
] | python | en | ['en', 'en', 'en'] | True |
CallableModelWrapper.__init__ | (self, callable_fn, output_layer) |
Wrap a callable function that takes a tensor as input and returns
a tensor as output with the given layer name.
:param callable_fn: The callable function taking a tensor and
returning a given layer as output.
:param output_layer: A string of the output layer ... |
Wrap a callable function that takes a tensor as input and returns
a tensor as output with the given layer name.
:param callable_fn: The callable function taking a tensor and
returning a given layer as output.
:param output_layer: A string of the output layer ... | def __init__(self, callable_fn, output_layer):
"""
Wrap a callable function that takes a tensor as input and returns
a tensor as output with the given layer name.
:param callable_fn: The callable function taking a tensor and
returning a given layer as output.
... | [
"def",
"__init__",
"(",
"self",
",",
"callable_fn",
",",
"output_layer",
")",
":",
"super",
"(",
"CallableModelWrapper",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"output_layer",
"=",
"output_layer",
"self",
".",
"callable_fn",
"=",
"callable... | [
220,
4
] | [
232,
38
] | python | en | ['en', 'error', 'th'] | False |
moments_close_enough | (t1, t2) |
Return True if the two times are very close to each other.
Works around databases losing time precision.
:param t1: Instant 1
:param t2: Instant 2
:return: Closeness boolean
|
Return True if the two times are very close to each other. | def moments_close_enough(t1, t2):
"""
Return True if the two times are very close to each other.
Works around databases losing time precision.
:param t1: Instant 1
:param t2: Instant 2
:return: Closeness boolean
"""
return (t1 - t2).total_seconds() < 0.1 | [
"def",
"moments_close_enough",
"(",
"t1",
",",
"t2",
")",
":",
"return",
"(",
"t1",
"-",
"t2",
")",
".",
"total_seconds",
"(",
")",
"<",
"0.1"
] | [
0,
0
] | [
10,
42
] | python | en | ['en', 'error', 'th'] | False |
avatar_url_from_dict | (userdict: Dict[str, Any], medium: bool = False) |
DEPRECATED: We should start using
get_avatar_field to populate users,
particularly for codepaths where the
client can compute gravatar URLs
on the client side.
|
DEPRECATED: We should start using
get_avatar_field to populate users,
particularly for codepaths where the
client can compute gravatar URLs
on the client side.
| def avatar_url_from_dict(userdict: Dict[str, Any], medium: bool = False) -> str:
"""
DEPRECATED: We should start using
get_avatar_field to populate users,
particularly for codepaths where the
client can compute gravatar URLs
on the client side.
... | [
"def",
"avatar_url_from_dict",
"(",
"userdict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"medium",
":",
"bool",
"=",
"False",
")",
"->",
"str",
":",
"url",
"=",
"_get_unversioned_avatar_url",
"(",
"userdict",
"[",
"\"id\"",
"]",
",",
"userdict",
"[... | [
29,
0
] | [
45,
14
] | python | en | ['en', 'error', 'th'] | False |
get_avatar_field | (
user_id: int,
realm_id: int,
email: str,
avatar_source: str,
avatar_version: int,
medium: bool,
client_gravatar: bool,
) |
Most of the parameters to this function map to fields
by the same name in UserProfile (avatar_source, realm_id,
email, etc.).
Then there are these:
medium - This means we want a medium-sized avatar. This can
affect the "s" parameter for gravatar avatars, or it
can give... |
Most of the parameters to this function map to fields
by the same name in UserProfile (avatar_source, realm_id,
email, etc.). | def get_avatar_field(
user_id: int,
realm_id: int,
email: str,
avatar_source: str,
avatar_version: int,
medium: bool,
client_gravatar: bool,
) -> Optional[str]:
"""
Most of the parameters to this function map to fields
by the same name in UserProfile (avatar_source, realm_id,
... | [
"def",
"get_avatar_field",
"(",
"user_id",
":",
"int",
",",
"realm_id",
":",
"int",
",",
"email",
":",
"str",
",",
"avatar_source",
":",
"str",
",",
"avatar_version",
":",
"int",
",",
"medium",
":",
"bool",
",",
"client_gravatar",
":",
"bool",
",",
")",
... | [
48,
0
] | [
97,
14
] | python | en | ['en', 'error', 'th'] | False |
absolute_avatar_url | (user_profile: UserProfile) |
Absolute URLs are used to simplify logic for applications that
won't be served by browsers, such as rendering GCM notifications.
|
Absolute URLs are used to simplify logic for applications that
won't be served by browsers, such as rendering GCM notifications.
| def absolute_avatar_url(user_profile: UserProfile) -> str:
"""
Absolute URLs are used to simplify logic for applications that
won't be served by browsers, such as rendering GCM notifications.
"""
avatar = avatar_url(user_profile)
# avatar_url can return None if client_gravatar=True, however here... | [
"def",
"absolute_avatar_url",
"(",
"user_profile",
":",
"UserProfile",
")",
"->",
"str",
":",
"avatar",
"=",
"avatar_url",
"(",
"user_profile",
")",
"# avatar_url can return None if client_gravatar=True, however here we use the default value of False",
"assert",
"avatar",
"is",... | [
128,
0
] | [
136,
63
] | python | en | ['en', 'error', 'th'] | False |
user_passes_test | (
test_func: Callable[[HttpResponse], bool],
login_url: Optional[str] = None,
redirect_field_name: str = REDIRECT_FIELD_NAME,
) |
Decorator for views that checks that the user passes the given test,
redirecting to the log-in page if necessary. The test should be a callable
that takes the user object and returns True if the user passes.
|
Decorator for views that checks that the user passes the given test,
redirecting to the log-in page if necessary. The test should be a callable
that takes the user object and returns True if the user passes.
| def user_passes_test(
test_func: Callable[[HttpResponse], bool],
login_url: Optional[str] = None,
redirect_field_name: str = REDIRECT_FIELD_NAME,
) -> Callable[[ViewFuncT], ViewFuncT]:
"""
Decorator for views that checks that the user passes the given test,
redirecting to the log-in page if nece... | [
"def",
"user_passes_test",
"(",
"test_func",
":",
"Callable",
"[",
"[",
"HttpResponse",
"]",
",",
"bool",
"]",
",",
"login_url",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"redirect_field_name",
":",
"str",
"=",
"REDIRECT_FIELD_NAME",
",",
")",
"-... | [
387,
0
] | [
423,
20
] | python | en | ['en', 'error', 'th'] | False |
do_login | (request: HttpRequest, user_profile: UserProfile) | Creates a session, logging in the user, using the Django method,
and also adds helpful data needed by our server logs.
| Creates a session, logging in the user, using the Django method,
and also adds helpful data needed by our server logs.
| def do_login(request: HttpRequest, user_profile: UserProfile) -> None:
"""Creates a session, logging in the user, using the Django method,
and also adds helpful data needed by our server logs.
"""
django_login(request, user_profile)
request._requestor_for_logs = user_profile.format_requestor_for_log... | [
"def",
"do_login",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"UserProfile",
")",
"->",
"None",
":",
"django_login",
"(",
"request",
",",
"user_profile",
")",
"request",
".",
"_requestor_for_logs",
"=",
"user_profile",
".",
"format_requestor_for... | [
442,
0
] | [
451,
50
] | python | en | ['en', 'en', 'en'] | True |
web_public_view | (
view_func: ViewFuncT,
redirect_field_name: str = REDIRECT_FIELD_NAME,
login_url: str = settings.HOME_NOT_LOGGED_IN,
) |
This wrapper adds client info for unauthenticated users but
forces authenticated users to go through 2fa.
NOTE: This function == zulip_login_required in a production environment as
web_public_view path has only been enabled for development purposes
currently.
|
This wrapper adds client info for unauthenticated users but
forces authenticated users to go through 2fa. | def web_public_view(
view_func: ViewFuncT,
redirect_field_name: str = REDIRECT_FIELD_NAME,
login_url: str = settings.HOME_NOT_LOGGED_IN,
) -> Union[Callable[[ViewFuncT], ViewFuncT], ViewFuncT]:
"""
This wrapper adds client info for unauthenticated users but
forces authenticated users to go throu... | [
"def",
"web_public_view",
"(",
"view_func",
":",
"ViewFuncT",
",",
"redirect_field_name",
":",
"str",
"=",
"REDIRECT_FIELD_NAME",
",",
"login_url",
":",
"str",
"=",
"settings",
".",
"HOME_NOT_LOGGED_IN",
",",
")",
"->",
"Union",
"[",
"Callable",
"[",
"[",
"Vie... | [
504,
0
] | [
525,
38
] | python | en | ['en', 'error', 'th'] | False |
internal_notify_view | (is_tornado_view: bool) | Used for situations where something running on the Zulip server
needs to make a request to the (other) Django/Tornado processes running on
the server. | Used for situations where something running on the Zulip server
needs to make a request to the (other) Django/Tornado processes running on
the server. | def internal_notify_view(is_tornado_view: bool) -> Callable[[ViewFuncT], ViewFuncT]:
# The typing here could be improved by using the Extended Callable types:
# https://mypy.readthedocs.io/en/latest/kinds_of_types.html#extended-callable-types
"""Used for situations where something running on the Zulip serve... | [
"def",
"internal_notify_view",
"(",
"is_tornado_view",
":",
"bool",
")",
"->",
"Callable",
"[",
"[",
"ViewFuncT",
"]",
",",
"ViewFuncT",
"]",
":",
"# The typing here could be improved by using the Extended Callable types:",
"# https://mypy.readthedocs.io/en/latest/kinds_of_types.... | [
807,
0
] | [
835,
29
] | python | en | ['en', 'en', 'en'] | True |
statsd_increment | (counter: str, val: int = 1) | Increments a statsd counter on completion of the
decorated function.
Pass the name of the counter to this decorator-returning function. | Increments a statsd counter on completion of the
decorated function. | def statsd_increment(counter: str, val: int = 1) -> Callable[[FuncT], FuncT]:
"""Increments a statsd counter on completion of the
decorated function.
Pass the name of the counter to this decorator-returning function."""
def wrapper(func: FuncT) -> FuncT:
@wraps(func)
def wrapped_func(*... | [
"def",
"statsd_increment",
"(",
"counter",
":",
"str",
",",
"val",
":",
"int",
"=",
"1",
")",
"->",
"Callable",
"[",
"[",
"FuncT",
"]",
",",
"FuncT",
"]",
":",
"def",
"wrapper",
"(",
"func",
":",
"FuncT",
")",
"->",
"FuncT",
":",
"@",
"wraps",
"(... | [
842,
0
] | [
857,
18
] | python | en | ['en', 'en', 'en'] | True |
rate_limit_user | (request: HttpRequest, user: UserProfile, domain: str) | Returns whether or not a user was rate limited. Will raise a RateLimited exception
if the user has been rate limited, otherwise returns and modifies request to contain
the rate limit information | Returns whether or not a user was rate limited. Will raise a RateLimited exception
if the user has been rate limited, otherwise returns and modifies request to contain
the rate limit information | def rate_limit_user(request: HttpRequest, user: UserProfile, domain: str) -> None:
"""Returns whether or not a user was rate limited. Will raise a RateLimited exception
if the user has been rate limited, otherwise returns and modifies request to contain
the rate limit information"""
RateLimitedUser(use... | [
"def",
"rate_limit_user",
"(",
"request",
":",
"HttpRequest",
",",
"user",
":",
"UserProfile",
",",
"domain",
":",
"str",
")",
"->",
"None",
":",
"RateLimitedUser",
"(",
"user",
",",
"domain",
"=",
"domain",
")",
".",
"rate_limit_request",
"(",
"request",
... | [
860,
0
] | [
865,
68
] | python | en | ['en', 'en', 'en'] | True |
rate_limit | (domain: str = "api_by_user") | Rate-limits a view. Takes an optional 'domain' param if you wish to
rate limit different types of API calls independently.
Returns a decorator | Rate-limits a view. Takes an optional 'domain' param if you wish to
rate limit different types of API calls independently. | def rate_limit(domain: str = "api_by_user") -> Callable[[ViewFuncT], ViewFuncT]:
"""Rate-limits a view. Takes an optional 'domain' param if you wish to
rate limit different types of API calls independently.
Returns a decorator"""
def wrapper(func: ViewFuncT) -> ViewFuncT:
@wraps(func)
... | [
"def",
"rate_limit",
"(",
"domain",
":",
"str",
"=",
"\"api_by_user\"",
")",
"->",
"Callable",
"[",
"[",
"ViewFuncT",
"]",
",",
"ViewFuncT",
"]",
":",
"def",
"wrapper",
"(",
"func",
":",
"ViewFuncT",
")",
"->",
"ViewFuncT",
":",
"@",
"wraps",
"(",
"fun... | [
868,
0
] | [
905,
18
] | python | en | ['en', 'en', 'en'] | True |
zulip_otp_required | (
redirect_field_name: str = "next",
login_url: str = settings.HOME_NOT_LOGGED_IN,
) |
The reason we need to create this function is that the stock
otp_required decorator doesn't play well with tests. We cannot
enable/disable if_configured parameter during tests since the decorator
retains its value due to closure.
Similar to :func:`~django.contrib.auth.decorators.login_required`, b... |
The reason we need to create this function is that the stock
otp_required decorator doesn't play well with tests. We cannot
enable/disable if_configured parameter during tests since the decorator
retains its value due to closure. | def zulip_otp_required(
redirect_field_name: str = "next",
login_url: str = settings.HOME_NOT_LOGGED_IN,
) -> Callable[[ViewFuncT], ViewFuncT]:
"""
The reason we need to create this function is that the stock
otp_required decorator doesn't play well with tests. We cannot
enable/disable if_config... | [
"def",
"zulip_otp_required",
"(",
"redirect_field_name",
":",
"str",
"=",
"\"next\"",
",",
"login_url",
":",
"str",
"=",
"settings",
".",
"HOME_NOT_LOGGED_IN",
",",
")",
"->",
"Callable",
"[",
"[",
"ViewFuncT",
"]",
",",
"ViewFuncT",
"]",
":",
"def",
"test",... | [
918,
0
] | [
967,
20
] | python | en | ['en', 'error', 'th'] | False |
GEOSCoordSeq.__init__ | (self, ptr, z=False) | Initialize from a GEOS pointer. | Initialize from a GEOS pointer. | def __init__(self, ptr, z=False):
"Initialize from a GEOS pointer."
if not isinstance(ptr, CS_PTR):
raise TypeError('Coordinate sequence should initialize with a CS_PTR.')
self._ptr = ptr
self._z = z | [
"def",
"__init__",
"(",
"self",
",",
"ptr",
",",
"z",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"ptr",
",",
"CS_PTR",
")",
":",
"raise",
"TypeError",
"(",
"'Coordinate sequence should initialize with a CS_PTR.'",
")",
"self",
".",
"_ptr",
"=",
... | [
19,
4
] | [
24,
19
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.__iter__ | (self) | Iterate over each point in the coordinate sequence. | Iterate over each point in the coordinate sequence. | def __iter__(self):
"Iterate over each point in the coordinate sequence."
for i in range(self.size):
yield self[i] | [
"def",
"__iter__",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"size",
")",
":",
"yield",
"self",
"[",
"i",
"]"
] | [
26,
4
] | [
29,
25
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.__len__ | (self) | Return the number of points in the coordinate sequence. | Return the number of points in the coordinate sequence. | def __len__(self):
"Return the number of points in the coordinate sequence."
return int(self.size) | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"int",
"(",
"self",
".",
"size",
")"
] | [
31,
4
] | [
33,
29
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.__str__ | (self) | Return the string representation of the coordinate sequence. | Return the string representation of the coordinate sequence. | def __str__(self):
"Return the string representation of the coordinate sequence."
return str(self.tuple) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"str",
"(",
"self",
".",
"tuple",
")"
] | [
35,
4
] | [
37,
30
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.__getitem__ | (self, index) | Return the coordinate sequence value at the given index. | Return the coordinate sequence value at the given index. | def __getitem__(self, index):
"Return the coordinate sequence value at the given index."
self._checkindex(index)
return self._point_getter(index) | [
"def",
"__getitem__",
"(",
"self",
",",
"index",
")",
":",
"self",
".",
"_checkindex",
"(",
"index",
")",
"return",
"self",
".",
"_point_getter",
"(",
"index",
")"
] | [
39,
4
] | [
42,
40
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.__setitem__ | (self, index, value) | Set the coordinate sequence value at the given index. | Set the coordinate sequence value at the given index. | def __setitem__(self, index, value):
"Set the coordinate sequence value at the given index."
# Checking the input value
if isinstance(value, (list, tuple)):
pass
elif numpy and isinstance(value, numpy.ndarray):
pass
else:
raise TypeError('Must ... | [
"def",
"__setitem__",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"# Checking the input value",
"if",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"pass",
"elif",
"numpy",
"and",
"isinstance",
"(",
"value",
",",
"nump... | [
44,
4
] | [
63,
34
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq._checkindex | (self, index) | Check the given index. | Check the given index. | def _checkindex(self, index):
"Check the given index."
if not (0 <= index < self.size):
raise IndexError('invalid GEOS Geometry index: %s' % index) | [
"def",
"_checkindex",
"(",
"self",
",",
"index",
")",
":",
"if",
"not",
"(",
"0",
"<=",
"index",
"<",
"self",
".",
"size",
")",
":",
"raise",
"IndexError",
"(",
"'invalid GEOS Geometry index: %s'",
"%",
"index",
")"
] | [
66,
4
] | [
69,
71
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq._checkdim | (self, dim) | Check the given dimension. | Check the given dimension. | def _checkdim(self, dim):
"Check the given dimension."
if dim < 0 or dim > 2:
raise GEOSException('invalid ordinate dimension "%d"' % dim) | [
"def",
"_checkdim",
"(",
"self",
",",
"dim",
")",
":",
"if",
"dim",
"<",
"0",
"or",
"dim",
">",
"2",
":",
"raise",
"GEOSException",
"(",
"'invalid ordinate dimension \"%d\"'",
"%",
"dim",
")"
] | [
71,
4
] | [
74,
72
] | python | en | ['en', 'it', 'en'] | True |
GEOSCoordSeq.getOrdinate | (self, dimension, index) | Return the value for the given dimension and index. | Return the value for the given dimension and index. | def getOrdinate(self, dimension, index):
"Return the value for the given dimension and index."
self._checkindex(index)
self._checkdim(dimension)
return capi.cs_getordinate(self.ptr, index, dimension, byref(c_double())) | [
"def",
"getOrdinate",
"(",
"self",
",",
"dimension",
",",
"index",
")",
":",
"self",
".",
"_checkindex",
"(",
"index",
")",
"self",
".",
"_checkdim",
"(",
"dimension",
")",
"return",
"capi",
".",
"cs_getordinate",
"(",
"self",
".",
"ptr",
",",
"index",
... | [
116,
4
] | [
120,
81
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.setOrdinate | (self, dimension, index, value) | Set the value for the given dimension and index. | Set the value for the given dimension and index. | def setOrdinate(self, dimension, index, value):
"Set the value for the given dimension and index."
self._checkindex(index)
self._checkdim(dimension)
capi.cs_setordinate(self.ptr, index, dimension, value) | [
"def",
"setOrdinate",
"(",
"self",
",",
"dimension",
",",
"index",
",",
"value",
")",
":",
"self",
".",
"_checkindex",
"(",
"index",
")",
"self",
".",
"_checkdim",
"(",
"dimension",
")",
"capi",
".",
"cs_setordinate",
"(",
"self",
".",
"ptr",
",",
"ind... | [
122,
4
] | [
126,
62
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.getX | (self, index) | Get the X value at the index. | Get the X value at the index. | def getX(self, index):
"Get the X value at the index."
return self.getOrdinate(0, index) | [
"def",
"getX",
"(",
"self",
",",
"index",
")",
":",
"return",
"self",
".",
"getOrdinate",
"(",
"0",
",",
"index",
")"
] | [
128,
4
] | [
130,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.setX | (self, index, value) | Set X with the value at the given index. | Set X with the value at the given index. | def setX(self, index, value):
"Set X with the value at the given index."
self.setOrdinate(0, index, value) | [
"def",
"setX",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"self",
".",
"setOrdinate",
"(",
"0",
",",
"index",
",",
"value",
")"
] | [
132,
4
] | [
134,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.getY | (self, index) | Get the Y value at the given index. | Get the Y value at the given index. | def getY(self, index):
"Get the Y value at the given index."
return self.getOrdinate(1, index) | [
"def",
"getY",
"(",
"self",
",",
"index",
")",
":",
"return",
"self",
".",
"getOrdinate",
"(",
"1",
",",
"index",
")"
] | [
136,
4
] | [
138,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.setY | (self, index, value) | Set Y with the value at the given index. | Set Y with the value at the given index. | def setY(self, index, value):
"Set Y with the value at the given index."
self.setOrdinate(1, index, value) | [
"def",
"setY",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"self",
".",
"setOrdinate",
"(",
"1",
",",
"index",
",",
"value",
")"
] | [
140,
4
] | [
142,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.getZ | (self, index) | Get Z with the value at the given index. | Get Z with the value at the given index. | def getZ(self, index):
"Get Z with the value at the given index."
return self.getOrdinate(2, index) | [
"def",
"getZ",
"(",
"self",
",",
"index",
")",
":",
"return",
"self",
".",
"getOrdinate",
"(",
"2",
",",
"index",
")"
] | [
144,
4
] | [
146,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.setZ | (self, index, value) | Set Z with the value at the given index. | Set Z with the value at the given index. | def setZ(self, index, value):
"Set Z with the value at the given index."
self.setOrdinate(2, index, value) | [
"def",
"setZ",
"(",
"self",
",",
"index",
",",
"value",
")",
":",
"self",
".",
"setOrdinate",
"(",
"2",
",",
"index",
",",
"value",
")"
] | [
148,
4
] | [
150,
41
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.size | (self) | Return the size of this coordinate sequence. | Return the size of this coordinate sequence. | def size(self):
"Return the size of this coordinate sequence."
return capi.cs_getsize(self.ptr, byref(c_uint())) | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"capi",
".",
"cs_getsize",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_uint",
"(",
")",
")",
")"
] | [
154,
4
] | [
156,
57
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.dims | (self) | Return the dimensions of this coordinate sequence. | Return the dimensions of this coordinate sequence. | def dims(self):
"Return the dimensions of this coordinate sequence."
return capi.cs_getdims(self.ptr, byref(c_uint())) | [
"def",
"dims",
"(",
"self",
")",
":",
"return",
"capi",
".",
"cs_getdims",
"(",
"self",
".",
"ptr",
",",
"byref",
"(",
"c_uint",
"(",
")",
")",
")"
] | [
159,
4
] | [
161,
57
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.hasz | (self) |
Return whether this coordinate sequence is 3D. This property value is
inherited from the parent Geometry.
|
Return whether this coordinate sequence is 3D. This property value is
inherited from the parent Geometry.
| def hasz(self):
"""
Return whether this coordinate sequence is 3D. This property value is
inherited from the parent Geometry.
"""
return self._z | [
"def",
"hasz",
"(",
"self",
")",
":",
"return",
"self",
".",
"_z"
] | [
164,
4
] | [
169,
22
] | python | en | ['en', 'error', 'th'] | False |
GEOSCoordSeq.clone | (self) | Clone this coordinate sequence. | Clone this coordinate sequence. | def clone(self):
"Clone this coordinate sequence."
return GEOSCoordSeq(capi.cs_clone(self.ptr), self.hasz) | [
"def",
"clone",
"(",
"self",
")",
":",
"return",
"GEOSCoordSeq",
"(",
"capi",
".",
"cs_clone",
"(",
"self",
".",
"ptr",
")",
",",
"self",
".",
"hasz",
")"
] | [
172,
4
] | [
174,
63
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.kml | (self) | Return the KML representation for the coordinates. | Return the KML representation for the coordinates. | def kml(self):
"Return the KML representation for the coordinates."
# Getting the substitution string depending on whether the coordinates have
# a Z dimension.
if self.hasz:
substr = '%s,%s,%s '
else:
substr = '%s,%s,0 '
return '<coordinates>%s</... | [
"def",
"kml",
"(",
"self",
")",
":",
"# Getting the substitution string depending on whether the coordinates have",
"# a Z dimension.",
"if",
"self",
".",
"hasz",
":",
"substr",
"=",
"'%s,%s,%s '",
"else",
":",
"substr",
"=",
"'%s,%s,0 '",
"return",
"'<coordinates>%s</co... | [
177,
4
] | [
186,
71
] | python | en | ['en', 'en', 'en'] | True |
GEOSCoordSeq.tuple | (self) | Return a tuple version of this coordinate sequence. | Return a tuple version of this coordinate sequence. | def tuple(self):
"Return a tuple version of this coordinate sequence."
n = self.size
get_point = self._point_getter
if n == 1:
return get_point(0)
return tuple(get_point(i) for i in range(n)) | [
"def",
"tuple",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"size",
"get_point",
"=",
"self",
".",
"_point_getter",
"if",
"n",
"==",
"1",
":",
"return",
"get_point",
"(",
"0",
")",
"return",
"tuple",
"(",
"get_point",
"(",
"i",
")",
"for",
"i",
... | [
189,
4
] | [
195,
52
] | python | en | ['en', 'en', 'en'] | True |
ArchiveTester.setUp | (self) |
Create temporary directory for testing extraction.
|
Create temporary directory for testing extraction.
| def setUp(self):
"""
Create temporary directory for testing extraction.
"""
self.old_cwd = os.getcwd()
self.tmpdir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.tmpdir)
self.archive_path = os.path.join(TEST_DIR, self.archive)
self.archive_lead_p... | [
"def",
"setUp",
"(",
"self",
")",
":",
"self",
".",
"old_cwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"self",
".",
"tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"self",
".",
"addCleanup",
"(",
"shutil",
".",
"rmtree",
",",
"self",
".",
"tmpdir"... | [
15,
4
] | [
25,
26
] | python | en | ['en', 'error', 'th'] | False |
test_disallowed_methods | (all_user_types_api_client, list_url) |
Tests that PUT, PATCH and DELETE aren't allowed to reservation list endpoint.
|
Tests that PUT, PATCH and DELETE aren't allowed to reservation list endpoint.
| def test_disallowed_methods(all_user_types_api_client, list_url):
"""
Tests that PUT, PATCH and DELETE aren't allowed to reservation list endpoint.
"""
check_disallowed_methods(all_user_types_api_client, (list_url, ), ('put', 'patch', 'delete')) | [
"def",
"test_disallowed_methods",
"(",
"all_user_types_api_client",
",",
"list_url",
")",
":",
"check_disallowed_methods",
"(",
"all_user_types_api_client",
",",
"(",
"list_url",
",",
")",
",",
"(",
"'put'",
",",
"'patch'",
",",
"'delete'",
")",
")"
] | [
198,
0
] | [
202,
97
] | python | en | ['en', 'error', 'th'] | False |
test_reservation_requires_authenticated_user | (api_client, list_url, reservation_data) |
Tests that an unauthenticated user cannot create a reservation.
|
Tests that an unauthenticated user cannot create a reservation.
| def test_reservation_requires_authenticated_user(api_client, list_url, reservation_data):
"""
Tests that an unauthenticated user cannot create a reservation.
"""
response = api_client.post(list_url, data=reservation_data)
assert response.status_code == 401 | [
"def",
"test_reservation_requires_authenticated_user",
"(",
"api_client",
",",
"list_url",
",",
"reservation_data",
")",
":",
"response",
"=",
"api_client",
".",
"post",
"(",
"list_url",
",",
"data",
"=",
"reservation_data",
")",
"assert",
"response",
".",
"status_c... | [
206,
0
] | [
211,
38
] | python | en | ['en', 'error', 'th'] | False |
test_authenticated_user_can_make_reservation | (api_client, list_url, reservation_data, resource_in_unit, user) |
Tests that an authenticated user can create a reservation.
|
Tests that an authenticated user can create a reservation.
| def test_authenticated_user_can_make_reservation(api_client, list_url, reservation_data, resource_in_unit, user):
"""
Tests that an authenticated user can create a reservation.
"""
api_client.force_authenticate(user=user)
response = api_client.post(list_url, data=reservation_data)
assert respon... | [
"def",
"test_authenticated_user_can_make_reservation",
"(",
"api_client",
",",
"list_url",
",",
"reservation_data",
",",
"resource_in_unit",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"response",
"=",
"api_client",
... | [
215,
0
] | [
226,
83
] | python | en | ['en', 'error', 'th'] | False |
test_authenticated_user_can_modify_reservation | (
api_client, detail_url, reservation_data, resource_in_unit, user) |
Tests that an authenticated user can modify her own reservation
|
Tests that an authenticated user can modify her own reservation
| def test_authenticated_user_can_modify_reservation(
api_client, detail_url, reservation_data, resource_in_unit, user):
"""
Tests that an authenticated user can modify her own reservation
"""
api_client.force_authenticate(user=user)
response = api_client.put(detail_url, data=reservation_data... | [
"def",
"test_authenticated_user_can_modify_reservation",
"(",
"api_client",
",",
"detail_url",
",",
"reservation_data",
",",
"resource_in_unit",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"response",
"=",
"api_client... | [
230,
0
] | [
242,
83
] | python | en | ['en', 'error', 'th'] | False |
test_another_user_modifies_reservations | (
api_client, detail_url, reservation_data, resource_in_unit, user2) |
Tests that an authenticated user can modify her own reservation
|
Tests that an authenticated user can modify her own reservation
| def test_another_user_modifies_reservations(
api_client, detail_url, reservation_data, resource_in_unit, user2):
"""
Tests that an authenticated user can modify her own reservation
"""
api_client.force_authenticate(user=user2)
# No permission
response = api_client.put(detail_url, data=r... | [
"def",
"test_another_user_modifies_reservations",
"(",
"api_client",
",",
"detail_url",
",",
"reservation_data",
",",
"resource_in_unit",
",",
"user2",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user2",
")",
"# No permission",
"response",
"=... | [
246,
0
] | [
265,
83
] | python | en | ['en', 'error', 'th'] | False |
test_authenticated_user_can_delete_reservation | (api_client, detail_url, reservation, user) |
Tests that an authenticated user can delete her own reservation
|
Tests that an authenticated user can delete her own reservation
| def test_authenticated_user_can_delete_reservation(api_client, detail_url, reservation, user):
"""
Tests that an authenticated user can delete her own reservation
"""
api_client.force_authenticate(user=user)
reservation_id = reservation.id
response = api_client.delete(detail_url)
assert res... | [
"def",
"test_authenticated_user_can_delete_reservation",
"(",
"api_client",
",",
"detail_url",
",",
"reservation",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"reservation_id",
"=",
"reservation",
".",
"id",
"respon... | [
269,
0
] | [
280,
53
] | python | en | ['en', 'error', 'th'] | False |
test_reservation_limit_per_user | (api_client, list_url, reservation, reservation_data, user) |
Tests that a user cannot exceed her active reservation limit for one resource.
|
Tests that a user cannot exceed her active reservation limit for one resource.
| def test_reservation_limit_per_user(api_client, list_url, reservation, reservation_data, user):
"""
Tests that a user cannot exceed her active reservation limit for one resource.
"""
api_client.force_authenticate(user=user)
# the user already has one reservation, making another reservation should n... | [
"def",
"test_reservation_limit_per_user",
"(",
"api_client",
",",
"list_url",
",",
"reservation",
",",
"reservation_data",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"# the user already has one reservation, making anothe... | [
284,
0
] | [
295,
114
] | python | en | ['en', 'error', 'th'] | False |
test_old_reservations_are_excluded | (api_client, list_url, resource_in_unit, reservation_data, user) |
Tests that a reservation in the past doesn't count when checking reservation limit.
|
Tests that a reservation in the past doesn't count when checking reservation limit.
| def test_old_reservations_are_excluded(api_client, list_url, resource_in_unit, reservation_data, user):
"""
Tests that a reservation in the past doesn't count when checking reservation limit.
"""
# the user already has this reservation which is in the past.
Reservation.objects.create(
resou... | [
"def",
"test_old_reservations_are_excluded",
"(",
"api_client",
",",
"list_url",
",",
"resource_in_unit",
",",
"reservation_data",
",",
"user",
")",
":",
"# the user already has this reservation which is in the past.",
"Reservation",
".",
"objects",
".",
"create",
"(",
"res... | [
299,
0
] | [
316,
38
] | python | en | ['en', 'error', 'th'] | False |
test_general_admins_have_no_reservation_limit | (
api_client, list_url, reservation, reservation_data,
general_admin) |
Tests that the reservation limits for a resource do not apply to staff.
|
Tests that the reservation limits for a resource do not apply to staff.
| def test_general_admins_have_no_reservation_limit(
api_client, list_url, reservation, reservation_data,
general_admin):
"""
Tests that the reservation limits for a resource do not apply to staff.
"""
api_client.force_authenticate(user=general_admin)
# the admin already has one reser... | [
"def",
"test_general_admins_have_no_reservation_limit",
"(",
"api_client",
",",
"list_url",
",",
"reservation",
",",
"reservation_data",
",",
"general_admin",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"general_admin",
")",
"# the admin already h... | [
320,
0
] | [
332,
38
] | python | en | ['en', 'error', 'th'] | False |
test_opening_hours | (api_client, list_url, reservation_data, resource_group,
user) |
Tests that a normal user cannot make reservations outside open hours.
|
Tests that a normal user cannot make reservations outside open hours.
| def test_opening_hours(api_client, list_url, reservation_data, resource_group,
user):
"""
Tests that a normal user cannot make reservations outside open hours.
"""
api_client.force_authenticate(user=user)
# invalid day
reservation_data['begin'] = '2115-06-01T09:00:00+02:0... | [
"def",
"test_opening_hours",
"(",
"api_client",
",",
"list_url",
",",
"reservation_data",
",",
"resource_group",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"# invalid day",
"reservation_data",
"[",
"'begin'",
"]"... | [
336,
0
] | [
377,
38
] | python | en | ['en', 'error', 'th'] | False |
test_normal_user_cannot_make_reservation_longer_than_max_period | (api_client, list_url, reservation_data, user) |
Tests that a normal user cannot make reservations longer than the resource's max period.
|
Tests that a normal user cannot make reservations longer than the resource's max period.
| def test_normal_user_cannot_make_reservation_longer_than_max_period(api_client, list_url, reservation_data, user):
"""
Tests that a normal user cannot make reservations longer than the resource's max period.
"""
api_client.force_authenticate(user=user)
# the reservation's length is 3h (11 -> 14) wh... | [
"def",
"test_normal_user_cannot_make_reservation_longer_than_max_period",
"(",
"api_client",
",",
"list_url",
",",
"reservation_data",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"# the reservation's length is 3h (11 -> 14) w... | [
381,
0
] | [
391,
82
] | python | en | ['en', 'error', 'th'] | False |
test_admin_can_make_reservation_outside_open_hours | (
api_client, list_url, reservation_data, general_admin) |
Tests that a staff member can make reservations outside opening hours.
Also tests that the resource's max period doesn't limit staff.
|
Tests that a staff member can make reservations outside opening hours. | def test_admin_can_make_reservation_outside_open_hours(
api_client, list_url, reservation_data, general_admin):
"""
Tests that a staff member can make reservations outside opening hours.
Also tests that the resource's max period doesn't limit staff.
"""
api_client.force_authenticate(user=ge... | [
"def",
"test_admin_can_make_reservation_outside_open_hours",
"(",
"api_client",
",",
"list_url",
",",
"reservation_data",
",",
"general_admin",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"general_admin",
")",
"# begin time before opening time, end ti... | [
395,
0
] | [
408,
38
] | python | en | ['en', 'error', 'th'] | False |
test_user_data_correct_and_only_for_admins | (
api_client, reservation, user, general_admin) |
Tests that user object is returned within Reservation data and it is in the correct form.
Also tests that only staff can see the user object.
|
Tests that user object is returned within Reservation data and it is in the correct form. | def test_user_data_correct_and_only_for_admins(
api_client, reservation, user, general_admin):
"""
Tests that user object is returned within Reservation data and it is in the correct form.
Also tests that only staff can see the user object.
"""
api_client.force_authenticate(user=user)
d... | [
"def",
"test_user_data_correct_and_only_for_admins",
"(",
"api_client",
",",
"reservation",
",",
"user",
",",
"general_admin",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"detail_url",
"=",
"reverse",
"(",
"'reservation-detail'",
... | [
438,
0
] | [
456,
37
] | python | en | ['en', 'error', 'th'] | False |
test_reservation_can_be_modified_by_overlapping_reservation | (api_client, reservation, reservation_data, user) |
Tests that a reservation can be modified with times that overlap with the original times.
|
Tests that a reservation can be modified with times that overlap with the original times.
| def test_reservation_can_be_modified_by_overlapping_reservation(api_client, reservation, reservation_data, user):
"""
Tests that a reservation can be modified with times that overlap with the original times.
"""
api_client.force_authenticate(user=user)
detail_url = reverse('reservation-detail', kwar... | [
"def",
"test_reservation_can_be_modified_by_overlapping_reservation",
"(",
"api_client",
",",
"reservation",
",",
"reservation_data",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"detail_url",
"=",
"reverse",
"(",
"'re... | [
460,
0
] | [
474,
83
] | python | en | ['en', 'error', 'th'] | False |
test_non_reservable_resource_restrictions | (
api_client, list_url, resource_group,
reservation_data, user, group, perm_type, general_admin) |
Tests that a normal user cannot make a reservation to a
non-reservable resource but admins can.
Creating a new reservation with POST and updating an existing one with PUT are both tested.
|
Tests that a normal user cannot make a reservation to a
non-reservable resource but admins can. | def test_non_reservable_resource_restrictions(
api_client, list_url, resource_group,
reservation_data, user, group, perm_type, general_admin):
"""
Tests that a normal user cannot make a reservation to a
non-reservable resource but admins can.
Creating a new reservation with POST and upd... | [
"def",
"test_non_reservable_resource_restrictions",
"(",
"api_client",
",",
"list_url",
",",
"resource_group",
",",
"reservation_data",
",",
"user",
",",
"group",
",",
"perm_type",
",",
"general_admin",
")",
":",
"resource_in_unit",
"=",
"resource_group",
".",
"resour... | [
479,
0
] | [
535,
38
] | python | en | ['en', 'error', 'th'] | False |
test_reservation_restrictions_by_owner | (
api_client, list_url, reservation, reservation_data,
user2, general_admin) |
Tests that a normal user can't modify other people's reservations
while an admin can.
|
Tests that a normal user can't modify other people's reservations
while an admin can.
| def test_reservation_restrictions_by_owner(
api_client, list_url, reservation, reservation_data,
user2, general_admin):
"""
Tests that a normal user can't modify other people's reservations
while an admin can.
"""
detail_url = reverse('reservation-detail', kwargs={'pk': reservation.p... | [
"def",
"test_reservation_restrictions_by_owner",
"(",
"api_client",
",",
"list_url",
",",
"reservation",
",",
"reservation_data",
",",
"user2",
",",
"general_admin",
")",
":",
"detail_url",
"=",
"reverse",
"(",
"'reservation-detail'",
",",
"kwargs",
"=",
"{",
"'pk'"... | [
539,
0
] | [
560,
38
] | python | en | ['en', 'error', 'th'] | False |
test_normal_users_cannot_make_reservations_for_others | (
api_client, list_url, reservation, reservation_data, user, user2) |
Tests that a normal user cannot make a reservation for other people.
|
Tests that a normal user cannot make a reservation for other people.
| def test_normal_users_cannot_make_reservations_for_others(
api_client, list_url, reservation, reservation_data, user, user2):
"""
Tests that a normal user cannot make a reservation for other people.
"""
api_client.force_authenticate(user=user)
detail_url = reverse('reservation-detail', kwarg... | [
"def",
"test_normal_users_cannot_make_reservations_for_others",
"(",
"api_client",
",",
"list_url",
",",
"reservation",
",",
"reservation_data",
",",
"user",
",",
"user2",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"detail_url",
... | [
564,
0
] | [
591,
39
] | python | en | ['en', 'error', 'th'] | False |
test_admins_can_make_reservations_for_others | (
api_client, list_url, reservation, reservation_data,
user2, general_admin) |
Tests that a staff member can make reservations for other people without normal user restrictions.
|
Tests that a staff member can make reservations for other people without normal user restrictions.
| def test_admins_can_make_reservations_for_others(
api_client, list_url, reservation, reservation_data,
user2, general_admin):
"""
Tests that a staff member can make reservations for other people without normal user restrictions.
"""
api_client.force_authenticate(user=general_admin)
... | [
"def",
"test_admins_can_make_reservations_for_others",
"(",
"api_client",
",",
"list_url",
",",
"reservation",
",",
"reservation_data",
",",
"user2",
",",
"general_admin",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"general_admin",
")",
"# de... | [
595,
0
] | [
622,
40
] | python | en | ['en', 'error', 'th'] | False |
test_reservation_user_filter | (api_client, list_url, reservation, resource_in_unit, user, user2) |
Tests that reservation user and is_own filtering work correctly.
|
Tests that reservation user and is_own filtering work correctly.
| def test_reservation_user_filter(api_client, list_url, reservation, resource_in_unit, user, user2):
"""
Tests that reservation user and is_own filtering work correctly.
"""
reservation2 = Reservation.objects.create(
resource=resource_in_unit,
begin=dateparse.parse_datetime('2115-04-07T1... | [
"def",
"test_reservation_user_filter",
"(",
"api_client",
",",
"list_url",
",",
"reservation",
",",
"resource_in_unit",
",",
"user",
",",
"user2",
")",
":",
"reservation2",
"=",
"Reservation",
".",
"objects",
".",
"create",
"(",
"resource",
"=",
"resource_in_unit"... | [
626,
0
] | [
655,
63
] | python | en | ['en', 'error', 'th'] | False |
test_max_reservation_period_error_message | (
api_client, list_url, resource_in_unit, reservation_data, user, input_hours, input_mins, expected) |
Tests that maximum reservation period error is returned in correct humanized form.
|
Tests that maximum reservation period error is returned in correct humanized form.
| def test_max_reservation_period_error_message(
api_client, list_url, resource_in_unit, reservation_data, user, input_hours, input_mins, expected):
"""
Tests that maximum reservation period error is returned in correct humanized form.
"""
reservation_data['end'] = '2115-04-04T16:00:00+02:00' # ... | [
"def",
"test_max_reservation_period_error_message",
"(",
"api_client",
",",
"list_url",
",",
"resource_in_unit",
",",
"reservation_data",
",",
"user",
",",
"input_hours",
",",
"input_mins",
",",
"expected",
")",
":",
"reservation_data",
"[",
"'end'",
"]",
"=",
"'211... | [
705,
0
] | [
719,
100
] | python | en | ['en', 'error', 'th'] | False |
test_reservation_excels | (staff_api_client, list_url, detail_url, reservation, user) |
Tests that reservation list and detail endpoints return .xlsx files when requested
|
Tests that reservation list and detail endpoints return .xlsx files when requested
| def test_reservation_excels(staff_api_client, list_url, detail_url, reservation, user):
"""
Tests that reservation list and detail endpoints return .xlsx files when requested
"""
response = staff_api_client.get(
list_url,
HTTP_ACCEPT='application/vnd.openxmlformats-officedocument.spread... | [
"def",
"test_reservation_excels",
"(",
"staff_api_client",
",",
"list_url",
",",
"detail_url",
",",
"reservation",
",",
"user",
")",
":",
"response",
"=",
"staff_api_client",
".",
"get",
"(",
"list_url",
",",
"HTTP_ACCEPT",
"=",
"'application/vnd.openxmlformats-office... | [
723,
0
] | [
745,
36
] | python | en | ['en', 'error', 'th'] | False |
test_admins_can_make_reservations_despite_delay | (
api_client, list_url, resource_in_unit, reservation_data, general_admin) |
Admin should be able to make reservations regardless of reservation delay limitations
|
Admin should be able to make reservations regardless of reservation delay limitations
| def test_admins_can_make_reservations_despite_delay(
api_client, list_url, resource_in_unit, reservation_data, general_admin):
"""
Admin should be able to make reservations regardless of reservation delay limitations
"""
api_client.force_authenticate(user=general_admin)
resource_in_unit.rese... | [
"def",
"test_admins_can_make_reservations_despite_delay",
"(",
"api_client",
",",
"list_url",
",",
"resource_in_unit",
",",
"reservation_data",
",",
"general_admin",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"general_admin",
")",
"resource_in_un... | [
1652,
0
] | [
1667,
92
] | python | en | ['en', 'error', 'th'] | False |
test_normal_user_can_not_make_staff_reservation | (
api_client, list_url, reservation_data_extra, user) |
Authenticated normal user should not be able to create a staff event reservation.
|
Authenticated normal user should not be able to create a staff event reservation.
| def test_normal_user_can_not_make_staff_reservation(
api_client, list_url, reservation_data_extra, user):
"""
Authenticated normal user should not be able to create a staff event reservation.
"""
api_client.force_authenticate(user=user)
reservation_data_extra['staff_event'] = True
respo... | [
"def",
"test_normal_user_can_not_make_staff_reservation",
"(",
"api_client",
",",
"list_url",
",",
"reservation_data_extra",
",",
"user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"user",
"=",
"user",
")",
"reservation_data_extra",
"[",
"'staff_event'",
"]... | [
1971,
0
] | [
1980,
38
] | python | en | ['en', 'error', 'th'] | False |
test_manager_can_make_staff_reservation | (
resource_in_unit, list_url, reservation_data, staff_user, staff_api_client) |
User with manager status on the resource should be able to make staff event reservations.
|
User with manager status on the resource should be able to make staff event reservations.
| def test_manager_can_make_staff_reservation(
resource_in_unit, list_url, reservation_data, staff_user, staff_api_client):
"""
User with manager status on the resource should be able to make staff event reservations.
"""
reservation_data['staff_event'] = True
reservation_data['reserver_name']... | [
"def",
"test_manager_can_make_staff_reservation",
"(",
"resource_in_unit",
",",
"list_url",
",",
"reservation_data",
",",
"staff_user",
",",
"staff_api_client",
")",
":",
"reservation_data",
"[",
"'staff_event'",
"]",
"=",
"True",
"reservation_data",
"[",
"'reserver_name'... | [
1984,
0
] | [
1997,
42
] | python | en | ['en', 'error', 'th'] | False |
test_reservation_default_type | (reservation_data, user_api_client) | Reservation should return default reservation type | Reservation should return default reservation type | def test_reservation_default_type(reservation_data, user_api_client):
""" Reservation should return default reservation type """
list_url = reverse('reservation-list')
response = user_api_client.post(list_url, data=reservation_data)
detail_url = reverse('reservation-detail', kwargs={'pk': response.data[... | [
"def",
"test_reservation_default_type",
"(",
"reservation_data",
",",
"user_api_client",
")",
":",
"list_url",
"=",
"reverse",
"(",
"'reservation-list'",
")",
"response",
"=",
"user_api_client",
".",
"post",
"(",
"list_url",
",",
"data",
"=",
"reservation_data",
")"... | [
2066,
0
] | [
2072,
59
] | python | en | ['en', 'da', 'en'] | True |
test_reservation_normal_type_normal_user | (resource_in_unit, reservation_data, user_api_client) | Normal user should be able to create a NORMAL type reservation | Normal user should be able to create a NORMAL type reservation | def test_reservation_normal_type_normal_user(resource_in_unit, reservation_data, user_api_client):
""" Normal user should be able to create a NORMAL type reservation """
list_url = reverse('reservation-list')
reservation_data['type'] = Reservation.TYPE_NORMAL
response = user_api_client.post(list_url, da... | [
"def",
"test_reservation_normal_type_normal_user",
"(",
"resource_in_unit",
",",
"reservation_data",
",",
"user_api_client",
")",
":",
"list_url",
"=",
"reverse",
"(",
"'reservation-list'",
")",
"reservation_data",
"[",
"'type'",
"]",
"=",
"Reservation",
".",
"TYPE_NORM... | [
2076,
0
] | [
2082,
59
] | python | en | ['en', 'en', 'en'] | True |
test_reservation_block_type_normal_user | (resource_in_unit, reservation_data, user_api_client) | Normal user should not be able to create a BLOCKED type reservation | Normal user should not be able to create a BLOCKED type reservation | def test_reservation_block_type_normal_user(resource_in_unit, reservation_data, user_api_client):
""" Normal user should not be able to create a BLOCKED type reservation """
list_url = reverse('reservation-list')
reservation_data['type'] = Reservation.TYPE_BLOCKED
response = user_api_client.post(list_ur... | [
"def",
"test_reservation_block_type_normal_user",
"(",
"resource_in_unit",
",",
"reservation_data",
",",
"user_api_client",
")",
":",
"list_url",
"=",
"reverse",
"(",
"'reservation-list'",
")",
"reservation_data",
"[",
"'type'",
"]",
"=",
"Reservation",
".",
"TYPE_BLOCK... | [
2086,
0
] | [
2091,
38
] | python | en | ['en', 'en', 'en'] | True |
test_reservation_block_type_manager | (resource_in_unit, reservation_data, api_client, unit_manager_user) | Unit manager user should be able to create a BLOCKED type reservation | Unit manager user should be able to create a BLOCKED type reservation | def test_reservation_block_type_manager(resource_in_unit, reservation_data, api_client, unit_manager_user):
""" Unit manager user should be able to create a BLOCKED type reservation """
api_client.force_authenticate(unit_manager_user)
list_url = reverse('reservation-list')
reservation_data['type'] = Res... | [
"def",
"test_reservation_block_type_manager",
"(",
"resource_in_unit",
",",
"reservation_data",
",",
"api_client",
",",
"unit_manager_user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"unit_manager_user",
")",
"list_url",
"=",
"reverse",
"(",
"'reservation-li... | [
2095,
0
] | [
2104,
59
] | python | en | ['en', 'en', 'en'] | True |
test_reservation_cannot_add_bogus_type | (resource_in_unit, reservation_data, api_client, unit_manager_user) | User should not be able to add a non-supported type to reservation | User should not be able to add a non-supported type to reservation | def test_reservation_cannot_add_bogus_type(resource_in_unit, reservation_data, api_client, unit_manager_user):
""" User should not be able to add a non-supported type to reservation """
api_client.force_authenticate(unit_manager_user)
list_url = reverse('reservation-list')
reservation_data['type'] = 'fo... | [
"def",
"test_reservation_cannot_add_bogus_type",
"(",
"resource_in_unit",
",",
"reservation_data",
",",
"api_client",
",",
"unit_manager_user",
")",
":",
"api_client",
".",
"force_authenticate",
"(",
"unit_manager_user",
")",
"list_url",
"=",
"reverse",
"(",
"'reservation... | [
2108,
0
] | [
2114,
38
] | python | en | ['en', 'en', 'en'] | True |
test_admin_can_make_staff_reservation | (
resource_in_unit, list_url, reservation_data, unit_admin_user, api_client) |
User with admin status on the resource should be able to make staff event reservations.
|
User with admin status on the resource should be able to make staff event reservations.
| def test_admin_can_make_staff_reservation(
resource_in_unit, list_url, reservation_data, unit_admin_user, api_client):
"""
User with admin status on the resource should be able to make staff event reservations.
"""
reservation_data['staff_event'] = True
reservation_data['reserver_name'] = 'h... | [
"def",
"test_admin_can_make_staff_reservation",
"(",
"resource_in_unit",
",",
"list_url",
",",
"reservation_data",
",",
"unit_admin_user",
",",
"api_client",
")",
":",
"reservation_data",
"[",
"'staff_event'",
"]",
"=",
"True",
"reservation_data",
"[",
"'reserver_name'",
... | [
2298,
0
] | [
2312,
42
] | python | en | ['en', 'error', 'th'] | False |
test_admin_can_create_special_type_reservation | (
resource_in_unit, list_url, reservation_data, unit_admin_user, api_client) |
User with admin status on the resource should be able to make special type reservations.
|
User with admin status on the resource should be able to make special type reservations.
| def test_admin_can_create_special_type_reservation(
resource_in_unit, list_url, reservation_data, unit_admin_user, api_client):
"""
User with admin status on the resource should be able to make special type reservations.
"""
reservation_data['type'] = Reservation.TYPE_BLOCKED
api_client.for... | [
"def",
"test_admin_can_create_special_type_reservation",
"(",
"resource_in_unit",
",",
"list_url",
",",
"reservation_data",
",",
"unit_admin_user",
",",
"api_client",
")",
":",
"reservation_data",
"[",
"'type'",
"]",
"=",
"Reservation",
".",
"TYPE_BLOCKED",
"api_client",
... | [
2316,
0
] | [
2328,
55
] | python | en | ['en', 'error', 'th'] | False |
test_manager_can_create_special_type_reservation | (
resource_in_unit, list_url, reservation_data, unit_manager_user, api_client) |
User with manager status on the resource should be able to make special type reservations.
|
User with manager status on the resource should be able to make special type reservations.
| def test_manager_can_create_special_type_reservation(
resource_in_unit, list_url, reservation_data, unit_manager_user, api_client):
"""
User with manager status on the resource should be able to make special type reservations.
"""
reservation_data['type'] = Reservation.TYPE_BLOCKED
api_clie... | [
"def",
"test_manager_can_create_special_type_reservation",
"(",
"resource_in_unit",
",",
"list_url",
",",
"reservation_data",
",",
"unit_manager_user",
",",
"api_client",
")",
":",
"reservation_data",
"[",
"'type'",
"]",
"=",
"Reservation",
".",
"TYPE_BLOCKED",
"api_clien... | [
2332,
0
] | [
2344,
55
] | python | en | ['en', 'error', 'th'] | False |
test_admin_can_bypass_manual_confirmation | (
resource_in_unit, list_url, reservation_data, unit_admin_user, api_client) |
User with admin status on the resource should be able to bypass manual confirmation.
|
User with admin status on the resource should be able to bypass manual confirmation.
| def test_admin_can_bypass_manual_confirmation(
resource_in_unit, list_url, reservation_data, unit_admin_user, api_client):
"""
User with admin status on the resource should be able to bypass manual confirmation.
"""
resource_in_unit.need_manual_confirmation = True
resource_in_unit.save()
... | [
"def",
"test_admin_can_bypass_manual_confirmation",
"(",
"resource_in_unit",
",",
"list_url",
",",
"reservation_data",
",",
"unit_admin_user",
",",
"api_client",
")",
":",
"resource_in_unit",
".",
"need_manual_confirmation",
"=",
"True",
"resource_in_unit",
".",
"save",
"... | [
2348,
0
] | [
2362,
53
] | python | en | ['en', 'error', 'th'] | False |
test_manager_can_bypass_manual_confirmation | (
resource_in_unit, list_url, reservation_data, unit_manager_user, api_client) |
User with manager status on the resource should be able to bypass manual confirmation.
|
User with manager status on the resource should be able to bypass manual confirmation.
| def test_manager_can_bypass_manual_confirmation(
resource_in_unit, list_url, reservation_data, unit_manager_user, api_client):
"""
User with manager status on the resource should be able to bypass manual confirmation.
"""
resource_in_unit.need_manual_confirmation = True
resource_in_unit.sav... | [
"def",
"test_manager_can_bypass_manual_confirmation",
"(",
"resource_in_unit",
",",
"list_url",
",",
"reservation_data",
",",
"unit_manager_user",
",",
"api_client",
")",
":",
"resource_in_unit",
".",
"need_manual_confirmation",
"=",
"True",
"resource_in_unit",
".",
"save",... | [
2366,
0
] | [
2380,
53
] | python | en | ['en', 'error', 'th'] | False |
test_query_counts | (user_api_client, staff_api_client, list_url, django_assert_max_num_queries) |
Test that DB query count is less than allowed
|
Test that DB query count is less than allowed
| def test_query_counts(user_api_client, staff_api_client, list_url, django_assert_max_num_queries):
"""
Test that DB query count is less than allowed
"""
with django_assert_max_num_queries(MAX_QUERIES):
user_api_client.get(list_url)
with django_assert_max_num_queries(MAX_QUERIES):
st... | [
"def",
"test_query_counts",
"(",
"user_api_client",
",",
"staff_api_client",
",",
"list_url",
",",
"django_assert_max_num_queries",
")",
":",
"with",
"django_assert_max_num_queries",
"(",
"MAX_QUERIES",
")",
":",
"user_api_client",
".",
"get",
"(",
"list_url",
")",
"w... | [
2384,
0
] | [
2392,
38
] | python | en | ['en', 'error', 'th'] | False |
DeletionTests.test_add_form_deletion_when_invalid | (self) |
Make sure that an add form that is filled out, but marked for deletion
doesn't cause validation errors.
|
Make sure that an add form that is filled out, but marked for deletion
doesn't cause validation errors.
| def test_add_form_deletion_when_invalid(self):
"""
Make sure that an add form that is filled out, but marked for deletion
doesn't cause validation errors.
"""
PoemFormSet = inlineformset_factory(Poet, Poem, can_delete=True, fields="__all__")
poet = Poet.objects.create(nam... | [
"def",
"test_add_form_deletion_when_invalid",
"(",
"self",
")",
":",
"PoemFormSet",
"=",
"inlineformset_factory",
"(",
"Poet",
",",
"Poem",
",",
"can_delete",
"=",
"True",
",",
"fields",
"=",
"\"__all__\"",
")",
"poet",
"=",
"Poet",
".",
"objects",
".",
"creat... | [
29,
4
] | [
55,
49
] | python | en | ['en', 'error', 'th'] | False |
DeletionTests.test_change_form_deletion_when_invalid | (self) |
Make sure that a change form that is filled out, but marked for deletion
doesn't cause validation errors.
|
Make sure that a change form that is filled out, but marked for deletion
doesn't cause validation errors.
| def test_change_form_deletion_when_invalid(self):
"""
Make sure that a change form that is filled out, but marked for deletion
doesn't cause validation errors.
"""
PoemFormSet = inlineformset_factory(Poet, Poem, can_delete=True, fields="__all__")
poet = Poet.objects.creat... | [
"def",
"test_change_form_deletion_when_invalid",
"(",
"self",
")",
":",
"PoemFormSet",
"=",
"inlineformset_factory",
"(",
"Poet",
",",
"Poem",
",",
"can_delete",
"=",
"True",
",",
"fields",
"=",
"\"__all__\"",
")",
"poet",
"=",
"Poet",
".",
"objects",
".",
"cr... | [
57,
4
] | [
84,
49
] | python | en | ['en', 'error', 'th'] | False |
DeletionTests.test_save_new | (self) |
Make sure inlineformsets respect commit=False
regression for #10750
|
Make sure inlineformsets respect commit=False
regression for #10750
| def test_save_new(self):
"""
Make sure inlineformsets respect commit=False
regression for #10750
"""
# exclude some required field from the forms
ChildFormSet = inlineformset_factory(School, Child, exclude=['father', 'mother'])
school = School.objects.create(name=... | [
"def",
"test_save_new",
"(",
"self",
")",
":",
"# exclude some required field from the forms",
"ChildFormSet",
"=",
"inlineformset_factory",
"(",
"School",
",",
"Child",
",",
"exclude",
"=",
"[",
"'father'",
",",
"'mother'",
"]",
")",
"school",
"=",
"School",
".",... | [
86,
4
] | [
109,
53
] | python | en | ['en', 'error', 'th'] | False |
InlineFormsetFactoryTest.test_inline_formset_factory | (self) |
These should both work without a problem.
|
These should both work without a problem.
| def test_inline_formset_factory(self):
"""
These should both work without a problem.
"""
inlineformset_factory(Parent, Child, fk_name='mother', fields="__all__")
inlineformset_factory(Parent, Child, fk_name='father', fields="__all__") | [
"def",
"test_inline_formset_factory",
"(",
"self",
")",
":",
"inlineformset_factory",
"(",
"Parent",
",",
"Child",
",",
"fk_name",
"=",
"'mother'",
",",
"fields",
"=",
"\"__all__\"",
")",
"inlineformset_factory",
"(",
"Parent",
",",
"Child",
",",
"fk_name",
"=",... | [
113,
4
] | [
118,
80
] | python | en | ['en', 'error', 'th'] | False |
InlineFormsetFactoryTest.test_exception_on_unspecified_foreign_key | (self) |
Child has two ForeignKeys to Parent, so if we don't specify which one
to use for the inline formset, we should get an exception.
|
Child has two ForeignKeys to Parent, so if we don't specify which one
to use for the inline formset, we should get an exception.
| def test_exception_on_unspecified_foreign_key(self):
"""
Child has two ForeignKeys to Parent, so if we don't specify which one
to use for the inline formset, we should get an exception.
"""
six.assertRaisesRegex(
self,
ValueError,
"'inline_form... | [
"def",
"test_exception_on_unspecified_foreign_key",
"(",
"self",
")",
":",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"ValueError",
",",
"\"'inline_formsets.Child' has more than one ForeignKey to 'inline_formsets.Parent'.\"",
",",
"inlineformset_factory",
",",
"Parent",
... | [
120,
4
] | [
130,
9
] | python | en | ['en', 'error', 'th'] | False |
InlineFormsetFactoryTest.test_fk_name_not_foreign_key_field_from_child | (self) |
If we specify fk_name, but it isn't a ForeignKey from the child model
to the parent model, we should get an exception.
|
If we specify fk_name, but it isn't a ForeignKey from the child model
to the parent model, we should get an exception.
| def test_fk_name_not_foreign_key_field_from_child(self):
"""
If we specify fk_name, but it isn't a ForeignKey from the child model
to the parent model, we should get an exception.
"""
self.assertRaises(
Exception,
"fk_name 'school' is not a ForeignKey to <... | [
"def",
"test_fk_name_not_foreign_key_field_from_child",
"(",
"self",
")",
":",
"self",
".",
"assertRaises",
"(",
"Exception",
",",
"\"fk_name 'school' is not a ForeignKey to <class 'inline_formsets.models.Parent'>\"",
",",
"inlineformset_factory",
",",
"Parent",
",",
"Child",
"... | [
132,
4
] | [
141,
9
] | python | en | ['en', 'error', 'th'] | False |
InlineFormsetFactoryTest.test_non_foreign_key_field | (self) |
If the field specified in fk_name is not a ForeignKey, we should get an
exception.
|
If the field specified in fk_name is not a ForeignKey, we should get an
exception.
| def test_non_foreign_key_field(self):
"""
If the field specified in fk_name is not a ForeignKey, we should get an
exception.
"""
six.assertRaisesRegex(
self, ValueError,
"'inline_formsets.Child' has no field named 'test'.",
inlineformset_factor... | [
"def",
"test_non_foreign_key_field",
"(",
"self",
")",
":",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"ValueError",
",",
"\"'inline_formsets.Child' has no field named 'test'.\"",
",",
"inlineformset_factory",
",",
"Parent",
",",
"Child",
",",
"fk_name",
"=",
... | [
143,
4
] | [
152,
9
] | python | en | ['en', 'error', 'th'] | False |
make_exp_dir | (
Ullman_or_ImageNet,
list_as_one_class,
start_idx,
stop_idx,
descendent_specifier) | Create directory to save data from current experiment, and return the path to it
Args:
All args are specifications of the experiment. See their description in configuration_for_experiment.py.
Returns:
exp_dir: path to experiment directory
| Create directory to save data from current experiment, and return the path to it | def make_exp_dir(
Ullman_or_ImageNet,
list_as_one_class,
start_idx,
stop_idx,
descendent_specifier):
"""Create directory to save data from current experiment, and return the path to it
Args:
All args are specifications of the experiment. See their description in ... | [
"def",
"make_exp_dir",
"(",
"Ullman_or_ImageNet",
",",
"list_as_one_class",
",",
"start_idx",
",",
"stop_idx",
",",
"descendent_specifier",
")",
":",
"# add the date to the experiment name",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"datetime_iden... | [
9,
0
] | [
52,
18
] | python | en | ['en', 'en', 'en'] | True |
make_dir_original_img_and_MIRC | (exp_dir) | Make a new directory where the original images and the final MIRCs are saved, and return the path to it.
Args:
exp_dir: path to experiment directory
Returns:
exp_dir_MIRCs_and_original_images: path to directory of the original images and the final MIRCs
| Make a new directory where the original images and the final MIRCs are saved, and return the path to it. | def make_dir_original_img_and_MIRC(exp_dir):
"""Make a new directory where the original images and the final MIRCs are saved, and return the path to it.
Args:
exp_dir: path to experiment directory
Returns:
exp_dir_MIRCs_and_original_images: path to directory of th... | [
"def",
"make_dir_original_img_and_MIRC",
"(",
"exp_dir",
")",
":",
"exp_dir_MIRCs_and_original_images",
"=",
"os",
".",
"path",
".",
"join",
"(",
"exp_dir",
",",
"\"MIRCs_and_original_images\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"exp_dir_MIR... | [
55,
0
] | [
71,
44
] | python | en | ['en', 'en', 'en'] | True |
write_to_npz | (
exp_dir,
img_identifier,
reduced_res_counter,
new_image_cuda,
prob_most_predictive_crop,
img_size_real_px_space,
target_list,
) | Save data in uncompressed format .npz.
Args:
exp_dir: path to experiment directory
img_identifier: string describing the datapoint, e.g. 'plane_INclass404'
reduced_res_counter: counter indicating how many times the resolution has been reduced (but... | Save data in uncompressed format .npz. | def write_to_npz(
exp_dir,
img_identifier,
reduced_res_counter,
new_image_cuda,
prob_most_predictive_crop,
img_size_real_px_space,
target_list,
):
"""Save data in uncompressed format .npz.
Args:
exp_dir: path to experiment directory
img_identifie... | [
"def",
"write_to_npz",
"(",
"exp_dir",
",",
"img_identifier",
",",
"reduced_res_counter",
",",
"new_image_cuda",
",",
"prob_most_predictive_crop",
",",
"img_size_real_px_space",
",",
"target_list",
",",
")",
":",
"# check that the folder in exp_dir that is specific to the img a... | [
74,
0
] | [
107,
5
] | python | en | ['en', 'en', 'it'] | True |
save_to_csv | (exp_dir, img_identifier, write_or_append, file_name, value) | save value to csv file
Args:
exp_dir: path to experiment directory
img_identifier: string describing the datapoint, e.g. 'plane_INclass404'
write_or_append: string determining whether the file is written to for the first time ("w") or appended to ("a")
file_name: name... | save value to csv file | def save_to_csv(exp_dir, img_identifier, write_or_append, file_name, value):
"""save value to csv file
Args:
exp_dir: path to experiment directory
img_identifier: string describing the datapoint, e.g. 'plane_INclass404'
write_or_append: string determining whether the file is wr... | [
"def",
"save_to_csv",
"(",
"exp_dir",
",",
"img_identifier",
",",
"write_or_append",
",",
"file_name",
",",
"value",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"exp_dir",
",",
"f\"{file_name}\"",
")",
",",
"write_or_append",
")",
"... | [
110,
0
] | [
123,
47
] | python | en | ['en', 'en', 'en'] | True |
save_data_to_csv | (
exp_dir,
img_identifier,
write_or_append,
pix_size_MIRC,
prob_MIRC,
prob_sub_MIRC) | Save data to csv files.
This is repetetive given that the data is also stored to npz-files. However, the csv-format shows the results in a quickly readable format and is hence helpful for debugging.
In theory, it would not have been necessary to save the three values recognition gap, probability of MIRC and pro... | Save data to csv files.
This is repetetive given that the data is also stored to npz-files. However, the csv-format shows the results in a quickly readable format and is hence helpful for debugging.
In theory, it would not have been necessary to save the three values recognition gap, probability of MIRC and pro... | def save_data_to_csv(
exp_dir,
img_identifier,
write_or_append,
pix_size_MIRC,
prob_MIRC,
prob_sub_MIRC):
"""Save data to csv files.
This is repetetive given that the data is also stored to npz-files. However, the csv-format shows the results in a quickly readable... | [
"def",
"save_data_to_csv",
"(",
"exp_dir",
",",
"img_identifier",
",",
"write_or_append",
",",
"pix_size_MIRC",
",",
"prob_MIRC",
",",
"prob_sub_MIRC",
")",
":",
"rec_gap",
"=",
"prob_MIRC",
"-",
"prob_sub_MIRC",
"save_to_csv",
"(",
"exp_dir",
",",
"img_identifier",... | [
126,
0
] | [
175,
5
] | python | en | ['en', 'en', 'en'] | True |
enforce_epsilon_and_compute_hash | (dataset_batch_dir, adv_dir, output_dir, epsilon) | Enforces size of perturbation on images, and compute hashes for all images.
Args:
dataset_batch_dir: directory with the images of specific dataset batch
adv_dir: directory with generated adversarial images
output_dir: directory where to copy result
epsilon: size of perturbation
Returns... | Enforces size of perturbation on images, and compute hashes for all images. | def enforce_epsilon_and_compute_hash(dataset_batch_dir, adv_dir, output_dir, epsilon):
"""Enforces size of perturbation on images, and compute hashes for all images.
Args:
dataset_batch_dir: directory with the images of specific dataset batch
adv_dir: directory with generated adversarial images
... | [
"def",
"enforce_epsilon_and_compute_hash",
"(",
"dataset_batch_dir",
",",
"adv_dir",
",",
"output_dir",
",",
"epsilon",
")",
":",
"dataset_images",
"=",
"[",
"f",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"dataset_batch_dir",
")",
"if",
"f",
".",
"endswith"... | [
77,
0
] | [
119,
23
] | python | en | ['en', 'en', 'en'] | True |
download_dataset | (
storage_client, image_batches, target_dir, local_dataset_copy=None
) | Downloads dataset, organize it by batches and rename images.
Args:
storage_client: instance of the CompetitionStorageClient
image_batches: subclass of ImageBatchesBase with data about images
target_dir: target directory, should exist and be empty
local_dataset_copy: directory with local dat... | Downloads dataset, organize it by batches and rename images. | def download_dataset(
storage_client, image_batches, target_dir, local_dataset_copy=None
):
"""Downloads dataset, organize it by batches and rename images.
Args:
storage_client: instance of the CompetitionStorageClient
image_batches: subclass of ImageBatchesBase with data about images
tar... | [
"def",
"download_dataset",
"(",
"storage_client",
",",
"image_batches",
",",
"target_dir",
",",
"local_dataset_copy",
"=",
"None",
")",
":",
"for",
"batch_id",
",",
"batch_value",
"in",
"iteritems",
"(",
"image_batches",
".",
"data",
")",
":",
"batch_dir",
"=",
... | [
122,
0
] | [
157,
75
] | python | en | ['en', 'en', 'en'] | True |
DatasetMetadata.__init__ | (self, fobj) | Initializes instance of DatasetMetadata.
Args:
fobj: file object
| Initializes instance of DatasetMetadata. | def __init__(self, fobj):
"""Initializes instance of DatasetMetadata.
Args:
fobj: file object
"""
self._true_labels = {}
self._target_classes = {}
reader = csv.reader(fobj)
header_row = next(reader)
try:
row_idx_image_id = header_row... | [
"def",
"__init__",
"(",
"self",
",",
"fobj",
")",
":",
"self",
".",
"_true_labels",
"=",
"{",
"}",
"self",
".",
"_target_classes",
"=",
"{",
"}",
"reader",
"=",
"csv",
".",
"reader",
"(",
"fobj",
")",
"header_row",
"=",
"next",
"(",
"reader",
")",
... | [
27,
4
] | [
52,
67
] | python | en | ['en', 'zu', 'en'] | True |
DatasetMetadata.get_true_label | (self, image_id) | Returns true label for image with given ID. | Returns true label for image with given ID. | def get_true_label(self, image_id):
"""Returns true label for image with given ID."""
return self._true_labels[image_id] | [
"def",
"get_true_label",
"(",
"self",
",",
"image_id",
")",
":",
"return",
"self",
".",
"_true_labels",
"[",
"image_id",
"]"
] | [
54,
4
] | [
56,
42
] | python | en | ['en', 'en', 'en'] | True |
DatasetMetadata.get_target_class | (self, image_id) | Returns target class for image with given ID. | Returns target class for image with given ID. | def get_target_class(self, image_id):
"""Returns target class for image with given ID."""
return self._target_classes[image_id] | [
"def",
"get_target_class",
"(",
"self",
",",
"image_id",
")",
":",
"return",
"self",
".",
"_target_classes",
"[",
"image_id",
"]"
] | [
58,
4
] | [
60,
45
] | python | en | ['en', 'en', 'en'] | True |
DatasetMetadata.save_target_classes_for_batch | (self, filename, image_batches, batch_id) | Saves file with target class for given dataset batch.
Args:
filename: output filename
image_batches: instance of ImageBatchesBase with dataset batches
batch_id: dataset batch ID
| Saves file with target class for given dataset batch. | def save_target_classes_for_batch(self, filename, image_batches, batch_id):
"""Saves file with target class for given dataset batch.
Args:
filename: output filename
image_batches: instance of ImageBatchesBase with dataset batches
batch_id: dataset batch ID
"""
... | [
"def",
"save_target_classes_for_batch",
"(",
"self",
",",
"filename",
",",
"image_batches",
",",
"batch_id",
")",
":",
"images",
"=",
"image_batches",
".",
"data",
"[",
"batch_id",
"]",
"[",
"\"images\"",
"]",
"with",
"open",
"(",
"filename",
",",
"\"w\"",
"... | [
62,
4
] | [
74,
71
] | python | en | ['en', 'en', 'en'] | True |
ForeignObjectRel.target_field | (self) |
When filtering against this relation, return the field on the remote
model against which the filtering should happen.
|
When filtering against this relation, return the field on the remote
model against which the filtering should happen.
| def target_field(self):
"""
When filtering against this relation, return the field on the remote
model against which the filtering should happen.
"""
target_fields = self.get_path_info()[-1].target_fields
if len(target_fields) > 1:
raise exceptions.FieldError(... | [
"def",
"target_field",
"(",
"self",
")",
":",
"target_fields",
"=",
"self",
".",
"get_path_info",
"(",
")",
"[",
"-",
"1",
"]",
".",
"target_fields",
"if",
"len",
"(",
"target_fields",
")",
">",
"1",
":",
"raise",
"exceptions",
".",
"FieldError",
"(",
... | [
66,
4
] | [
74,
31
] | python | en | ['en', 'error', 'th'] | False |
ForeignObjectRel.get_choices | (self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, ordering=()) |
Return choices with a default blank choices included, for use
as <select> choices for this field.
Analog of django.db.models.fields.Field.get_choices(), provided
initially for utilization by RelatedFieldListFilter.
|
Return choices with a default blank choices included, for use
as <select> choices for this field. | def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH, ordering=()):
"""
Return choices with a default blank choices included, for use
as <select> choices for this field.
Analog of django.db.models.fields.Field.get_choices(), provided
initially for utilization... | [
"def",
"get_choices",
"(",
"self",
",",
"include_blank",
"=",
"True",
",",
"blank_choice",
"=",
"BLANK_CHOICE_DASH",
",",
"ordering",
"=",
"(",
")",
")",
":",
"qs",
"=",
"self",
".",
"related_model",
".",
"_default_manager",
".",
"all",
"(",
")",
"if",
"... | [
116,
4
] | [
129,
9
] | python | en | ['en', 'error', 'th'] | False |
ForeignObjectRel.is_hidden | (self) | Should the related object be hidden? | Should the related object be hidden? | def is_hidden(self):
"""Should the related object be hidden?"""
return bool(self.related_name) and self.related_name[-1] == '+' | [
"def",
"is_hidden",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"related_name",
")",
"and",
"self",
".",
"related_name",
"[",
"-",
"1",
"]",
"==",
"'+'"
] | [
131,
4
] | [
133,
71
] | python | en | ['en', 'en', 'en'] | True |
ForeignObjectRel.set_field_name | (self) |
Set the related field's name, this is not available until later stages
of app loading, so set_field_name is called from
set_attributes_from_rel()
|
Set the related field's name, this is not available until later stages
of app loading, so set_field_name is called from
set_attributes_from_rel()
| def set_field_name(self):
"""
Set the related field's name, this is not available until later stages
of app loading, so set_field_name is called from
set_attributes_from_rel()
"""
# By default foreign object doesn't relate to any remote field (for
# example custom... | [
"def",
"set_field_name",
"(",
"self",
")",
":",
"# By default foreign object doesn't relate to any remote field (for",
"# example custom multicolumn joins currently have no remote field).",
"self",
".",
"field_name",
"=",
"None"
] | [
141,
4
] | [
149,
30
] | python | en | ['en', 'error', 'th'] | False |
ForeignObjectRel.get_cache_name | (self) |
Return the name of the cache key to use for storing an instance of the
forward model on the reverse model.
|
Return the name of the cache key to use for storing an instance of the
forward model on the reverse model.
| def get_cache_name(self):
"""
Return the name of the cache key to use for storing an instance of the
forward model on the reverse model.
"""
return self.get_accessor_name() | [
"def",
"get_cache_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_accessor_name",
"(",
")"
] | [
171,
4
] | [
176,
39
] | python | en | ['en', 'error', 'th'] | False |
ManyToOneRel.get_related_field | (self) |
Return the Field in the 'to' object to which this relationship is tied.
|
Return the Field in the 'to' object to which this relationship is tied.
| def get_related_field(self):
"""
Return the Field in the 'to' object to which this relationship is tied.
"""
field = self.model._meta.get_field(self.field_name)
if not field.concrete:
raise exceptions.FieldDoesNotExist("No related field named '%s'" % self.field_name)
... | [
"def",
"get_related_field",
"(",
"self",
")",
":",
"field",
"=",
"self",
".",
"model",
".",
"_meta",
".",
"get_field",
"(",
"self",
".",
"field_name",
")",
"if",
"not",
"field",
".",
"concrete",
":",
"raise",
"exceptions",
".",
"FieldDoesNotExist",
"(",
... | [
212,
4
] | [
219,
20
] | python | en | ['en', 'error', 'th'] | False |
ManyToManyRel.get_related_field | (self) |
Return the field in the 'to' object to which this relationship is tied.
Provided for symmetry with ManyToOneRel.
|
Return the field in the 'to' object to which this relationship is tied.
Provided for symmetry with ManyToOneRel.
| def get_related_field(self):
"""
Return the field in the 'to' object to which this relationship is tied.
Provided for symmetry with ManyToOneRel.
"""
opts = self.through._meta
if self.through_fields:
field = opts.get_field(self.through_fields[0])
else:... | [
"def",
"get_related_field",
"(",
"self",
")",
":",
"opts",
"=",
"self",
".",
"through",
".",
"_meta",
"if",
"self",
".",
"through_fields",
":",
"field",
"=",
"opts",
".",
"get_field",
"(",
"self",
".",
"through_fields",
"[",
"0",
"]",
")",
"else",
":",... | [
276,
4
] | [
289,
46
] | python | en | ['en', 'error', 'th'] | False |
ThingerShell.do_quit | (self, arg) | Exit Thinger | Exit Thinger | def do_quit(self, arg):
"Exit Thinger"
print("Bye!")
return True | [
"def",
"do_quit",
"(",
"self",
",",
"arg",
")",
":",
"print",
"(",
"\"Bye!\"",
")",
"return",
"True"
] | [
46,
4
] | [
49,
19
] | python | en | ['en', 'en', 'en'] | False |
read_32 | (fobj, start_length, size) |
Read a 32bit RGB icon resource. Seems to be either uncompressed or
an RLE packbits-like scheme.
|
Read a 32bit RGB icon resource. Seems to be either uncompressed or
an RLE packbits-like scheme.
| def read_32(fobj, start_length, size):
"""
Read a 32bit RGB icon resource. Seems to be either uncompressed or
an RLE packbits-like scheme.
"""
(start, length) = start_length
fobj.seek(start)
pixel_size = (size[0] * size[2], size[1] * size[2])
sizesq = pixel_size[0] * pixel_size[1]
i... | [
"def",
"read_32",
"(",
"fobj",
",",
"start_length",
",",
"size",
")",
":",
"(",
"start",
",",
"length",
")",
"=",
"start_length",
"fobj",
".",
"seek",
"(",
"start",
")",
"pixel_size",
"=",
"(",
"size",
"[",
"0",
"]",
"*",
"size",
"[",
"2",
"]",
"... | [
49,
0
] | [
88,
22
] | python | en | ['en', 'error', 'th'] | False |
_save | (im, fp, filename) |
Saves the image as a series of PNG files,
that are then converted to a .icns file
using the macOS command line utility 'iconutil'.
macOS only.
|
Saves the image as a series of PNG files,
that are then converted to a .icns file
using the macOS command line utility 'iconutil'. | def _save(im, fp, filename):
"""
Saves the image as a series of PNG files,
that are then converted to a .icns file
using the macOS command line utility 'iconutil'.
macOS only.
"""
if hasattr(fp, "flush"):
fp.flush()
# create the temporary set of pngs
with tempfile.Temporary... | [
"def",
"_save",
"(",
"im",
",",
"fp",
",",
"filename",
")",
":",
"if",
"hasattr",
"(",
"fp",
",",
"\"flush\"",
")",
":",
"fp",
".",
"flush",
"(",
")",
"# create the temporary set of pngs",
"with",
"tempfile",
".",
"TemporaryDirectory",
"(",
"\".iconset\"",
... | [
304,
0
] | [
357,
34
] | 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.