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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
select_related_descend | (field, restricted, requested, load_fields, reverse=False) |
Returns True if this field should be used to descend deeper for
select_related() purposes. Used by both the query construction code
(sql.query.fill_related_selections()) and the model instance creation code
(query.get_klass_info()).
Arguments:
* field - the field to be checked
* restrict... |
Returns True if this field should be used to descend deeper for
select_related() purposes. Used by both the query construction code
(sql.query.fill_related_selections()) and the model instance creation code
(query.get_klass_info()). | def select_related_descend(field, restricted, requested, load_fields, reverse=False):
"""
Returns True if this field should be used to descend deeper for
select_related() purposes. Used by both the query construction code
(sql.query.fill_related_selections()) and the model instance creation code
(qu... | [
"def",
"select_related_descend",
"(",
"field",
",",
"restricted",
",",
"requested",
",",
"load_fields",
",",
"reverse",
"=",
"False",
")",
":",
"if",
"not",
"field",
".",
"remote_field",
":",
"return",
"False",
"if",
"field",
".",
"remote_field",
".",
"paren... | [
201,
0
] | [
234,
15
] | python | en | ['en', 'error', 'th'] | False |
refs_expression | (lookup_parts, annotations) |
A helper method to check if the lookup_parts contains references
to the given annotations set. Because the LOOKUP_SEP is contained in the
default annotation names we must check each prefix of the lookup_parts
for a match.
|
A helper method to check if the lookup_parts contains references
to the given annotations set. Because the LOOKUP_SEP is contained in the
default annotation names we must check each prefix of the lookup_parts
for a match.
| def refs_expression(lookup_parts, annotations):
"""
A helper method to check if the lookup_parts contains references
to the given annotations set. Because the LOOKUP_SEP is contained in the
default annotation names we must check each prefix of the lookup_parts
for a match.
"""
for n in range... | [
"def",
"refs_expression",
"(",
"lookup_parts",
",",
"annotations",
")",
":",
"for",
"n",
"in",
"range",
"(",
"len",
"(",
"lookup_parts",
")",
"+",
"1",
")",
":",
"level_n_lookup",
"=",
"LOOKUP_SEP",
".",
"join",
"(",
"lookup_parts",
"[",
"0",
":",
"n",
... | [
237,
0
] | [
248,
20
] | python | en | ['en', 'error', 'th'] | False |
check_rel_lookup_compatibility | (model, target_opts, field) |
Check that self.model is compatible with target_opts. Compatibility
is OK if:
1) model and opts match (where proxy inheritance is removed)
2) model is parent of opts' model or the other way around
|
Check that self.model is compatible with target_opts. Compatibility
is OK if:
1) model and opts match (where proxy inheritance is removed)
2) model is parent of opts' model or the other way around
| def check_rel_lookup_compatibility(model, target_opts, field):
"""
Check that self.model is compatible with target_opts. Compatibility
is OK if:
1) model and opts match (where proxy inheritance is removed)
2) model is parent of opts' model or the other way around
"""
def check(opts):
... | [
"def",
"check_rel_lookup_compatibility",
"(",
"model",
",",
"target_opts",
",",
"field",
")",
":",
"def",
"check",
"(",
"opts",
")",
":",
"return",
"(",
"model",
".",
"_meta",
".",
"concrete_model",
"==",
"opts",
".",
"concrete_model",
"or",
"opts",
".",
"... | [
251,
0
] | [
276,
5
] | python | en | ['en', 'error', 'th'] | False |
DeferredAttribute.__get__ | (self, instance, cls=None) |
Retrieves and caches the value from the datastore on the first lookup.
Returns the cached value.
|
Retrieves and caches the value from the datastore on the first lookup.
Returns the cached value.
| def __get__(self, instance, cls=None):
"""
Retrieves and caches the value from the datastore on the first lookup.
Returns the cached value.
"""
if instance is None:
return self
data = instance.__dict__
if data.get(self.field_name, self) is self:
... | [
"def",
"__get__",
"(",
"self",
",",
"instance",
",",
"cls",
"=",
"None",
")",
":",
"if",
"instance",
"is",
"None",
":",
"return",
"self",
"data",
"=",
"instance",
".",
"__dict__",
"if",
"data",
".",
"get",
"(",
"self",
".",
"field_name",
",",
"self",... | [
102,
4
] | [
118,
36
] | python | en | ['en', 'error', 'th'] | False |
DeferredAttribute._check_parent_chain | (self, instance, name) |
Check if the field value can be fetched from a parent field already
loaded in the instance. This can be done if the to-be fetched
field is a primary key field.
|
Check if the field value can be fetched from a parent field already
loaded in the instance. This can be done if the to-be fetched
field is a primary key field.
| def _check_parent_chain(self, instance, name):
"""
Check if the field value can be fetched from a parent field already
loaded in the instance. This can be done if the to-be fetched
field is a primary key field.
"""
opts = instance._meta
f = opts.get_field(name)
... | [
"def",
"_check_parent_chain",
"(",
"self",
",",
"instance",
",",
"name",
")",
":",
"opts",
"=",
"instance",
".",
"_meta",
"f",
"=",
"opts",
".",
"get_field",
"(",
"name",
")",
"link_field",
"=",
"opts",
".",
"get_ancestor_link",
"(",
"f",
".",
"model",
... | [
120,
4
] | [
131,
19
] | python | en | ['en', 'error', 'th'] | False |
RegisterLookupMixin.merge_dicts | (dicts) |
Merge dicts in reverse to preference the order of the original list. e.g.,
merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
|
Merge dicts in reverse to preference the order of the original list. e.g.,
merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
| def merge_dicts(dicts):
"""
Merge dicts in reverse to preference the order of the original list. e.g.,
merge_dicts([a, b]) will preference the keys in 'a' over those in 'b'.
"""
merged = {}
for d in reversed(dicts):
merged.update(d)
return merged | [
"def",
"merge_dicts",
"(",
"dicts",
")",
":",
"merged",
"=",
"{",
"}",
"for",
"d",
"in",
"reversed",
"(",
"dicts",
")",
":",
"merged",
".",
"update",
"(",
"d",
")",
"return",
"merged"
] | [
165,
4
] | [
173,
21
] | python | en | ['en', 'error', 'th'] | False |
RegisterLookupMixin._unregister_lookup | (cls, lookup, lookup_name=None) |
Remove given lookup from cls lookups. For use in tests only as it's
not thread-safe.
|
Remove given lookup from cls lookups. For use in tests only as it's
not thread-safe.
| def _unregister_lookup(cls, lookup, lookup_name=None):
"""
Remove given lookup from cls lookups. For use in tests only as it's
not thread-safe.
"""
if lookup_name is None:
lookup_name = lookup.lookup_name
del cls.class_lookups[lookup_name] | [
"def",
"_unregister_lookup",
"(",
"cls",
",",
"lookup",
",",
"lookup_name",
"=",
"None",
")",
":",
"if",
"lookup_name",
"is",
"None",
":",
"lookup_name",
"=",
"lookup",
".",
"lookup_name",
"del",
"cls",
".",
"class_lookups",
"[",
"lookup_name",
"]"
] | [
191,
4
] | [
198,
42
] | python | en | ['en', 'error', 'th'] | False |
EventsEndpointTest.test_events_get_events_endpoint_guest_cant_use_all_public_streams_param | (self) |
This test is meant to execute the very beginning of the codepath
to ensure guest users are immediately disallowed to use the
all_public_streams param. Deeper testing is hard (and not necessary for this case)
due to the codepath expecting AsyncDjangoHandler to be attached to the request,... |
This test is meant to execute the very beginning of the codepath
to ensure guest users are immediately disallowed to use the
all_public_streams param. Deeper testing is hard (and not necessary for this case)
due to the codepath expecting AsyncDjangoHandler to be attached to the request,... | def test_events_get_events_endpoint_guest_cant_use_all_public_streams_param(self) -> None:
"""
This test is meant to execute the very beginning of the codepath
to ensure guest users are immediately disallowed to use the
all_public_streams param. Deeper testing is hard (and not necessary ... | [
"def",
"test_events_get_events_endpoint_guest_cant_use_all_public_streams_param",
"(",
"self",
")",
"->",
"None",
":",
"guest_user",
"=",
"self",
".",
"example_user",
"(",
"\"polonius\"",
")",
"self",
".",
"assertEqual",
"(",
"guest_user",
".",
"role",
",",
"UserProfi... | [
160,
4
] | [
173,
76
] | python | en | ['en', 'error', 'th'] | False |
intranges_from_list | (list_) | Represent a list of integers as a sequence of ranges:
((start_0, end_0), (start_1, end_1), ...), such that the original
integers are exactly those x such that start_i <= x < end_i for some i.
Ranges are encoded as single integers (start << 32 | end), not as tuples.
| Represent a list of integers as a sequence of ranges:
((start_0, end_0), (start_1, end_1), ...), such that the original
integers are exactly those x such that start_i <= x < end_i for some i. | def intranges_from_list(list_):
"""Represent a list of integers as a sequence of ranges:
((start_0, end_0), (start_1, end_1), ...), such that the original
integers are exactly those x such that start_i <= x < end_i for some i.
Ranges are encoded as single integers (start << 32 | end), not as tuples.
... | [
"def",
"intranges_from_list",
"(",
"list_",
")",
":",
"sorted_list",
"=",
"sorted",
"(",
"list_",
")",
"ranges",
"=",
"[",
"]",
"last_write",
"=",
"-",
"1",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"sorted_list",
")",
")",
":",
"if",
"i",
"+",
"... | [
9,
0
] | [
28,
24
] | python | en | ['en', 'en', 'en'] | True |
intranges_contain | (int_, ranges) | Determine if `int_` falls into one of the ranges in `ranges`. | Determine if `int_` falls into one of the ranges in `ranges`. | def intranges_contain(int_, ranges):
"""Determine if `int_` falls into one of the ranges in `ranges`."""
tuple_ = _encode_range(int_, 0)
pos = bisect.bisect_left(ranges, tuple_)
# we could be immediately ahead of a tuple (start, end)
# with start < int_ <= end
if pos > 0:
left, right = _... | [
"def",
"intranges_contain",
"(",
"int_",
",",
"ranges",
")",
":",
"tuple_",
"=",
"_encode_range",
"(",
"int_",
",",
"0",
")",
"pos",
"=",
"bisect",
".",
"bisect_left",
"(",
"ranges",
",",
"tuple_",
")",
"# we could be immediately ahead of a tuple (start, end)",
... | [
37,
0
] | [
52,
16
] | python | en | ['en', 'en', 'en'] | True |
gitter_workspace_to_realm | (
domain_name: str, gitter_data: GitterDataT, realm_subdomain: str
) |
Returns:
1. realm, converted realm data
2. avatars, which is list to map avatars to Zulip avatar records.json
3. user_map, which is a dictionary to map from Gitter user id to Zulip user id
4. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
|
Returns:
1. realm, converted realm data
2. avatars, which is list to map avatars to Zulip avatar records.json
3. user_map, which is a dictionary to map from Gitter user id to Zulip user id
4. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
| def gitter_workspace_to_realm(
domain_name: str, gitter_data: GitterDataT, realm_subdomain: str
) -> Tuple[ZerverFieldsT, List[ZerverFieldsT], Dict[str, int], Dict[str, int]]:
"""
Returns:
1. realm, converted realm data
2. avatars, which is list to map avatars to Zulip avatar records.json
3. use... | [
"def",
"gitter_workspace_to_realm",
"(",
"domain_name",
":",
"str",
",",
"gitter_data",
":",
"GitterDataT",
",",
"realm_subdomain",
":",
"str",
")",
"->",
"Tuple",
"[",
"ZerverFieldsT",
",",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"Dict",
"[",
"str",
",",
"i... | [
35,
0
] | [
61,
47
] | python | en | ['en', 'error', 'th'] | False |
build_userprofile | (
timestamp: Any, domain_name: str, gitter_data: GitterDataT
) |
Returns:
1. zerver_userprofile, which is a list of user profile
2. avatar_list, which is list to map avatars to Zulip avatars records.json
3. added_users, which is a dictionary to map from Gitter user id to Zulip id
|
Returns:
1. zerver_userprofile, which is a list of user profile
2. avatar_list, which is list to map avatars to Zulip avatars records.json
3. added_users, which is a dictionary to map from Gitter user id to Zulip id
| def build_userprofile(
timestamp: Any, domain_name: str, gitter_data: GitterDataT
) -> Tuple[List[ZerverFieldsT], List[ZerverFieldsT], Dict[str, int]]:
"""
Returns:
1. zerver_userprofile, which is a list of user profile
2. avatar_list, which is list to map avatars to Zulip avatars records.json
3... | [
"def",
"build_userprofile",
"(",
"timestamp",
":",
"Any",
",",
"domain_name",
":",
"str",
",",
"gitter_data",
":",
"GitterDataT",
")",
"->",
"Tuple",
"[",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"Dict",
"[",
"str",
... | [
64,
0
] | [
109,
52
] | python | en | ['en', 'error', 'th'] | False |
build_stream_map | (
timestamp: Any, gitter_data: GitterDataT
) |
Returns:
1. stream, which is the list of streams
2. defaultstreams, which is the list of default streams
3. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
|
Returns:
1. stream, which is the list of streams
2. defaultstreams, which is the list of default streams
3. stream_map, which is a dictionary to map from Gitter rooms to Zulip stream id
| def build_stream_map(
timestamp: Any, gitter_data: GitterDataT
) -> Tuple[List[ZerverFieldsT], List[ZerverFieldsT], Dict[str, int]]:
"""
Returns:
1. stream, which is the list of streams
2. defaultstreams, which is the list of default streams
3. stream_map, which is a dictionary to map from Gitte... | [
"def",
"build_stream_map",
"(",
"timestamp",
":",
"Any",
",",
"gitter_data",
":",
"GitterDataT",
")",
"->",
"Tuple",
"[",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"Dict",
"[",
"str",
",",
"int",
"]",
"]",
":",
"lo... | [
118,
0
] | [
151,
46
] | python | en | ['en', 'error', 'th'] | False |
build_recipient_and_subscription | (
zerver_userprofile: List[ZerverFieldsT], zerver_stream: List[ZerverFieldsT]
) |
Assumes that there is at least one stream with 'stream_id' = 0,
and that this stream is the only defaultstream, with 'defaultstream_id' = 0
Returns:
1. zerver_recipient, which is a list of mapped recipient
2. zerver_subscription, which is a list of mapped subscription
|
Assumes that there is at least one stream with 'stream_id' = 0,
and that this stream is the only defaultstream, with 'defaultstream_id' = 0
Returns:
1. zerver_recipient, which is a list of mapped recipient
2. zerver_subscription, which is a list of mapped subscription
| def build_recipient_and_subscription(
zerver_userprofile: List[ZerverFieldsT], zerver_stream: List[ZerverFieldsT]
) -> Tuple[List[ZerverFieldsT], List[ZerverFieldsT]]:
"""
Assumes that there is at least one stream with 'stream_id' = 0,
and that this stream is the only defaultstream, with 'defaultstrea... | [
"def",
"build_recipient_and_subscription",
"(",
"zerver_userprofile",
":",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"zerver_stream",
":",
"List",
"[",
"ZerverFieldsT",
"]",
")",
"->",
"Tuple",
"[",
"List",
"[",
"ZerverFieldsT",
"]",
",",
"List",
"[",
"ZerverField... | [
154,
0
] | [
196,
48
] | python | en | ['en', 'error', 'th'] | False |
convert_gitter_workspace_messages | (
gitter_data: GitterDataT,
output_dir: str,
subscriber_map: Dict[int, Set[int]],
user_map: Dict[str, int],
stream_map: Dict[str, int],
user_short_name_to_full_name: Dict[str, str],
chunk_size: int = MESSAGE_BATCH_CHUNK_SIZE,
) |
Messages are stored in batches
|
Messages are stored in batches
| def convert_gitter_workspace_messages(
gitter_data: GitterDataT,
output_dir: str,
subscriber_map: Dict[int, Set[int]],
user_map: Dict[str, int],
stream_map: Dict[str, int],
user_short_name_to_full_name: Dict[str, str],
chunk_size: int = MESSAGE_BATCH_CHUNK_SIZE,
) -> None:
"""
Messag... | [
"def",
"convert_gitter_workspace_messages",
"(",
"gitter_data",
":",
"GitterDataT",
",",
"output_dir",
":",
"str",
",",
"subscriber_map",
":",
"Dict",
"[",
"int",
",",
"Set",
"[",
"int",
"]",
"]",
",",
"user_map",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
... | [
199,
0
] | [
266,
69
] | python | en | ['en', 'error', 'th'] | False |
test_offline_node_running | (sample_cluster) |
Assure that algorithm doesn't explode if a job is marked running
in an offline node
|
Assure that algorithm doesn't explode if a job is marked running
in an offline node
| def test_offline_node_running(sample_cluster):
"""
Assure that algorithm doesn't explode if a job is marked running
in an offline node
"""
default, ig_large, ig_small = sample_cluster()
ig_small.instance_list[0].capacity = 0
tasks = [Job(status='running', execution_node='i1', instance_group=... | [
"def",
"test_offline_node_running",
"(",
"sample_cluster",
")",
":",
"default",
",",
"ig_large",
",",
"ig_small",
"=",
"sample_cluster",
"(",
")",
"ig_small",
".",
"instance_list",
"[",
"0",
"]",
".",
"capacity",
"=",
"0",
"tasks",
"=",
"[",
"Job",
"(",
"s... | [
84,
0
] | [
93,
70
] | python | en | ['en', 'error', 'th'] | False |
test_offline_node_waiting | (sample_cluster) |
Same but for a waiting job
|
Same but for a waiting job
| def test_offline_node_waiting(sample_cluster):
"""
Same but for a waiting job
"""
default, ig_large, ig_small = sample_cluster()
ig_small.instance_list[0].capacity = 0
tasks = [Job(status='waiting', instance_group=ig_small)]
capacities = InstanceGroup.objects.capacity_values(qs=[default, ig_... | [
"def",
"test_offline_node_waiting",
"(",
"sample_cluster",
")",
":",
"default",
",",
"ig_large",
",",
"ig_small",
"=",
"sample_cluster",
"(",
")",
"ig_small",
".",
"instance_list",
"[",
"0",
"]",
".",
"capacity",
"=",
"0",
"tasks",
"=",
"[",
"Job",
"(",
"s... | [
96,
0
] | [
104,
70
] | python | en | ['en', 'error', 'th'] | False |
test_RBAC_reduced_filter | (sample_cluster) |
User can see jobs that are running in `ig_small` and `ig_large` IGs,
but user does not have permission to see those actual instance groups.
Verify that this does not blow everything up.
|
User can see jobs that are running in `ig_small` and `ig_large` IGs,
but user does not have permission to see those actual instance groups.
Verify that this does not blow everything up.
| def test_RBAC_reduced_filter(sample_cluster):
"""
User can see jobs that are running in `ig_small` and `ig_large` IGs,
but user does not have permission to see those actual instance groups.
Verify that this does not blow everything up.
"""
default, ig_large, ig_small = sample_cluster()
tasks... | [
"def",
"test_RBAC_reduced_filter",
"(",
"sample_cluster",
")",
":",
"default",
",",
"ig_large",
",",
"ig_small",
"=",
"sample_cluster",
"(",
")",
"tasks",
"=",
"[",
"Job",
"(",
"status",
"=",
"'waiting'",
",",
"instance_group",
"=",
"default",
")",
",",
"Job... | [
107,
0
] | [
118,
60
] | python | en | ['en', 'error', 'th'] | False |
develop._resolve_setup_path | (egg_base, install_dir, egg_path) |
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
|
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
| def _resolve_setup_path(egg_base, install_dir, egg_path):
"""
Generate a path from egg_base back to '.' where the
setup script resides and ensure that path points to the
setup path from $install_dir/$egg_path.
"""
path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
... | [
"def",
"_resolve_setup_path",
"(",
"egg_base",
",",
"install_dir",
",",
"egg_path",
")",
":",
"path_to_setup",
"=",
"egg_base",
".",
"replace",
"(",
"os",
".",
"sep",
",",
"'/'",
")",
".",
"rstrip",
"(",
"'/'",
")",
"if",
"path_to_setup",
"!=",
"os",
"."... | [
86,
4
] | [
103,
28
] | python | en | ['en', 'error', 'th'] | False |
TestFormBuilder.test_fields | (self) |
This tests that all fields were added to the form with the correct types
|
This tests that all fields were added to the form with the correct types
| def test_fields(self):
"""
This tests that all fields were added to the form with the correct types
"""
form_class = self.fb.get_form_class()
# All fields are present in form
field_names = form_class.base_fields.keys()
self.assertIn('your_name', field_names)
... | [
"def",
"test_fields",
"(",
"self",
")",
":",
"form_class",
"=",
"self",
".",
"fb",
".",
"get_form_class",
"(",
")",
"# All fields are present in form",
"field_names",
"=",
"form_class",
".",
"base_fields",
".",
"keys",
"(",
")",
"self",
".",
"assertIn",
"(",
... | [
123,
4
] | [
164,
97
] | python | en | ['en', 'error', 'th'] | False |
TestCustomFormBuilder.test_using_custom_form_builder | (self) | Tests that charfield max_length is 120 characters. | Tests that charfield max_length is 120 characters. | def test_using_custom_form_builder(self):
"""Tests that charfield max_length is 120 characters."""
form_class = self.form_page.get_form_class()
form = form_class()
# check name field exists
self.assertIsInstance(form.base_fields['name'], forms.CharField)
# check max_lengt... | [
"def",
"test_using_custom_form_builder",
"(",
"self",
")",
":",
"form_class",
"=",
"self",
".",
"form_page",
".",
"get_form_class",
"(",
")",
"form",
"=",
"form_class",
"(",
")",
"# check name field exists",
"self",
".",
"assertIsInstance",
"(",
"form",
".",
"ba... | [
189,
4
] | [
196,
66
] | python | en | ['en', 'en', 'en'] | True |
TestCustomFormBuilder.test_adding_custom_field | (self) | Tests that we can add the ipaddress field, which is an extended choice. | Tests that we can add the ipaddress field, which is an extended choice. | def test_adding_custom_field(self):
"""Tests that we can add the ipaddress field, which is an extended choice."""
ExtendedFormField.objects.create(
page=self.form_page,
sort_order=1,
label='Device IP Address',
field_type='ipaddress',
required=T... | [
"def",
"test_adding_custom_field",
"(",
"self",
")",
":",
"ExtendedFormField",
".",
"objects",
".",
"create",
"(",
"page",
"=",
"self",
".",
"form_page",
",",
"sort_order",
"=",
"1",
",",
"label",
"=",
"'Device IP Address'",
",",
"field_type",
"=",
"'ipaddress... | [
198,
4
] | [
211,
79
] | python | en | ['en', 'en', 'en'] | True |
_get_mro | (cls) |
Returns the bases classes for cls sorted by the MRO.
Works around an issue on Jython where inspect.getmro will not return all
base classes if multiple classes share the same name. Instead, this
function will return a tuple containing the class itself, and the contents
of cls.__bases__. See https:/... |
Returns the bases classes for cls sorted by the MRO. | def _get_mro(cls):
"""
Returns the bases classes for cls sorted by the MRO.
Works around an issue on Jython where inspect.getmro will not return all
base classes if multiple classes share the same name. Instead, this
function will return a tuple containing the class itself, and the contents
of ... | [
"def",
"_get_mro",
"(",
"cls",
")",
":",
"if",
"platform",
".",
"python_implementation",
"(",
")",
"==",
"\"Jython\"",
":",
"return",
"(",
"cls",
",",
")",
"+",
"cls",
".",
"__bases__",
"return",
"inspect",
".",
"getmro",
"(",
"cls",
")"
] | [
21,
0
] | [
32,
30
] | python | en | ['en', 'error', 'th'] | False |
get_unpatched_class | (cls) | Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
| Protect against re-patching the distutils if reloaded | def get_unpatched_class(cls):
"""Protect against re-patching the distutils if reloaded
Also ensures that no other distutils extension monkeypatched the distutils
first.
"""
external_bases = (
cls
for cls in _get_mro(cls)
if not cls.__module__.startswith('setuptools')
)
... | [
"def",
"get_unpatched_class",
"(",
"cls",
")",
":",
"external_bases",
"=",
"(",
"cls",
"for",
"cls",
"in",
"_get_mro",
"(",
"cls",
")",
"if",
"not",
"cls",
".",
"__module__",
".",
"startswith",
"(",
"'setuptools'",
")",
")",
"base",
"=",
"next",
"(",
"... | [
44,
0
] | [
59,
15
] | python | en | ['en', 'en', 'en'] | True |
_patch_distribution_metadata | () | Patch write_pkg_file and read_pkg_file for higher metadata standards | Patch write_pkg_file and read_pkg_file for higher metadata standards | def _patch_distribution_metadata():
"""Patch write_pkg_file and read_pkg_file for higher metadata standards"""
for attr in ('write_pkg_file', 'read_pkg_file', 'get_metadata_version'):
new_val = getattr(setuptools.dist, attr)
setattr(distutils.dist.DistributionMetadata, attr, new_val) | [
"def",
"_patch_distribution_metadata",
"(",
")",
":",
"for",
"attr",
"in",
"(",
"'write_pkg_file'",
",",
"'read_pkg_file'",
",",
"'get_metadata_version'",
")",
":",
"new_val",
"=",
"getattr",
"(",
"setuptools",
".",
"dist",
",",
"attr",
")",
"setattr",
"(",
"d... | [
101,
0
] | [
105,
67
] | python | en | ['en', 'en', 'en'] | True |
patch_func | (replacement, target_mod, func_name) |
Patch func_name in target_mod with replacement
Important - original must be resolved by name to avoid
patching an already patched function.
|
Patch func_name in target_mod with replacement | def patch_func(replacement, target_mod, func_name):
"""
Patch func_name in target_mod with replacement
Important - original must be resolved by name to avoid
patching an already patched function.
"""
original = getattr(target_mod, func_name)
# set the 'unpatched' attribute on the replaceme... | [
"def",
"patch_func",
"(",
"replacement",
",",
"target_mod",
",",
"func_name",
")",
":",
"original",
"=",
"getattr",
"(",
"target_mod",
",",
"func_name",
")",
"# set the 'unpatched' attribute on the replacement to",
"# point to the original.",
"vars",
"(",
"replacement",
... | [
108,
0
] | [
122,
47
] | python | en | ['en', 'error', 'th'] | False |
patch_for_msvc_specialized_compiler | () |
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
|
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
| def patch_for_msvc_specialized_compiler():
"""
Patch functions in distutils to use standalone Microsoft Visual C++
compilers.
"""
# import late to avoid circular imports on Python < 3.5
msvc = import_module('setuptools.msvc')
if platform.system() != 'Windows':
# Compilers only avail... | [
"def",
"patch_for_msvc_specialized_compiler",
"(",
")",
":",
"# import late to avoid circular imports on Python < 3.5",
"msvc",
"=",
"import_module",
"(",
"'setuptools.msvc'",
")",
"if",
"platform",
".",
"system",
"(",
")",
"!=",
"'Windows'",
":",
"# Compilers only availabl... | [
129,
0
] | [
176,
12
] | python | en | ['en', 'error', 'th'] | False |
test_urlencode_host_filter | (post, admin_user, organization) |
Host filters saved on the model must correspond to the same result
as when that host_filter is used in the URL as a querystring.
That means that it must be url-encoded patterns like %22 for quotes
must be escaped as the string is saved to the model.
Expected host filter in this test would match a ... |
Host filters saved on the model must correspond to the same result
as when that host_filter is used in the URL as a querystring.
That means that it must be url-encoded patterns like %22 for quotes
must be escaped as the string is saved to the model. | def test_urlencode_host_filter(post, admin_user, organization):
"""
Host filters saved on the model must correspond to the same result
as when that host_filter is used in the URL as a querystring.
That means that it must be url-encoded patterns like %22 for quotes
must be escaped as the string is sa... | [
"def",
"test_urlencode_host_filter",
"(",
"post",
",",
"admin_user",
",",
"organization",
")",
":",
"# Create smart inventory with host filter that corresponds to querystring",
"post",
"(",
"reverse",
"(",
"'api:inventory_list'",
")",
",",
"data",
"=",
"{",
"'name'",
":",... | [
232,
0
] | [
258,
80
] | python | en | ['en', 'error', 'th'] | False |
HomeTest._sanity_check | (self, result: HttpResponse) |
Use this for tests that are geared toward specific edge cases, but
which still want the home page to load properly.
|
Use this for tests that are geared toward specific edge cases, but
which still want the home page to load properly.
| def _sanity_check(self, result: HttpResponse) -> None:
"""
Use this for tests that are geared toward specific edge cases, but
which still want the home page to load properly.
"""
html = result.content.decode("utf-8")
if "start a conversation" not in html:
rais... | [
"def",
"_sanity_check",
"(",
"self",
",",
"result",
":",
"HttpResponse",
")",
"->",
"None",
":",
"html",
"=",
"result",
".",
"content",
".",
"decode",
"(",
"\"utf-8\"",
")",
"if",
"\"start a conversation\"",
"not",
"in",
"html",
":",
"raise",
"AssertionError... | [
417,
4
] | [
424,
68
] | python | en | ['en', 'error', 'th'] | False |
HomeTest.test_people | (self) |
We send three lists of users. The first two below are disjoint
lists of users, and the records we send for them have identical
structure.
The realm_bots bucket is somewhat redundant, since all bots will
be in one of the first two buckets. They do include fields, however,
... |
We send three lists of users. The first two below are disjoint
lists of users, and the records we send for them have identical
structure. | def test_people(self) -> None:
hamlet = self.example_user("hamlet")
realm = get_realm("zulip")
self.login_user(hamlet)
bots = {}
for i in range(3):
bots[i] = self.create_bot(
owner=hamlet,
bot_email=f"bot-{i}@zulip.com",
... | [
"def",
"test_people",
"(",
"self",
")",
"->",
"None",
":",
"hamlet",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"self",
".",
"login_user",
"(",
"hamlet",
")",
"bots",
"=",
"{",
"}",
"for"... | [
552,
4
] | [
689,
9
] | python | en | ['en', 'error', 'th'] | False |
Registry.register | (self, model, **kwargs) |
Register a model as a setting, adding it to the wagtail admin menu
|
Register a model as a setting, adding it to the wagtail admin menu
| def register(self, model, **kwargs):
"""
Register a model as a setting, adding it to the wagtail admin menu
"""
# Don't bother registering this if it is already registered
if model in self:
return model
self.append(model)
# Register a new menu item i... | [
"def",
"register",
"(",
"self",
",",
"model",
",",
"*",
"*",
"kwargs",
")",
":",
"# Don't bother registering this if it is already registered",
"if",
"model",
"in",
"self",
":",
"return",
"model",
"self",
".",
"append",
"(",
"model",
")",
"# Register a new menu it... | [
40,
4
] | [
61,
20
] | python | en | ['en', 'error', 'th'] | False |
Registry.register_decorator | (self, model=None, **kwargs) |
Register a model as a setting in the Wagtail admin
|
Register a model as a setting in the Wagtail admin
| def register_decorator(self, model=None, **kwargs):
"""
Register a model as a setting in the Wagtail admin
"""
if model is None:
return lambda model: self.register(model, **kwargs)
return self.register(model, **kwargs) | [
"def",
"register_decorator",
"(",
"self",
",",
"model",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"model",
"is",
"None",
":",
"return",
"lambda",
"model",
":",
"self",
".",
"register",
"(",
"model",
",",
"*",
"*",
"kwargs",
")",
"return",... | [
63,
4
] | [
69,
45
] | python | en | ['en', 'error', 'th'] | False |
Registry.get_by_natural_key | (self, app_label, model_name) |
Get a setting model using its app_label and model_name.
If the app_label.model_name combination is not a valid model, or the
model is not registered as a setting, returns None.
|
Get a setting model using its app_label and model_name. | def get_by_natural_key(self, app_label, model_name):
"""
Get a setting model using its app_label and model_name.
If the app_label.model_name combination is not a valid model, or the
model is not registered as a setting, returns None.
"""
try:
Model = apps.get... | [
"def",
"get_by_natural_key",
"(",
"self",
",",
"app_label",
",",
"model_name",
")",
":",
"try",
":",
"Model",
"=",
"apps",
".",
"get_model",
"(",
"app_label",
",",
"model_name",
")",
"except",
"LookupError",
":",
"return",
"None",
"if",
"Model",
"not",
"in... | [
71,
4
] | [
84,
20
] | python | en | ['en', 'error', 'th'] | False |
gkern | (kernlen=21, nsig=3) | Returns a 2D Gaussian kernel array. | Returns a 2D Gaussian kernel array. | def gkern(kernlen=21, nsig=3):
"""Returns a 2D Gaussian kernel array."""
interval = (2 * nsig + 1.) / (kernlen)
x = np.linspace(-nsig - interval / 2., nsig + interval / 2.,
kernlen + 1)
kern1d = np.diff(stats.norm.cdf(x))
kernel_raw = np.sqrt(np.outer(kern1d, kern1d))
kernel ... | [
"def",
"gkern",
"(",
"kernlen",
"=",
"21",
",",
"nsig",
"=",
"3",
")",
":",
"interval",
"=",
"(",
"2",
"*",
"nsig",
"+",
"1.",
")",
"/",
"(",
"kernlen",
")",
"x",
"=",
"np",
".",
"linspace",
"(",
"-",
"nsig",
"-",
"interval",
"/",
"2.",
",",
... | [
11,
0
] | [
19,
17
] | python | en | ['en', 'lb', 'en'] | True |
View.__init__ | (self, **kwargs) |
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
|
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
| def __init__(self, **kwargs):
"""
Constructor. Called in the URLconf; can contain helpful extra
keyword arguments, and other things.
"""
# Go through keyword arguments, and either save their values to our
# instance, or raise an error.
for key, value in six.iterit... | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Go through keyword arguments, and either save their values to our",
"# instance, or raise an error.",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"kwargs",
")",
":",
"setattr",
... | [
35,
4
] | [
43,
37
] | python | en | ['en', 'error', 'th'] | False |
View.as_view | (cls, **initkwargs) |
Main entry point for a request-response process.
|
Main entry point for a request-response process.
| def as_view(cls, **initkwargs):
"""
Main entry point for a request-response process.
"""
for key in initkwargs:
if key in cls.http_method_names:
raise TypeError("You tried to pass in the %s method name as a "
"keyword argument t... | [
"def",
"as_view",
"(",
"cls",
",",
"*",
"*",
"initkwargs",
")",
":",
"for",
"key",
"in",
"initkwargs",
":",
"if",
"key",
"in",
"cls",
".",
"http_method_names",
":",
"raise",
"TypeError",
"(",
"\"You tried to pass in the %s method name as a \"",
"\"keyword argument... | [
46,
4
] | [
77,
19
] | python | en | ['en', 'error', 'th'] | False |
View.options | (self, request, *args, **kwargs) |
Handles responding to requests for the OPTIONS HTTP verb.
|
Handles responding to requests for the OPTIONS HTTP verb.
| def options(self, request, *args, **kwargs):
"""
Handles responding to requests for the OPTIONS HTTP verb.
"""
response = http.HttpResponse()
response['Allow'] = ', '.join(self._allowed_methods())
response['Content-Length'] = '0'
return response | [
"def",
"options",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"http",
".",
"HttpResponse",
"(",
")",
"response",
"[",
"'Allow'",
"]",
"=",
"', '",
".",
"join",
"(",
"self",
".",
"_allowed_methods... | [
96,
4
] | [
103,
23
] | python | en | ['en', 'error', 'th'] | False |
TemplateResponseMixin.render_to_response | (self, context, **response_kwargs) |
Returns a response, using the `response_class` for this
view, with a template rendered with the given context.
If any keyword arguments are provided, they will be
passed to the constructor of the response class.
|
Returns a response, using the `response_class` for this
view, with a template rendered with the given context. | def render_to_response(self, context, **response_kwargs):
"""
Returns a response, using the `response_class` for this
view, with a template rendered with the given context.
If any keyword arguments are provided, they will be
passed to the constructor of the response class.
... | [
"def",
"render_to_response",
"(",
"self",
",",
"context",
",",
"*",
"*",
"response_kwargs",
")",
":",
"response_kwargs",
".",
"setdefault",
"(",
"'content_type'",
",",
"self",
".",
"content_type",
")",
"return",
"self",
".",
"response_class",
"(",
"request",
"... | [
118,
4
] | [
133,
9
] | python | en | ['en', 'error', 'th'] | False |
TemplateResponseMixin.get_template_names | (self) |
Returns a list of template names to be used for the request. Must return
a list. May not be called if render_to_response is overridden.
|
Returns a list of template names to be used for the request. Must return
a list. May not be called if render_to_response is overridden.
| def get_template_names(self):
"""
Returns a list of template names to be used for the request. Must return
a list. May not be called if render_to_response is overridden.
"""
if self.template_name is None:
raise ImproperlyConfigured(
"TemplateResponseMi... | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"if",
"self",
".",
"template_name",
"is",
"None",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"TemplateResponseMixin requires either a definition of \"",
"\"'template_name' or an implementation of 'get_template_names()'\"",
")"... | [
135,
4
] | [
145,
39
] | python | en | ['en', 'error', 'th'] | False |
RedirectView.get_redirect_url | (self, *args, **kwargs) |
Return the URL redirect to. Keyword arguments from the
URL pattern match generating the redirect request
are provided as kwargs to this method.
|
Return the URL redirect to. Keyword arguments from the
URL pattern match generating the redirect request
are provided as kwargs to this method.
| def get_redirect_url(self, *args, **kwargs):
"""
Return the URL redirect to. Keyword arguments from the
URL pattern match generating the redirect request
are provided as kwargs to this method.
"""
if self.url:
url = self.url % kwargs
elif self.pattern_... | [
"def",
"get_redirect_url",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"url",
":",
"url",
"=",
"self",
".",
"url",
"%",
"kwargs",
"elif",
"self",
".",
"pattern_name",
":",
"try",
":",
"url",
"=",
"reverse",
... | [
167,
4
] | [
186,
18
] | python | en | ['en', 'error', 'th'] | False |
Shampoo.step | (self, closure: OptLossClosure = None) | Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
| Performs a single optimization step. | def step(self, closure: OptLossClosure = None) -> OptFloat:
"""Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
"""
loss = None
if closure is not None:
loss = closure()
for group ... | [
"def",
"step",
"(",
"self",
",",
"closure",
":",
"OptLossClosure",
"=",
"None",
")",
"->",
"OptFloat",
":",
"loss",
"=",
"None",
"if",
"closure",
"is",
"not",
"None",
":",
"loss",
"=",
"closure",
"(",
")",
"for",
"group",
"in",
"self",
".",
"param_gr... | [
75,
4
] | [
146,
19
] | python | en | ['en', 'en', 'en'] | True |
DeactivatedRealmTest.test_send_deactivated_realm | (self) |
rest_dispatch rejects requests in a deactivated realm, both /json and api
|
rest_dispatch rejects requests in a deactivated realm, both /json and api | def test_send_deactivated_realm(self) -> None:
"""
rest_dispatch rejects requests in a deactivated realm, both /json and api
"""
realm = get_realm("zulip")
do_deactivate_realm(get_realm("zulip"), acting_user=None)
result = self.client_post(
"/json/messages",... | [
"def",
"test_send_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"do_deactivate_realm",
"(",
"get_realm",
"(",
"\"zulip\"",
")",
",",
"acting_user",
"=",
"None",
")",
"result",
"=",
"self",
".",
"cl... | [
1061,
4
] | [
1112,
9
] | python | en | ['en', 'error', 'th'] | False |
DeactivatedRealmTest.test_fetch_api_key_deactivated_realm | (self) |
authenticated_json_view views fail in a deactivated realm
|
authenticated_json_view views fail in a deactivated realm | def test_fetch_api_key_deactivated_realm(self) -> None:
"""
authenticated_json_view views fail in a deactivated realm
"""
realm = get_realm("zulip")
user_profile = self.example_user("hamlet")
test_password = "abcd1234"
user_profile.set_password(test_password)
... | [
"def",
"test_fetch_api_key_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"realm",
"=",
"get_realm",
"(",
"\"zulip\"",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"test_password",
"=",
"\"abcd1234\"",
"user_profile",
".... | [
1114,
4
] | [
1130,
9
] | python | en | ['en', 'error', 'th'] | False |
DeactivatedRealmTest.test_webhook_deactivated_realm | (self) |
Using a webhook while in a deactivated realm fails
|
Using a webhook while in a deactivated realm fails | def test_webhook_deactivated_realm(self) -> None:
"""
Using a webhook while in a deactivated realm fails
"""
do_deactivate_realm(get_realm("zulip"), acting_user=None)
user_profile = self.example_user("hamlet")
api_key = get_api_key(user_profile)
url = f"/api/v1/e... | [
"def",
"test_webhook_deactivated_realm",
"(",
"self",
")",
"->",
"None",
":",
"do_deactivate_realm",
"(",
"get_realm",
"(",
"\"zulip\"",
")",
",",
"acting_user",
"=",
"None",
")",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"api_key... | [
1132,
4
] | [
1145,
9
] | python | en | ['en', 'error', 'th'] | False |
LoginRequiredTest.test_login_required | (self) |
Verifies the zulip_login_required decorator blocks deactivated users.
|
Verifies the zulip_login_required decorator blocks deactivated users.
| def test_login_required(self) -> None:
"""
Verifies the zulip_login_required decorator blocks deactivated users.
"""
user_profile = self.example_user("hamlet")
# Verify fails if logged-out
result = self.client_get("/accounts/accept_terms/")
self.assertEqual(resul... | [
"def",
"test_login_required",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"# Verify fails if logged-out",
"result",
"=",
"self",
".",
"client_get",
"(",
"\"/accounts/accept_terms/\"",
")",
"self",
... | [
1149,
4
] | [
1179,
49
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_send_deactivated_user | (self) |
rest_dispatch rejects requests from deactivated users, both /json and api
|
rest_dispatch rejects requests from deactivated users, both /json and api | def test_send_deactivated_user(self) -> None:
"""
rest_dispatch rejects requests from deactivated users, both /json and api
"""
user_profile = self.example_user("hamlet")
self.login_user(user_profile)
do_deactivate_user(user_profile, acting_user=None)
result = s... | [
"def",
"test_send_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"self",
".",
"login_user",
"(",
"user_profile",
")",
"do_deactivate_user",
"(",
"user_profile",
",",
"acting_user",
... | [
1213,
4
] | [
1259,
90
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_fetch_api_key_deactivated_user | (self) |
authenticated_json_view views fail with a deactivated user
|
authenticated_json_view views fail with a deactivated user | def test_fetch_api_key_deactivated_user(self) -> None:
"""
authenticated_json_view views fail with a deactivated user
"""
user_profile = self.example_user("hamlet")
email = user_profile.delivery_email
test_password = "abcd1234"
user_profile.set_password(test_pass... | [
"def",
"test_fetch_api_key_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"email",
"=",
"user_profile",
".",
"delivery_email",
"test_password",
"=",
"\"abcd1234\"",
"user_profile",
".... | [
1261,
4
] | [
1276,
90
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_login_deactivated_user | (self) |
logging in fails with an inactive user
|
logging in fails with an inactive user | def test_login_deactivated_user(self) -> None:
"""
logging in fails with an inactive user
"""
user_profile = self.example_user("hamlet")
do_deactivate_user(user_profile, acting_user=None)
result = self.login_with_return(self.example_email("hamlet"))
self.assert_... | [
"def",
"test_login_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"do_deactivate_user",
"(",
"user_profile",
",",
"acting_user",
"=",
"None",
")",
"result",
"=",
"self",
".",
"l... | [
1278,
4
] | [
1287,
76
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_login_deactivated_mirror_dummy | (self) |
logging in fails with an inactive user
|
logging in fails with an inactive user | def test_login_deactivated_mirror_dummy(self) -> None:
"""
logging in fails with an inactive user
"""
user_profile = self.example_user("hamlet")
user_profile.is_mirror_dummy = True
user_profile.save()
password = initial_password(user_profile.delivery_email)
... | [
"def",
"test_login_deactivated_mirror_dummy",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"user_profile",
".",
"is_mirror_dummy",
"=",
"True",
"user_profile",
".",
"save",
"(",
")",
"password",
"... | [
1289,
4
] | [
1328,
79
] | python | en | ['en', 'error', 'th'] | False |
InactiveUserTest.test_webhook_deactivated_user | (self) |
Deactivated users can't use webhooks
|
Deactivated users can't use webhooks | def test_webhook_deactivated_user(self) -> None:
"""
Deactivated users can't use webhooks
"""
user_profile = self.example_user("hamlet")
do_deactivate_user(user_profile, acting_user=None)
api_key = get_api_key(user_profile)
url = f"/api/v1/external/jira?api_key=... | [
"def",
"test_webhook_deactivated_user",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"do_deactivate_user",
"(",
"user_profile",
",",
"acting_user",
"=",
"None",
")",
"api_key",
"=",
"get_api_key",
... | [
1330,
4
] | [
1342,
90
] | python | en | ['en', 'error', 'th'] | False |
TestUserAgentParsing.test_user_agent_parsing | (self) | Test for our user agent parsing logic, using a large data set. | Test for our user agent parsing logic, using a large data set. | def test_user_agent_parsing(self) -> None:
"""Test for our user agent parsing logic, using a large data set."""
user_agents_parsed: Dict[str, int] = defaultdict(int)
user_agents_path = os.path.join(
settings.DEPLOY_ROOT, "zerver/tests/fixtures/user_agents_unique"
)
wi... | [
"def",
"test_user_agent_parsing",
"(",
"self",
")",
"->",
"None",
":",
"user_agents_parsed",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
"=",
"defaultdict",
"(",
"int",
")",
"user_agents_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"settings",
".",
"DE... | [
1986,
4
] | [
2001,
61
] | python | en | ['en', 'en', 'en'] | True |
spawn | (cmd, search_path=1, verbose=0, dry_run=0, env=None) | Run another program, specified as a command list 'cmd', in a new process.
'cmd' is just the argument list for the new process, ie.
cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
There is no way to run a program with a name different from that of its
executable.
If 'search_... | Run another program, specified as a command list 'cmd', in a new process. | def spawn(cmd, search_path=1, verbose=0, dry_run=0, env=None):
"""Run another program, specified as a command list 'cmd', in a new process.
'cmd' is just the argument list for the new process, ie.
cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
There is no way to run a program w... | [
"def",
"spawn",
"(",
"cmd",
",",
"search_path",
"=",
"1",
",",
"verbose",
"=",
"0",
",",
"dry_run",
"=",
"0",
",",
"env",
"=",
"None",
")",
":",
"# cmd is documented as a list, but just in case some code passes a tuple",
"# in, protect our %-formatting code against horr... | [
22,
0
] | [
87,
70
] | python | en | ['en', 'en', 'en'] | True |
find_executable | (executable, path=None) | Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
| Tries to find 'executable' in the directories listed in 'path'. | def find_executable(executable, path=None):
"""Tries to find 'executable' in the directories listed in 'path'.
A string listing directories separated by 'os.pathsep'; defaults to
os.environ['PATH']. Returns the complete filename or None if not found.
"""
_, ext = os.path.splitext(executable)
i... | [
"def",
"find_executable",
"(",
"executable",
",",
"path",
"=",
"None",
")",
":",
"_",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"executable",
")",
"if",
"(",
"sys",
".",
"platform",
"==",
"'win32'",
")",
"and",
"(",
"ext",
"!=",
"'.... | [
90,
0
] | [
124,
15
] | python | en | ['en', 'en', 'en'] | True |
Filter.__init__ | (self, source, require_matching_tags=True) | Creates a Filter
:arg source: the source token stream
:arg require_matching_tags: whether or not to require matching tags
| Creates a Filter | def __init__(self, source, require_matching_tags=True):
"""Creates a Filter
:arg source: the source token stream
:arg require_matching_tags: whether or not to require matching tags
"""
super(Filter, self).__init__(source)
self.require_matching_tags = require_matching_t... | [
"def",
"__init__",
"(",
"self",
",",
"source",
",",
"require_matching_tags",
"=",
"True",
")",
":",
"super",
"(",
"Filter",
",",
"self",
")",
".",
"__init__",
"(",
"source",
")",
"self",
".",
"require_matching_tags",
"=",
"require_matching_tags"
] | [
17,
4
] | [
26,
58
] | python | en | ['en', 'gl', 'en'] | True |
RandomBinaryProjectionTreeNode.insert_entry_for_bucket | (self, bucket_key, tree_depth) |
Increases counter for specified bucket_key (leaf of tree) and
also increases counters along the way from the root to the leaf.
|
Increases counter for specified bucket_key (leaf of tree) and
also increases counters along the way from the root to the leaf.
| def insert_entry_for_bucket(self, bucket_key, tree_depth):
"""
Increases counter for specified bucket_key (leaf of tree) and
also increases counters along the way from the root to the leaf.
"""
# First increase vector count of this subtree
self.vector_count = self.vector... | [
"def",
"insert_entry_for_bucket",
"(",
"self",
",",
"bucket_key",
",",
"tree_depth",
")",
":",
"# First increase vector count of this subtree",
"self",
".",
"vector_count",
"=",
"self",
".",
"vector_count",
"+",
"1",
"if",
"tree_depth",
"<",
"len",
"(",
"bucket_key"... | [
38,
4
] | [
67,
40
] | python | en | ['en', 'error', 'th'] | False |
RandomBinaryProjectionTreeNode.collect_all_bucket_keys | (self) |
Just collects all buckets keys from subtree
|
Just collects all buckets keys from subtree
| def collect_all_bucket_keys(self):
"""
Just collects all buckets keys from subtree
"""
if len(self.childs) == 0:
# This is a leaf so just return the bucket key (we reached the bucket leaf)
#print 'Returning (collect) leaf bucket key %s with %d vectors' % (self.buc... | [
"def",
"collect_all_bucket_keys",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"childs",
")",
"==",
"0",
":",
"# This is a leaf so just return the bucket key (we reached the bucket leaf)",
"#print 'Returning (collect) leaf bucket key %s with %d vectors' % (self.bucket_key,... | [
69,
4
] | [
83,
21
] | python | en | ['en', 'error', 'th'] | False |
RandomBinaryProjectionTreeNode.bucket_keys_to_guarantee_result_set_size | (self, bucket_key, N, tree_depth) |
Returns list of bucket keys based on the specified bucket key
and minimum result size N.
|
Returns list of bucket keys based on the specified bucket key
and minimum result size N.
| def bucket_keys_to_guarantee_result_set_size(self, bucket_key, N, tree_depth):
"""
Returns list of bucket keys based on the specified bucket key
and minimum result size N.
"""
if tree_depth == len(bucket_key):
#print 'Returning leaf bucket key %s with %d vectors' % (... | [
"def",
"bucket_keys_to_guarantee_result_set_size",
"(",
"self",
",",
"bucket_key",
",",
"N",
",",
"tree_depth",
")",
":",
"if",
"tree_depth",
"==",
"len",
"(",
"bucket_key",
")",
":",
"#print 'Returning leaf bucket key %s with %d vectors' % (self.bucket_key, self.vector_count... | [
85,
4
] | [
116,
117
] | python | en | ['en', 'error', 'th'] | False |
RandomBinaryProjectionTree.__init__ | (self, hash_name, projection_count, minimum_result_size, rand_seed=None) |
Creates projection_count random vectors, that are used for projections
thus working as normals of random hyperplanes. Each random vector /
hyperplane will result in one bit of hash.
So if you for example decide to use projection_count=10, the bucket
keys will have 10 digits and... |
Creates projection_count random vectors, that are used for projections
thus working as normals of random hyperplanes. Each random vector /
hyperplane will result in one bit of hash. | def __init__(self, hash_name, projection_count, minimum_result_size, rand_seed=None):
"""
Creates projection_count random vectors, that are used for projections
thus working as normals of random hyperplanes. Each random vector /
hyperplane will result in one bit of hash.
So if y... | [
"def",
"__init__",
"(",
"self",
",",
"hash_name",
",",
"projection_count",
",",
"minimum_result_size",
",",
"rand_seed",
"=",
"None",
")",
":",
"super",
"(",
"RandomBinaryProjectionTree",
",",
"self",
")",
".",
"__init__",
"(",
"hash_name",
")",
"self",
".",
... | [
133,
4
] | [
149,
54
] | python | en | ['en', 'error', 'th'] | False |
RandomBinaryProjectionTree.reset | (self, dim) | Resets / Initializes the hash for the specified dimension. | Resets / Initializes the hash for the specified dimension. | def reset(self, dim):
""" Resets / Initializes the hash for the specified dimension. """
if self.dim != dim:
self.dim = dim
self.normals = self.rand.randn(self.projection_count, dim)
self.tree_root = RandomBinaryProjectionTreeNode() | [
"def",
"reset",
"(",
"self",
",",
"dim",
")",
":",
"if",
"self",
".",
"dim",
"!=",
"dim",
":",
"self",
".",
"dim",
"=",
"dim",
"self",
".",
"normals",
"=",
"self",
".",
"rand",
".",
"randn",
"(",
"self",
".",
"projection_count",
",",
"dim",
")",
... | [
151,
4
] | [
156,
61
] | python | en | ['en', 'en', 'en'] | True |
RandomBinaryProjectionTree.hash_vector | (self, v, querying=False) |
Hashes the vector and returns the binary bucket key as string.
|
Hashes the vector and returns the binary bucket key as string.
| def hash_vector(self, v, querying=False):
"""
Hashes the vector and returns the binary bucket key as string.
"""
if scipy.sparse.issparse(v):
# If vector is sparse, make sure we have the CSR representation
# of the projection matrix
if self.normals_csr... | [
"def",
"hash_vector",
"(",
"self",
",",
"v",
",",
"querying",
"=",
"False",
")",
":",
"if",
"scipy",
".",
"sparse",
".",
"issparse",
"(",
"v",
")",
":",
"# If vector is sparse, make sure we have the CSR representation",
"# of the projection matrix",
"if",
"self",
... | [
158,
4
] | [
188,
31
] | python | en | ['en', 'error', 'th'] | False |
RandomBinaryProjectionTree.get_config | (self) |
Returns pickle-serializable configuration struct for storage.
|
Returns pickle-serializable configuration struct for storage.
| def get_config(self):
"""
Returns pickle-serializable configuration struct for storage.
"""
# Fill this dict with config data
return {
'hash_name': self.hash_name,
'dim': self.dim,
'projection_count': self.projection_count,
'normals... | [
"def",
"get_config",
"(",
"self",
")",
":",
"# Fill this dict with config data",
"return",
"{",
"'hash_name'",
":",
"self",
".",
"hash_name",
",",
"'dim'",
":",
"self",
".",
"dim",
",",
"'projection_count'",
":",
"self",
".",
"projection_count",
",",
"'normals'"... | [
190,
4
] | [
202,
9
] | python | en | ['en', 'error', 'th'] | False |
RandomBinaryProjectionTree.apply_config | (self, config) |
Applies config
|
Applies config
| def apply_config(self, config):
"""
Applies config
"""
self.hash_name = config['hash_name']
self.dim = config['dim']
self.projection_count = config['projection_count']
self.normals = config['normals']
self.tree_root = config['tree_root']
self.minim... | [
"def",
"apply_config",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"hash_name",
"=",
"config",
"[",
"'hash_name'",
"]",
"self",
".",
"dim",
"=",
"config",
"[",
"'dim'",
"]",
"self",
".",
"projection_count",
"=",
"config",
"[",
"'projection_count'",
... | [
204,
4
] | [
213,
64
] | python | en | ['en', 'error', 'th'] | False |
Marker.evaluate | (self, environment=None) | Evaluate a marker.
Return the boolean from evaluating the given marker against the
environment. environment is an optional argument to override all or
part of the determined environment.
The environment is determined from the current Python process.
| Evaluate a marker. | def evaluate(self, environment=None):
# type: (Optional[Dict[str, str]]) -> bool
"""Evaluate a marker.
Return the boolean from evaluating the given marker against the
environment. environment is an optional argument to override all or
part of the determined environment.
... | [
"def",
"evaluate",
"(",
"self",
",",
"environment",
"=",
"None",
")",
":",
"# type: (Optional[Dict[str, str]]) -> bool",
"current_environment",
"=",
"default_environment",
"(",
")",
"if",
"environment",
"is",
"not",
"None",
":",
"current_environment",
".",
"update",
... | [
313,
4
] | [
327,
68
] | python | en | ['en', 'en', 'en'] | True |
WidgetWithScript.render_html | (self, name, value, attrs) | Render the HTML (non-JS) portion of the field markup | Render the HTML (non-JS) portion of the field markup | def render_html(self, name, value, attrs):
"""Render the HTML (non-JS) portion of the field markup"""
return super().render(name, value, attrs) | [
"def",
"render_html",
"(",
"self",
",",
"name",
",",
"value",
",",
"attrs",
")",
":",
"return",
"super",
"(",
")",
".",
"render",
"(",
"name",
",",
"value",
",",
"attrs",
")"
] | [
5,
4
] | [
7,
49
] | python | en | ['en', 'en', 'en'] | True |
start_reconnect_task | (server: KaleServer, peer_info_arg: PeerInfo, log, auth: bool) |
Start a background task that checks connection and reconnects periodically to a peer.
|
Start a background task that checks connection and reconnects periodically to a peer.
| def start_reconnect_task(server: KaleServer, peer_info_arg: PeerInfo, log, auth: bool):
"""
Start a background task that checks connection and reconnects periodically to a peer.
"""
peer_info = PeerInfo(socket.gethostbyname(peer_info_arg.host), peer_info_arg.port)
async def connection_check():
... | [
"def",
"start_reconnect_task",
"(",
"server",
":",
"KaleServer",
",",
"peer_info_arg",
":",
"PeerInfo",
",",
"log",
",",
"auth",
":",
"bool",
")",
":",
"peer_info",
"=",
"PeerInfo",
"(",
"socket",
".",
"gethostbyname",
"(",
"peer_info_arg",
".",
"host",
")",... | [
7,
0
] | [
27,
50
] | python | en | ['en', 'error', 'th'] | False |
convert_BigWig2Wig | (fname, path_to_binary=None) | uses the UCSC bigwigToWig to do the conversion, ready for reading | uses the UCSC bigwigToWig to do the conversion, ready for reading | def convert_BigWig2Wig(fname, path_to_binary=None):
""" uses the UCSC bigwigToWig to do the conversion, ready for reading """
tmp_path = tempfile.mkdtemp()
success=subprocess.check_call(["BigWig2Wig", fname,
"%s/out.wig" % tmp_path])
if success==0:
... | [
"def",
"convert_BigWig2Wig",
"(",
"fname",
",",
"path_to_binary",
"=",
"None",
")",
":",
"tmp_path",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"success",
"=",
"subprocess",
".",
"check_call",
"(",
"[",
"\"BigWig2Wig\"",
",",
"fname",
",",
"\"%s/out.wig\"",
... | [
19,
0
] | [
28,
39
] | python | en | ['en', 'en', 'en'] | True |
convert_Wig2BigWig | (fname, chromSizes, outfile, verbose=False) | uses the UCSC wigToBigWig to do the conversion | uses the UCSC wigToBigWig to do the conversion | def convert_Wig2BigWig(fname, chromSizes, outfile, verbose=False):
""" uses the UCSC wigToBigWig to do the conversion """
# try and cast string to a string if it isn't already!
if type(fname) is not str:
raise TypeError("The filename passed to convert_Wig2BigWig is not a " \
... | [
"def",
"convert_Wig2BigWig",
"(",
"fname",
",",
"chromSizes",
",",
"outfile",
",",
"verbose",
"=",
"False",
")",
":",
"# try and cast string to a string if it isn't already!",
"if",
"type",
"(",
"fname",
")",
"is",
"not",
"str",
":",
"raise",
"TypeError",
"(",
"... | [
30,
0
] | [
56,
23
] | python | en | ['en', 'en', 'en'] | True |
mathWigs | (wig1, wig2, operation="sum", verbose=False) | performs a maths operation on two wig files, like summing them | performs a maths operation on two wig files, like summing them | def mathWigs(wig1, wig2, operation="sum", verbose=False):
"""performs a maths operation on two wig files, like summing them """
# find overlapping chrs and unique chrs in each set of wig data. maths will only be
# done on data that exists on matching chrs for both datasets
intersect_Chr = set.... | [
"def",
"mathWigs",
"(",
"wig1",
",",
"wig2",
",",
"operation",
"=",
"\"sum\"",
",",
"verbose",
"=",
"False",
")",
":",
"# find overlapping chrs and unique chrs in each set of wig data. maths will only be",
"# done on data that exists on matching chrs for both datasets",
"intersec... | [
842,
0
] | [
888,
18
] | python | en | ['en', 'en', 'en'] | True |
scaleWig | (infile, scaleFactor, outfile, isBigWig=False,
bigWigToWig=None, wigToBigWig=None, verbose=False) | reads, scales and output bigwig data | reads, scales and output bigwig data | def scaleWig(infile, scaleFactor, outfile, isBigWig=False,
bigWigToWig=None, wigToBigWig=None, verbose=False):
""" reads, scales and output bigwig data"""
thiswig = wigData(infile, isBigWig=isBigWig, wigToBigWig_binary=wigToBigWig,
bigWigToWig_binary=bigWigToWig)
... | [
"def",
"scaleWig",
"(",
"infile",
",",
"scaleFactor",
",",
"outfile",
",",
"isBigWig",
"=",
"False",
",",
"bigWigToWig",
"=",
"None",
",",
"wigToBigWig",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"thiswig",
"=",
"wigData",
"(",
"infile",
",",
... | [
890,
0
] | [
904,
19
] | python | en | ['en', 'en', 'en'] | True |
wigData.__init__ | (self, fname=None, isBigWig=False, bigWigToWig_binary=None,
wigToBigWig_binary=None, process_mode=1) | class constructor: this takes the filename of the wig file and
reads the data from it into the class attributes. filename should
be a string and point to a file that exists | class constructor: this takes the filename of the wig file and
reads the data from it into the class attributes. filename should
be a string and point to a file that exists | def __init__(self, fname=None, isBigWig=False, bigWigToWig_binary=None,
wigToBigWig_binary=None, process_mode=1):
""" class constructor: this takes the filename of the wig file and
reads the data from it into the class attributes. filename should
be a string and point t... | [
"def",
"__init__",
"(",
"self",
",",
"fname",
"=",
"None",
",",
"isBigWig",
"=",
"False",
",",
"bigWigToWig_binary",
"=",
"None",
",",
"wigToBigWig_binary",
"=",
"None",
",",
"process_mode",
"=",
"1",
")",
":",
"# set some defaults",
"self",
".",
"__filename... | [
62,
4
] | [
143,
66
] | python | en | ['en', 'en', 'en'] | True |
wigData.trimBigWigMultiLines | (self, datalines, return_keep=False) | the bigWigToWig conversion introduces multiple track lines for a
chromosome with each track being ~1024 entries long. This is pissing
annoying! and needs to be removed in order to get one track per
chromosome. There might at some point be a valid reason for having more
than one track... | the bigWigToWig conversion introduces multiple track lines for a
chromosome with each track being ~1024 entries long. This is pissing
annoying! and needs to be removed in order to get one track per
chromosome. There might at some point be a valid reason for having more
than one track... | def trimBigWigMultiLines(self, datalines, return_keep=False):
""" the bigWigToWig conversion introduces multiple track lines for a
chromosome with each track being ~1024 entries long. This is pissing
annoying! and needs to be removed in order to get one track per
chromosome. ... | [
"def",
"trimBigWigMultiLines",
"(",
"self",
",",
"datalines",
",",
"return_keep",
"=",
"False",
")",
":",
"# this does a regular expression match across a large numpy array fast!",
"datalines",
"=",
"numpy",
".",
"array",
"(",
"datalines",
")",
"r",
"=",
"re",
".",
... | [
145,
4
] | [
186,
34
] | python | en | ['en', 'en', 'en'] | True |
wigData.parseWigStructure | (self, datalines, index=None) | parse the structure of the wig data ready to make tracks from | parse the structure of the wig data ready to make tracks from | def parseWigStructure(self, datalines, index=None):
""" parse the structure of the wig data ready to make tracks from """
maxind = len(datalines)
if index is not None:
datalines = datalines[index]
track_indexes=[]
new_start_found=False
... | [
"def",
"parseWigStructure",
"(",
"self",
",",
"datalines",
",",
"index",
"=",
"None",
")",
":",
"maxind",
"=",
"len",
"(",
"datalines",
")",
"if",
"index",
"is",
"not",
"None",
":",
"datalines",
"=",
"datalines",
"[",
"index",
"]",
"track_indexes",
"=",
... | [
188,
4
] | [
231,
29
] | python | en | ['en', 'en', 'en'] | True |
wigData.set_region | (self, region_rep, start=None, stop=None) | sets the current region within the wigData object | sets the current region within the wigData object | def set_region(self, region_rep, start=None, stop=None):
''' sets the current region within the wigData object '''
this_region = generic_set_region(region_rep, start, stop,
generated_by=self._generated_by_script)
# check selecte... | [
"def",
"set_region",
"(",
"self",
",",
"region_rep",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"this_region",
"=",
"generic_set_region",
"(",
"region_rep",
",",
"start",
",",
"stop",
",",
"generated_by",
"=",
"self",
".",
"_generated_b... | [
233,
4
] | [
256,
59
] | python | en | ['en', 'en', 'en'] | True |
wigData.clear_region_selection | (self) | clears the variables defining the current feature selection | clears the variables defining the current feature selection | def clear_region_selection(self):
""" clears the variables defining the current feature selection """
self.region=None
self._current_data=None | [
"def",
"clear_region_selection",
"(",
"self",
")",
":",
"self",
".",
"region",
"=",
"None",
"self",
".",
"_current_data",
"=",
"None"
] | [
258,
4
] | [
263,
31
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_length | (self) | return length, in base-pars of the selected region | return length, in base-pars of the selected region | def get_region_length(self):
''' return length, in base-pars of the selected region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
return(self.region.stop-self.region.start) | [
"def",
"get_region_length",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"region",
".",
"stop",
"-",
"self",
".",
"region",
"... | [
282,
4
] | [
290,
50
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_ndatapoint | (self) | return number of datapoints in the selected region | return number of datapoints in the selected region | def get_region_ndatapoint(self):
''' return number of datapoints in the selected region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_ndatapoint()) | [
"def",
"get_region_ndatapoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_ndatapoint",
"(",
... | [
292,
4
] | [
300,
54
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_data | (self, expand=False) | return the position and data information within the set region | return the position and data information within the set region | def get_region_data(self, expand=False):
''' return the position and data information within the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_data()) | [
"def",
"get_region_data",
"(",
"self",
",",
"expand",
"=",
"False",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
... | [
302,
4
] | [
310,
48
] | python | en | ['en', 'en', 'en'] | True |
wigData.set_region_data | (self, newdata) | sets the data information within the set region | sets the data information within the set region | def set_region_data(self, newdata):
''' sets the data information within the set region '''
self.tracks[self.region.chrid].set_region_data(newdata) | [
"def",
"set_region_data",
"(",
"self",
",",
"newdata",
")",
":",
"self",
".",
"tracks",
"[",
"self",
".",
"region",
".",
"chrid",
"]",
".",
"set_region_data",
"(",
"newdata",
")"
] | [
312,
4
] | [
316,
63
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_min | (self) | return the minimum value and the positions with this value
within the set region | return the minimum value and the positions with this value
within the set region | def get_region_min(self):
''' return the minimum value and the positions with this value
within the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_min()) | [
"def",
"get_region_min",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_min",
"(",
")",
")"
] | [
318,
4
] | [
327,
47
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_max | (self) | return the maximum value and the positions with this value
within the set region | return the maximum value and the positions with this value
within the set region | def get_region_max(self):
''' return the maximum value and the positions with this value
within the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_max()) | [
"def",
"get_region_max",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_max",
"(",
")",
")"
] | [
329,
4
] | [
338,
47
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_mean | (self) | return the mean value for the set region | return the mean value for the set region | def get_region_mean(self):
''' return the mean value for the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_mean()) | [
"def",
"get_region_mean",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_mean",
"(",
")",
")"
... | [
340,
4
] | [
348,
48
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_median | (self) | return the median value for the set region | return the median value for the set region | def get_region_median(self):
''' return the median value for the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_median()) | [
"def",
"get_region_median",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_median",
"(",
")",
... | [
350,
4
] | [
358,
50
] | python | en | ['en', 'da', 'en'] | True |
wigData.get_region_stddev | (self) | return the std deviation for the set region | return the std deviation for the set region | def get_region_stddev(self):
''' return the std deviation for the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_stddev()) | [
"def",
"get_region_stddev",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_stddev",
"(",
")",
... | [
360,
4
] | [
368,
50
] | python | en | ['en', 'da', 'en'] | True |
wigData.get_region_stderr | (self) | return the std error on the mean for the set region | return the std error on the mean for the set region | def get_region_stderr(self):
''' return the std error on the mean for the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_stderr()) | [
"def",
"get_region_stderr",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_stderr",
"(",
")",
... | [
370,
4
] | [
378,
50
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_stats | (self) | return mean, median, stddev ans stderr for the region | return mean, median, stddev ans stderr for the region | def get_region_stats(self):
""" return mean, median, stddev ans stderr for the region """
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_stats()) | [
"def",
"get_region_stats",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_stats",
"(",
")",
")... | [
380,
4
] | [
388,
49
] | python | en | ['en', 'no', 'en'] | True |
wigData.get_region_fracbases | (self) | return the fraction of bases in the region that have a signal | return the fraction of bases in the region that have a signal | def get_region_fracbases(self):
""" return the fraction of bases in the region that have a signal """
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_fracbases()) | [
"def",
"get_region_fracbases",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_fracbases",
"(",
"... | [
390,
4
] | [
398,
53
] | python | en | ['en', 'en', 'en'] | True |
wigData.get_region_mean_per_base | (self) | return the maximum value and the positions with this value
within the set region | return the maximum value and the positions with this value
within the set region | def get_region_mean_per_base(self):
''' return the maximum value and the positions with this value
within the set region '''
if self._current_data is None:
msg = "No region set"
raise ValueError(msg)
return(self._current_data.region_mea... | [
"def",
"get_region_mean_per_base",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current_data",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"_current_data",
".",
"region_mean_per_base",
... | [
400,
4
] | [
409,
57
] | python | en | ['en', 'en', 'en'] | True |
wigData.writeWig | (self, filename, isBigWig=False, fulldata=False, name=None,
desc=None, rgbcolstr=None, chromSizes=None,
multiple_definitionlines = True, verbose=False) | writes all, or a subset, of the wig data to a new output wigfile
chromSizes is a dictionary of key, value pairs comprising chromosome
names and lengths. | writes all, or a subset, of the wig data to a new output wigfile
chromSizes is a dictionary of key, value pairs comprising chromosome
names and lengths. | def writeWig(self, filename, isBigWig=False, fulldata=False, name=None,
desc=None, rgbcolstr=None, chromSizes=None,
multiple_definitionlines = True, verbose=False):
''' writes all, or a subset, of the wig data to a new output wigfile
chromSizes is a d... | [
"def",
"writeWig",
"(",
"self",
",",
"filename",
",",
"isBigWig",
"=",
"False",
",",
"fulldata",
"=",
"False",
",",
"name",
"=",
"None",
",",
"desc",
"=",
"None",
",",
"rgbcolstr",
"=",
"None",
",",
"chromSizes",
"=",
"None",
",",
"multiple_definitionlin... | [
411,
4
] | [
476,
74
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.__init__ | (self, trackdata=None) | class constructor: this takes the filename of the wig file and
reads the data from it into the class attributes. filename should
be a string and point to a file that exists | class constructor: this takes the filename of the wig file and
reads the data from it into the class attributes. filename should
be a string and point to a file that exists | def __init__(self, trackdata=None):
""" class constructor: this takes the filename of the wig file and
reads the data from it into the class attributes. filename should
be a string and point to a file that exists """
self.wigtype=None
self.chr=None
self.... | [
"def",
"__init__",
"(",
"self",
",",
"trackdata",
"=",
"None",
")",
":",
"self",
".",
"wigtype",
"=",
"None",
"self",
".",
"chr",
"=",
"None",
"self",
".",
"start",
"=",
"None",
"self",
".",
"step",
"=",
"None",
"self",
".",
"span",
"=",
"1",
"se... | [
482,
4
] | [
599,
61
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.set_region | (self, region_rep, start=None, stop=None) | sets the current region within the wigTrack object | sets the current region within the wigTrack object | def set_region(self, region_rep, start=None, stop=None):
''' sets the current region within the wigTrack object '''
if start is None and stop is not None:
start=1
elif start is not None and stop is None:
stop=int(self.position.max()+1)
... | [
"def",
"set_region",
"(",
"self",
",",
"region_rep",
",",
"start",
"=",
"None",
",",
"stop",
"=",
"None",
")",
":",
"if",
"start",
"is",
"None",
"and",
"stop",
"is",
"not",
"None",
":",
"start",
"=",
"1",
"elif",
"start",
"is",
"not",
"None",
"and"... | [
601,
4
] | [
618,
63
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.region_length | (self) | return length, in base-pars of the selected region | return length, in base-pars of the selected region | def region_length(self):
''' return length, in base-pars of the selected region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
return(self.region.stop-self.region.start) | [
"def",
"region_length",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"region",
".",
"stop",
"-",
"self",
".",
"region",
".",
... | [
620,
4
] | [
628,
50
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.region_ndatapoint | (self) | return number of datapoints in the selected region | return number of datapoints in the selected region | def region_ndatapoint(self):
''' return number of datapoints in the selected region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
return(len(self._region_index)) | [
"def",
"region_ndatapoint",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"len",
"(",
"self",
".",
"_region_index",
")",
")"
] | [
630,
4
] | [
638,
39
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.region_data | (self, expand=False) | return the position and data information within the set region | return the position and data information within the set region | def region_data(self, expand=False):
''' return the position and data information within the set region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
if not expand:
return((self.position[self._region_index],... | [
"def",
"region_data",
"(",
"self",
",",
"expand",
"=",
"False",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"if",
"not",
"expand",
":",
"return",
"(",
"(",
"self",
... | [
640,
4
] | [
658,
52
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.set_region_data | (self, newdata) | sets the data information within the set region | sets the data information within the set region | def set_region_data(self, newdata):
''' sets the data information within the set region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
if type(newdata) is not numpy.ndarray:
try:
newdata = num... | [
"def",
"set_region_data",
"(",
"self",
",",
"newdata",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"if",
"type",
"(",
"newdata",
")",
"is",
"not",
"numpy",
".",
"nda... | [
660,
4
] | [
680,
45
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.region_min | (self) | return the minimum value and the positions with this value
within the set region | return the minimum value and the positions with this value
within the set region | def region_min(self):
''' return the minimum value and the positions with this value
within the set region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
minval = self.data[self._region_index].min()
val_... | [
"def",
"region_min",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"minval",
"=",
"self",
".",
"data",
"[",
"self",
".",
"_region_index",
"]",
".",
"min",... | [
682,
4
] | [
695,
38
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.region_max | (self) | return the maximum value and the positions with this value
within the set region | return the maximum value and the positions with this value
within the set region | def region_max(self):
''' return the maximum value and the positions with this value
within the set region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
maxval = self.data[self._region_index].max()
val_... | [
"def",
"region_max",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"maxval",
"=",
"self",
".",
"data",
"[",
"self",
".",
"_region_index",
"]",
".",
"max",... | [
697,
4
] | [
710,
38
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.region_mean | (self) | return the mean value for the set region | return the mean value for the set region | def region_mean(self):
''' return the mean value for the set region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
return(self.data[self._region_index].mean()) | [
"def",
"region_mean",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"data",
"[",
"self",
".",
"_region_index",
"]",
".",
"mean... | [
712,
4
] | [
720,
52
] | python | en | ['en', 'en', 'en'] | True |
wigTrack.region_median | (self) | return the median value for the set region | return the median value for the set region | def region_median(self):
''' return the median value for the set region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
return(numpy.median(self.data[self._region_index])) | [
"def",
"region_median",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"numpy",
".",
"median",
"(",
"self",
".",
"data",
"[",
"self",
".",
... | [
722,
4
] | [
730,
59
] | python | en | ['en', 'da', 'en'] | True |
wigTrack.region_stddev | (self) | return the std deviation for the set region
Here we correct numpys typical standard deviation routine to make it an
unbiased estimator, according to GURLAND, J. & TRIPATHI, R. C. 1971.
"Simple Approximation for Unbiased Estimation of Standard Deviation."
American Statisticia... | return the std deviation for the set region
Here we correct numpys typical standard deviation routine to make it an
unbiased estimator, according to GURLAND, J. & TRIPATHI, R. C. 1971.
"Simple Approximation for Unbiased Estimation of Standard Deviation."
American Statisticia... | def region_stddev(self):
''' return the std deviation for the set region
Here we correct numpys typical standard deviation routine to make it an
unbiased estimator, according to GURLAND, J. & TRIPATHI, R. C. 1971.
"Simple Approximation for Unbiased Estimation of Stand... | [
"def",
"region_stddev",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"data",
"[",
"self",
".",
"_region_index",
"]",
".",
"st... | [
732,
4
] | [
748,
64
] | python | en | ['en', 'da', 'en'] | True |
wigTrack.region_stderr | (self) | return the std error on the mean for the set region | return the std error on the mean for the set region | def region_stderr(self):
''' return the std error on the mean for the set region '''
if self.region is None:
msg = "No region set"
raise ValueError(msg)
return(self.region_stddev()/self.region_ndatapoint()... | [
"def",
"region_stderr",
"(",
"self",
")",
":",
"if",
"self",
".",
"region",
"is",
"None",
":",
"msg",
"=",
"\"No region set\"",
"raise",
"ValueError",
"(",
"msg",
")",
"return",
"(",
"self",
".",
"region_stddev",
"(",
")",
"/",
"self",
".",
"region_ndata... | [
750,
4
] | [
758,
61
] | 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.