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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
GoodnessOfFit.compute_results | (self) |
Computes statistics and stores the results in GoodnessOfFitResult object
Returns:
GoodnessOfFitResult object that holds the computed statistics
|
Computes statistics and stores the results in GoodnessOfFitResult object | def compute_results(self):
"""
Computes statistics and stores the results in GoodnessOfFitResult object
Returns:
GoodnessOfFitResult object that holds the computed statistics
"""
assert self.x_cond.all()
assert self.estimator is not None
assert self.probabilistic_model is not No... | [
"def",
"compute_results",
"(",
"self",
")",
":",
"assert",
"self",
".",
"x_cond",
".",
"all",
"(",
")",
"assert",
"self",
".",
"estimator",
"is",
"not",
"None",
"assert",
"self",
".",
"probabilistic_model",
"is",
"not",
"None",
"gof_result",
"=",
"Goodness... | [
88,
2
] | [
151,
21
] | python | en | ['en', 'error', 'th'] | False |
string_to_ascii | (value) |
Convert a string to ascii.
|
Convert a string to ascii.
| def string_to_ascii(value):
"""
Convert a string to ascii.
"""
return str(anyascii(value)) | [
"def",
"string_to_ascii",
"(",
"value",
")",
":",
"return",
"str",
"(",
"anyascii",
"(",
"value",
")",
")"
] | [
26,
0
] | [
31,
31
] | python | en | ['en', 'error', 'th'] | False |
get_model_string | (model) |
Returns a string that can be used to identify the specified model.
The format is: `app_label.ModelName`
This an be reversed with the `resolve_model_string` function
|
Returns a string that can be used to identify the specified model. | def get_model_string(model):
"""
Returns a string that can be used to identify the specified model.
The format is: `app_label.ModelName`
This an be reversed with the `resolve_model_string` function
"""
return model._meta.app_label + '.' + model.__name__ | [
"def",
"get_model_string",
"(",
"model",
")",
":",
"return",
"model",
".",
"_meta",
".",
"app_label",
"+",
"'.'",
"+",
"model",
".",
"__name__"
] | [
34,
0
] | [
42,
55
] | python | en | ['en', 'error', 'th'] | False |
resolve_model_string | (model_string, default_app=None) |
Resolve an 'app_label.model_name' string into an actual model class.
If a model class is passed in, just return that.
Raises a LookupError if a model can not be found, or ValueError if passed
something that is neither a model or a string.
|
Resolve an 'app_label.model_name' string into an actual model class.
If a model class is passed in, just return that. | def resolve_model_string(model_string, default_app=None):
"""
Resolve an 'app_label.model_name' string into an actual model class.
If a model class is passed in, just return that.
Raises a LookupError if a model can not be found, or ValueError if passed
something that is neither a model or a string... | [
"def",
"resolve_model_string",
"(",
"model_string",
",",
"default_app",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"model_string",
",",
"str",
")",
":",
"try",
":",
"app_label",
",",
"model_name",
"=",
"model_string",
".",
"split",
"(",
"\".\"",
")",
... | [
45,
0
] | [
72,
97
] | python | en | ['en', 'error', 'th'] | False |
escape_script | (text) |
Escape `</script>` tags in 'text' so that it can be placed within a `<script>` block without
accidentally closing it. A '-' character will be inserted for each time it is escaped:
`<-/script>`, `<--/script>` etc.
|
Escape `</script>` tags in 'text' so that it can be placed within a `<script>` block without
accidentally closing it. A '-' character will be inserted for each time it is escaped:
`<-/script>`, `<--/script>` etc.
| def escape_script(text):
"""
Escape `</script>` tags in 'text' so that it can be placed within a `<script>` block without
accidentally closing it. A '-' character will be inserted for each time it is escaped:
`<-/script>`, `<--/script>` etc.
"""
return SCRIPT_RE.sub(r'<-\1/script>', text) | [
"def",
"escape_script",
"(",
"text",
")",
":",
"return",
"SCRIPT_RE",
".",
"sub",
"(",
"r'<-\\1/script>'",
",",
"text",
")"
] | [
78,
0
] | [
84,
47
] | python | en | ['en', 'error', 'th'] | False |
cautious_slugify | (value) |
Convert a string to ASCII exactly as Django's slugify does, with the exception
that any non-ASCII alphanumeric characters (that cannot be ASCIIfied under Unicode
normalisation) are escaped into codes like 'u0421' instead of being deleted entirely.
This ensures that the result of slugifying e.g. Cyrill... |
Convert a string to ASCII exactly as Django's slugify does, with the exception
that any non-ASCII alphanumeric characters (that cannot be ASCIIfied under Unicode
normalisation) are escaped into codes like 'u0421' instead of being deleted entirely. | def cautious_slugify(value):
"""
Convert a string to ASCII exactly as Django's slugify does, with the exception
that any non-ASCII alphanumeric characters (that cannot be ASCIIfied under Unicode
normalisation) are escaped into codes like 'u0421' instead of being deleted entirely.
This ensures that ... | [
"def",
"cautious_slugify",
"(",
"value",
")",
":",
"value",
"=",
"force_str",
"(",
"value",
")",
"# Normalize the string to decomposed unicode form. This causes accented Latin",
"# characters to be split into 'base character' + 'accent modifier'; the latter will",
"# be stripped out by t... | [
90,
0
] | [
119,
25
] | python | en | ['en', 'error', 'th'] | False |
safe_snake_case | (value) |
Convert a string to ASCII similar to Django's slugify, with catious handling of
non-ASCII alphanumeric characters. See `cautious_slugify`.
Any inner whitespace, hyphens or dashes will be converted to underscores and
will be safe for Django template or filename usage.
|
Convert a string to ASCII similar to Django's slugify, with catious handling of
non-ASCII alphanumeric characters. See `cautious_slugify`. | def safe_snake_case(value):
"""
Convert a string to ASCII similar to Django's slugify, with catious handling of
non-ASCII alphanumeric characters. See `cautious_slugify`.
Any inner whitespace, hyphens or dashes will be converted to underscores and
will be safe for Django template or filename usage.... | [
"def",
"safe_snake_case",
"(",
"value",
")",
":",
"slugified_ascii_string",
"=",
"cautious_slugify",
"(",
"value",
")",
"snake_case_string",
"=",
"slugified_ascii_string",
".",
"replace",
"(",
"\"-\"",
",",
"\"_\"",
")",
"return",
"snake_case_string"
] | [
122,
0
] | [
135,
28
] | python | en | ['en', 'error', 'th'] | False |
accepts_kwarg | (func, kwarg) |
Determine whether the callable `func` has a signature that accepts the keyword argument `kwarg`
|
Determine whether the callable `func` has a signature that accepts the keyword argument `kwarg`
| def accepts_kwarg(func, kwarg):
"""
Determine whether the callable `func` has a signature that accepts the keyword argument `kwarg`
"""
signature = inspect.signature(func)
try:
signature.bind_partial(**{kwarg: None})
return True
except TypeError:
return False | [
"def",
"accepts_kwarg",
"(",
"func",
",",
"kwarg",
")",
":",
"signature",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"try",
":",
"signature",
".",
"bind_partial",
"(",
"*",
"*",
"{",
"kwarg",
":",
"None",
"}",
")",
"return",
"True",
"except",
... | [
138,
0
] | [
147,
20
] | python | en | ['en', 'error', 'th'] | False |
find_available_slug | (parent, requested_slug, ignore_page_id=None) |
Finds an available slug within the specified parent.
If the requested slug is not available, this adds a number on the end, for example:
- 'requested-slug'
- 'requested-slug-1'
- 'requested-slug-2'
And so on, until an available slug is found.
The `ignore_page_id` keyword argument is ... |
Finds an available slug within the specified parent. | def find_available_slug(parent, requested_slug, ignore_page_id=None):
"""
Finds an available slug within the specified parent.
If the requested slug is not available, this adds a number on the end, for example:
- 'requested-slug'
- 'requested-slug-1'
- 'requested-slug-2'
And so on, unt... | [
"def",
"find_available_slug",
"(",
"parent",
",",
"requested_slug",
",",
"ignore_page_id",
"=",
"None",
")",
":",
"pages",
"=",
"parent",
".",
"get_children",
"(",
")",
".",
"filter",
"(",
"slug__startswith",
"=",
"requested_slug",
")",
"if",
"ignore_page_id",
... | [
179,
0
] | [
208,
15
] | python | en | ['en', 'error', 'th'] | False |
get_content_languages | () |
Cache of settings.WAGTAIL_CONTENT_LANGUAGES in a dictionary for easy lookups by key.
|
Cache of settings.WAGTAIL_CONTENT_LANGUAGES in a dictionary for easy lookups by key.
| def get_content_languages():
"""
Cache of settings.WAGTAIL_CONTENT_LANGUAGES in a dictionary for easy lookups by key.
"""
content_languages = getattr(settings, 'WAGTAIL_CONTENT_LANGUAGES', None)
languages = dict(settings.LANGUAGES)
if content_languages is None:
# Default to a single lan... | [
"def",
"get_content_languages",
"(",
")",
":",
"content_languages",
"=",
"getattr",
"(",
"settings",
",",
"'WAGTAIL_CONTENT_LANGUAGES'",
",",
"None",
")",
"languages",
"=",
"dict",
"(",
"settings",
".",
"LANGUAGES",
")",
"if",
"content_languages",
"is",
"None",
... | [
212,
0
] | [
249,
34
] | python | en | ['en', 'error', 'th'] | False |
get_supported_content_language_variant | (lang_code, strict=False) |
Return the language code that's listed in supported languages, possibly
selecting a more generic variant. Raise LookupError if nothing is found.
If `strict` is False (the default), look for a country-specific variant
when neither the language code nor its generic variant is found.
lru_cache should ... |
Return the language code that's listed in supported languages, possibly
selecting a more generic variant. Raise LookupError if nothing is found.
If `strict` is False (the default), look for a country-specific variant
when neither the language code nor its generic variant is found.
lru_cache should ... | def get_supported_content_language_variant(lang_code, strict=False):
"""
Return the language code that's listed in supported languages, possibly
selecting a more generic variant. Raise LookupError if nothing is found.
If `strict` is False (the default), look for a country-specific variant
when neith... | [
"def",
"get_supported_content_language_variant",
"(",
"lang_code",
",",
"strict",
"=",
"False",
")",
":",
"if",
"lang_code",
":",
"# If 'fr-ca' is not supported, try special fallback or language-only 'fr'.",
"possible_lang_codes",
"=",
"[",
"lang_code",
"]",
"try",
":",
"po... | [
253,
0
] | [
285,
32
] | python | en | ['en', 'error', 'th'] | False |
reset_cache | (**kwargs) |
Clear cache when global WAGTAIL_CONTENT_LANGUAGES/LANGUAGES/LANGUAGE_CODE settings are changed
|
Clear cache when global WAGTAIL_CONTENT_LANGUAGES/LANGUAGES/LANGUAGE_CODE settings are changed
| def reset_cache(**kwargs):
"""
Clear cache when global WAGTAIL_CONTENT_LANGUAGES/LANGUAGES/LANGUAGE_CODE settings are changed
"""
if kwargs["setting"] in ("WAGTAIL_CONTENT_LANGUAGES", "LANGUAGES", "LANGUAGE_CODE"):
get_content_languages.cache_clear()
get_supported_content_language_varian... | [
"def",
"reset_cache",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
"[",
"\"setting\"",
"]",
"in",
"(",
"\"WAGTAIL_CONTENT_LANGUAGES\"",
",",
"\"LANGUAGES\"",
",",
"\"LANGUAGE_CODE\"",
")",
":",
"get_content_languages",
".",
"cache_clear",
"(",
")",
"get_su... | [
289,
0
] | [
295,
60
] | python | en | ['en', 'error', 'th'] | False |
multigetattr | (item, accessor) |
Like getattr, but accepts a dotted path as the accessor to be followed to any depth.
At each step, the lookup on the object can be a dictionary lookup (foo['bar']) or an attribute
lookup (foo.bar), and if it results in a callable, will be called (provided we can do so with
no arguments, and it does not... |
Like getattr, but accepts a dotted path as the accessor to be followed to any depth.
At each step, the lookup on the object can be a dictionary lookup (foo['bar']) or an attribute
lookup (foo.bar), and if it results in a callable, will be called (provided we can do so with
no arguments, and it does not... | def multigetattr(item, accessor):
"""
Like getattr, but accepts a dotted path as the accessor to be followed to any depth.
At each step, the lookup on the object can be a dictionary lookup (foo['bar']) or an attribute
lookup (foo.bar), and if it results in a callable, will be called (provided we can do ... | [
"def",
"multigetattr",
"(",
"item",
",",
"accessor",
")",
":",
"current",
"=",
"item",
"for",
"bit",
"in",
"accessor",
".",
"split",
"(",
"'.'",
")",
":",
"try",
":",
"# dictionary lookup",
"current",
"=",
"current",
"[",
"bit",
"]",
"# ValueError/IndexErr... | [
298,
0
] | [
344,
18
] | python | en | ['en', 'error', 'th'] | False |
convertToDisjointRanges | (nestedRanges: List[Any] # noqa: C901
) | Convert ranges. | Convert ranges. | def convertToDisjointRanges(nestedRanges: List[Any] # noqa: C901
) -> List[Any]:
"""Convert ranges."""
points: List = []
for nested_range in nestedRanges:
points.append({'offset': nested_range['startOffset'], 'type': 0,
'range': nested_range})
... | [
"def",
"convertToDisjointRanges",
"(",
"nestedRanges",
":",
"List",
"[",
"Any",
"]",
"# noqa: C901",
")",
"->",
"List",
"[",
"Any",
"]",
":",
"points",
":",
"List",
"=",
"[",
"]",
"for",
"nested_range",
"in",
"nestedRanges",
":",
"points",
".",
"append",
... | [
309,
0
] | [
356,
76
] | python | en | ['en', 'lb', 'en'] | False |
Coverage.startJSCoverage | (self, options: Dict = None, **kwargs: Any
) | Start JS coverage measurement.
Available options are:
* ``resetOnNavigation`` (bool): Whether to reset coverage on every
navigation. Defaults to ``True``.
* ``reportAnonymousScript`` (bool): Whether anonymous script generated
by the page should be reported. Defaults to ``Fa... | Start JS coverage measurement. | async def startJSCoverage(self, options: Dict = None, **kwargs: Any
) -> None:
"""Start JS coverage measurement.
Available options are:
* ``resetOnNavigation`` (bool): Whether to reset coverage on every
navigation. Defaults to ``True``.
* ``repor... | [
"async",
"def",
"startJSCoverage",
"(",
"self",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"await",
"self",
".",
"_jsCoverage"... | [
52,
4
] | [
71,
45
] | python | en | ['en', 'da', 'en'] | True |
Coverage.stopJSCoverage | (self) | Stop JS coverage measurement and get result.
Return list of coverage reports for all scripts. Each report includes:
* ``url`` (str): Script url.
* ``text`` (str): Script content.
* ``ranges`` (List[Dict]): Script ranges that were executed. Ranges are
sorted and non-overlappin... | Stop JS coverage measurement and get result. | async def stopJSCoverage(self) -> List:
"""Stop JS coverage measurement and get result.
Return list of coverage reports for all scripts. Each report includes:
* ``url`` (str): Script url.
* ``text`` (str): Script content.
* ``ranges`` (List[Dict]): Script ranges that were execu... | [
"async",
"def",
"stopJSCoverage",
"(",
"self",
")",
"->",
"List",
":",
"return",
"await",
"self",
".",
"_jsCoverage",
".",
"stop",
"(",
")"
] | [
73,
4
] | [
90,
44
] | python | en | ['en', 'en', 'en'] | True |
Coverage.startCSSCoverage | (self, options: Dict = None, **kwargs: Any
) | Start CSS coverage measurement.
Available options are:
* ``resetOnNavigation`` (bool): Whether to reset coverage on every
navigation. Defaults to ``True``.
| Start CSS coverage measurement. | async def startCSSCoverage(self, options: Dict = None, **kwargs: Any
) -> None:
"""Start CSS coverage measurement.
Available options are:
* ``resetOnNavigation`` (bool): Whether to reset coverage on every
navigation. Defaults to ``True``.
"""
... | [
"async",
"def",
"startCSSCoverage",
"(",
"self",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"await",
"self",
".",
"_cssCoverag... | [
92,
4
] | [
102,
46
] | python | en | ['en', 'en', 'en'] | True |
Coverage.stopCSSCoverage | (self) | Stop CSS coverage measurement and get result.
Return list of coverage reports for all non-anonymous scripts. Each
report includes:
* ``url`` (str): StyleSheet url.
* ``text`` (str): StyleSheet content.
* ``ranges`` (List[Dict]): StyleSheet ranges that were executed. Ranges
... | Stop CSS coverage measurement and get result. | async def stopCSSCoverage(self) -> List:
"""Stop CSS coverage measurement and get result.
Return list of coverage reports for all non-anonymous scripts. Each
report includes:
* ``url`` (str): StyleSheet url.
* ``text`` (str): StyleSheet content.
* ``ranges`` (List[Dict]... | [
"async",
"def",
"stopCSSCoverage",
"(",
"self",
")",
"->",
"List",
":",
"return",
"await",
"self",
".",
"_cssCoverage",
".",
"stop",
"(",
")"
] | [
104,
4
] | [
122,
45
] | python | en | ['en', 'en', 'en'] | True |
JSCoverage.start | (self, options: Dict = None, **kwargs: Any) | Start coverage measurement. | Start coverage measurement. | async def start(self, options: Dict = None, **kwargs: Any) -> None:
"""Start coverage measurement."""
options = merge_dict(options, kwargs)
if self._enabled:
raise PageError('JSCoverage is always enabled.')
self._resetOnNavigation = (True if 'resetOnNavigation' not in options... | [
"async",
"def",
"start",
"(",
"self",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"if",
"self",
".",
"_enabled",
":",
"rais... | [
136,
4
] | [
160,
76
] | python | en | ['en', 'it', 'en'] | True |
JSCoverage.stop | (self) | Stop coverage measurement and return results. | Stop coverage measurement and return results. | async def stop(self) -> List:
"""Stop coverage measurement and return results."""
if not self._enabled:
raise PageError('JSCoverage is not enabled.')
self._enabled = False
result = await self._client.send('Profiler.takePreciseCoverage')
await self._client.send('Profi... | [
"async",
"def",
"stop",
"(",
"self",
")",
"->",
"List",
":",
"if",
"not",
"self",
".",
"_enabled",
":",
"raise",
"PageError",
"(",
"'JSCoverage is not enabled.'",
")",
"self",
".",
"_enabled",
"=",
"False",
"result",
"=",
"await",
"self",
".",
"_client",
... | [
192,
4
] | [
215,
23
] | python | en | ['en', 'en', 'en'] | True |
CSSCoverage.start | (self, options: Dict = None, **kwargs: Any) | Start coverage measurement. | Start coverage measurement. | async def start(self, options: Dict = None, **kwargs: Any) -> None:
"""Start coverage measurement."""
options = merge_dict(options, kwargs)
if self._enabled:
raise PageError('CSSCoverage is already enabled.')
self._resetOnNavigation = (True if 'resetOnNavigation' not in optio... | [
"async",
"def",
"start",
"(",
"self",
",",
"options",
":",
"Dict",
"=",
"None",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"None",
":",
"options",
"=",
"merge_dict",
"(",
"options",
",",
"kwargs",
")",
"if",
"self",
".",
"_enabled",
":",
"rais... | [
229,
4
] | [
250,
61
] | python | en | ['en', 'it', 'en'] | True |
CSSCoverage.stop | (self) | Stop coverage measurement and return results. | Stop coverage measurement and return results. | async def stop(self) -> List:
"""Stop coverage measurement and return results."""
if not self._enabled:
raise PageError('CSSCoverage is not enabled.')
self._enabled = False
result = await self._client.send('CSS.stopRuleUsageTracking')
await self._client.send('CSS.disa... | [
"async",
"def",
"stop",
"(",
"self",
")",
"->",
"List",
":",
"if",
"not",
"self",
".",
"_enabled",
":",
"raise",
"PageError",
"(",
"'CSSCoverage is not enabled.'",
")",
"self",
".",
"_enabled",
"=",
"False",
"result",
"=",
"await",
"self",
".",
"_client",
... | [
274,
4
] | [
306,
23
] | python | en | ['en', 'en', 'en'] | True |
undersampled | (semibmaj, semibmin) |
We want more than 2 pixels across the beam major and minor axes.
:param Semibmaj/semibmin: describe the beam size in pixels
:returns: True if beam is undersampled, False otherwise
|
We want more than 2 pixels across the beam major and minor axes. | def undersampled(semibmaj, semibmin):
"""
We want more than 2 pixels across the beam major and minor axes.
:param Semibmaj/semibmin: describe the beam size in pixels
:returns: True if beam is undersampled, False otherwise
"""
return semibmaj * 2 <= 1 or semibmin * 2 <= 1 | [
"def",
"undersampled",
"(",
"semibmaj",
",",
"semibmin",
")",
":",
"return",
"semibmaj",
"*",
"2",
"<=",
"1",
"or",
"semibmin",
"*",
"2",
"<=",
"1"
] | [
5,
0
] | [
12,
49
] | python | en | ['en', 'error', 'th'] | False |
oversampled | (semibmaj, semibmin, x=30) |
It has been identified that having too many pixels across the restoring
beam can lead to bad images, however further testing is required to
determine the exact number.
:param Semibmaj/semibmin: describe the beam size in pixels
:returns: True if beam is oversampled, False otherwise
|
It has been identified that having too many pixels across the restoring
beam can lead to bad images, however further testing is required to
determine the exact number. | def oversampled(semibmaj, semibmin, x=30):
"""
It has been identified that having too many pixels across the restoring
beam can lead to bad images, however further testing is required to
determine the exact number.
:param Semibmaj/semibmin: describe the beam size in pixels
:returns: True if bea... | [
"def",
"oversampled",
"(",
"semibmaj",
",",
"semibmin",
",",
"x",
"=",
"30",
")",
":",
"return",
"semibmaj",
">",
"x",
"or",
"semibmin",
">",
"x"
] | [
15,
0
] | [
24,
39
] | python | en | ['en', 'error', 'th'] | False |
highly_elliptical | (semibmaj, semibmin, x=2.0) |
If the beam is highly elliptical it can cause source association
problems within TraP. Again further testing is required to determine
exactly where the cut needs to be.
:param Semibmaj/semibmin: describe the beam size in pixels
:returns: True if the beam is highly elliptical, False otherwise
|
If the beam is highly elliptical it can cause source association
problems within TraP. Again further testing is required to determine
exactly where the cut needs to be. | def highly_elliptical(semibmaj, semibmin, x=2.0):
"""
If the beam is highly elliptical it can cause source association
problems within TraP. Again further testing is required to determine
exactly where the cut needs to be.
:param Semibmaj/semibmin: describe the beam size in pixels
:returns: Tru... | [
"def",
"highly_elliptical",
"(",
"semibmaj",
",",
"semibmin",
",",
"x",
"=",
"2.0",
")",
":",
"return",
"semibmaj",
"/",
"semibmin",
">",
"x"
] | [
27,
0
] | [
36,
34
] | python | en | ['en', 'error', 'th'] | False |
not_full_fieldofview | (nx, ny, cellsize, fov) |
This has been raised as an interesting test, as if the full field of
view (FOV) has not been imaged we may want to image the full dataset.
The imaged FOV information can be estimated using the number of pixels
and the size of the pixels.
:param nx: number of pixels in x direction
:param ny: nu... |
This has been raised as an interesting test, as if the full field of
view (FOV) has not been imaged we may want to image the full dataset.
The imaged FOV information can be estimated using the number of pixels
and the size of the pixels. | def not_full_fieldofview(nx, ny, cellsize, fov):
"""
This has been raised as an interesting test, as if the full field of
view (FOV) has not been imaged we may want to image the full dataset.
The imaged FOV information can be estimated using the number of pixels
and the size of the pixels.
:par... | [
"def",
"not_full_fieldofview",
"(",
"nx",
",",
"ny",
",",
"cellsize",
",",
"fov",
")",
":",
"return",
"nx",
"*",
"ny",
"*",
"(",
"cellsize",
"/",
"3600",
")",
"*",
"(",
"cellsize",
"/",
"3600",
")",
"<",
"fov"
] | [
39,
0
] | [
50,
60
] | python | en | ['en', 'error', 'th'] | False |
infinite | (smaj, smin, bpa) |
If the beam is not correctly fitted by AWimager, one or more parameters
will be recorded as infinite.
:param smaj: Semi-major axis (arbitrary units)
:param smin: Semi-minor axis
:param bpa: Postion angle
|
If the beam is not correctly fitted by AWimager, one or more parameters
will be recorded as infinite. | def infinite(smaj, smin, bpa):
"""
If the beam is not correctly fitted by AWimager, one or more parameters
will be recorded as infinite.
:param smaj: Semi-major axis (arbitrary units)
:param smin: Semi-minor axis
:param bpa: Postion angle
"""
return smaj == float('inf') or smin == float... | [
"def",
"infinite",
"(",
"smaj",
",",
"smin",
",",
"bpa",
")",
":",
"return",
"smaj",
"==",
"float",
"(",
"'inf'",
")",
"or",
"smin",
"==",
"float",
"(",
"'inf'",
")",
"or",
"bpa",
"==",
"float",
"(",
"'inf'",
")"
] | [
53,
0
] | [
62,
78
] | python | en | ['en', 'error', 'th'] | False |
beam_invalid | (semibmaj, semibmin, theta, oversampled_x=30, elliptical_x=2.0) | Are the beam shape properties ok?
:param semibmaj/semibmin: size of the beam in pixels
:returns: True/False
| Are the beam shape properties ok? | def beam_invalid(semibmaj, semibmin, theta, oversampled_x=30, elliptical_x=2.0):
""" Are the beam shape properties ok?
:param semibmaj/semibmin: size of the beam in pixels
:returns: True/False
"""
formatted = "bmaj=%s and bmin=%s (pixels)" % (nice_format(semibmaj),
... | [
"def",
"beam_invalid",
"(",
"semibmaj",
",",
"semibmin",
",",
"theta",
",",
"oversampled_x",
"=",
"30",
",",
"elliptical_x",
"=",
"2.0",
")",
":",
"formatted",
"=",
"\"bmaj=%s and bmin=%s (pixels)\"",
"%",
"(",
"nice_format",
"(",
"semibmaj",
")",
",",
"nice_f... | [
65,
0
] | [
91,
20
] | python | en | ['en', 'en', 'en'] | True |
RLWallet.get_keys | (self, puzzle_hash: bytes32) |
Returns keys for puzzle_hash.
|
Returns keys for puzzle_hash.
| async def get_keys(self, puzzle_hash: bytes32) -> Tuple[G1Element, PrivateKey]:
"""
Returns keys for puzzle_hash.
"""
index_for_puzzlehash = await self.wallet_state_manager.puzzle_store.index_for_puzzle_hash_and_wallet(
puzzle_hash, self.id()
)
if index_for_pu... | [
"async",
"def",
"get_keys",
"(",
"self",
",",
"puzzle_hash",
":",
"bytes32",
")",
"->",
"Tuple",
"[",
"G1Element",
",",
"PrivateKey",
"]",
":",
"index_for_puzzlehash",
"=",
"await",
"self",
".",
"wallet_state_manager",
".",
"puzzle_store",
".",
"index_for_puzzle... | [
417,
4
] | [
428,
30
] | python | en | ['en', 'error', 'th'] | False |
RLWallet.get_keys_pk | (self, clawback_pubkey: bytes) |
Return keys for pubkey
|
Return keys for pubkey
| async def get_keys_pk(self, clawback_pubkey: bytes):
"""
Return keys for pubkey
"""
index_for_pubkey = await self.wallet_state_manager.puzzle_store.index_for_pubkey(
G1Element.from_bytes(clawback_pubkey)
)
if index_for_pubkey is None:
raise ValueEr... | [
"async",
"def",
"get_keys_pk",
"(",
"self",
",",
"clawback_pubkey",
":",
"bytes",
")",
":",
"index_for_pubkey",
"=",
"await",
"self",
".",
"wallet_state_manager",
".",
"puzzle_store",
".",
"index_for_pubkey",
"(",
"G1Element",
".",
"from_bytes",
"(",
"clawback_pub... | [
430,
4
] | [
442,
30
] | python | en | ['en', 'error', 'th'] | False |
RLWallet.push_transaction | (self, tx: TransactionRecord) | Use this API to send transactions. | Use this API to send transactions. | async def push_transaction(self, tx: TransactionRecord) -> None:
""" Use this API to send transactions. """
await self.wallet_state_manager.add_pending_transaction(tx) | [
"async",
"def",
"push_transaction",
"(",
"self",
",",
"tx",
":",
"TransactionRecord",
")",
"->",
"None",
":",
"await",
"self",
".",
"wallet_state_manager",
".",
"add_pending_transaction",
"(",
"tx",
")"
] | [
689,
4
] | [
691,
67
] | python | en | ['en', 'en', 'en'] | True |
FreshdeskHookTests.test_ticket_creation | (self) |
Messages are generated on ticket creation through Freshdesk's
"Dispatch'r" service.
|
Messages are generated on ticket creation through Freshdesk's
"Dispatch'r" service.
| def test_ticket_creation(self) -> None:
"""
Messages are generated on ticket creation through Freshdesk's
"Dispatch'r" service.
"""
expected_topic = "#11: Test ticket subject ☃"
expected_message = """
Requester ☃ Bob <requester-bob@example.com> created [ticket #11](http:/... | [
"def",
"test_ticket_creation",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"#11: Test ticket subject ☃\"",
"expected_message",
"=",
"\"\"\"\nRequester ☃ Bob <requester-bob@example.com> created [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11):\n\n``` quot... | [
10,
4
] | [
34,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshdeskHookTests.test_status_change | (self) |
Messages are generated when a ticket's status changes through
Freshdesk's "Observer" service.
|
Messages are generated when a ticket's status changes through
Freshdesk's "Observer" service.
| def test_status_change(self) -> None:
"""
Messages are generated when a ticket's status changes through
Freshdesk's "Observer" service.
"""
expected_topic = "#11: Test ticket subject ☃"
expected_message = """
Requester Bob <requester-bob@example.com> updated [ticket #11](... | [
"def",
"test_status_change",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"#11: Test ticket subject ☃\"",
"expected_message",
"=",
"\"\"\"\nRequester Bob <requester-bob@example.com> updated [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11):\n\n* **Status**... | [
36,
4
] | [
54,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshdeskHookTests.test_priority_change | (self) |
Messages are generated when a ticket's priority changes through
Freshdesk's "Observer" service.
|
Messages are generated when a ticket's priority changes through
Freshdesk's "Observer" service.
| def test_priority_change(self) -> None:
"""
Messages are generated when a ticket's priority changes through
Freshdesk's "Observer" service.
"""
expected_topic = "#11: Test ticket subject"
expected_message = """
Requester Bob <requester-bob@example.com> updated [ticket #11... | [
"def",
"test_priority_change",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"#11: Test ticket subject\"",
"expected_message",
"=",
"\"\"\"\nRequester Bob <requester-bob@example.com> updated [ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11):\n\n* **Priority... | [
56,
4
] | [
73,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshdeskHookTests.test_unknown_event_payload_ignore | (self, check_send_webhook_message_mock: MagicMock) |
Ignore unknown event payloads.
|
Ignore unknown event payloads.
| def test_unknown_event_payload_ignore(self, check_send_webhook_message_mock: MagicMock) -> None:
"""
Ignore unknown event payloads.
"""
self.url = self.build_webhook_url()
payload = self.get_body("unknown_payload")
kwargs = {
"HTTP_AUTHORIZATION": self.encode_... | [
"def",
"test_unknown_event_payload_ignore",
"(",
"self",
",",
"check_send_webhook_message_mock",
":",
"MagicMock",
")",
"->",
"None",
":",
"self",
".",
"url",
"=",
"self",
".",
"build_webhook_url",
"(",
")",
"payload",
"=",
"self",
".",
"get_body",
"(",
"\"unkno... | [
76,
4
] | [
88,
40
] | python | en | ['en', 'error', 'th'] | False |
FreshdeskHookTests.note_change | (self, fixture: str, note_type: str) |
Messages are generated when a note gets added to a ticket through
Freshdesk's "Observer" service.
|
Messages are generated when a note gets added to a ticket through
Freshdesk's "Observer" service.
| def note_change(self, fixture: str, note_type: str) -> None:
"""
Messages are generated when a note gets added to a ticket through
Freshdesk's "Observer" service.
"""
expected_topic = "#11: Test ticket subject"
expected_message = """
Requester Bob <requester-bob@example.c... | [
"def",
"note_change",
"(",
"self",
",",
"fixture",
":",
"str",
",",
"note_type",
":",
"str",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"#11: Test ticket subject\"",
"expected_message",
"=",
"\"\"\"\nRequester Bob <requester-bob@example.com> added a {} note to \\\n[ti... | [
90,
4
] | [
108,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshdeskHookTests.test_inline_image | (self) |
Freshdesk sends us descriptions as HTML, so we have to make the
descriptions Zulip Markdown-friendly while still doing our best to
preserve links and images.
|
Freshdesk sends us descriptions as HTML, so we have to make the
descriptions Zulip Markdown-friendly while still doing our best to
preserve links and images.
| def test_inline_image(self) -> None:
"""
Freshdesk sends us descriptions as HTML, so we have to make the
descriptions Zulip Markdown-friendly while still doing our best to
preserve links and images.
"""
expected_topic = "#12: Not enough ☃ guinea pigs"
expected_mes... | [
"def",
"test_inline_image",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"#12: Not enough ☃ guinea pigs\"",
"expected_message",
"=",
"\"\"\"\nRequester \\u2603 Bob <requester-bob@example.com> created [ticket #12](http://test1234zzz.freshdesk.com/helpdesk/tickets/12):\\n\\n... | [
116,
4
] | [
132,
9
] | python | en | ['en', 'error', 'th'] | False |
is_canarytoken | (message: Dict[str, Any]) |
Requests sent from Thinkst canaries are either from canarytokens or
canaries, which can be differentiated by the value of the `AlertType`
field.
|
Requests sent from Thinkst canaries are either from canarytokens or
canaries, which can be differentiated by the value of the `AlertType`
field.
| def is_canarytoken(message: Dict[str, Any]) -> bool:
"""
Requests sent from Thinkst canaries are either from canarytokens or
canaries, which can be differentiated by the value of the `AlertType`
field.
"""
return message["AlertType"] == "CanarytokenIncident" | [
"def",
"is_canarytoken",
"(",
"message",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"return",
"message",
"[",
"\"AlertType\"",
"]",
"==",
"\"CanarytokenIncident\""
] | [
12,
0
] | [
18,
56
] | python | en | ['en', 'error', 'th'] | False |
canary_name | (message: Dict[str, Any]) |
Returns the name of the canary or canarytoken.
|
Returns the name of the canary or canarytoken.
| def canary_name(message: Dict[str, Any]) -> str:
"""
Returns the name of the canary or canarytoken.
"""
if is_canarytoken(message):
return message["Reminder"]
else:
return message["CanaryName"] | [
"def",
"canary_name",
"(",
"message",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"str",
":",
"if",
"is_canarytoken",
"(",
"message",
")",
":",
"return",
"message",
"[",
"\"Reminder\"",
"]",
"else",
":",
"return",
"message",
"[",
"\"CanaryName\"... | [
21,
0
] | [
28,
36
] | python | en | ['en', 'error', 'th'] | False |
canary_kind | (message: Dict[str, Any]) |
Returns a description of the kind of request - canary or canarytoken.
|
Returns a description of the kind of request - canary or canarytoken.
| def canary_kind(message: Dict[str, Any]) -> str:
"""
Returns a description of the kind of request - canary or canarytoken.
"""
if is_canarytoken(message):
return "canarytoken"
else:
return "canary" | [
"def",
"canary_kind",
"(",
"message",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"str",
":",
"if",
"is_canarytoken",
"(",
"message",
")",
":",
"return",
"\"canarytoken\"",
"else",
":",
"return",
"\"canary\""
] | [
31,
0
] | [
38,
23
] | python | en | ['en', 'error', 'th'] | False |
source_ip_and_reverse_dns | (message: Dict[str, Any]) |
Extract the source IP and reverse DNS information from a canary request.
|
Extract the source IP and reverse DNS information from a canary request.
| def source_ip_and_reverse_dns(message: Dict[str, Any]) -> Tuple[Optional[str], Optional[str]]:
"""
Extract the source IP and reverse DNS information from a canary request.
"""
reverse_dns, source_ip = (None, None)
if "SourceIP" in message:
source_ip = message["SourceIP"]
# `ReverseDNS` ... | [
"def",
"source_ip_and_reverse_dns",
"(",
"message",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"str",
"]",
",",
"Optional",
"[",
"str",
"]",
"]",
":",
"reverse_dns",
",",
"source_ip",
"=",
"(",
"None",
",",
"N... | [
41,
0
] | [
53,
35
] | python | en | ['en', 'error', 'th'] | False |
body | (message: Dict[str, Any]) |
Construct the response to a canary or canarytoken request.
|
Construct the response to a canary or canarytoken request.
| def body(message: Dict[str, Any]) -> str:
"""
Construct the response to a canary or canarytoken request.
"""
title = canary_kind(message).title()
name = canary_name(message)
body = f"**:alert: {title} *{name}* has been triggered!**\n\n{message['Intro']}\n\n"
if "IncidentHash" in message:
... | [
"def",
"body",
"(",
"message",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"str",
":",
"title",
"=",
"canary_kind",
"(",
"message",
")",
".",
"title",
"(",
")",
"name",
"=",
"canary_name",
"(",
"message",
")",
"body",
"=",
"f\"**:alert: {tit... | [
56,
0
] | [
102,
15
] | python | en | ['en', 'error', 'th'] | False |
api_thinkst_webhook | (
request: HttpRequest,
user_profile: UserProfile,
message: Dict[str, Any] = REQ(argument_type="body"),
user_specified_topic: Optional[str] = REQ("topic", default=None),
) |
Construct a response to a webhook event from a Thinkst canary or canarytoken.
Thinkst offers public canarytokens with canarytokens.org and with their canary
product, but the schema returned by these identically named services are
completely different - canarytokens from canarytokens.org are handled by... |
Construct a response to a webhook event from a Thinkst canary or canarytoken. | def api_thinkst_webhook(
request: HttpRequest,
user_profile: UserProfile,
message: Dict[str, Any] = REQ(argument_type="body"),
user_specified_topic: Optional[str] = REQ("topic", default=None),
) -> HttpResponse:
"""
Construct a response to a webhook event from a Thinkst canary or canarytoken.
... | [
"def",
"api_thinkst_webhook",
"(",
"request",
":",
"HttpRequest",
",",
"user_profile",
":",
"UserProfile",
",",
"message",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
"REQ",
"(",
"argument_type",
"=",
"\"body\"",
")",
",",
"user_specified_topic",
":",
"Op... | [
107,
0
] | [
139,
25
] | python | en | ['en', 'error', 'th'] | False |
gen_lightcurve | (band, dataset, skyregion, datapoints=10) |
returns: a list of created SQLAlchemy objects
|
returns: a list of created SQLAlchemy objects
| def gen_lightcurve(band, dataset, skyregion, datapoints=10):
"""
returns: a list of created SQLAlchemy objects
"""
start = datetime.fromtimestamp(0)
ten_sec = timedelta(seconds=10)
xtrsrcs = []
images = []
assocs = []
for i in range(datapoints):
taustart_ts = start + ten_sec ... | [
"def",
"gen_lightcurve",
"(",
"band",
",",
"dataset",
",",
"skyregion",
",",
"datapoints",
"=",
"10",
")",
":",
"start",
"=",
"datetime",
".",
"fromtimestamp",
"(",
"0",
")",
"ten_sec",
"=",
"timedelta",
"(",
"seconds",
"=",
"10",
")",
"xtrsrcs",
"=",
... | [
68,
0
] | [
99,
36
] | python | en | ['en', 'error', 'th'] | False |
PushBouncerNotificationTest.test_push_bouncer_api | (self) | This is a variant of the below test_push_api, but using the full
push notification bouncer flow
| This is a variant of the below test_push_api, but using the full
push notification bouncer flow
| def test_push_bouncer_api(self) -> None:
"""This is a variant of the below test_push_api, but using the full
push notification bouncer flow
"""
self.add_mock_response()
user = self.example_user("cordelia")
self.login_user(user)
server = RemoteZulipServer.objects.g... | [
"def",
"test_push_bouncer_api",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"add_mock_response",
"(",
")",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"cordelia\"",
")",
"self",
".",
"login_user",
"(",
"user",
")",
"server",
"=",
"RemoteZulipServe... | [
308,
4
] | [
423,
37
] | python | en | ['en', 'en', 'en'] | True |
AnalyticsBouncerTest.test_analytics_api | (self) | This is a variant of the below test_push_api, but using the full
push notification bouncer flow
| This is a variant of the below test_push_api, but using the full
push notification bouncer flow
| def test_analytics_api(self) -> None:
"""This is a variant of the below test_push_api, but using the full
push notification bouncer flow
"""
ANALYTICS_URL = settings.PUSH_NOTIFICATION_BOUNCER_URL + "/api/v1/remotes/server/analytics"
ANALYTICS_STATUS_URL = ANALYTICS_URL + "/status... | [
"def",
"test_analytics_api",
"(",
"self",
")",
"->",
"None",
":",
"ANALYTICS_URL",
"=",
"settings",
".",
"PUSH_NOTIFICATION_BOUNCER_URL",
"+",
"\"/api/v1/remotes/server/analytics\"",
"ANALYTICS_STATUS_URL",
"=",
"ANALYTICS_URL",
"+",
"\"/status\"",
"user",
"=",
"self",
... | [
431,
4
] | [
603,
13
] | python | en | ['en', 'en', 'en'] | True |
AnalyticsBouncerTest.test_analytics_api_invalid | (self) | This is a variant of the below test_push_api, but using the full
push notification bouncer flow
| This is a variant of the below test_push_api, but using the full
push notification bouncer flow
| def test_analytics_api_invalid(self) -> None:
"""This is a variant of the below test_push_api, but using the full
push notification bouncer flow
"""
self.add_mock_response()
user = self.example_user("hamlet")
end_time = self.TIME_ZERO
realm_stat = LoggingCountSta... | [
"def",
"test_analytics_api_invalid",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"add_mock_response",
"(",
")",
"user",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"end_time",
"=",
"self",
".",
"TIME_ZERO",
"realm_stat",
"=",
"LoggingCountS... | [
607,
4
] | [
626,
61
] | python | en | ['en', 'en', 'en'] | True |
HandlePushNotificationTest.test_deleted_message | (self) | Simulates the race where message is deleted before handlingx push notifications | Simulates the race where message is deleted before handlingx push notifications | def test_deleted_message(self) -> None:
"""Simulates the race where message is deleted before handlingx push notifications"""
user_profile = self.example_user("hamlet")
message = self.get_message(Recipient.PERSONAL, type_id=1)
UserMessage.objects.create(
user_profile=user_pro... | [
"def",
"test_deleted_message",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"message",
"=",
"self",
".",
"get_message",
"(",
"Recipient",
".",
"PERSONAL",
",",
"type_id",
"=",
"1",
")",
"Use... | [
970,
4
] | [
997,
50
] | python | en | ['en', 'en', 'en'] | True |
HandlePushNotificationTest.test_missing_message | (self) | Simulates the race where message is missing when handling push notifications | Simulates the race where message is missing when handling push notifications | def test_missing_message(self) -> None:
"""Simulates the race where message is missing when handling push notifications"""
user_profile = self.example_user("hamlet")
message = self.get_message(Recipient.PERSONAL, type_id=1)
UserMessage.objects.create(
user_profile=user_profil... | [
"def",
"test_missing_message",
"(",
"self",
")",
"->",
"None",
":",
"user_profile",
"=",
"self",
".",
"example_user",
"(",
"\"hamlet\"",
")",
"message",
"=",
"self",
".",
"get_message",
"(",
"Recipient",
".",
"PERSONAL",
",",
"type_id",
"=",
"1",
")",
"Use... | [
999,
4
] | [
1030,
13
] | python | en | ['en', 'en', 'en'] | True |
HandlePushNotificationTest.test_user_message_does_not_exist | (self) | This simulates a condition that should only be an error if the user is
not long-term idle; we fake it, though, in the sense that the user should
not have received the message in the first place | This simulates a condition that should only be an error if the user is
not long-term idle; we fake it, though, in the sense that the user should
not have received the message in the first place | def test_user_message_does_not_exist(self) -> None:
"""This simulates a condition that should only be an error if the user is
not long-term idle; we fake it, though, in the sense that the user should
not have received the message in the first place"""
self.make_stream("public_stream")
... | [
"def",
"test_user_message_does_not_exist",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"make_stream",
"(",
"\"public_stream\"",
")",
"sender",
"=",
"self",
".",
"example_user",
"(",
"\"iago\"",
")",
"message_id",
"=",
"self",
".",
"send_stream_message",
"(... | [
1198,
4
] | [
1216,
56
] | python | en | ['en', 'en', 'en'] | True |
HandlePushNotificationTest.test_user_message_soft_deactivated | (self) | This simulates a condition that should only be an error if the user is
not long-term idle; we fake it, though, in the sense that the user should
not have received the message in the first place | This simulates a condition that should only be an error if the user is
not long-term idle; we fake it, though, in the sense that the user should
not have received the message in the first place | def test_user_message_soft_deactivated(self) -> None:
"""This simulates a condition that should only be an error if the user is
not long-term idle; we fake it, though, in the sense that the user should
not have received the message in the first place"""
self.setup_apns_tokens()
s... | [
"def",
"test_user_message_soft_deactivated",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"setup_apns_tokens",
"(",
")",
"self",
".",
"setup_gcm_tokens",
"(",
")",
"self",
".",
"make_stream",
"(",
"\"public_stream\"",
")",
"self",
".",
"subscribe",
"(",
"... | [
1218,
4
] | [
1269,
56
] | python | en | ['en', 'en', 'en'] | True |
TestAPNs.test_get_apns_client | (self) | This test is pretty hacky, and needs to carefully reset the state
it modifies in order to avoid leaking state that can lead to
nondeterministic results for other tests.
| This test is pretty hacky, and needs to carefully reset the state
it modifies in order to avoid leaking state that can lead to
nondeterministic results for other tests.
| def test_get_apns_client(self) -> None:
"""This test is pretty hacky, and needs to carefully reset the state
it modifies in order to avoid leaking state that can lead to
nondeterministic results for other tests.
"""
import zerver.lib.push_notifications
zerver.lib.push_no... | [
"def",
"test_get_apns_client",
"(",
"self",
")",
"->",
"None",
":",
"import",
"zerver",
".",
"lib",
".",
"push_notifications",
"zerver",
".",
"lib",
".",
"push_notifications",
".",
"_apns_client_initialized",
"=",
"False",
"try",
":",
"with",
"self",
".",
"set... | [
1307,
4
] | [
1325,
61
] | python | en | ['en', 'en', 'en'] | True |
fix_reference_dec | (imagename) |
If the FITS file specified has a reference dec of 90 (or pi/2), make it
infinitesimally less. This works around problems with ill-defined
coordinate systems at the north celestial pole.
|
If the FITS file specified has a reference dec of 90 (or pi/2), make it
infinitesimally less. This works around problems with ill-defined
coordinate systems at the north celestial pole.
| def fix_reference_dec(imagename):
"""
If the FITS file specified has a reference dec of 90 (or pi/2), make it
infinitesimally less. This works around problems with ill-defined
coordinate systems at the north celestial pole.
"""
# TINY is an arbitrary constant which we regard as "far enough" away... | [
"def",
"fix_reference_dec",
"(",
"imagename",
")",
":",
"# TINY is an arbitrary constant which we regard as \"far enough\" away from",
"# dec 90 (or pi/2). In theory, we ought to be able to us",
"# sys.float_info.epsilon, but pyfits seems to round this when writing it",
"# to a FITS file so that i... | [
14,
0
] | [
37,
22
] | python | en | ['en', 'error', 'th'] | False |
convert | (casa_image, ms, fits_filename=None) | Convert a CASA image to FITS, taking care of header keywords
:argument casa_image: CASA image
:type casa_image: casacore.images.image
:argument ms: CASA measurement set
:type ms: casacore.tables.table
:keyword fits_filename: FITS output filename
:type fits_filename: str
:returns: None
... | Convert a CASA image to FITS, taking care of header keywords | def convert(casa_image, ms, fits_filename=None):
"""Convert a CASA image to FITS, taking care of header keywords
:argument casa_image: CASA image
:type casa_image: casacore.images.image
:argument ms: CASA measurement set
:type ms: casacore.tables.table
:keyword fits_filename: FITS output filen... | [
"def",
"convert",
"(",
"casa_image",
",",
"ms",
",",
"fits_filename",
"=",
"None",
")",
":",
"if",
"fits_filename",
"is",
"None",
":",
"fits_filename",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"casa_image",
")",
"[",
"0",
"]",
"+",
"\".fits\"",
"#... | [
40,
0
] | [
112,
19
] | python | en | ['en', 'en', 'en'] | True |
combine | (fitsfiles, outputfile, method="average") | Combine a set of FITS files, taking care of header keywords
:argument fitsfiles: FITS filenames to combine
:type fitsfiles: tuple
:argument outputfile: output FITS filename
:type outputfile: str
:keyword method: average or sum the images
:type method: str
:returns: None
| Combine a set of FITS files, taking care of header keywords | def combine(fitsfiles, outputfile, method="average"):
"""Combine a set of FITS files, taking care of header keywords
:argument fitsfiles: FITS filenames to combine
:type fitsfiles: tuple
:argument outputfile: output FITS filename
:type outputfile: str
:keyword method: average or sum the images... | [
"def",
"combine",
"(",
"fitsfiles",
",",
"outputfile",
",",
"method",
"=",
"\"average\"",
")",
":",
"if",
"method",
"is",
"None",
":",
"return",
"N",
"=",
"len",
"(",
"fitsfiles",
")",
"if",
"N",
"==",
"1",
":",
"shutil",
".",
"copyfile",
"(",
"fitsf... | [
115,
0
] | [
174,
20
] | python | en | ['en', 'en', 'en'] | True |
render_value_in_context | (value, context) |
Converts any value to a string to become part of a rendered template. This
means escaping, if required, and conversion to a unicode object. If value
is a string, it is expected to have already been translated.
|
Converts any value to a string to become part of a rendered template. This
means escaping, if required, and conversion to a unicode object. If value
is a string, it is expected to have already been translated.
| def render_value_in_context(value, context):
"""
Converts any value to a string to become part of a rendered template. This
means escaping, if required, and conversion to a unicode object. If value
is a string, it is expected to have already been translated.
"""
value = template_localtime(value,... | [
"def",
"render_value_in_context",
"(",
"value",
",",
"context",
")",
":",
"value",
"=",
"template_localtime",
"(",
"value",
",",
"use_tz",
"=",
"context",
".",
"use_tz",
")",
"value",
"=",
"localize",
"(",
"value",
",",
"use_l10n",
"=",
"context",
".",
"us... | [
1015,
0
] | [
1027,
20
] | python | en | ['en', 'error', 'th'] | False |
token_kwargs | (bits, parser, support_legacy=False) |
A utility method for parsing token keyword arguments.
:param bits: A list containing remainder of the token (split by spaces)
that is to be checked for arguments. Valid arguments will be removed
from this list.
:param support_legacy: If set to true ``True``, the legacy format
``1 ... |
A utility method for parsing token keyword arguments. | def token_kwargs(bits, parser, support_legacy=False):
"""
A utility method for parsing token keyword arguments.
:param bits: A list containing remainder of the token (split by spaces)
that is to be checked for arguments. Valid arguments will be removed
from this list.
:param support_le... | [
"def",
"token_kwargs",
"(",
"bits",
",",
"parser",
",",
"support_legacy",
"=",
"False",
")",
":",
"if",
"not",
"bits",
":",
"return",
"{",
"}",
"match",
"=",
"kwarg_re",
".",
"match",
"(",
"bits",
"[",
"0",
"]",
")",
"kwarg_format",
"=",
"match",
"an... | [
1052,
0
] | [
1099,
17
] | python | en | ['en', 'error', 'th'] | False |
Template.render | (self, context) | Display stage -- can be called many times | Display stage -- can be called many times | def render(self, context):
"Display stage -- can be called many times"
with context.render_context.push_state(self):
if context.template is None:
with context.bind_template(self):
context.template_name = self.name
return self._render(co... | [
"def",
"render",
"(",
"self",
",",
"context",
")",
":",
"with",
"context",
".",
"render_context",
".",
"push_state",
"(",
"self",
")",
":",
"if",
"context",
".",
"template",
"is",
"None",
":",
"with",
"context",
".",
"bind_template",
"(",
"self",
")",
... | [
200,
4
] | [
208,
44
] | python | en | ['en', 'en', 'en'] | True |
Template.compile_nodelist | (self) |
Parse and compile the template source into a nodelist. If debug
is True and an exception occurs during parsing, the exception is
is annotated with contextual line information where it occurred in the
template source.
|
Parse and compile the template source into a nodelist. If debug
is True and an exception occurs during parsing, the exception is
is annotated with contextual line information where it occurred in the
template source.
| def compile_nodelist(self):
"""
Parse and compile the template source into a nodelist. If debug
is True and an exception occurs during parsing, the exception is
is annotated with contextual line information where it occurred in the
template source.
"""
if self.eng... | [
"def",
"compile_nodelist",
"(",
"self",
")",
":",
"if",
"self",
".",
"engine",
".",
"debug",
":",
"lexer",
"=",
"DebugLexer",
"(",
"self",
".",
"source",
")",
"else",
":",
"lexer",
"=",
"Lexer",
"(",
"self",
".",
"source",
")",
"tokens",
"=",
"lexer"... | [
210,
4
] | [
233,
17
] | python | en | ['en', 'error', 'th'] | False |
Template.get_exception_info | (self, exception, token) |
Return a dictionary containing contextual line information of where
the exception occurred in the template. The following information is
provided:
message
The message of the exception raised.
source_lines
The lines before, after, and including the line ... |
Return a dictionary containing contextual line information of where
the exception occurred in the template. The following information is
provided: | def get_exception_info(self, exception, token):
"""
Return a dictionary containing contextual line information of where
the exception occurred in the template. The following information is
provided:
message
The message of the exception raised.
source_lines
... | [
"def",
"get_exception_info",
"(",
"self",
",",
"exception",
",",
"token",
")",
":",
"start",
",",
"end",
"=",
"token",
".",
"position",
"context_lines",
"=",
"10",
"line",
"=",
"0",
"upto",
"=",
"0",
"source_lines",
"=",
"[",
"]",
"before",
"=",
"durin... | [
235,
4
] | [
311,
9
] | python | en | ['en', 'error', 'th'] | False |
Token.__init__ | (self, token_type, contents, position=None, lineno=None) |
A token representing a string from the template.
token_type
One of TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK, or TOKEN_COMMENT.
contents
The token source string.
position
An optional tuple containing the start and end index of the token
in the... |
A token representing a string from the template. | def __init__(self, token_type, contents, position=None, lineno=None):
"""
A token representing a string from the template.
token_type
One of TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK, or TOKEN_COMMENT.
contents
The token source string.
position
An ... | [
"def",
"__init__",
"(",
"self",
",",
"token_type",
",",
"contents",
",",
"position",
"=",
"None",
",",
"lineno",
"=",
"None",
")",
":",
"self",
".",
"token_type",
",",
"self",
".",
"contents",
"=",
"token_type",
",",
"contents",
"self",
".",
"lineno",
... | [
324,
4
] | [
345,
32
] | python | en | ['en', 'error', 'th'] | False |
Lexer.tokenize | (self) |
Return a list of tokens from a given template_string.
|
Return a list of tokens from a given template_string.
| def tokenize(self):
"""
Return a list of tokens from a given template_string.
"""
in_tag = False
lineno = 1
result = []
for bit in tag_re.split(self.template_string):
if bit:
result.append(self.create_token(bit, None, lineno, in_tag))
... | [
"def",
"tokenize",
"(",
"self",
")",
":",
"in_tag",
"=",
"False",
"lineno",
"=",
"1",
"result",
"=",
"[",
"]",
"for",
"bit",
"in",
"tag_re",
".",
"split",
"(",
"self",
".",
"template_string",
")",
":",
"if",
"bit",
":",
"result",
".",
"append",
"("... | [
373,
4
] | [
385,
21
] | python | en | ['en', 'error', 'th'] | False |
Lexer.create_token | (self, token_string, position, lineno, in_tag) |
Convert the given token string into a new Token object and return it.
If in_tag is True, we are processing something that matched a tag,
otherwise it should be treated as a literal string.
|
Convert the given token string into a new Token object and return it.
If in_tag is True, we are processing something that matched a tag,
otherwise it should be treated as a literal string.
| def create_token(self, token_string, position, lineno, in_tag):
"""
Convert the given token string into a new Token object and return it.
If in_tag is True, we are processing something that matched a tag,
otherwise it should be treated as a literal string.
"""
if in_tag a... | [
"def",
"create_token",
"(",
"self",
",",
"token_string",
",",
"position",
",",
"lineno",
",",
"in_tag",
")",
":",
"if",
"in_tag",
"and",
"token_string",
".",
"startswith",
"(",
"BLOCK_TAG_START",
")",
":",
"# The [2:-2] ranges below strip off *_TAG_START and *_TAG_END... | [
387,
4
] | [
415,
20
] | python | en | ['en', 'error', 'th'] | False |
DebugLexer.tokenize | (self) |
Split a template string into tokens and annotates each token with its
start and end position in the source. This is slower than the default
lexer so we only use it when debug is True.
|
Split a template string into tokens and annotates each token with its
start and end position in the source. This is slower than the default
lexer so we only use it when debug is True.
| def tokenize(self):
"""
Split a template string into tokens and annotates each token with its
start and end position in the source. This is slower than the default
lexer so we only use it when debug is True.
"""
lineno = 1
result = []
upto = 0
for ... | [
"def",
"tokenize",
"(",
"self",
")",
":",
"lineno",
"=",
"1",
"result",
"=",
"[",
"]",
"upto",
"=",
"0",
"for",
"match",
"in",
"tag_re",
".",
"finditer",
"(",
"self",
".",
"template_string",
")",
":",
"start",
",",
"end",
"=",
"match",
".",
"span",... | [
419,
4
] | [
442,
21
] | python | en | ['en', 'error', 'th'] | False |
Parser.parse | (self, parse_until=None) |
Iterate through the parser tokens and compiles each one into a node.
If parse_until is provided, parsing will stop once one of the
specified tokens has been reached. This is formatted as a list of
tokens, e.g. ['elif', 'else', 'endif']. If no matching token is
reached, raise an... |
Iterate through the parser tokens and compiles each one into a node. | def parse(self, parse_until=None):
"""
Iterate through the parser tokens and compiles each one into a node.
If parse_until is provided, parsing will stop once one of the
specified tokens has been reached. This is formatted as a list of
tokens, e.g. ['elif', 'else', 'endif']. If ... | [
"def",
"parse",
"(",
"self",
",",
"parse_until",
"=",
"None",
")",
":",
"if",
"parse_until",
"is",
"None",
":",
"parse_until",
"=",
"[",
"]",
"nodelist",
"=",
"NodeList",
"(",
")",
"while",
"self",
".",
"tokens",
":",
"token",
"=",
"self",
".",
"next... | [
462,
4
] | [
520,
23
] | python | en | ['en', 'error', 'th'] | False |
Parser.error | (self, token, e) |
Return an exception annotated with the originating token. Since the
parser can be called recursively, check if a token is already set. This
ensures the innermost token is highlighted if an exception occurs,
e.g. a compile error within the body of an if statement.
|
Return an exception annotated with the originating token. Since the
parser can be called recursively, check if a token is already set. This
ensures the innermost token is highlighted if an exception occurs,
e.g. a compile error within the body of an if statement.
| def error(self, token, e):
"""
Return an exception annotated with the originating token. Since the
parser can be called recursively, check if a token is already set. This
ensures the innermost token is highlighted if an exception occurs,
e.g. a compile error within the body of an... | [
"def",
"error",
"(",
"self",
",",
"token",
",",
"e",
")",
":",
"if",
"not",
"isinstance",
"(",
"e",
",",
"Exception",
")",
":",
"e",
"=",
"TemplateSyntaxError",
"(",
"e",
")",
"if",
"not",
"hasattr",
"(",
"e",
",",
"'token'",
")",
":",
"e",
".",
... | [
543,
4
] | [
554,
16
] | python | en | ['en', 'error', 'th'] | False |
Parser.compile_filter | (self, token) |
Convenient wrapper for FilterExpression
|
Convenient wrapper for FilterExpression
| def compile_filter(self, token):
"""
Convenient wrapper for FilterExpression
"""
return FilterExpression(token, self) | [
"def",
"compile_filter",
"(",
"self",
",",
"token",
")",
":",
"return",
"FilterExpression",
"(",
"token",
",",
"self",
")"
] | [
595,
4
] | [
599,
44
] | python | en | ['en', 'error', 'th'] | False |
Variable.resolve | (self, context) | Resolve this variable against a given context. | Resolve this variable against a given context. | def resolve(self, context):
"""Resolve this variable against a given context."""
if self.lookups is not None:
# We're dealing with a variable that needs to be resolved
value = self._resolve_lookup(context)
else:
# We're dealing with a literal, so it's already ... | [
"def",
"resolve",
"(",
"self",
",",
"context",
")",
":",
"if",
"self",
".",
"lookups",
"is",
"not",
"None",
":",
"# We're dealing with a variable that needs to be resolved",
"value",
"=",
"self",
".",
"_resolve_lookup",
"(",
"context",
")",
"else",
":",
"# We're... | [
844,
4
] | [
860,
20
] | python | en | ['en', 'en', 'en'] | True |
Variable._resolve_lookup | (self, context) |
Performs resolution of a real variable (i.e. not a literal) against the
given context.
As indicated by the method's name, this method is an implementation
detail and shouldn't be called by external code. Use Variable.resolve()
instead.
|
Performs resolution of a real variable (i.e. not a literal) against the
given context. | def _resolve_lookup(self, context):
"""
Performs resolution of a real variable (i.e. not a literal) against the
given context.
As indicated by the method's name, this method is an implementation
detail and shouldn't be called by external code. Use Variable.resolve()
inst... | [
"def",
"_resolve_lookup",
"(",
"self",
",",
"context",
")",
":",
"current",
"=",
"context",
"try",
":",
"# catch-all for silent variable failures",
"for",
"bit",
"in",
"self",
".",
"lookups",
":",
"try",
":",
"# dictionary lookup",
"current",
"=",
"current",
"["... | [
868,
4
] | [
932,
22
] | python | en | ['en', 'error', 'th'] | False |
Node.render | (self, context) |
Return the node rendered as a string.
|
Return the node rendered as a string.
| def render(self, context):
"""
Return the node rendered as a string.
"""
pass | [
"def",
"render",
"(",
"self",
",",
"context",
")",
":",
"pass"
] | [
942,
4
] | [
946,
12
] | python | en | ['en', 'error', 'th'] | False |
Node.render_annotated | (self, context) |
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
|
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render method directly.
| def render_annotated(self, context):
"""
Render the node. If debug is True and an exception occurs during
rendering, the exception is annotated with contextual line information
where it occurred in the template. For internal usage this method is
preferred over using the render me... | [
"def",
"render_annotated",
"(",
"self",
",",
"context",
")",
":",
"try",
":",
"return",
"self",
".",
"render",
"(",
"context",
")",
"except",
"Exception",
"as",
"e",
":",
"if",
"context",
".",
"template",
".",
"engine",
".",
"debug",
"and",
"not",
"has... | [
948,
4
] | [
960,
17
] | python | en | ['en', 'error', 'th'] | False |
Node.get_nodes_by_type | (self, nodetype) |
Return a list of all nodes (within this node and its nodelist)
of the given type
|
Return a list of all nodes (within this node and its nodelist)
of the given type
| def get_nodes_by_type(self, nodetype):
"""
Return a list of all nodes (within this node and its nodelist)
of the given type
"""
nodes = []
if isinstance(self, nodetype):
nodes.append(self)
for attr in self.child_nodelists:
nodelist = getatt... | [
"def",
"get_nodes_by_type",
"(",
"self",
",",
"nodetype",
")",
":",
"nodes",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"self",
",",
"nodetype",
")",
":",
"nodes",
".",
"append",
"(",
"self",
")",
"for",
"attr",
"in",
"self",
".",
"child_nodelists",
":",
... | [
965,
4
] | [
977,
20
] | python | en | ['en', 'error', 'th'] | False |
NodeList.get_nodes_by_type | (self, nodetype) | Return a list of all nodes of the given type | Return a list of all nodes of the given type | def get_nodes_by_type(self, nodetype):
"Return a list of all nodes of the given type"
nodes = []
for node in self:
nodes.extend(node.get_nodes_by_type(nodetype))
return nodes | [
"def",
"get_nodes_by_type",
"(",
"self",
",",
"nodetype",
")",
":",
"nodes",
"=",
"[",
"]",
"for",
"node",
"in",
"self",
":",
"nodes",
".",
"extend",
"(",
"node",
".",
"get_nodes_by_type",
"(",
"nodetype",
")",
")",
"return",
"nodes"
] | [
995,
4
] | [
1000,
20
] | python | en | ['en', 'en', 'en'] | True |
mock_get_event_queryset_no_job_created | () |
SQLite friendly since partitions aren't supported. Do not add the faked job_created field to the filter. If we do, it will result in an sql query for the
job_created field. That field does not actually exist in a non-partition scenario.
|
SQLite friendly since partitions aren't supported. Do not add the faked job_created field to the filter. If we do, it will result in an sql query for the
job_created field. That field does not actually exist in a non-partition scenario.
| def mock_get_event_queryset_no_job_created():
"""
SQLite friendly since partitions aren't supported. Do not add the faked job_created field to the filter. If we do, it will result in an sql query for the
job_created field. That field does not actually exist in a non-partition scenario.
"""
def even... | [
"def",
"mock_get_event_queryset_no_job_created",
"(",
")",
":",
"def",
"event_qs",
"(",
"self",
")",
":",
"kwargs",
"=",
"{",
"self",
".",
"event_parent_key",
":",
"self",
".",
"id",
"}",
"return",
"self",
".",
"event_class",
".",
"objects",
".",
"filter",
... | [
170,
0
] | [
181,
22
] | python | en | ['en', 'error', 'th'] | False |
TravisHookTests.test_travis_message | (self) |
Build notifications are generated by Travis after build completes.
The subject describes the repo and Stash "project". The
content describes the commits pushed.
|
Build notifications are generated by Travis after build completes. | def test_travis_message(self) -> None:
"""
Build notifications are generated by Travis after build completes.
The subject describes the repo and Stash "project". The
content describes the commits pushed.
"""
expected_message = (
"Author: josh_mandel\nBuild st... | [
"def",
"test_travis_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"(",
"\"Author: josh_mandel\\nBuild status: Passed :thumbs_up:\\n\"",
"\"Details: [changes](https://github.com/hl7-fhir/fhir-sv\"",
"\"n/compare/6dccb98bcfd9...6c457d366a31), [build log](ht\"",
"\... | [
11,
4
] | [
30,
9
] | python | en | ['en', 'error', 'th'] | False |
lookup | (tag) |
:param tag: Integer tag number
:returns: Taginfo namedtuple, From the TAGS_V2 info if possible,
otherwise just populating the value and name from TAGS.
If the tag is not recognized, "unknown" is returned for the name
|
:param tag: Integer tag number
:returns: Taginfo namedtuple, From the TAGS_V2 info if possible,
otherwise just populating the value and name from TAGS.
If the tag is not recognized, "unknown" is returned for the name | def lookup(tag):
"""
:param tag: Integer tag number
:returns: Taginfo namedtuple, From the TAGS_V2 info if possible,
otherwise just populating the value and name from TAGS.
If the tag is not recognized, "unknown" is returned for the name
"""
return TAGS_V2.get(tag, TagInfo(tag, TAG... | [
"def",
"lookup",
"(",
"tag",
")",
":",
"return",
"TAGS_V2",
".",
"get",
"(",
"tag",
",",
"TagInfo",
"(",
"tag",
",",
"TAGS",
".",
"get",
"(",
"tag",
",",
"\"unknown\"",
")",
")",
")"
] | [
35,
0
] | [
44,
67
] | python | en | ['en', 'error', 'th'] | False |
TestPageEdit.test_edit_multipart | (self) |
Test checks if 'enctype="multipart/form-data"' is added and only to forms that require multipart encoding.
|
Test checks if 'enctype="multipart/form-data"' is added and only to forms that require multipart encoding.
| def test_edit_multipart(self):
"""
Test checks if 'enctype="multipart/form-data"' is added and only to forms that require multipart encoding.
"""
# check for SimplePage where is no file field
response = self.client.get(reverse('wagtailadmin_pages:edit', args=(self.event_page.id, ... | [
"def",
"test_edit_multipart",
"(",
"self",
")",
":",
"# check for SimplePage where is no file field",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:edit'",
",",
"args",
"=",
"(",
"self",
".",
"event_page",
".",
"id",... | [
124,
4
] | [
137,
70
] | python | en | ['en', 'error', 'th'] | False |
TestPageEdit.test_upload_file_publish | (self) |
Check that file uploads work when directly publishing
|
Check that file uploads work when directly publishing
| def test_upload_file_publish(self):
"""
Check that file uploads work when directly publishing
"""
file_upload = ContentFile(b"A new file", name='published-file.txt')
post_data = {
'title': 'New file',
'slug': 'new-file',
'file_field': file_uplo... | [
"def",
"test_upload_file_publish",
"(",
"self",
")",
":",
"file_upload",
"=",
"ContentFile",
"(",
"b\"A new file\"",
",",
"name",
"=",
"'published-file.txt'",
")",
"post_data",
"=",
"{",
"'title'",
":",
"'New file'",
",",
"'slug'",
":",
"'new-file'",
",",
"'file... | [
144,
4
] | [
165,
68
] | python | en | ['en', 'error', 'th'] | False |
TestPageEdit.test_upload_file_draft | (self) |
Check that file uploads work when saving a draft
|
Check that file uploads work when saving a draft
| def test_upload_file_draft(self):
"""
Check that file uploads work when saving a draft
"""
file_upload = ContentFile(b"A new file", name='draft-file.txt')
post_data = {
'title': 'New file',
'slug': 'new-file',
'file_field': file_upload,
... | [
"def",
"test_upload_file_draft",
"(",
"self",
")",
":",
"file_upload",
"=",
"ContentFile",
"(",
"b\"A new file\"",
",",
"name",
"=",
"'draft-file.txt'",
")",
"post_data",
"=",
"{",
"'title'",
":",
"'New file'",
",",
"'slug'",
":",
"'new-file'",
",",
"'file_field... | [
167,
4
] | [
195,
68
] | python | en | ['en', 'error', 'th'] | False |
TestPageEdit.test_first_published_at_editable | (self) | Test that we can update the first_published_at via the Page edit form,
for page models that expose it. | Test that we can update the first_published_at via the Page edit form,
for page models that expose it. | def test_first_published_at_editable(self):
"""Test that we can update the first_published_at via the Page edit form,
for page models that expose it."""
# Add child page, of a type which has first_published_at in its form
child_page = ManyToManyBlogPage(
title="Hello world!"... | [
"def",
"test_first_published_at_editable",
"(",
"self",
")",
":",
"# Add child page, of a type which has first_published_at in its form",
"child_page",
"=",
"ManyToManyBlogPage",
"(",
"title",
"=",
"\"Hello world!\"",
",",
"slug",
"=",
"\"hello-again-world\"",
",",
"body",
"=... | [
379,
4
] | [
417,
44
] | python | en | ['en', 'en', 'en'] | True |
TestPageEdit.test_preview_does_not_cache | (self) |
Tests solution to issue #5975
|
Tests solution to issue #5975
| def test_preview_does_not_cache(self):
'''
Tests solution to issue #5975
'''
post_data = {
'title': "I've been edited one time!",
'content': "Some content",
'slug': 'hello-world',
'action-submit': "Submit",
}
preview_url = r... | [
"def",
"test_preview_does_not_cache",
"(",
"self",
")",
":",
"post_data",
"=",
"{",
"'title'",
":",
"\"I've been edited one time!\"",
",",
"'content'",
":",
"\"Some content\"",
",",
"'slug'",
":",
"'hello-world'",
",",
"'action-submit'",
":",
"\"Submit\"",
",",
"}",... | [
730,
4
] | [
749,
83
] | python | en | ['en', 'error', 'th'] | False |
TestPageEdit.test_edit_after_change_language_code | (self) |
Verify that changing LANGUAGE_CODE with no corresponding database change does not break editing
|
Verify that changing LANGUAGE_CODE with no corresponding database change does not break editing
| def test_edit_after_change_language_code(self):
"""
Verify that changing LANGUAGE_CODE with no corresponding database change does not break editing
"""
# Add a draft revision
self.child_page.title = "Hello world updated"
self.child_page.save_revision()
# Hack the... | [
"def",
"test_edit_after_change_language_code",
"(",
"self",
")",
":",
"# Add a draft revision",
"self",
".",
"child_page",
".",
"title",
"=",
"\"Hello world updated\"",
"self",
".",
"child_page",
".",
"save_revision",
"(",
")",
"# Hack the Locale model to simulate a page tr... | [
1023,
4
] | [
1048,
103
] | python | en | ['en', 'error', 'th'] | False |
TestPageEdit.test_edit_after_change_language_code_without_revisions | (self) |
Verify that changing LANGUAGE_CODE with no corresponding database change does not break editing
|
Verify that changing LANGUAGE_CODE with no corresponding database change does not break editing
| def test_edit_after_change_language_code_without_revisions(self):
"""
Verify that changing LANGUAGE_CODE with no corresponding database change does not break editing
"""
# Hack the Locale model to simulate a page tree that was created with LANGUAGE_CODE = 'de'
# (which is not a v... | [
"def",
"test_edit_after_change_language_code_without_revisions",
"(",
"self",
")",
":",
"# Hack the Locale model to simulate a page tree that was created with LANGUAGE_CODE = 'de'",
"# (which is not a valid content language under the current configuration)",
"Locale",
".",
"objects",
".",
"u... | [
1050,
4
] | [
1073,
103
] | python | en | ['en', 'error', 'th'] | False |
TestIssue3982.test_create_accessible | (self) |
Create a page under the site root, check the flash message has a valid
"View live" button.
|
Create a page under the site root, check the flash message has a valid
"View live" button.
| def test_create_accessible(self):
"""
Create a page under the site root, check the flash message has a valid
"View live" button.
"""
response, page = self._create_page(Page.objects.get(pk=2))
self.assertIsNotNone(page.url)
self.assertTrue(any(
'View li... | [
"def",
"test_create_accessible",
"(",
"self",
")",
":",
"response",
",",
"page",
"=",
"self",
".",
"_create_page",
"(",
"Page",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"2",
")",
")",
"self",
".",
"assertIsNotNone",
"(",
"page",
".",
"url",
")",
"... | [
1443,
4
] | [
1452,
57
] | python | en | ['en', 'error', 'th'] | False |
TestIssue3982.test_create_inaccessible | (self) |
Create a page outside of the site root, check the flash message does
not have a "View live" button.
|
Create a page outside of the site root, check the flash message does
not have a "View live" button.
| def test_create_inaccessible(self):
"""
Create a page outside of the site root, check the flash message does
not have a "View live" button.
"""
response, page = self._create_page(Page.objects.get(pk=1))
self.assertIsNone(page.url)
self.assertFalse(any(
... | [
"def",
"test_create_inaccessible",
"(",
"self",
")",
":",
"response",
",",
"page",
"=",
"self",
".",
"_create_page",
"(",
"Page",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"1",
")",
")",
"self",
".",
"assertIsNone",
"(",
"page",
".",
"url",
")",
"s... | [
1454,
4
] | [
1463,
57
] | python | en | ['en', 'error', 'th'] | False |
TestIssue3982.test_edit_accessible | (self) |
Edit a page under the site root, check the flash message has a valid
"View live" button.
|
Edit a page under the site root, check the flash message has a valid
"View live" button.
| def test_edit_accessible(self):
"""
Edit a page under the site root, check the flash message has a valid
"View live" button.
"""
response, page = self._edit_page(Page.objects.get(pk=2))
self.assertIsNotNone(page.url)
self.assertTrue(any(
'View live' in... | [
"def",
"test_edit_accessible",
"(",
"self",
")",
":",
"response",
",",
"page",
"=",
"self",
".",
"_edit_page",
"(",
"Page",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"2",
")",
")",
"self",
".",
"assertIsNotNone",
"(",
"page",
".",
"url",
")",
"self... | [
1476,
4
] | [
1485,
57
] | python | en | ['en', 'error', 'th'] | False |
TestIssue3982.test_edit_inaccessible | (self) |
Edit a page outside of the site root, check the flash message does
not have a "View live" button.
|
Edit a page outside of the site root, check the flash message does
not have a "View live" button.
| def test_edit_inaccessible(self):
"""
Edit a page outside of the site root, check the flash message does
not have a "View live" button.
"""
response, page = self._edit_page(Page.objects.get(pk=1))
self.assertIsNone(page.url)
self.assertFalse(any(
'View... | [
"def",
"test_edit_inaccessible",
"(",
"self",
")",
":",
"response",
",",
"page",
"=",
"self",
".",
"_edit_page",
"(",
"Page",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"1",
")",
")",
"self",
".",
"assertIsNone",
"(",
"page",
".",
"url",
")",
"self"... | [
1487,
4
] | [
1496,
57
] | python | en | ['en', 'error', 'th'] | False |
TestIssue3982.test_approve_accessible | (self) |
Edit a page under the site root, check the flash message has a valid
"View live" button.
|
Edit a page under the site root, check the flash message has a valid
"View live" button.
| def test_approve_accessible(self):
"""
Edit a page under the site root, check the flash message has a valid
"View live" button.
"""
response, page = self._approve_page(Page.objects.get(pk=2))
self.assertIsNotNone(page.url)
self.assertTrue(any(
'View li... | [
"def",
"test_approve_accessible",
"(",
"self",
")",
":",
"response",
",",
"page",
"=",
"self",
".",
"_approve_page",
"(",
"Page",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"2",
")",
")",
"self",
".",
"assertIsNotNone",
"(",
"page",
".",
"url",
")",
... | [
1514,
4
] | [
1523,
57
] | python | en | ['en', 'error', 'th'] | False |
TestIssue3982.test_approve_inaccessible | (self) |
Edit a page outside of the site root, check the flash message does
not have a "View live" button.
|
Edit a page outside of the site root, check the flash message does
not have a "View live" button.
| def test_approve_inaccessible(self):
"""
Edit a page outside of the site root, check the flash message does
not have a "View live" button.
"""
response, page = self._approve_page(Page.objects.get(pk=1))
self.assertIsNone(page.url)
self.assertFalse(any(
... | [
"def",
"test_approve_inaccessible",
"(",
"self",
")",
":",
"response",
",",
"page",
"=",
"self",
".",
"_approve_page",
"(",
"Page",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"1",
")",
")",
"self",
".",
"assertIsNone",
"(",
"page",
".",
"url",
")",
... | [
1525,
4
] | [
1534,
57
] | python | en | ['en', 'error', 'th'] | False |
TestValidationErrorMessages.test_field_error | (self) | Field errors should be shown against the relevant fields, not in the header message | Field errors should be shown against the relevant fields, not in the header message | def test_field_error(self):
"""Field errors should be shown against the relevant fields, not in the header message"""
post_data = {
'title': "",
'date_from': "2017-12-25",
'slug': "christmas",
'audience': "public",
'location': "The North Pole",... | [
"def",
"test_field_error",
"(",
"self",
")",
":",
"post_data",
"=",
"{",
"'title'",
":",
"\"\"",
",",
"'date_from'",
":",
"\"2017-12-25\"",
",",
"'slug'",
":",
"\"christmas\"",
",",
"'audience'",
":",
"\"public\"",
",",
"'location'",
":",
"\"The North Pole\"",
... | [
1707,
4
] | [
1742,
72
] | python | en | ['en', 'en', 'en'] | True |
TestValidationErrorMessages.test_non_field_error | (self) | Non-field errors should be shown in the header message | Non-field errors should be shown in the header message | def test_non_field_error(self):
"""Non-field errors should be shown in the header message"""
post_data = {
'title': "Christmas",
'date_from': "2017-12-25",
'date_to': "2017-12-24",
'slug': "christmas",
'audience': "public",
'locatio... | [
"def",
"test_non_field_error",
"(",
"self",
")",
":",
"post_data",
"=",
"{",
"'title'",
":",
"\"Christmas\"",
",",
"'date_from'",
":",
"\"2017-12-25\"",
",",
"'date_to'",
":",
"\"2017-12-24\"",
",",
"'slug'",
":",
"\"christmas\"",
",",
"'audience'",
":",
"\"publ... | [
1744,
4
] | [
1778,
100
] | python | en | ['en', 'en', 'en'] | True |
TestValidationErrorMessages.test_field_and_non_field_error | (self) |
If both field and non-field errors exist, all errors should be shown in the header message
with appropriate context to identify the field; and field errors should also be shown
against the relevant fields.
|
If both field and non-field errors exist, all errors should be shown in the header message
with appropriate context to identify the field; and field errors should also be shown
against the relevant fields.
| def test_field_and_non_field_error(self):
"""
If both field and non-field errors exist, all errors should be shown in the header message
with appropriate context to identify the field; and field errors should also be shown
against the relevant fields.
"""
post_data = {
... | [
"def",
"test_field_and_non_field_error",
"(",
"self",
")",
":",
"post_data",
"=",
"{",
"'title'",
":",
"\"\"",
",",
"'date_from'",
":",
"\"2017-12-25\"",
",",
"'date_to'",
":",
"\"2017-12-24\"",
",",
"'slug'",
":",
"\"christmas\"",
",",
"'audience'",
":",
"\"pub... | [
1780,
4
] | [
1823,
89
] | python | en | ['en', 'error', 'th'] | False |
SGDP.step | (self, closure: OptLossClosure = None) | r"""Performs a single optimization step.
Arguments:
closure: A closure that reevaluates the model and returns the loss.
| r"""Performs a single optimization step. | def step(self, closure: OptLossClosure = None) -> OptFloat:
r"""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... | [
125,
4
] | [
185,
19
] | python | en | ['en', 'en', 'en'] | True |
__optim_args_from_interpreter_flags | () | Return a list of command-line arguments reproducing the current
optimization settings in sys.flags. | Return a list of command-line arguments reproducing the current
optimization settings in sys.flags. | def __optim_args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
optimization settings in sys.flags."""
args = []
value = sys.flags.optimize
if value > 0:
args.append("-" + "O" * value)
return args | [
"def",
"__optim_args_from_interpreter_flags",
"(",
")",
":",
"args",
"=",
"[",
"]",
"value",
"=",
"sys",
".",
"flags",
".",
"optimize",
"if",
"value",
">",
"0",
":",
"args",
".",
"append",
"(",
"\"-\"",
"+",
"\"O\"",
"*",
"value",
")",
"return",
"args"... | [
4,
0
] | [
11,
15
] | python | en | ['en', 'en', 'en'] | True |
HasCopy.copy | (self, name='') | Return a copy of current page | Return a copy of current page | def copy(self, name=''):
"""Return a copy of current page"""
payload = {"name": name or "Copy - " + random_title()}
endpoint = self.json.related['copy']
page = Page(self.connection, endpoint=endpoint)
return page.post(payload) | [
"def",
"copy",
"(",
"self",
",",
"name",
"=",
"''",
")",
":",
"payload",
"=",
"{",
"\"name\"",
":",
"name",
"or",
"\"Copy - \"",
"+",
"random_title",
"(",
")",
"}",
"endpoint",
"=",
"self",
".",
"json",
".",
"related",
"[",
"'copy'",
"]",
"page",
"... | [
8,
4
] | [
13,
33
] | python | en | ['en', 'en', 'en'] | True |
JsonableError.msg_format | () | Override in subclasses. Gets the items in `data_fields` as format args.
This should return (a translation of) a string literal.
The reason it's not simply a class attribute is to allow
translation to work.
| Override in subclasses. Gets the items in `data_fields` as format args. | def msg_format() -> str:
"""Override in subclasses. Gets the items in `data_fields` as format args.
This should return (a translation of) a string literal.
The reason it's not simply a class attribute is to allow
translation to work.
"""
# Secretly this gets one more fo... | [
"def",
"msg_format",
"(",
")",
"->",
"str",
":",
"# Secretly this gets one more format arg not in `data_fields`: `_msg`.",
"# That's for the sake of the `JsonableError` base logic itself, for",
"# the simplest form of use where we just get a plain message string",
"# at construction time.",
"r... | [
106,
4
] | [
117,
23
] | python | en | ['en', 'en', 'en'] | True |
std_hash | (b) |
The standard hash used in many places.
|
The standard hash used in many places.
| def std_hash(b) -> bytes32:
"""
The standard hash used in many places.
"""
return bytes32(blspy.Util.hash256(bytes(b))) | [
"def",
"std_hash",
"(",
"b",
")",
"->",
"bytes32",
":",
"return",
"bytes32",
"(",
"blspy",
".",
"Util",
".",
"hash256",
"(",
"bytes",
"(",
"b",
")",
")",
")"
] | [
5,
0
] | [
9,
48
] | python | en | ['en', 'error', 'th'] | False |
supports_color | () |
Returns True if the running system's terminal supports color,
and False otherwise.
|
Returns True if the running system's terminal supports color,
and False otherwise.
| def supports_color():
"""
Returns True if the running system's terminal supports color,
and False otherwise.
"""
plat = sys.platform
supported_platform = plat != 'Pocket PC' and (plat != 'win32' or 'ANSICON' in os.environ)
# isatty is not always implemented, #6223.
is_a_tty = hasattr(sy... | [
"def",
"supports_color",
"(",
")",
":",
"plat",
"=",
"sys",
".",
"platform",
"supported_platform",
"=",
"plat",
"!=",
"'Pocket PC'",
"and",
"(",
"plat",
"!=",
"'win32'",
"or",
"'ANSICON'",
"in",
"os",
".",
"environ",
")",
"# isatty is not always implemented, #62... | [
10,
0
] | [
22,
15
] | python | en | ['en', 'error', 'th'] | False |
make_style | (config_string='') |
Create a Style object from the given config_string.
If config_string is empty django.utils.termcolors.DEFAULT_PALETTE is used.
|
Create a Style object from the given config_string. | def make_style(config_string=''):
"""
Create a Style object from the given config_string.
If config_string is empty django.utils.termcolors.DEFAULT_PALETTE is used.
"""
style = Style()
color_settings = termcolors.parse_color_setting(config_string)
# The nocolor palette has all available ... | [
"def",
"make_style",
"(",
"config_string",
"=",
"''",
")",
":",
"style",
"=",
"Style",
"(",
")",
"color_settings",
"=",
"termcolors",
".",
"parse_color_setting",
"(",
"config_string",
")",
"# The nocolor palette has all available roles.",
"# Use that palette as the basis ... | [
29,
0
] | [
56,
16
] | python | en | ['en', 'error', 'th'] | False |
no_style | () |
Returns a Style object with no color scheme.
|
Returns a Style object with no color scheme.
| def no_style():
"""
Returns a Style object with no color scheme.
"""
return make_style('nocolor') | [
"def",
"no_style",
"(",
")",
":",
"return",
"make_style",
"(",
"'nocolor'",
")"
] | [
60,
0
] | [
64,
32
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.