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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Follow.follower | (self) |
This user follows the followed
:return: User following the user
|
This user follows the followed
:return: User following the user
| def follower(self) -> 'helix.User':
"""
This user follows the followed
:return: User following the user
"""
return helix.Users(self._api, int(self.from_id))[0] | [
"def",
"follower",
"(",
"self",
")",
"->",
"'helix.User'",
":",
"return",
"helix",
".",
"Users",
"(",
"self",
".",
"_api",
",",
"int",
"(",
"self",
".",
"from_id",
")",
")",
"[",
"0",
"]"
] | [
19,
4
] | [
24,
59
] | python | en | ['en', 'error', 'th'] | False |
Follow.followed | (self) |
This user is being followed by the follower
:return: User being followed
|
This user is being followed by the follower
:return: User being followed
| def followed(self) -> 'helix.User':
"""
This user is being followed by the follower
:return: User being followed
"""
return helix.Users(self._api, int(self.to_id))[0] | [
"def",
"followed",
"(",
"self",
")",
"->",
"'helix.User'",
":",
"return",
"helix",
".",
"Users",
"(",
"self",
".",
"_api",
",",
"int",
"(",
"self",
".",
"to_id",
")",
")",
"[",
"0",
"]"
] | [
27,
4
] | [
32,
57
] | python | en | ['en', 'error', 'th'] | False |
WideResNet.__init__ | (self, args) |
TODO: Write Comment
|
TODO: Write Comment
| def __init__(self, args):
"""
TODO: Write Comment
"""
self.name = 'WideResNet'
CifarModel.__init__(self, args) | [
"def",
"__init__",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"name",
"=",
"'WideResNet'",
"CifarModel",
".",
"__init__",
"(",
"self",
",",
"args",
")"
] | [
10,
4
] | [
17,
39
] | python | en | ['en', 'error', 'th'] | False |
WideResNet.network | (self, img_input) |
TODO: Write Comment
|
TODO: Write Comment
| def network(self, img_input):
"""
TODO: Write Comment
"""
from tensorflow.keras import initializers, layers, regularizers
depth = 16
wide = 8
weight_decay = 0.0005
def conv3x3(x,filters):
"""
TODO: Write Co... | [
"def",
"network",
"(",
"self",
",",
"img_input",
")",
":",
"from",
"tensorflow",
".",
"keras",
"import",
"initializers",
",",
"layers",
",",
"regularizers",
"depth",
"=",
"16",
"wide",
"=",
"8",
"weight_decay",
"=",
"0.0005",
"def",
"conv3x3",
"(",
"x",
... | [
19,
4
] | [
92,
16
] | python | en | ['en', 'error', 'th'] | False |
WideResNet.scheduler | (self, epoch) |
TODO: Write Comment
|
TODO: Write Comment
| def scheduler(self, epoch):
"""
TODO: Write Comment
"""
if epoch <= 60:
return 0.1
if epoch <= 120:
return 0.02
if epoch <= 160:
return 0.004
return 0.0008 | [
"def",
"scheduler",
"(",
"self",
",",
"epoch",
")",
":",
"if",
"epoch",
"<=",
"60",
":",
"return",
"0.1",
"if",
"epoch",
"<=",
"120",
":",
"return",
"0.02",
"if",
"epoch",
"<=",
"160",
":",
"return",
"0.004",
"return",
"0.0008"
] | [
94,
4
] | [
105,
21
] | python | en | ['en', 'error', 'th'] | False |
make_distribution_for_install_requirement | (install_req) | Returns a Distribution for the given InstallRequirement
| Returns a Distribution for the given InstallRequirement
| def make_distribution_for_install_requirement(install_req):
# type: (InstallRequirement) -> AbstractDistribution
"""Returns a Distribution for the given InstallRequirement
"""
# Editable requirements will always be source distributions. They use the
# legacy logic until we create a modern standard f... | [
"def",
"make_distribution_for_install_requirement",
"(",
"install_req",
")",
":",
"# type: (InstallRequirement) -> AbstractDistribution",
"# Editable requirements will always be source distributions. They use the",
"# legacy logic until we create a modern standard for them.",
"if",
"install_req"... | [
9,
0
] | [
23,
42
] | python | en | ['en', 'en', 'en'] | True |
mkpath | (name, mode=0o777, verbose=1, dry_run=0) | Create a directory and any missing ancestor directories.
If the directory already exists (or if 'name' is the empty string, which
means the current directory, which of course exists), then do nothing.
Raise DistutilsFileError if unable to create some directory along the way
(eg. some sub-path exists, b... | Create a directory and any missing ancestor directories. | def mkpath(name, mode=0o777, verbose=1, dry_run=0):
"""Create a directory and any missing ancestor directories.
If the directory already exists (or if 'name' is the empty string, which
means the current directory, which of course exists), then do nothing.
Raise DistutilsFileError if unable to create so... | [
"def",
"mkpath",
"(",
"name",
",",
"mode",
"=",
"0o777",
",",
"verbose",
"=",
"1",
",",
"dry_run",
"=",
"0",
")",
":",
"global",
"_path_created",
"# Detect a common bug -- name is None",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"raise"... | [
16,
0
] | [
77,
23
] | python | en | ['en', 'en', 'en'] | True |
create_tree | (base_dir, files, mode=0o777, verbose=1, dry_run=0) | Create all the empty directories under 'base_dir' needed to put 'files'
there.
'base_dir' is just the name of a directory which doesn't necessarily
exist yet; 'files' is a list of filenames to be interpreted relative to
'base_dir'. 'base_dir' + the directory portion of every file in 'files'
will b... | Create all the empty directories under 'base_dir' needed to put 'files'
there. | def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0):
"""Create all the empty directories under 'base_dir' needed to put 'files'
there.
'base_dir' is just the name of a directory which doesn't necessarily
exist yet; 'files' is a list of filenames to be interpreted relative to
'base_di... | [
"def",
"create_tree",
"(",
"base_dir",
",",
"files",
",",
"mode",
"=",
"0o777",
",",
"verbose",
"=",
"1",
",",
"dry_run",
"=",
"0",
")",
":",
"# First get the list of directories to create",
"need_dir",
"=",
"set",
"(",
")",
"for",
"file",
"in",
"files",
"... | [
79,
0
] | [
96,
59
] | python | en | ['en', 'en', 'en'] | True |
copy_tree | (src, dst, preserve_mode=1, preserve_times=1,
preserve_symlinks=0, update=0, verbose=1, dry_run=0) | Copy an entire directory tree 'src' to a new location 'dst'.
Both 'src' and 'dst' must be directory names. If 'src' is not a
directory, raise DistutilsFileError. If 'dst' does not exist, it is
created with 'mkpath()'. The end result of the copy is that every
file in 'src' is copied to 'dst', and dir... | Copy an entire directory tree 'src' to a new location 'dst'. | def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
preserve_symlinks=0, update=0, verbose=1, dry_run=0):
"""Copy an entire directory tree 'src' to a new location 'dst'.
Both 'src' and 'dst' must be directory names. If 'src' is not a
directory, raise DistutilsFileError. If 'dst' does... | [
"def",
"copy_tree",
"(",
"src",
",",
"dst",
",",
"preserve_mode",
"=",
"1",
",",
"preserve_times",
"=",
"1",
",",
"preserve_symlinks",
"=",
"0",
",",
"update",
"=",
"0",
",",
"verbose",
"=",
"1",
",",
"dry_run",
"=",
"0",
")",
":",
"from",
"distutils... | [
98,
0
] | [
165,
18
] | python | en | ['en', 'en', 'en'] | True |
_build_cmdtuple | (path, cmdtuples) | Helper for remove_tree(). | Helper for remove_tree(). | def _build_cmdtuple(path, cmdtuples):
"""Helper for remove_tree()."""
for f in os.listdir(path):
real_f = os.path.join(path,f)
if os.path.isdir(real_f) and not os.path.islink(real_f):
_build_cmdtuple(real_f, cmdtuples)
else:
cmdtuples.append((os.remove, real_f))
... | [
"def",
"_build_cmdtuple",
"(",
"path",
",",
"cmdtuples",
")",
":",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"real_f",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"f",
")",
"if",
"os",
".",
"path",
".",
"isdir",
... | [
167,
0
] | [
175,
38
] | python | da | ['da', 'it', 'en'] | False |
remove_tree | (directory, verbose=1, dry_run=0) | Recursively remove an entire directory tree.
Any errors are ignored (apart from being reported to stdout if 'verbose'
is true).
| Recursively remove an entire directory tree. | def remove_tree(directory, verbose=1, dry_run=0):
"""Recursively remove an entire directory tree.
Any errors are ignored (apart from being reported to stdout if 'verbose'
is true).
"""
global _path_created
if verbose >= 1:
log.info("removing '%s' (and everything under it)", directory)
... | [
"def",
"remove_tree",
"(",
"directory",
",",
"verbose",
"=",
"1",
",",
"dry_run",
"=",
"0",
")",
":",
"global",
"_path_created",
"if",
"verbose",
">=",
"1",
":",
"log",
".",
"info",
"(",
"\"removing '%s' (and everything under it)\"",
",",
"directory",
")",
"... | [
177,
0
] | [
199,
61
] | python | en | ['en', 'en', 'en'] | True |
ensure_relative | (path) | Take the full path 'path', and make it a relative path.
This is useful to make 'path' the second argument to os.path.join().
| Take the full path 'path', and make it a relative path. | def ensure_relative(path):
"""Take the full path 'path', and make it a relative path.
This is useful to make 'path' the second argument to os.path.join().
"""
drive, path = os.path.splitdrive(path)
if path[0:1] == os.sep:
path = drive + path[1:]
return path | [
"def",
"ensure_relative",
"(",
"path",
")",
":",
"drive",
",",
"path",
"=",
"os",
".",
"path",
".",
"splitdrive",
"(",
"path",
")",
"if",
"path",
"[",
"0",
":",
"1",
"]",
"==",
"os",
".",
"sep",
":",
"path",
"=",
"drive",
"+",
"path",
"[",
"1",... | [
201,
0
] | [
209,
15
] | python | en | ['en', 'en', 'en'] | True |
decode_dxt1 | (data, alpha=False) |
input: one "row" of data (i.e. will produce 4*width pixels)
|
input: one "row" of data (i.e. will produce 4*width pixels)
| def decode_dxt1(data, alpha=False):
"""
input: one "row" of data (i.e. will produce 4*width pixels)
"""
blocks = len(data) // 8 # number of blocks in row
ret = (bytearray(), bytearray(), bytearray(), bytearray())
for block in range(blocks):
# Decode next 8-byte block.
idx = bl... | [
"def",
"decode_dxt1",
"(",
"data",
",",
"alpha",
"=",
"False",
")",
":",
"blocks",
"=",
"len",
"(",
"data",
")",
"//",
"8",
"# number of blocks in row",
"ret",
"=",
"(",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
"... | [
51,
0
] | [
103,
14
] | python | en | ['en', 'error', 'th'] | False |
decode_dxt3 | (data) |
input: one "row" of data (i.e. will produce 4*width pixels)
|
input: one "row" of data (i.e. will produce 4*width pixels)
| def decode_dxt3(data):
"""
input: one "row" of data (i.e. will produce 4*width pixels)
"""
blocks = len(data) // 16 # number of blocks in row
ret = (bytearray(), bytearray(), bytearray(), bytearray())
for block in range(blocks):
idx = block * 16
block = data[idx : idx + 16]
... | [
"def",
"decode_dxt3",
"(",
"data",
")",
":",
"blocks",
"=",
"len",
"(",
"data",
")",
"//",
"16",
"# number of blocks in row",
"ret",
"=",
"(",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
... | [
106,
0
] | [
156,
14
] | python | en | ['en', 'error', 'th'] | False |
decode_dxt5 | (data) |
input: one "row" of data (i.e. will produce 4 * width pixels)
|
input: one "row" of data (i.e. will produce 4 * width pixels)
| def decode_dxt5(data):
"""
input: one "row" of data (i.e. will produce 4 * width pixels)
"""
blocks = len(data) // 16 # number of blocks in row
ret = (bytearray(), bytearray(), bytearray(), bytearray())
for block in range(blocks):
idx = block * 16
block = data[idx : idx + 16]
... | [
"def",
"decode_dxt5",
"(",
"data",
")",
":",
"blocks",
"=",
"len",
"(",
"data",
")",
"//",
"16",
"# number of blocks in row",
"ret",
"=",
"(",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
",",
"bytearray",
"(",
")",
... | [
159,
0
] | [
226,
14
] | python | en | ['en', 'error', 'th'] | False |
get_realm_email_validator | (realm: Realm) |
RESTRICTIVE REALMS:
Some realms only allow emails within a set
of domains that are configured in RealmDomain.
We get the set of domains up front so that
folks can validate multiple emails without
multiple round trips to the database.
|
RESTRICTIVE REALMS: | def get_realm_email_validator(realm: Realm) -> Callable[[str], None]:
if not realm.emails_restricted_to_domains:
# Should we also do '+' check for non-resticted realms?
if realm.disallow_disposable_email_addresses:
return validate_disposable
# allow any email through
ret... | [
"def",
"get_realm_email_validator",
"(",
"realm",
":",
"Realm",
")",
"->",
"Callable",
"[",
"[",
"str",
"]",
",",
"None",
"]",
":",
"if",
"not",
"realm",
".",
"emails_restricted_to_domains",
":",
"# Should we also do '+' check for non-resticted realms?",
"if",
"real... | [
27,
0
] | [
76,
19
] | python | en | ['en', 'error', 'th'] | False |
email_allowed_for_realm | (email: str, realm: Realm) |
Avoid calling this in a loop!
Instead, call get_realm_email_validator()
outside of the loop.
|
Avoid calling this in a loop!
Instead, call get_realm_email_validator()
outside of the loop.
| def email_allowed_for_realm(email: str, realm: Realm) -> None:
"""
Avoid calling this in a loop!
Instead, call get_realm_email_validator()
outside of the loop.
"""
get_realm_email_validator(realm)(email) | [
"def",
"email_allowed_for_realm",
"(",
"email",
":",
"str",
",",
"realm",
":",
"Realm",
")",
"->",
"None",
":",
"get_realm_email_validator",
"(",
"realm",
")",
"(",
"email",
")"
] | [
83,
0
] | [
89,
43
] | python | en | ['en', 'error', 'th'] | False |
get_existing_user_errors | (
target_realm: Realm,
emails: Set[str],
verbose: bool = False,
) |
We use this function even for a list of one emails.
It checks "new" emails to make sure that they don't
already exist. There's a bit of fiddly logic related
to cross-realm bots and mirror dummies too.
|
We use this function even for a list of one emails. | def get_existing_user_errors(
target_realm: Realm,
emails: Set[str],
verbose: bool = False,
) -> Dict[str, Tuple[str, bool]]:
"""
We use this function even for a list of one emails.
It checks "new" emails to make sure that they don't
already exist. There's a bit of fiddly logic related
... | [
"def",
"get_existing_user_errors",
"(",
"target_realm",
":",
"Realm",
",",
"emails",
":",
"Set",
"[",
"str",
"]",
",",
"verbose",
":",
"bool",
"=",
"False",
",",
")",
"->",
"Dict",
"[",
"str",
",",
"Tuple",
"[",
"str",
",",
"bool",
"]",
"]",
":",
"... | [
118,
0
] | [
188,
17
] | python | en | ['en', 'error', 'th'] | False |
validate_email_not_already_in_realm | (
target_realm: Realm, email: str, verbose: bool = True
) |
NOTE:
Only use this to validate that a single email
is not already used in the realm.
We should start using bulk_check_new_emails()
for any endpoint that takes multiple emails,
such as the "invite" interface.
|
NOTE:
Only use this to validate that a single email
is not already used in the realm. | def validate_email_not_already_in_realm(
target_realm: Realm, email: str, verbose: bool = True
) -> None:
"""
NOTE:
Only use this to validate that a single email
is not already used in the realm.
We should start using bulk_check_new_emails()
for any endpoint that takes multi... | [
"def",
"validate_email_not_already_in_realm",
"(",
"target_realm",
":",
"Realm",
",",
"email",
":",
"str",
",",
"verbose",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"error_dict",
"=",
"get_existing_user_errors",
"(",
"target_realm",
",",
"{",
"email",
... | [
191,
0
] | [
209,
34
] | python | en | ['en', 'error', 'th'] | False |
setup | (**attrs) | The gateway to the Distutils: do everything your setup script needs
to do, in a highly flexible and user-driven way. Briefly: create a
Distribution instance; find and parse config files; parse the command
line; run each Distutils command found there, customized by the options
supplied to 'setup()' (as ... | The gateway to the Distutils: do everything your setup script needs
to do, in a highly flexible and user-driven way. Briefly: create a
Distribution instance; find and parse config files; parse the command
line; run each Distutils command found there, customized by the options
supplied to 'setup()' (as ... | def setup (**attrs):
"""The gateway to the Distutils: do everything your setup script needs
to do, in a highly flexible and user-driven way. Briefly: create a
Distribution instance; find and parse config files; parse the command
line; run each Distutils command found there, customized by the options
... | [
"def",
"setup",
"(",
"*",
"*",
"attrs",
")",
":",
"global",
"_setup_stop_after",
",",
"_setup_distribution",
"# Determine the distribution class -- either caller-supplied or",
"# our Distribution (see below).",
"klass",
"=",
"attrs",
".",
"get",
"(",
"'distclass'",
")",
"... | [
56,
0
] | [
164,
15
] | python | en | ['en', 'en', 'en'] | True |
run_setup | (script_name, script_args=None, stop_after="run") | Run a setup script in a somewhat controlled environment, and
return the Distribution instance that drives things. This is useful
if you need to find out the distribution meta-data (passed as
keyword args from 'script' to 'setup()', or the contents of the
config files or command-line.
'script_name'... | Run a setup script in a somewhat controlled environment, and
return the Distribution instance that drives things. This is useful
if you need to find out the distribution meta-data (passed as
keyword args from 'script' to 'setup()', or the contents of the
config files or command-line. | def run_setup (script_name, script_args=None, stop_after="run"):
"""Run a setup script in a somewhat controlled environment, and
return the Distribution instance that drives things. This is useful
if you need to find out the distribution meta-data (passed as
keyword args from 'script' to 'setup()', or ... | [
"def",
"run_setup",
"(",
"script_name",
",",
"script_args",
"=",
"None",
",",
"stop_after",
"=",
"\"run\"",
")",
":",
"if",
"stop_after",
"not",
"in",
"(",
"'init'",
",",
"'config'",
",",
"'commandline'",
",",
"'run'",
")",
":",
"raise",
"ValueError",
"(",... | [
169,
0
] | [
231,
30
] | python | en | ['en', 'en', 'en'] | True |
test_successful_get_open_invitations | (self) |
A GET call to /json/invites returns all unexpired invitations.
|
A GET call to /json/invites returns all unexpired invitations.
| def test_successful_get_open_invitations(self) -> None:
"""
A GET call to /json/invites returns all unexpired invitations.
"""
realm = get_realm("zulip")
days_to_activate = getattr(settings, "INVITATION_LINK_VALIDITY_DAYS", "Wrong")
active_value = getattr(confirmation_set... | [
"def",
"test_successful_get_open_invitations",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"days_to_activate",
"=",
"getattr",
"(",
"settings",
",",
"\"INVITATION_LINK_VALIDITY_DAYS\"",
",",
"\"Wrong\"",
")",
"active_value",
... | [
2102,
4
] | [
2148,
69
] | python | en | ['en', 'error', 'th'] | False |
test_successful_delete_invitation | (self) |
A DELETE call to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
|
A DELETE call to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
| def test_successful_delete_invitation(self) -> None:
"""
A DELETE call to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
"""
self.login("iago")
invitee = "DeleteMe@zulip.com"
self.assert_json_success(self.invite(invitee,... | [
"def",
"test_successful_delete_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"invitee",
"=",
"\"DeleteMe@zulip.com\"",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\"... | [
2150,
4
] | [
2174,
9
] | python | en | ['en', 'error', 'th'] | False |
test_successful_member_delete_invitation | (self) |
A DELETE call from member account to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
|
A DELETE call from member account to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
| def test_successful_member_delete_invitation(self) -> None:
"""
A DELETE call from member account to /json/invites/<ID> should delete the invite and
any scheduled invitation reminder emails.
"""
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
... | [
"def",
"test_successful_member_delete_invitation",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"user_profile",
")",
"invitee",
"=",
"\"DeleteMe@zulip.com\"",
"self",
... | [
2176,
4
] | [
2212,
9
] | python | en | ['en', 'error', 'th'] | False |
test_delete_multiuse_invite | (self) |
A DELETE call to /json/invites/multiuse<ID> should delete the
multiuse_invite.
|
A DELETE call to /json/invites/multiuse<ID> should delete the
multiuse_invite.
| def test_delete_multiuse_invite(self) -> None:
"""
A DELETE call to /json/invites/multiuse<ID> should delete the
multiuse_invite.
"""
self.login("iago")
zulip_realm = get_realm("zulip")
multiuse_invite = MultiuseInvite.objects.create(
referred_by=self... | [
"def",
"test_delete_multiuse_invite",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"multiuse_invite",
"=",
"MultiuseInvite",
".",
"objects",
".",
"create",
"(",
"referr... | [
2241,
4
] | [
2284,
66
] | python | en | ['en', 'error', 'th'] | False |
test_successful_resend_invitation | (self) |
A POST call to /json/invites/<ID>/resend should send an invitation reminder email
and delete any scheduled invitation reminder email.
|
A POST call to /json/invites/<ID>/resend should send an invitation reminder email
and delete any scheduled invitation reminder email.
| def test_successful_resend_invitation(self) -> None:
"""
A POST call to /json/invites/<ID>/resend should send an invitation reminder email
and delete any scheduled invitation reminder email.
"""
self.login("iago")
invitee = "resend_me@zulip.com"
self.assert_json_... | [
"def",
"test_successful_resend_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"invitee",
"=",
"\"resend_me@zulip.com\"",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\... | [
2286,
4
] | [
2329,
41
] | python | en | ['en', 'error', 'th'] | False |
test_successful_member_resend_invitation | (self) | A POST call from member a account to /json/invites/<ID>/resend
should send an invitation reminder email and delete any
scheduled invitation reminder email if they send the invite.
| A POST call from member a account to /json/invites/<ID>/resend
should send an invitation reminder email and delete any
scheduled invitation reminder email if they send the invite.
| def test_successful_member_resend_invitation(self) -> None:
"""A POST call from member a account to /json/invites/<ID>/resend
should send an invitation reminder email and delete any
scheduled invitation reminder email if they send the invite.
"""
self.login("hamlet")
user... | [
"def",
"test_successful_member_resend_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"invitee",
"=",
"\"resend_me@zulip.com\"",
"self",
".",
... | [
2331,
4
] | [
2386,
85
] | python | en | ['en', 'en', 'en'] | True |
AddNewUserHistoryTest.test_add_new_user_history_race | (self) | Sends a message during user creation | Sends a message during user creation | def test_add_new_user_history_race(self) -> None:
"""Sends a message during user creation"""
# Create a user who hasn't had historical messages added
realm = get_realm("zulip")
stream = Stream.objects.get(realm=realm, name="Denmark")
DefaultStream.objects.create(stream=stream, re... | [
"def",
"test_add_new_user_history_race",
"(",
"self",
")",
"->",
"None",
":",
"# Create a user who hasn't had historical messages added",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"stream",
"=",
"Stream",
".",
"objects",
".",
"get",
"(",
"realm",
"=",
"realm... | [
239,
4
] | [
310,
50
] | python | en | ['fr', 'en', 'en'] | True |
AddNewUserHistoryTest.test_auto_subbed_to_personals | (self) |
Newly created users are auto-subbed to the ability to receive
personals.
|
Newly created users are auto-subbed to the ability to receive
personals.
| def test_auto_subbed_to_personals(self) -> None:
"""
Newly created users are auto-subbed to the ability to receive
personals.
"""
test_email = self.nonreg_email("test")
self.register(test_email, "test")
user_profile = self.nonreg_user("test")
old_messages_... | [
"def",
"test_auto_subbed_to_personals",
"(",
"self",
")",
"->",
"None",
":",
"test_email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"test\"",
")",
"self",
".",
"register",
"(",
"test_email",
",",
"\"test\"",
")",
"user_profile",
"=",
"self",
".",
"nonreg_user"... | [
312,
4
] | [
340,
13
] | python | en | ['en', 'error', 'th'] | False |
PasswordResetTest.test_ldap_auth_only | (self) | If the email auth backend is not enabled, password reset should do nothing | If the email auth backend is not enabled, password reset should do nothing | def test_ldap_auth_only(self) -> None:
"""If the email auth backend is not enabled, password reset should do nothing"""
email = self.example_email("hamlet")
with self.assertLogs(level="INFO") as m:
result = self.client_post("/accounts/password/reset/", {"email": email})
s... | [
"def",
"test_ldap_auth_only",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"example_email",
"(",
"\"hamlet\"",
")",
"with",
"self",
".",
"assertLogs",
"(",
"level",
"=",
"\"INFO\"",
")",
"as",
"m",
":",
"result",
"=",
"self",
".",
"c... | [
575,
4
] | [
596,
37
] | python | en | ['en', 'en', 'en'] | True |
PasswordResetTest.test_ldap_and_email_auth | (self) | If both email and LDAP auth backends are enabled, limit password
reset to users outside the LDAP domain | If both email and LDAP auth backends are enabled, limit password
reset to users outside the LDAP domain | def test_ldap_and_email_auth(self) -> None:
"""If both email and LDAP auth backends are enabled, limit password
reset to users outside the LDAP domain"""
# If the domain matches, we don't generate an email
with self.settings(LDAP_APPEND_DOMAIN="zulip.com"):
email = self.examp... | [
"def",
"test_ldap_and_email_auth",
"(",
"self",
")",
"->",
"None",
":",
"# If the domain matches, we don't generate an email",
"with",
"self",
".",
"settings",
"(",
"LDAP_APPEND_DOMAIN",
"=",
"\"zulip.com\"",
")",
":",
"email",
"=",
"self",
".",
"example_email",
"(",
... | [
605,
4
] | [
629,
50
] | python | en | ['en', 'en', 'en'] | True |
PasswordResetTest.test_redirect_endpoints | (self) |
These tests are mostly designed to give us 100% URL coverage
in our URL coverage reports. Our mechanism for finding URL
coverage doesn't handle redirects, so we just have a few quick
tests here.
|
These tests are mostly designed to give us 100% URL coverage
in our URL coverage reports. Our mechanism for finding URL
coverage doesn't handle redirects, so we just have a few quick
tests here.
| def test_redirect_endpoints(self) -> None:
"""
These tests are mostly designed to give us 100% URL coverage
in our URL coverage reports. Our mechanism for finding URL
coverage doesn't handle redirects, so we just have a few quick
tests here.
"""
result = self.cli... | [
"def",
"test_redirect_endpoints",
"(",
"self",
")",
"->",
"None",
":",
"result",
"=",
"self",
".",
"client_get",
"(",
"\"/accounts/password/reset/done/\"",
")",
"self",
".",
"assert_in_success_response",
"(",
"[",
"\"Check your email\"",
"]",
",",
"result",
")",
"... | [
631,
4
] | [
648,
58
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_register_deactivated | (self) |
If you try to register for a deactivated realm, you get a clear error
page.
|
If you try to register for a deactivated realm, you get a clear error
page.
| def test_register_deactivated(self) -> None:
"""
If you try to register for a deactivated realm, you get a clear error
page.
"""
realm = get_realm("zulip")
realm.deactivated = True
realm.save(update_fields=["deactivated"])
result = self.client_post(
... | [
"def",
"test_register_deactivated",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"realm",
".",
"deactivated",
"=",
"True",
"realm",
".",
"save",
"(",
"update_fields",
"=",
"[",
"\"deactivated\"",
"]",
")",
"result",
... | [
788,
4
] | [
804,
36
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_register_with_invalid_email | (self) |
If you try to register with invalid email, you get an invalid email
page
|
If you try to register with invalid email, you get an invalid email
page
| def test_register_with_invalid_email(self) -> None:
"""
If you try to register with invalid email, you get an invalid email
page
"""
invalid_email = "foo\x00bar"
result = self.client_post("/accounts/home/", {"email": invalid_email}, subdomain="zulip")
self.assert... | [
"def",
"test_register_with_invalid_email",
"(",
"self",
")",
"->",
"None",
":",
"invalid_email",
"=",
"\"foo\\x00bar\"",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/accounts/home/\"",
",",
"{",
"\"email\"",
":",
"invalid_email",
"}",
",",
"subdomain",
"=",... | [
806,
4
] | [
815,
66
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_register_deactivated_partway_through | (self) |
If you try to register for a deactivated realm, you get a clear error
page.
|
If you try to register for a deactivated realm, you get a clear error
page.
| def test_register_deactivated_partway_through(self) -> None:
"""
If you try to register for a deactivated realm, you get a clear error
page.
"""
email = self.nonreg_email("test")
result = self.client_post("/accounts/home/", {"email": email}, subdomain="zulip")
sel... | [
"def",
"test_register_deactivated_partway_through",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"test\"",
")",
"result",
"=",
"self",
".",
"client_post",
"(",
"\"/accounts/home/\"",
",",
"{",
"\"email\"",
":",
"email",
... | [
817,
4
] | [
836,
36
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_login_deactivated_realm | (self) |
If you try to log in to a deactivated realm, you get a clear error page.
|
If you try to log in to a deactivated realm, you get a clear error page.
| def test_login_deactivated_realm(self) -> None:
"""
If you try to log in to a deactivated realm, you get a clear error page.
"""
realm = get_realm("zulip")
realm.deactivated = True
realm.save(update_fields=["deactivated"])
result = self.login_with_return(self.exa... | [
"def",
"test_login_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"realm",
".",
"deactivated",
"=",
"True",
"realm",
".",
"save",
"(",
"update_fields",
"=",
"[",
"\"deactivated\"",
"]",
")",
"result... | [
838,
4
] | [
848,
62
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_non_ascii_login | (self) |
You can log in even if your password contain non-ASCII characters.
|
You can log in even if your password contain non-ASCII characters.
| def test_non_ascii_login(self) -> None:
"""
You can log in even if your password contain non-ASCII characters.
"""
email = self.nonreg_email("test")
password = "hümbüǵ"
# Registering succeeds.
self.register(email, password)
user_profile = self.nonreg_u... | [
"def",
"test_non_ascii_login",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"test\"",
")",
"password",
"=",
"\"hümbüǵ\"",
"# Registering succeeds.",
"self",
".",
"register",
"(",
"email",
",",
"password",
")",
"user... | [
857,
4
] | [
874,
54
] | python | en | ['en', 'error', 'th'] | False |
LoginTest.test_login_page_redirects_logged_in_user | (self) | You will be redirected to the app's main page if you land on the
login page when already logged in.
| You will be redirected to the app's main page if you land on the
login page when already logged in.
| def test_login_page_redirects_logged_in_user(self) -> None:
"""You will be redirected to the app's main page if you land on the
login page when already logged in.
"""
self.login("cordelia")
response = self.client_get("/login/")
self.assertEqual(response["Location"], "http... | [
"def",
"test_login_page_redirects_logged_in_user",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"cordelia\"",
")",
"response",
"=",
"self",
".",
"client_get",
"(",
"\"/login/\"",
")",
"self",
".",
"assertEqual",
"(",
"response",
"[",
"\"Lo... | [
877,
4
] | [
883,
73
] | python | en | ['en', 'en', 'en'] | True |
LoginTest.test_login_page_redirects_logged_in_user_under_2fa | (self) | You will be redirected to the app's main page if you land on the
login page when already logged in.
| You will be redirected to the app's main page if you land on the
login page when already logged in.
| def test_login_page_redirects_logged_in_user_under_2fa(self) -> None:
"""You will be redirected to the app's main page if you land on the
login page when already logged in.
"""
user_profile = self.example_user("cordelia")
self.create_default_device(user_profile)
self.log... | [
"def",
"test_login_page_redirects_logged_in_user_under_2fa",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"self",
".",
"create_default_device",
"(",
"user_profile",
")",
"self",
".",
"login",
"(",
... | [
890,
4
] | [
901,
73
] | python | en | ['en', 'en', 'en'] | True |
InviteUserBase.invite | (
self,
invitee_emails: str,
stream_names: Sequence[str],
body: str = "",
invite_as: int = PreregistrationUser.INVITE_AS["MEMBER"],
) |
Invites the specified users to Zulip with the specified streams.
users should be a string containing the users to invite, comma or
newline separated.
streams should be a list of strings.
|
Invites the specified users to Zulip with the specified streams. | def invite(
self,
invitee_emails: str,
stream_names: Sequence[str],
body: str = "",
invite_as: int = PreregistrationUser.INVITE_AS["MEMBER"],
) -> HttpResponse:
"""
Invites the specified users to Zulip with the specified streams.
users should be a str... | [
"def",
"invite",
"(",
"self",
",",
"invitee_emails",
":",
"str",
",",
"stream_names",
":",
"Sequence",
"[",
"str",
"]",
",",
"body",
":",
"str",
"=",
"\"\"",
",",
"invite_as",
":",
"int",
"=",
"PreregistrationUser",
".",
"INVITE_AS",
"[",
"\"MEMBER\"",
"... | [
949,
4
] | [
974,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_successful_invite_user | (self) |
A call to /json/invites with valid parameters causes an invitation
email to be sent.
|
A call to /json/invites with valid parameters causes an invitation
email to be sent.
| def test_successful_invite_user(self) -> None:
"""
A call to /json/invites with valid parameters causes an invitation
email to be sent.
"""
self.login("hamlet")
invitee = "alice-test@zulip.com"
self.assert_json_success(self.invite(invitee, ["Denmark"]))
se... | [
"def",
"test_successful_invite_user",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"invitee",
"=",
"\"alice-test@zulip.com\"",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\"De... | [
978,
4
] | [
987,
41
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_mirror_dummy_user | (self) |
A mirror dummy account is a temporary account
that we keep in our system if we are mirroring
data from something like Zephyr or IRC.
We want users to eventually just sign up or
register for Zulip, in which case we will just
fully "activate" the account.
Here we... |
A mirror dummy account is a temporary account
that we keep in our system if we are mirroring
data from something like Zephyr or IRC. | def test_invite_mirror_dummy_user(self) -> None:
"""
A mirror dummy account is a temporary account
that we keep in our system if we are mirroring
data from something like Zephyr or IRC.
We want users to eventually just sign up or
register for Zulip, in which case we will... | [
"def",
"test_invite_mirror_dummy_user",
"(",
"self",
")",
"->",
"None",
":",
"inviter",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"inviter",
")",
"mirror_user",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\... | [
1151,
4
] | [
1184,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_user_as_invalid_type | (self) |
Test inviting a user as invalid type of user i.e. type of invite_as
is not in PreregistrationUser.INVITE_AS
|
Test inviting a user as invalid type of user i.e. type of invite_as
is not in PreregistrationUser.INVITE_AS
| def test_invite_user_as_invalid_type(self) -> None:
"""
Test inviting a user as invalid type of user i.e. type of invite_as
is not in PreregistrationUser.INVITE_AS
"""
self.login("iago")
invitee = self.nonreg_email("alice")
response = self.invite(invitee, ["Denmar... | [
"def",
"test_invite_user_as_invalid_type",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"iago\"",
")",
"invitee",
"=",
"self",
".",
"nonreg_email",
"(",
"\"alice\"",
")",
"response",
"=",
"self",
".",
"invite",
"(",
"invitee",
",",
"["... | [
1262,
4
] | [
1270,
84
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_successful_invite_user_with_name | (self) |
A call to /json/invites with valid parameters causes an invitation
email to be sent.
|
A call to /json/invites with valid parameters causes an invitation
email to be sent.
| def test_successful_invite_user_with_name(self) -> None:
"""
A call to /json/invites with valid parameters causes an invitation
email to be sent.
"""
self.login("hamlet")
email = "alice-test@zulip.com"
invitee = f"Alice Test <{email}>"
self.assert_json_suc... | [
"def",
"test_successful_invite_user_with_name",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"email",
"=",
"\"alice-test@zulip.com\"",
"invitee",
"=",
"f\"Alice Test <{email}>\"",
"self",
".",
"assert_json_success",
"(",
"self",
... | [
1298,
4
] | [
1308,
39
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_successful_invite_user_with_name_and_normal_one | (self) |
A call to /json/invites with valid parameters causes an invitation
email to be sent.
|
A call to /json/invites with valid parameters causes an invitation
email to be sent.
| def test_successful_invite_user_with_name_and_normal_one(self) -> None:
"""
A call to /json/invites with valid parameters causes an invitation
email to be sent.
"""
self.login("hamlet")
email = "alice-test@zulip.com"
email2 = "bob-test@zulip.com"
invitee =... | [
"def",
"test_successful_invite_user_with_name_and_normal_one",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"email",
"=",
"\"alice-test@zulip.com\"",
"email2",
"=",
"\"bob-test@zulip.com\"",
"invitee",
"=",
"f\"Alice Test <{email}>, {... | [
1310,
4
] | [
1322,
47
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_others_to_realm_setting | (self) |
The invite_to_realm_policy realm setting works properly.
|
The invite_to_realm_policy realm setting works properly.
| def test_invite_others_to_realm_setting(self) -> None:
"""
The invite_to_realm_policy realm setting works properly.
"""
realm = get_realm("zulip")
do_set_realm_property(
realm, "invite_to_realm_policy", Realm.POLICY_ADMINS_ONLY, acting_user=None
)
sel... | [
"def",
"test_invite_others_to_realm_setting",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"do_set_realm_property",
"(",
"realm",
",",
"\"invite_to_realm_policy\"",
",",
"Realm",
".",
"POLICY_ADMINS_ONLY",
",",
"acting_user",
... | [
1331,
4
] | [
1422,
47
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_user_signup_initial_history | (self) |
Test that a new user invited to a stream receives some initial
history but only from public streams.
|
Test that a new user invited to a stream receives some initial
history but only from public streams.
| def test_invite_user_signup_initial_history(self) -> None:
"""
Test that a new user invited to a stream receives some initial
history but only from public streams.
"""
self.login("hamlet")
user_profile = self.example_user("hamlet")
private_stream_name = "Secret"
... | [
"def",
"test_invite_user_signup_initial_history",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"private_stream_name",
"=",
"\"Secret\"",
"self",
".",
... | [
1424,
4
] | [
1475,
85
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_multi_user_invite | (self) |
Invites multiple users with a variety of delimiters.
|
Invites multiple users with a variety of delimiters.
| def test_multi_user_invite(self) -> None:
"""
Invites multiple users with a variety of delimiters.
"""
self.login("hamlet")
# Intentionally use a weird string.
self.assert_json_success(
self.invite(
"""bob-test@zulip.com, carol-test@zulip.c... | [
"def",
"test_multi_user_invite",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"# Intentionally use a weird string.",
"self",
".",
"assert_json_success",
"(",
"self",
".",
"invite",
"(",
"\"\"\"bob-test@zulip.com, carol-test@zuli... | [
1477,
4
] | [
1502,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_missing_or_invalid_params | (self) |
Tests inviting with various missing or invalid parameters.
|
Tests inviting with various missing or invalid parameters.
| def test_missing_or_invalid_params(self) -> None:
"""
Tests inviting with various missing or invalid parameters.
"""
realm = get_realm("zulip")
do_set_realm_property(realm, "emails_restricted_to_domains", True, acting_user=None)
self.login("hamlet")
invitee_email... | [
"def",
"test_missing_or_invalid_params",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"do_set_realm_property",
"(",
"realm",
",",
"\"emails_restricted_to_domains\"",
",",
"True",
",",
"acting_user",
"=",
"None",
")",
"self... | [
1527,
4
] | [
1551,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_guest_user_invitation | (self) |
Guest user can't invite new users
|
Guest user can't invite new users
| def test_guest_user_invitation(self) -> None:
"""
Guest user can't invite new users
"""
self.login("polonius")
invitee = "alice-test@zulip.com"
self.assert_json_error(self.invite(invitee, ["Denmark"]), "Not allowed for guest users")
self.assertEqual(find_key_by_em... | [
"def",
"test_guest_user_invitation",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"polonius\"",
")",
"invitee",
"=",
"\"alice-test@zulip.com\"",
"self",
".",
"assert_json_error",
"(",
"self",
".",
"invite",
"(",
"invitee",
",",
"[",
"\"Den... | [
1553,
4
] | [
1561,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invalid_stream | (self) |
Tests inviting to a non-existent stream.
|
Tests inviting to a non-existent stream.
| def test_invalid_stream(self) -> None:
"""
Tests inviting to a non-existent stream.
"""
self.login("hamlet")
self.assert_json_error(
self.invite("iago-test@zulip.com", ["NotARealStream"]),
f"Stream does not exist with id: {self.INVALID_STREAM_ID}. No invit... | [
"def",
"test_invalid_stream",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"self",
".",
"assert_json_error",
"(",
"self",
".",
"invite",
"(",
"\"iago-test@zulip.com\"",
",",
"[",
"\"NotARealStream\"",
"]",
")",
",",
"f\"... | [
1563,
4
] | [
1572,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_existing_user | (self) |
If you invite an address already using Zulip, no invitation is sent.
|
If you invite an address already using Zulip, no invitation is sent.
| def test_invite_existing_user(self) -> None:
"""
If you invite an address already using Zulip, no invitation is sent.
"""
self.login("hamlet")
hamlet_email = "hAmLeT@zUlIp.com"
result = self.invite(hamlet_email, ["Denmark"])
self.assert_json_error(result, "We wer... | [
"def",
"test_invite_existing_user",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"hamlet_email",
"=",
"\"hAmLeT@zUlIp.com\"",
"result",
"=",
"self",
".",
"invite",
"(",
"hamlet_email",
",",
"[",
"\"Denmark\"",
"]",
")",
... | [
1574,
4
] | [
1587,
34
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_links_in_name | (self) |
If you invite an address already using Zulip, no invitation is sent.
|
If you invite an address already using Zulip, no invitation is sent.
| def test_invite_links_in_name(self) -> None:
"""
If you invite an address already using Zulip, no invitation is sent.
"""
hamlet = self.example_user("hamlet")
self.login_user(hamlet)
# Test we properly handle links in user full names
do_change_full_name(hamlet, "<... | [
"def",
"test_invite_links_in_name",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"hamlet",
")",
"# Test we properly handle links in user full names",
"do_change_full_name",
"("... | [
1593,
4
] | [
1616,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_some_existing_some_new | (self) |
If you invite a mix of already existing and new users, invitations are
only sent to the new users.
|
If you invite a mix of already existing and new users, invitations are
only sent to the new users.
| def test_invite_some_existing_some_new(self) -> None:
"""
If you invite a mix of already existing and new users, invitations are
only sent to the new users.
"""
self.login("hamlet")
existing = [self.example_email("hamlet"), "othello@zulip.com"]
new = ["foo-test@zu... | [
"def",
"test_invite_some_existing_some_new",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"existing",
"=",
"[",
"self",
".",
"example_email",
"(",
"\"hamlet\"",
")",
",",
"\"othello@zulip.com\"",
"]",
"new",
"=",
"[",
"\... | [
1622,
4
] | [
1650,
65
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_outside_domain_in_closed_realm | (self) |
In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address.
|
In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address.
| def test_invite_outside_domain_in_closed_realm(self) -> None:
"""
In a realm with `emails_restricted_to_domains = True`, you can't invite people
with a different domain from that of the realm or your e-mail address.
"""
zulip_realm = get_realm("zulip")
zulip_realm.emails_... | [
"def",
"test_invite_outside_domain_in_closed_realm",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"True",
"zulip_realm",
".",
"save",
"(",
")",
"self",
".",
"l... | [
1652,
4
] | [
1667,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_using_disposable_email | (self) |
In a realm with `disallow_disposable_email_addresses = True`, you can't invite
people with a disposable domain.
|
In a realm with `disallow_disposable_email_addresses = True`, you can't invite
people with a disposable domain.
| def test_invite_using_disposable_email(self) -> None:
"""
In a realm with `disallow_disposable_email_addresses = True`, you can't invite
people with a disposable domain.
"""
zulip_realm = get_realm("zulip")
zulip_realm.emails_restricted_to_domains = False
zulip_re... | [
"def",
"test_invite_using_disposable_email",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"disallow_disposable_email_addresses",
"=",
"T... | [
1669,
4
] | [
1685,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_outside_domain_in_open_realm | (self) |
In a realm with `emails_restricted_to_domains = False`, you can invite people
with a different domain from that of the realm or your e-mail address.
|
In a realm with `emails_restricted_to_domains = False`, you can invite people
with a different domain from that of the realm or your e-mail address.
| def test_invite_outside_domain_in_open_realm(self) -> None:
"""
In a realm with `emails_restricted_to_domains = False`, you can invite people
with a different domain from that of the realm or your e-mail address.
"""
zulip_realm = get_realm("zulip")
zulip_realm.emails_res... | [
"def",
"test_invite_outside_domain_in_open_realm",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"save",
"(",
")",
"self",
".",
"lo... | [
1687,
4
] | [
1700,
50
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_outside_domain_before_closing | (self) |
If you invite someone with a different domain from that of the realm
when `emails_restricted_to_domains = False`, but `emails_restricted_to_domains` later
changes to true, the invitation should succeed but the invitee's signup
attempt should fail.
|
If you invite someone with a different domain from that of the realm
when `emails_restricted_to_domains = False`, but `emails_restricted_to_domains` later
changes to true, the invitation should succeed but the invitee's signup
attempt should fail.
| def test_invite_outside_domain_before_closing(self) -> None:
"""
If you invite someone with a different domain from that of the realm
when `emails_restricted_to_domains = False`, but `emails_restricted_to_domains` later
changes to true, the invitation should succeed but the invitee's sig... | [
"def",
"test_invite_outside_domain_before_closing",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"save",
"(",
")",
"self",
".",
"l... | [
1702,
4
] | [
1724,
81
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_disposable_emails_before_closing | (self) |
If you invite someone with a disposable email when
`disallow_disposable_email_addresses = False`, but
later changes to true, the invitation should succeed
but the invitee's signup attempt should fail.
|
If you invite someone with a disposable email when
`disallow_disposable_email_addresses = False`, but
later changes to true, the invitation should succeed
but the invitee's signup attempt should fail.
| def test_disposable_emails_before_closing(self) -> None:
"""
If you invite someone with a disposable email when
`disallow_disposable_email_addresses = False`, but
later changes to true, the invitation should succeed
but the invitee's signup attempt should fail.
"""
... | [
"def",
"test_disposable_emails_before_closing",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"disallow_disposable_email_addresses",
"=",
... | [
1726,
4
] | [
1749,
85
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_with_email_containing_plus_before_closing | (self) |
If you invite someone with an email containing plus when
`emails_restricted_to_domains = False`, but later change
`emails_restricted_to_domains = True`, the invitation should
succeed but the invitee's signup attempt should fail as
users are not allowed to sign up using email con... |
If you invite someone with an email containing plus when
`emails_restricted_to_domains = False`, but later change
`emails_restricted_to_domains = True`, the invitation should
succeed but the invitee's signup attempt should fail as
users are not allowed to sign up using email con... | def test_invite_with_email_containing_plus_before_closing(self) -> None:
"""
If you invite someone with an email containing plus when
`emails_restricted_to_domains = False`, but later change
`emails_restricted_to_domains = True`, the invitation should
succeed but the invitee's si... | [
"def",
"test_invite_with_email_containing_plus_before_closing",
"(",
"self",
")",
"->",
"None",
":",
"zulip_realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"zulip_realm",
".",
"emails_restricted_to_domains",
"=",
"False",
"zulip_realm",
".",
"save",
"(",
")",
"self",... | [
1751,
4
] | [
1777,
9
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_invite_with_non_ascii_streams | (self) |
Inviting someone to streams with non-ASCII characters succeeds.
|
Inviting someone to streams with non-ASCII characters succeeds.
| def test_invite_with_non_ascii_streams(self) -> None:
"""
Inviting someone to streams with non-ASCII characters succeeds.
"""
self.login("hamlet")
invitee = "alice-test@zulip.com"
stream_name = "hümbüǵ"
# Make sure we're subscribed before inviting someone.
... | [
"def",
"test_invite_with_non_ascii_streams",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"invitee",
"=",
"\"alice-test@zulip.com\"",
"stream_name",
"=",
"\"hümbüǵ\"",
"# Make sure we're subscribed before inviting someone.",
"self",
... | [
1796,
4
] | [
1808,
69
] | python | en | ['en', 'error', 'th'] | False |
InviteUserTest.test_confirmation_obj_not_exist_error | (self) | Since the key is a param input by the user to the registration endpoint,
if it inserts an invalid value, the confirmation object won't be found. This
tests if, in that scenario, we handle the exception by redirecting the user to
the confirmation_link_expired_error page.
| Since the key is a param input by the user to the registration endpoint,
if it inserts an invalid value, the confirmation object won't be found. This
tests if, in that scenario, we handle the exception by redirecting the user to
the confirmation_link_expired_error page.
| def test_confirmation_obj_not_exist_error(self) -> None:
"""Since the key is a param input by the user to the registration endpoint,
if it inserts an invalid value, the confirmation object won't be found. This
tests if, in that scenario, we handle the exception by redirecting the user to
... | [
"def",
"test_confirmation_obj_not_exist_error",
"(",
"self",
")",
"->",
"None",
":",
"email",
"=",
"self",
".",
"nonreg_email",
"(",
"\"alice\"",
")",
"password",
"=",
"\"password\"",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"inviter",
"=",
"self",
".... | [
1982,
4
] | [
2011,
51
] | python | en | ['en', 'en', 'en'] | True |
default_subprocess_runner | (cmd, cwd=None, extra_environ=None) | The default method of calling the wrapper subprocess. | The default method of calling the wrapper subprocess. | def default_subprocess_runner(cmd, cwd=None, extra_environ=None):
"""The default method of calling the wrapper subprocess."""
env = os.environ.copy()
if extra_environ:
env.update(extra_environ)
check_call(cmd, cwd=cwd, env=env) | [
"def",
"default_subprocess_runner",
"(",
"cmd",
",",
"cwd",
"=",
"None",
",",
"extra_environ",
"=",
"None",
")",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"if",
"extra_environ",
":",
"env",
".",
"update",
"(",
"extra_environ",
")",
... | [
68,
0
] | [
74,
37
] | python | en | ['en', 'en', 'en'] | True |
quiet_subprocess_runner | (cmd, cwd=None, extra_environ=None) | A method of calling the wrapper subprocess while suppressing output. | A method of calling the wrapper subprocess while suppressing output. | def quiet_subprocess_runner(cmd, cwd=None, extra_environ=None):
"""A method of calling the wrapper subprocess while suppressing output."""
env = os.environ.copy()
if extra_environ:
env.update(extra_environ)
check_output(cmd, cwd=cwd, env=env, stderr=STDOUT) | [
"def",
"quiet_subprocess_runner",
"(",
"cmd",
",",
"cwd",
"=",
"None",
",",
"extra_environ",
"=",
"None",
")",
":",
"env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"if",
"extra_environ",
":",
"env",
".",
"update",
"(",
"extra_environ",
")",
"c... | [
77,
0
] | [
83,
54
] | python | en | ['en', 'en', 'en'] | True |
norm_and_check | (source_tree, requested) | Normalise and check a backend path.
Ensure that the requested backend path is specified as a relative path,
and resolves to a location under the given source tree.
Return an absolute version of the requested path.
| Normalise and check a backend path. | def norm_and_check(source_tree, requested):
"""Normalise and check a backend path.
Ensure that the requested backend path is specified as a relative path,
and resolves to a location under the given source tree.
Return an absolute version of the requested path.
"""
if os.path.isabs(requested):
... | [
"def",
"norm_and_check",
"(",
"source_tree",
",",
"requested",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"requested",
")",
":",
"raise",
"ValueError",
"(",
"\"paths must be relative\"",
")",
"abs_source",
"=",
"os",
".",
"path",
".",
"abspath",
... | [
86,
0
] | [
107,
24
] | python | en | ['en', 'en', 'en'] | True |
Pep517HookCaller.subprocess_runner | (self, runner) | A context manager for temporarily overriding the default subprocess
runner.
| A context manager for temporarily overriding the default subprocess
runner.
| def subprocess_runner(self, runner):
"""A context manager for temporarily overriding the default subprocess
runner.
"""
prev = self._subprocess_runner
self._subprocess_runner = runner
try:
yield
finally:
self._subprocess_runner = prev | [
"def",
"subprocess_runner",
"(",
"self",
",",
"runner",
")",
":",
"prev",
"=",
"self",
".",
"_subprocess_runner",
"self",
".",
"_subprocess_runner",
"=",
"runner",
"try",
":",
"yield",
"finally",
":",
"self",
".",
"_subprocess_runner",
"=",
"prev"
] | [
154,
4
] | [
163,
42
] | python | en | ['en', 'en', 'en'] | True |
Pep517HookCaller.get_requires_for_build_wheel | (self, config_settings=None) | Identify packages required for building a wheel
Returns a list of dependency specifications, e.g.::
["wheel >= 0.25", "setuptools"]
This does not include requirements specified in pyproject.toml.
It returns the result of calling the equivalently named hook in a
subprocess.... | Identify packages required for building a wheel | def get_requires_for_build_wheel(self, config_settings=None):
"""Identify packages required for building a wheel
Returns a list of dependency specifications, e.g.::
["wheel >= 0.25", "setuptools"]
This does not include requirements specified in pyproject.toml.
It returns t... | [
"def",
"get_requires_for_build_wheel",
"(",
"self",
",",
"config_settings",
"=",
"None",
")",
":",
"return",
"self",
".",
"_call_hook",
"(",
"'get_requires_for_build_wheel'",
",",
"{",
"'config_settings'",
":",
"config_settings",
"}",
")"
] | [
165,
4
] | [
178,
10
] | python | en | ['en', 'en', 'en'] | True |
Pep517HookCaller.prepare_metadata_for_build_wheel | (
self, metadata_directory, config_settings=None,
_allow_fallback=True) | Prepare a ``*.dist-info`` folder with metadata for this project.
Returns the name of the newly created folder.
If the build backend defines a hook with this name, it will be called
in a subprocess. If not, the backend will be asked to build a wheel,
and the dist-info extracted from tha... | Prepare a ``*.dist-info`` folder with metadata for this project. | def prepare_metadata_for_build_wheel(
self, metadata_directory, config_settings=None,
_allow_fallback=True):
"""Prepare a ``*.dist-info`` folder with metadata for this project.
Returns the name of the newly created folder.
If the build backend defines a hook with this n... | [
"def",
"prepare_metadata_for_build_wheel",
"(",
"self",
",",
"metadata_directory",
",",
"config_settings",
"=",
"None",
",",
"_allow_fallback",
"=",
"True",
")",
":",
"return",
"self",
".",
"_call_hook",
"(",
"'prepare_metadata_for_build_wheel'",
",",
"{",
"'metadata_... | [
180,
4
] | [
196,
10
] | python | en | ['en', 'en', 'en'] | True |
Pep517HookCaller.build_wheel | (
self, wheel_directory, config_settings=None,
metadata_directory=None) | Build a wheel from this project.
Returns the name of the newly created file.
In general, this will call the 'build_wheel' hook in the backend.
However, if that was previously called by
'prepare_metadata_for_build_wheel', and the same metadata_directory is
used, the previously b... | Build a wheel from this project. | def build_wheel(
self, wheel_directory, config_settings=None,
metadata_directory=None):
"""Build a wheel from this project.
Returns the name of the newly created file.
In general, this will call the 'build_wheel' hook in the backend.
However, if that was previou... | [
"def",
"build_wheel",
"(",
"self",
",",
"wheel_directory",
",",
"config_settings",
"=",
"None",
",",
"metadata_directory",
"=",
"None",
")",
":",
"if",
"metadata_directory",
"is",
"not",
"None",
":",
"metadata_directory",
"=",
"abspath",
"(",
"metadata_directory",... | [
198,
4
] | [
216,
10
] | python | en | ['en', 'en', 'en'] | True |
Pep517HookCaller.get_requires_for_build_sdist | (self, config_settings=None) | Identify packages required for building a wheel
Returns a list of dependency specifications, e.g.::
["setuptools >= 26"]
This does not include requirements specified in pyproject.toml.
It returns the result of calling the equivalently named hook in a
subprocess.
| Identify packages required for building a wheel | def get_requires_for_build_sdist(self, config_settings=None):
"""Identify packages required for building a wheel
Returns a list of dependency specifications, e.g.::
["setuptools >= 26"]
This does not include requirements specified in pyproject.toml.
It returns the result o... | [
"def",
"get_requires_for_build_sdist",
"(",
"self",
",",
"config_settings",
"=",
"None",
")",
":",
"return",
"self",
".",
"_call_hook",
"(",
"'get_requires_for_build_sdist'",
",",
"{",
"'config_settings'",
":",
"config_settings",
"}",
")"
] | [
218,
4
] | [
231,
10
] | python | en | ['en', 'en', 'en'] | True |
Pep517HookCaller.build_sdist | (self, sdist_directory, config_settings=None) | Build an sdist from this project.
Returns the name of the newly created file.
This calls the 'build_sdist' backend hook in a subprocess.
| Build an sdist from this project. | def build_sdist(self, sdist_directory, config_settings=None):
"""Build an sdist from this project.
Returns the name of the newly created file.
This calls the 'build_sdist' backend hook in a subprocess.
"""
return self._call_hook('build_sdist', {
'sdist_directory': a... | [
"def",
"build_sdist",
"(",
"self",
",",
"sdist_directory",
",",
"config_settings",
"=",
"None",
")",
":",
"return",
"self",
".",
"_call_hook",
"(",
"'build_sdist'",
",",
"{",
"'sdist_directory'",
":",
"abspath",
"(",
"sdist_directory",
")",
",",
"'config_setting... | [
233,
4
] | [
243,
10
] | python | en | ['en', 'en', 'en'] | True |
plot2d | (x,y,export_path=None) |
Scatter plot with y=x line.
|
Scatter plot with y=x line.
| def plot2d(x,y,export_path=None):
"""
Scatter plot with y=x line.
"""
plt.cla()
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (6, 6)
plt.scatter(np.array(x), np.array(y), color='black', alpha=0.4)
plt.xlabel('x')
plt.ylabel('y')
if e... | [
"def",
"plot2d",
"(",
"x",
",",
"y",
",",
"export_path",
"=",
"None",
")",
":",
"plt",
".",
"cla",
"(",
")",
"matplotlib",
".",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"12",
"matplotlib",
".",
"rcParams",
"[",
"'figure.figsize'",
"]",
"=",
"(",
"6"... | [
17,
0
] | [
34,
18
] | python | en | ['en', 'error', 'th'] | False |
scatter | (pred,obs,plot_label,export_path=None) |
Scatter plot with y=x line.
|
Scatter plot with y=x line.
| def scatter(pred,obs,plot_label,export_path=None):
"""
Scatter plot with y=x line.
"""
plt.cla()
upper = np.array([pred.max(),obs.max()]).max()
lower = np.array([pred.min(),obs.min()]).min()
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (6, 6)
... | [
"def",
"scatter",
"(",
"pred",
",",
"obs",
",",
"plot_label",
",",
"export_path",
"=",
"None",
")",
":",
"plt",
".",
"cla",
"(",
")",
"upper",
"=",
"np",
".",
"array",
"(",
"[",
"pred",
".",
"max",
"(",
")",
",",
"obs",
".",
"max",
"(",
")",
... | [
38,
0
] | [
58,
18
] | python | en | ['en', 'error', 'th'] | False |
tsne_plot | (data,y=[],label='y',colors='hls', export_path=None, legend=None) |
t-SNE plot for domain and progress visualization.
|
t-SNE plot for domain and progress visualization.
| def tsne_plot(data,y=[],label='y',colors='hls', export_path=None, legend=None):
"""
t-SNE plot for domain and progress visualization.
"""
from sklearn.manifold import TSNE
import seaborn as sns
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (5, 5)
... | [
"def",
"tsne_plot",
"(",
"data",
",",
"y",
"=",
"[",
"]",
",",
"label",
"=",
"'y'",
",",
"colors",
"=",
"'hls'",
",",
"export_path",
"=",
"None",
",",
"legend",
"=",
"None",
")",
":",
"from",
"sklearn",
".",
"manifold",
"import",
"TSNE",
"import",
... | [
62,
0
] | [
96,
18
] | python | en | ['en', 'error', 'th'] | False |
scatter_overlay | (df, y=[], label='y', colors='hls', export_path=None, legend=None) |
Scatter for 2D domain and progress visualization.
|
Scatter for 2D domain and progress visualization.
| def scatter_overlay(df, y=[], label='y', colors='hls', export_path=None, legend=None):
"""
Scatter for 2D domain and progress visualization.
"""
import seaborn as sns
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (6, 6)
if len(y) == len(df):
... | [
"def",
"scatter_overlay",
"(",
"df",
",",
"y",
"=",
"[",
"]",
",",
"label",
"=",
"'y'",
",",
"colors",
"=",
"'hls'",
",",
"export_path",
"=",
"None",
",",
"legend",
"=",
"None",
")",
":",
"import",
"seaborn",
"as",
"sns",
"matplotlib",
".",
"rcParams... | [
100,
0
] | [
126,
18
] | python | en | ['en', 'error', 'th'] | False |
max_observed | (points, batch_size) |
Compute max observed.
|
Compute max observed.
| def max_observed(points, batch_size):
"""
Compute max observed.
"""
index = []
max_obs = []
for i in range(round(len(points)/batch_size)):
current_max = points[:batch_size*(i+1)].max()
max_obs.append(current_max)
index.append(i+1)
return index, max_obs | [
"def",
"max_observed",
"(",
"points",
",",
"batch_size",
")",
":",
"index",
"=",
"[",
"]",
"max_obs",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"round",
"(",
"len",
"(",
"points",
")",
"/",
"batch_size",
")",
")",
":",
"current_max",
"=",
"poi... | [
130,
0
] | [
142,
25
] | python | en | ['en', 'error', 'th'] | False |
rate | (seq) |
Rate of convergence in time.
|
Rate of convergence in time.
| def rate(seq):
"""
Rate of convergence in time.
"""
sequence = []
for i in range(len(seq)-1):
r = (seq[i+1] - seq[i])
sequence.append(r)
return sequence | [
"def",
"rate",
"(",
"seq",
")",
":",
"sequence",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"seq",
")",
"-",
"1",
")",
":",
"r",
"=",
"(",
"seq",
"[",
"i",
"+",
"1",
"]",
"-",
"seq",
"[",
"i",
"]",
")",
"sequence",
".",
... | [
144,
0
] | [
154,
19
] | python | en | ['en', 'error', 'th'] | False |
plot_convergence | (data, batch_size, avg=False, export_path=None) |
Plot optimizer convergence.
|
Plot optimizer convergence.
| def plot_convergence(data, batch_size, avg=False, export_path=None):
"""
Plot optimizer convergence.
"""
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (10, 5)
points = np.array(data)
index, max_obs = max_observed(points, batch_size)
conv_rate = rate... | [
"def",
"plot_convergence",
"(",
"data",
",",
"batch_size",
",",
"avg",
"=",
"False",
",",
"export_path",
"=",
"None",
")",
":",
"matplotlib",
".",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"12",
"matplotlib",
".",
"rcParams",
"[",
"'figure.figsize'",
"]",
... | [
156,
0
] | [
181,
25
] | python | en | ['en', 'error', 'th'] | False |
average_convergence | (data, partition) |
Average convergence output for plots.
|
Average convergence output for plots.
| def average_convergence(data, partition):
"""
Average convergence output for plots.
"""
max_obs_list = []
for data_i in np.array(data):
points = np.array(data_i)
max_obs = []
index = []
for i in range(round(len(points)/partition)):
current_max =... | [
"def",
"average_convergence",
"(",
"data",
",",
"partition",
")",
":",
"max_obs_list",
"=",
"[",
"]",
"for",
"data_i",
"in",
"np",
".",
"array",
"(",
"data",
")",
":",
"points",
"=",
"np",
".",
"array",
"(",
"data_i",
")",
"max_obs",
"=",
"[",
"]",
... | [
185,
0
] | [
207,
27
] | python | en | ['en', 'error', 'th'] | False |
plot_avg_convergence | (data, batch_size, export_path=None) |
Plot average optimizer convergence.
|
Plot average optimizer convergence.
| def plot_avg_convergence(data, batch_size, export_path=None):
"""
Plot average optimizer convergence.
"""
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (10, 5)
index, mean, std = average_convergence(data, batch_size)
conv_rate = rate(mean)
... | [
"def",
"plot_avg_convergence",
"(",
"data",
",",
"batch_size",
",",
"export_path",
"=",
"None",
")",
":",
"matplotlib",
".",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"12",
"matplotlib",
".",
"rcParams",
"[",
"'figure.figsize'",
"]",
"=",
"(",
"10",
",",
"... | [
209,
0
] | [
235,
25
] | python | en | ['en', 'error', 'th'] | False |
compare_convergence | (data_list, batch_sizes, legend_list=None, xlabel='Batch' ,export_path=None) |
Plot average optimizer convergence for a list of runs.
|
Plot average optimizer convergence for a list of runs.
| def compare_convergence(data_list, batch_sizes, legend_list=None, xlabel='Batch' ,export_path=None):
"""
Plot average optimizer convergence for a list of runs.
"""
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (10, 5)
if type(batch_sizes) == type(1):
... | [
"def",
"compare_convergence",
"(",
"data_list",
",",
"batch_sizes",
",",
"legend_list",
"=",
"None",
",",
"xlabel",
"=",
"'Batch'",
",",
"export_path",
"=",
"None",
")",
":",
"matplotlib",
".",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"12",
"matplotlib",
".... | [
239,
0
] | [
294,
25
] | python | en | ['en', 'error', 'th'] | False |
pred_obs | (pred, obs, title='Fit', return_data=False, export_path=None, return_scores=False) |
Run a regression using the trained GP and return
pred-obs plot for known data. return_data = True
gives pred-obs data.
|
Run a regression using the trained GP and return
pred-obs plot for known data. return_data = True
gives pred-obs data.
| def pred_obs(pred, obs, title='Fit', return_data=False, export_path=None, return_scores=False):
"""
Run a regression using the trained GP and return
pred-obs plot for known data. return_data = True
gives pred-obs data.
"""
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figur... | [
"def",
"pred_obs",
"(",
"pred",
",",
"obs",
",",
"title",
"=",
"'Fit'",
",",
"return_data",
"=",
"False",
",",
"export_path",
"=",
"None",
",",
"return_scores",
"=",
"False",
")",
":",
"matplotlib",
".",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"12",
... | [
298,
0
] | [
323,
36
] | python | en | ['en', 'error', 'th'] | False |
spearman_map | (df, export_path=None) |
Plot a spearman correlation dendrogram and heat map for a dataframe.
|
Plot a spearman correlation dendrogram and heat map for a dataframe.
| def spearman_map(df, export_path=None):
"""
Plot a spearman correlation dendrogram and heat map for a dataframe.
"""
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 10))
corr = spearmanr(df).correlation
corr_linkage = hierarchy.ward(corr)
dendro = hierarchy.dendrogram(corr_linkage,
... | [
"def",
"spearman_map",
"(",
"df",
",",
"export_path",
"=",
"None",
")",
":",
"fig",
",",
"(",
"ax1",
",",
"ax2",
")",
"=",
"plt",
".",
"subplots",
"(",
"1",
",",
"2",
",",
"figsize",
"=",
"(",
"12",
",",
"10",
")",
")",
"corr",
"=",
"spearmanr"... | [
327,
0
] | [
347,
21
] | python | en | ['en', 'error', 'th'] | False |
hor_bar | (values, names=[], size=(10,20), title='', xlabel='', ylabel='', sort=True, export_path=None, color='gray') |
Horizontal bar bar chart.
|
Horizontal bar bar chart.
| def hor_bar(values, names=[], size=(10,20), title='', xlabel='', ylabel='', sort=True, export_path=None, color='gray'):
"""
Horizontal bar bar chart.
"""
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = size
if len(names) != len(values):
names = np.... | [
"def",
"hor_bar",
"(",
"values",
",",
"names",
"=",
"[",
"]",
",",
"size",
"=",
"(",
"10",
",",
"20",
")",
",",
"title",
"=",
"''",
",",
"xlabel",
"=",
"''",
",",
"ylabel",
"=",
"''",
",",
"sort",
"=",
"True",
",",
"export_path",
"=",
"None",
... | [
351,
0
] | [
383,
18
] | python | en | ['en', 'error', 'th'] | False |
prior_plot | (prior_list, X, legends, title='', xlabel='x', ylabel='density',
export_path=None, legend_position='lower left', log=False) |
Plot priors on X.
|
Plot priors on X.
| def prior_plot(prior_list, X, legends, title='', xlabel='x', ylabel='density',
export_path=None, legend_position='lower left', log=False):
"""
Plot priors on X.
"""
matplotlib.rcParams['font.size'] = 12
matplotlib.rcParams['figure.figsize'] = (6, 6)
# Get log probs
logp... | [
"def",
"prior_plot",
"(",
"prior_list",
",",
"X",
",",
"legends",
",",
"title",
"=",
"''",
",",
"xlabel",
"=",
"'x'",
",",
"ylabel",
"=",
"'density'",
",",
"export_path",
"=",
"None",
",",
"legend_position",
"=",
"'lower left'",
",",
"log",
"=",
"False",... | [
385,
0
] | [
417,
21
] | python | en | ['en', 'error', 'th'] | False |
plot_choices | (obj, proposed, export_path=None) | !
@brief Plot low dimensional embedding (t-SNE) of initialization
points over user specified domain.
Parameters
----------
@param[in] obj (class): Objective object with methods defined in
bro.objective.
@param[in] proposed (DataFrame): Proposed experiments.
@p... | !
| def plot_choices(obj, proposed, export_path=None):
"""!
@brief Plot low dimensional embedding (t-SNE) of initialization
points over user specified domain.
Parameters
----------
@param[in] obj (class): Objective object with methods defined in
bro.objective.
@pa... | [
"def",
"plot_choices",
"(",
"obj",
",",
"proposed",
",",
"export_path",
"=",
"None",
")",
":",
"X",
"=",
"pd",
".",
"concat",
"(",
"[",
"obj",
".",
"domain",
",",
"obj",
".",
"results",
".",
"drop",
"(",
"'yield'",
",",
"axis",
"=",
"1",
")",
","... | [
421,
0
] | [
469,
48
] | python | en | ['en', 'ja', 'hi'] | False |
pdp_points | (bo_object, descriptor, config='mean', grid=100, seed=1) |
Partial dependence of a given descriptor on the outcome of model
predictions. Acts on a BO object after model training. Note: config='mean'
sets inactive dimensions to their mean value and config='sample' randomly
samples the domain and sets the inactive dimensions to the sample values.
|
Partial dependence of a given descriptor on the outcome of model
predictions. Acts on a BO object after model training. Note: config='mean'
sets inactive dimensions to their mean value and config='sample' randomly
samples the domain and sets the inactive dimensions to the sample values.
| def pdp_points(bo_object, descriptor, config='mean', grid=100, seed=1):
"""
Partial dependence of a given descriptor on the outcome of model
predictions. Acts on a BO object after model training. Note: config='mean'
sets inactive dimensions to their mean value and config='sample' randomly
samples th... | [
"def",
"pdp_points",
"(",
"bo_object",
",",
"descriptor",
",",
"config",
"=",
"'mean'",
",",
"grid",
"=",
"100",
",",
"seed",
"=",
"1",
")",
":",
"# Descriptors",
"columns",
"=",
"bo_object",
".",
"obj",
".",
"domain",
".",
"columns",
".",
"values",
"#... | [
473,
0
] | [
505,
28
] | python | en | ['en', 'error', 'th'] | False |
dependence_plot | (bo_object, descriptors, samples=100, export_path=None) |
Plot partial dependence of a given dimension with all other
dimensions set to the domain mean. Plot N samples of other
descriptor configurations for inactive dimensions drawn from
the optimization domain.
|
Plot partial dependence of a given dimension with all other
dimensions set to the domain mean. Plot N samples of other
descriptor configurations for inactive dimensions drawn from
the optimization domain.
| def dependence_plot(bo_object, descriptors, samples=100, export_path=None):
"""
Plot partial dependence of a given dimension with all other
dimensions set to the domain mean. Plot N samples of other
descriptor configurations for inactive dimensions drawn from
the optimization domain.
"""
... | [
"def",
"dependence_plot",
"(",
"bo_object",
",",
"descriptors",
",",
"samples",
"=",
"100",
",",
"export_path",
"=",
"None",
")",
":",
"matplotlib",
".",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"12",
"descriptors",
"=",
"list",
"(",
"descriptors",
")",
"... | [
507,
0
] | [
552,
21
] | python | en | ['en', 'error', 'th'] | False |
embedding_plot | (data, labels=[], export_path=None) |
PCA and t-SNE plots.
|
PCA and t-SNE plots.
| def embedding_plot(data, labels=[], export_path=None):
"""
PCA and t-SNE plots.
"""
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
# PCA
pca = PCA(n_components=2, copy=True)
pca.fit(data)
pca_results = pca.transform(data)
# t-SNE
tsne = TSN... | [
"def",
"embedding_plot",
"(",
"data",
",",
"labels",
"=",
"[",
"]",
",",
"export_path",
"=",
"None",
")",
":",
"from",
"sklearn",
".",
"manifold",
"import",
"TSNE",
"from",
"sklearn",
".",
"decomposition",
"import",
"PCA",
"# PCA",
"pca",
"=",
"PCA",
"("... | [
556,
0
] | [
617,
18
] | python | en | ['en', 'error', 'th'] | False |
register | (key, version, description=None, format='json', expensive=None) |
A decorator used to register a function as a metric collector.
Decorated functions should do the following based on format:
- json: return JSON-serializable objects.
- csv: write CSV data to a filename named 'key'
@register('projects_by_scm_type', 1)
def projects_by_scm_type():
return... |
A decorator used to register a function as a metric collector. | def register(key, version, description=None, format='json', expensive=None):
"""
A decorator used to register a function as a metric collector.
Decorated functions should do the following based on format:
- json: return JSON-serializable objects.
- csv: write CSV data to a filename named 'key'
... | [
"def",
"register",
"(",
"key",
",",
"version",
",",
"description",
"=",
"None",
",",
"format",
"=",
"'json'",
",",
"expensive",
"=",
"None",
")",
":",
"def",
"decorate",
"(",
"f",
")",
":",
"f",
".",
"__awx_analytics_key__",
"=",
"key",
"f",
".",
"__... | [
54,
0
] | [
75,
19
] | python | en | ['en', 'error', 'th'] | False |
gather | (dest=None, module=None, subset=None, since=None, until=None, collection_type='scheduled') |
Gather all defined metrics and write them as JSON files in a .tgz
:param dest: the (optional) absolute path to write a compressed tarball
:param module: the module to search for registered analytic collector
functions; defaults to awx.main.analytics.collectors
|
Gather all defined metrics and write them as JSON files in a .tgz | def gather(dest=None, module=None, subset=None, since=None, until=None, collection_type='scheduled'):
"""
Gather all defined metrics and write them as JSON files in a .tgz
:param dest: the (optional) absolute path to write a compressed tarball
:param module: the module to search for registered analyt... | [
"def",
"gather",
"(",
"dest",
"=",
"None",
",",
"module",
"=",
"None",
",",
"subset",
"=",
"None",
",",
"since",
"=",
"None",
",",
"until",
"=",
"None",
",",
"collection_type",
"=",
"'scheduled'",
")",
":",
"log_level",
"=",
"logging",
".",
"ERROR",
... | [
163,
0
] | [
326,
23
] | python | en | ['en', 'error', 'th'] | False |
ship | (path) |
Ship gathered metrics to the Insights API
|
Ship gathered metrics to the Insights API
| def ship(path):
"""
Ship gathered metrics to the Insights API
"""
if not path:
logger.error('Insights for Ansible Automation Platform TAR not found')
return False
if not os.path.exists(path):
logger.error('Insights for Ansible Automation Platform TAR {} not found'.format(path... | [
"def",
"ship",
"(",
"path",
")",
":",
"if",
"not",
"path",
":",
"logger",
".",
"error",
"(",
"'Insights for Ansible Automation Platform TAR not found'",
")",
"return",
"False",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"logger",
... | [
329,
0
] | [
369,
19
] | python | en | ['en', 'error', 'th'] | False |
compute_hash | (env, actions, extensive=False) | Computes hash of observations returned by environment for a given scenario.
Args:
env: environment
actions: number of actions
extensive: whether to run full episode
Returns:
hash
| Computes hash of observations returned by environment for a given scenario. | def compute_hash(env, actions, extensive=False):
"""Computes hash of observations returned by environment for a given scenario.
Args:
env: environment
actions: number of actions
extensive: whether to run full episode
Returns:
hash
"""
o = env.reset()
hash_value = observation_hash(o)
done... | [
"def",
"compute_hash",
"(",
"env",
",",
"actions",
",",
"extensive",
"=",
"False",
")",
":",
"o",
"=",
"env",
".",
"reset",
"(",
")",
"hash_value",
"=",
"observation_hash",
"(",
"o",
")",
"done",
"=",
"False",
"step",
"=",
"0",
"while",
"not",
"done"... | [
51,
0
] | [
72,
19
] | python | en | ['en', 'en', 'en'] | True |
FootballEnvTest.check_determinism | (self, extensive=False) | Check that environment is deterministic. | Check that environment is deterministic. | def check_determinism(self, extensive=False):
"""Check that environment is deterministic."""
if 'UNITTEST_IN_DOCKER' in os.environ:
return
cfg = config.Config({
'level': 'tests.11_vs_11_hard_deterministic'
})
env = football_env.FootballEnv(cfg)
actions = len(football_action_set.get... | [
"def",
"check_determinism",
"(",
"self",
",",
"extensive",
"=",
"False",
")",
":",
"if",
"'UNITTEST_IN_DOCKER'",
"in",
"os",
".",
"environ",
":",
"return",
"cfg",
"=",
"config",
".",
"Config",
"(",
"{",
"'level'",
":",
"'tests.11_vs_11_hard_deterministic'",
"}... | [
115,
2
] | [
132,
15
] | python | en | ['en', 'en', 'en'] | True |
FootballEnvTest.test_score_empty_goal | (self) | Score on an empty goal. | Score on an empty goal. | def test_score_empty_goal(self):
"""Score on an empty goal."""
cfg = config.Config()
env = football_env.FootballEnv(cfg)
cfg['level'] = 'academy_empty_goal'
last_o = env.reset()[0]
for _ in range(120):
o, reward, done, _ = env.step(football_action_set.action_right)
o = o[0]
if... | [
"def",
"test_score_empty_goal",
"(",
"self",
")",
":",
"cfg",
"=",
"config",
".",
"Config",
"(",
")",
"env",
"=",
"football_env",
".",
"FootballEnv",
"(",
"cfg",
")",
"cfg",
"[",
"'level'",
"]",
"=",
"'academy_empty_goal'",
"last_o",
"=",
"env",
".",
"re... | [
134,
2
] | [
154,
15
] | python | en | ['en', 'fy', 'en'] | True |
FootballEnvTest.test_render | (self) | Make sure rendering is not broken. | Make sure rendering is not broken. | def test_render(self):
"""Make sure rendering is not broken."""
if 'UNITTEST_IN_DOCKER' in os.environ:
# Rendering is not supported.
return
cfg = config.Config({
'level': 'tests.11_vs_11_hard_deterministic',
})
env = football_env.FootballEnv(cfg)
env.render()
o = env.rese... | [
"def",
"test_render",
"(",
"self",
")",
":",
"if",
"'UNITTEST_IN_DOCKER'",
"in",
"os",
".",
"environ",
":",
"# Rendering is not supported.",
"return",
"cfg",
"=",
"config",
".",
"Config",
"(",
"{",
"'level'",
":",
"'tests.11_vs_11_hard_deterministic'",
",",
"}",
... | [
156,
2
] | [
172,
15
] | python | en | ['en', 'nl', 'en'] | True |
FootballEnvTest.test_dynamic_render | (self) | Verifies dynamic render support. | Verifies dynamic render support. | def test_dynamic_render(self):
"""Verifies dynamic render support."""
if 'UNITTEST_IN_DOCKER' in os.environ:
# Rendering is not supported.
return
cfg = config.Config({
'level': 'tests.11_vs_11_hard_deterministic',
})
env = football_env.FootballEnv(cfg)
o = env.reset()
for... | [
"def",
"test_dynamic_render",
"(",
"self",
")",
":",
"if",
"'UNITTEST_IN_DOCKER'",
"in",
"os",
".",
"environ",
":",
"# Rendering is not supported.",
"return",
"cfg",
"=",
"config",
".",
"Config",
"(",
"{",
"'level'",
":",
"'tests.11_vs_11_hard_deterministic'",
",",
... | [
174,
2
] | [
194,
15
] | python | en | ['fr', 'en', 'en'] | True |
FootballEnvTest.test_different_action_formats | (self) | Verify different action formats are accepted. | Verify different action formats are accepted. | def test_different_action_formats(self):
"""Verify different action formats are accepted."""
cfg = config.Config()
env = football_env.FootballEnv(cfg)
env.reset()
env.step(football_action_set.action_right)
env.step([football_action_set.action_right])
env.step(np.array([football_action_set.ac... | [
"def",
"test_different_action_formats",
"(",
"self",
")",
":",
"cfg",
"=",
"config",
".",
"Config",
"(",
")",
"env",
"=",
"football_env",
".",
"FootballEnv",
"(",
"cfg",
")",
"env",
".",
"reset",
"(",
")",
"env",
".",
"step",
"(",
"football_action_set",
... | [
196,
2
] | [
205,
15
] | python | en | ['en', 'en', 'en'] | True |
FootballEnvTest.test_multi_instance | (self) | Validates that two instances of the env can run in the same thread. | Validates that two instances of the env can run in the same thread. | def test_multi_instance(self):
"""Validates that two instances of the env can run in the same thread."""
tpool = pool.ThreadPool(processes=2)
run1 = tpool.apply_async(self.check_determinism)
run2 = tpool.apply_async(self.check_determinism)
run1.get()
run2.get() | [
"def",
"test_multi_instance",
"(",
"self",
")",
":",
"tpool",
"=",
"pool",
".",
"ThreadPool",
"(",
"processes",
"=",
"2",
")",
"run1",
"=",
"tpool",
".",
"apply_async",
"(",
"self",
".",
"check_determinism",
")",
"run2",
"=",
"tpool",
".",
"apply_async",
... | [
213,
2
] | [
219,
14
] | python | en | ['en', 'en', 'en'] | True |
FootballEnvTest.test_multi_render | (self) | Only one rendering instance allowed at a time. | Only one rendering instance allowed at a time. | def test_multi_render(self):
"""Only one rendering instance allowed at a time."""
if 'UNITTEST_IN_DOCKER' in os.environ:
# Rendering is not supported.
return
cfg = config.Config({})
env1 = football_env.FootballEnv(cfg)
env1.render()
env1.reset()
env2 = football_env.FootballEnv(c... | [
"def",
"test_multi_render",
"(",
"self",
")",
":",
"if",
"'UNITTEST_IN_DOCKER'",
"in",
"os",
".",
"environ",
":",
"# Rendering is not supported.",
"return",
"cfg",
"=",
"config",
".",
"Config",
"(",
"{",
"}",
")",
"env1",
"=",
"football_env",
".",
"FootballEnv... | [
221,
2
] | [
242,
38
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.