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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
applyTransform | (im, transform, inPlace=False) |
(pyCMS) Applies a transform to a given image.
If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised.
If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a
:exc:`PyCMSError` is raised.
If ``im.mode``, ``transform.inMode`` or ``transform.outMode`` is not
suppo... |
(pyCMS) Applies a transform to a given image. | def applyTransform(im, transform, inPlace=False):
"""
(pyCMS) Applies a transform to a given image.
If ``im.mode != transform.inMode``, a :exc:`PyCMSError` is raised.
If ``inPlace`` is ``True`` and ``transform.inMode != transform.outMode``, a
:exc:`PyCMSError` is raised.
If ``im.mode``, ``tra... | [
"def",
"applyTransform",
"(",
"im",
",",
"transform",
",",
"inPlace",
"=",
"False",
")",
":",
"try",
":",
"if",
"inPlace",
":",
"transform",
".",
"apply_in_place",
"(",
"im",
")",
"imOut",
"=",
"None",
"else",
":",
"imOut",
"=",
"transform",
".",
"appl... | [
605,
0
] | [
655,
16
] | python | en | ['en', 'error', 'th'] | False |
createProfile | (colorSpace, colorTemp=-1) |
(pyCMS) Creates a profile.
If colorSpace not in ``["LAB", "XYZ", "sRGB"]``,
a :exc:`PyCMSError` is raised.
If using LAB and ``colorTemp`` is not a positive integer,
a :exc:`PyCMSError` is raised.
If an error occurs while creating the profile,
a :exc:`PyCMSError` is raised.
Use this ... |
(pyCMS) Creates a profile. | def createProfile(colorSpace, colorTemp=-1):
"""
(pyCMS) Creates a profile.
If colorSpace not in ``["LAB", "XYZ", "sRGB"]``,
a :exc:`PyCMSError` is raised.
If using LAB and ``colorTemp`` is not a positive integer,
a :exc:`PyCMSError` is raised.
If an error occurs while creating the profil... | [
"def",
"createProfile",
"(",
"colorSpace",
",",
"colorTemp",
"=",
"-",
"1",
")",
":",
"if",
"colorSpace",
"not",
"in",
"[",
"\"LAB\"",
",",
"\"XYZ\"",
",",
"\"sRGB\"",
"]",
":",
"raise",
"PyCMSError",
"(",
"f\"Color space not supported for on-the-fly profile creat... | [
658,
0
] | [
704,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileName | (profile) |
(pyCMS) Gets the internal product name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised If an error occurs while trying
to obtain the name tag, a :exc:`PyCMSError` is raised.
Use this function to obtain the INTERNAL nam... | def getProfileName(profile):
"""
(pyCMS) Gets the internal product name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised If an error occurs while trying
to obtain the name tag, a :exc:`PyCMSError` is raised.
Use this... | [
"def",
"getProfileName",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"# do it in py... | [
707,
0
] | [
746,
34
] | python | en | ['en', 'error', 'th'] | False | |
getProfileInfo | (profile) |
(pyCMS) Gets the internal product information for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the info tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the ... |
(pyCMS) Gets the internal product information for the given profile. | def getProfileInfo(profile):
"""
(pyCMS) Gets the internal product information for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile,
a :exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the info tag,
a :exc:`PyCMSError` is raised.
... | [
"def",
"getProfileInfo",
"(",
"profile",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"# add an extra newline to preserve pyCMS compatibility",
"# Python, not... | [
749,
0
] | [
786,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileCopyright | (profile) |
(pyCMS) Gets the copyright for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the copyright tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the information st... |
(pyCMS) Gets the copyright for the given profile. | def getProfileCopyright(profile):
"""
(pyCMS) Gets the copyright for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the copyright tag,
a :exc:`PyCMSError` is raised.
Use t... | [
"def",
"getProfileCopyright",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return",... | [
789,
0
] | [
814,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileManufacturer | (profile) |
(pyCMS) Gets the manufacturer for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the manufacturer tag, a
:exc:`PyCMSError` is raised.
Use this function to obtain the informat... |
(pyCMS) Gets the manufacturer for the given profile. | def getProfileManufacturer(profile):
"""
(pyCMS) Gets the manufacturer for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the manufacturer tag, a
:exc:`PyCMSError` is raised.
... | [
"def",
"getProfileManufacturer",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"retur... | [
817,
0
] | [
842,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileModel | (profile) |
(pyCMS) Gets the model for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the model tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the information stored in ... |
(pyCMS) Gets the model for the given profile. | def getProfileModel(profile):
"""
(pyCMS) Gets the model for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the model tag,
a :exc:`PyCMSError` is raised.
Use this function... | [
"def",
"getProfileModel",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return",
"... | [
845,
0
] | [
871,
34
] | python | en | ['en', 'error', 'th'] | False |
getProfileDescription | (profile) |
(pyCMS) Gets the description for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the description tag,
a :exc:`PyCMSError` is raised.
Use this function to obtain the informatio... |
(pyCMS) Gets the description for the given profile. | def getProfileDescription(profile):
"""
(pyCMS) Gets the description for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the description tag,
a :exc:`PyCMSError` is raised.
... | [
"def",
"getProfileDescription",
"(",
"profile",
")",
":",
"try",
":",
"# add an extra newline to preserve pyCMS compatibility",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return... | [
874,
0
] | [
900,
34
] | python | en | ['en', 'error', 'th'] | False |
getDefaultIntent | (profile) |
(pyCMS) Gets the default intent name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the default intent, a
:exc:`PyCMSError` is raised.
Use this function to determine the ... |
(pyCMS) Gets the default intent name for the given profile. | def getDefaultIntent(profile):
"""
(pyCMS) Gets the default intent name for the given profile.
If ``profile`` isn't a valid CmsProfile object or filename to a profile, a
:exc:`PyCMSError` is raised.
If an error occurs while trying to obtain the default intent, a
:exc:`PyCMSError` is raised.
... | [
"def",
"getDefaultIntent",
"(",
"profile",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"return",
"profile",
".",
"profile",
".",
"rendering_intent",
... | [
903,
0
] | [
939,
34
] | python | en | ['en', 'error', 'th'] | False |
isIntentSupported | (profile, intent, direction) |
(pyCMS) Checks if a given intent is supported.
Use this function to verify that you can use your desired
``intent`` with ``profile``, and that ``profile`` can be used for the
input/output/proof profile as you desire.
Some profiles are created specifically for one "direction", can cannot
be us... |
(pyCMS) Checks if a given intent is supported. | def isIntentSupported(profile, intent, direction):
"""
(pyCMS) Checks if a given intent is supported.
Use this function to verify that you can use your desired
``intent`` with ``profile``, and that ``profile`` can be used for the
input/output/proof profile as you desire.
Some profiles are crea... | [
"def",
"isIntentSupported",
"(",
"profile",
",",
"intent",
",",
"direction",
")",
":",
"try",
":",
"if",
"not",
"isinstance",
"(",
"profile",
",",
"ImageCmsProfile",
")",
":",
"profile",
"=",
"ImageCmsProfile",
"(",
"profile",
")",
"# FIXME: I get different resu... | [
942,
0
] | [
990,
34
] | python | en | ['en', 'error', 'th'] | False |
versions | () |
(pyCMS) Fetches versions.
|
(pyCMS) Fetches versions.
| def versions():
"""
(pyCMS) Fetches versions.
"""
return (VERSION, core.littlecms_version, sys.version.split()[0], Image.__version__) | [
"def",
"versions",
"(",
")",
":",
"return",
"(",
"VERSION",
",",
"core",
".",
"littlecms_version",
",",
"sys",
".",
"version",
".",
"split",
"(",
")",
"[",
"0",
"]",
",",
"Image",
".",
"__version__",
")"
] | [
993,
0
] | [
998,
87
] | python | en | ['en', 'error', 'th'] | False |
ImageCmsProfile.__init__ | (self, profile) |
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
|
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object | def __init__(self, profile):
"""
:param profile: Either a string representing a filename,
a file like object containing a profile or a
low-level profile object
"""
if isinstance(profile, str):
if sys.platform == "win32":
profile_bytes... | [
"def",
"__init__",
"(",
"self",
",",
"profile",
")",
":",
"if",
"isinstance",
"(",
"profile",
",",
"str",
")",
":",
"if",
"sys",
".",
"platform",
"==",
"\"win32\"",
":",
"profile_bytes_path",
"=",
"profile",
".",
"encode",
"(",
")",
"try",
":",
"profil... | [
152,
4
] | [
175,
55
] | python | en | ['en', 'error', 'th'] | False |
ImageCmsProfile.tobytes | (self) |
Returns the profile in a format suitable for embedding in
saved images.
:returns: a bytes object containing the ICC profile.
|
Returns the profile in a format suitable for embedding in
saved images. | def tobytes(self):
"""
Returns the profile in a format suitable for embedding in
saved images.
:returns: a bytes object containing the ICC profile.
"""
return core.profile_tobytes(self.profile) | [
"def",
"tobytes",
"(",
"self",
")",
":",
"return",
"core",
".",
"profile_tobytes",
"(",
"self",
".",
"profile",
")"
] | [
187,
4
] | [
195,
49
] | python | en | ['en', 'error', 'th'] | False |
find_summary_files | (basedir) |
Search basedir recursively to find files named
sequencing_summary.txt, will follow symlinks
|
Search basedir recursively to find files named
sequencing_summary.txt, will follow symlinks
| def find_summary_files(basedir):
'''
Search basedir recursively to find files named
sequencing_summary.txt, will follow symlinks
'''
i = 0
for currdir, _, files in os.walk(basedir, followlinks=True):
for fn in files:
if fn == 'sequencing_summary.txt':
i += 1
... | [
"def",
"find_summary_files",
"(",
"basedir",
")",
":",
"i",
"=",
"0",
"for",
"currdir",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"basedir",
",",
"followlinks",
"=",
"True",
")",
":",
"for",
"fn",
"in",
"files",
":",
"if",
"fn",
"==",
... | [
3,
0
] | [
15,
72
] | python | en | ['en', 'error', 'th'] | False |
parse_sequencing_summary | (seq_summary_fn) |
Parse a sequencing summary file to create a
dictionary of read id to fast5 file name mappings.
Fast5 file names do not include full path yet.
|
Parse a sequencing summary file to create a
dictionary of read id to fast5 file name mappings.
Fast5 file names do not include full path yet.
| def parse_sequencing_summary(seq_summary_fn):
'''
Parse a sequencing summary file to create a
dictionary of read id to fast5 file name mappings.
Fast5 file names do not include full path yet.
'''
read_id_filemap = {}
with open(seq_summary_fn) as ss:
# skip header
_ = next(ss)... | [
"def",
"parse_sequencing_summary",
"(",
"seq_summary_fn",
")",
":",
"read_id_filemap",
"=",
"{",
"}",
"with",
"open",
"(",
"seq_summary_fn",
")",
"as",
"ss",
":",
"# skip header",
"_",
"=",
"next",
"(",
"ss",
")",
"for",
"record",
"in",
"ss",
":",
"filenam... | [
18,
0
] | [
31,
26
] | python | en | ['en', 'error', 'th'] | False |
find_fast5s | (basedir) |
Search basedir recursively to find fast5 files
will follow symlinks
|
Search basedir recursively to find fast5 files
will follow symlinks
| def find_fast5s(basedir):
'''
Search basedir recursively to find fast5 files
will follow symlinks
'''
i = 0
for currdir, _, files in os.walk(basedir, followlinks=True):
for fn in files:
if fn.endswith('.fast5'):
i += 1
yield os.path.join(currd... | [
"def",
"find_fast5s",
"(",
"basedir",
")",
":",
"i",
"=",
"0",
"for",
"currdir",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"basedir",
",",
"followlinks",
"=",
"True",
")",
":",
"for",
"fn",
"in",
"files",
":",
"if",
"fn",
".",
"endswi... | [
34,
0
] | [
46,
55
] | python | en | ['en', 'error', 'th'] | False |
get_full_filepath_for_read_id_mappings | (read_id_filemap, fast5_basedir) |
Extend the filepath for fast5s in a read id to fast5 mapping.
Files or read ids that cannot be found in fast5_basedir
will be removed.
|
Extend the filepath for fast5s in a read id to fast5 mapping.
Files or read ids that cannot be found in fast5_basedir
will be removed.
| def get_full_filepath_for_read_id_mappings(read_id_filemap, fast5_basedir):
'''
Extend the filepath for fast5s in a read id to fast5 mapping.
Files or read ids that cannot be found in fast5_basedir
will be removed.
'''
fullpath_filemap = {}
read_id_map_with_fullpaths = {}
for fullpath in... | [
"def",
"get_full_filepath_for_read_id_mappings",
"(",
"read_id_filemap",
",",
"fast5_basedir",
")",
":",
"fullpath_filemap",
"=",
"{",
"}",
"read_id_map_with_fullpaths",
"=",
"{",
"}",
"for",
"fullpath",
"in",
"find_fast5s",
"(",
"fast5_basedir",
")",
":",
"_",
",",... | [
49,
0
] | [
69,
37
] | python | en | ['en', 'error', 'th'] | False |
get_fast5_read_id_mapping | (summaries_basedir, fast5_basedir) |
Creates a dictionary mapping read_ids to the location of
their raw fast5 files on disk.
Parameters:
-----------
summaries_basedir: str, required
Directory which is recursively searched for sequencing_summary.txt
files produced by albacore or other basecaller
... |
Creates a dictionary mapping read_ids to the location of
their raw fast5 files on disk.
Parameters:
-----------
summaries_basedir: str, required
Directory which is recursively searched for sequencing_summary.txt
files produced by albacore or other basecaller
... | def get_fast5_read_id_mapping(summaries_basedir, fast5_basedir):
'''
Creates a dictionary mapping read_ids to the location of
their raw fast5 files on disk.
Parameters:
-----------
summaries_basedir: str, required
Directory which is recursively searched for sequencing_sum... | [
"def",
"get_fast5_read_id_mapping",
"(",
"summaries_basedir",
",",
"fast5_basedir",
")",
":",
"read_id_filemap",
"=",
"{",
"}",
"for",
"summary_fn",
"in",
"find_summary_files",
"(",
"summaries_basedir",
")",
":",
"read_id_filemap",
".",
"update",
"(",
"parse_sequencin... | [
72,
0
] | [
102,
26
] | python | en | ['en', 'error', 'th'] | False |
install_scripts.write_script | (self, script_name, contents, mode="t", *ignored) | Write an executable file to the scripts directory | Write an executable file to the scripts directory | def write_script(self, script_name, contents, mode="t", *ignored):
"""Write an executable file to the scripts directory"""
from setuptools.command.easy_install import chmod, current_umask
log.info("Installing %s script to %s", script_name, self.install_dir)
target = os.path.join(self.in... | [
"def",
"write_script",
"(",
"self",
",",
"script_name",
",",
"contents",
",",
"mode",
"=",
"\"t\"",
",",
"*",
"ignored",
")",
":",
"from",
"setuptools",
".",
"command",
".",
"easy_install",
"import",
"chmod",
",",
"current_umask",
"log",
".",
"info",
"(",
... | [
53,
4
] | [
67,
39
] | python | en | ['en', 'en', 'en'] | True |
FitsImage.read_data | (self, hdu_index, plane) |
Read and store data from our FITS file.
NOTE: PyFITS reads the data into an array indexed as [y][x]. We
take the transpose to make this more intuitively reasonable and
consistent with (eg) ds9 display of the FitsFile. Transpose back
before viewing the array with RO.DS9, saving ... |
Read and store data from our FITS file. | def read_data(self, hdu_index, plane):
"""
Read and store data from our FITS file.
NOTE: PyFITS reads the data into an array indexed as [y][x]. We
take the transpose to make this more intuitively reasonable and
consistent with (eg) ds9 display of the FitsFile. Transpose back
... | [
"def",
"read_data",
"(",
"self",
",",
"hdu_index",
",",
"plane",
")",
":",
"with",
"pyfits",
".",
"open",
"(",
"self",
".",
"url",
")",
"as",
"hdulist",
":",
"hdu",
"=",
"hdulist",
"[",
"hdu_index",
"]",
"data",
"=",
"numpy",
".",
"float64",
"(",
"... | [
50,
4
] | [
70,
19
] | python | en | ['en', 'error', 'th'] | False |
FitsImage.parse_coordinates | (self) | Returns a WCS object | Returns a WCS object | def parse_coordinates(self):
"""Returns a WCS object"""
header = self.header
wcs = WCS()
try:
wcs.crval = header['crval1'], header['crval2']
wcs.crpix = header['crpix1'] - 1, header['crpix2'] - 1
wcs.cdelt = header['cdelt1'], header['cdelt2']
e... | [
"def",
"parse_coordinates",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"header",
"wcs",
"=",
"WCS",
"(",
")",
"try",
":",
"wcs",
".",
"crval",
"=",
"header",
"[",
"'crval1'",
"]",
",",
"header",
"[",
"'crval2'",
"]",
"wcs",
".",
"crpix",
"=... | [
73,
4
] | [
103,
18
] | python | en | ['en', 'bg', 'en'] | True |
FitsImage.parse_frequency | (self) |
Set some 'shortcut' variables for access to the frequency parameters
in the FITS file header.
@param hdulist: hdulist to parse
@type hdulist: hdulist
|
Set some 'shortcut' variables for access to the frequency parameters
in the FITS file header. | def parse_frequency(self):
"""
Set some 'shortcut' variables for access to the frequency parameters
in the FITS file header.
@param hdulist: hdulist to parse
@type hdulist: hdulist
"""
freq_eff = None
freq_bw = None
try:
header = self.... | [
"def",
"parse_frequency",
"(",
"self",
")",
":",
"freq_eff",
"=",
"None",
"freq_bw",
"=",
"None",
"try",
":",
"header",
"=",
"self",
".",
"header",
"if",
"'RESTFRQ'",
"in",
"header",
":",
"freq_eff",
"=",
"header",
"[",
"'RESTFRQ'",
"]",
"if",
"'RESTBW'"... | [
113,
4
] | [
147,
32
] | python | en | ['en', 'error', 'th'] | False |
FitsImage.parse_beam | (self) | Read and return the beam properties bmaj, bmin and bpa values from
the fits header.
Returns:
- Beam parameters, (semimajor, semiminor, position angle)
in (pixels, pixels, radians)
| Read and return the beam properties bmaj, bmin and bpa values from
the fits header. | def parse_beam(self):
"""Read and return the beam properties bmaj, bmin and bpa values from
the fits header.
Returns:
- Beam parameters, (semimajor, semiminor, position angle)
in (pixels, pixels, radians)
"""
# AIPS FITS file; stored in the history section
... | [
"def",
"parse_beam",
"(",
"self",
")",
":",
"# AIPS FITS file; stored in the history section",
"beam_regex",
"=",
"re",
".",
"compile",
"(",
"r'''\n BMAJ\n \\s*=\\s*\n (?P<bmaj>[-\\d\\.eE]+)\n \\s*\n BMIN\n \\s*=\\s*\n ... | [
154,
4
] | [
199,
30
] | python | en | ['en', 'en', 'en'] | True |
FitsImage.parse_times | (self) | Returns:
- taustart_ts: tz naive (implicit UTC) datetime at start of observation.
- tau_time: Integration time, in seconds
| Returns:
- taustart_ts: tz naive (implicit UTC) datetime at start of observation.
- tau_time: Integration time, in seconds
| def parse_times(self):
"""Returns:
- taustart_ts: tz naive (implicit UTC) datetime at start of observation.
- tau_time: Integration time, in seconds
"""
# Attempt to do something sane with timestamps.
try:
start = self.parse_start_time()
except Key... | [
"def",
"parse_times",
"(",
"self",
")",
":",
"# Attempt to do something sane with timestamps.",
"try",
":",
"start",
"=",
"self",
".",
"parse_start_time",
"(",
")",
"except",
"KeyError",
":",
"#If no start time specified, give up:",
"logger",
".",
"warn",
"(",
"\"Time... | [
202,
4
] | [
235,
34
] | python | en | ['en', 'la', 'en'] | False |
FitsImage.parse_start_time | (self) |
Returns:
- start time of image as an instance of ``datetime.datetime``
|
Returns:
- start time of image as an instance of ``datetime.datetime``
| def parse_start_time(self):
"""
Returns:
- start time of image as an instance of ``datetime.datetime``
"""
header = self.header
try:
start = dateutil.parser.parse(header['date-obs'])
except AttributeError:
# Maybe it's a float, Westerbork... | [
"def",
"parse_start_time",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"header",
"try",
":",
"start",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"header",
"[",
"'date-obs'",
"]",
")",
"except",
"AttributeError",
":",
"# Maybe it's a float, Wes... | [
238,
4
] | [
256,
20
] | python | en | ['en', 'error', 'th'] | False |
prevent_search | (relation) |
Used to mark a model field or relation as "restricted from filtering"
e.g.,
class AuthToken(BaseModel):
user = prevent_search(models.ForeignKey(...))
sensitive_data = prevent_search(models.CharField(...))
The flag set by this function is used by
`awx.api.filters.FieldLookupBackend... |
Used to mark a model field or relation as "restricted from filtering"
e.g., | def prevent_search(relation):
"""
Used to mark a model field or relation as "restricted from filtering"
e.g.,
class AuthToken(BaseModel):
user = prevent_search(models.ForeignKey(...))
sensitive_data = prevent_search(models.CharField(...))
The flag set by this function is used by
... | [
"def",
"prevent_search",
"(",
"relation",
")",
":",
"setattr",
"(",
"relation",
",",
"'__prevent_search__'",
",",
"True",
")",
"return",
"relation"
] | [
390,
0
] | [
404,
19
] | python | en | ['en', 'error', 'th'] | False |
accepts_json | (relation) |
Used to mark a model field as allowing JSON e.g,. JobTemplate.extra_vars
This is *mostly* used as a way to provide type hints for certain fields
so that HTTP OPTIONS reports the type data we need for the CLI to allow
JSON/YAML input.
|
Used to mark a model field as allowing JSON e.g,. JobTemplate.extra_vars
This is *mostly* used as a way to provide type hints for certain fields
so that HTTP OPTIONS reports the type data we need for the CLI to allow
JSON/YAML input.
| def accepts_json(relation):
"""
Used to mark a model field as allowing JSON e.g,. JobTemplate.extra_vars
This is *mostly* used as a way to provide type hints for certain fields
so that HTTP OPTIONS reports the type data we need for the CLI to allow
JSON/YAML input.
"""
setattr(relation, '__a... | [
"def",
"accepts_json",
"(",
"relation",
")",
":",
"setattr",
"(",
"relation",
",",
"'__accepts_json__'",
",",
"True",
")",
"return",
"relation"
] | [
407,
0
] | [
415,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseModel.clean_fields | (self, exclude=None) |
Override default clean_fields to support methods for cleaning
individual model fields.
|
Override default clean_fields to support methods for cleaning
individual model fields.
| def clean_fields(self, exclude=None):
"""
Override default clean_fields to support methods for cleaning
individual model fields.
"""
exclude = exclude or []
errors = {}
try:
super(BaseModel, self).clean_fields(exclude)
except ValidationError as... | [
"def",
"clean_fields",
"(",
"self",
",",
"exclude",
"=",
"None",
")",
":",
"exclude",
"=",
"exclude",
"or",
"[",
"]",
"errors",
"=",
"{",
"}",
"try",
":",
"super",
"(",
"BaseModel",
",",
"self",
")",
".",
"clean_fields",
"(",
"exclude",
")",
"except"... | [
112,
4
] | [
132,
41
] | python | en | ['en', 'error', 'th'] | False |
mad_scaling | (signal) |
Scale a signal using median absolute deviation method
|
Scale a signal using median absolute deviation method
| def mad_scaling(signal):
'''
Scale a signal using median absolute deviation method
'''
shift = np.median(signal)
scale = np.median(np.abs(signal - shift))
return (signal - shift) / scale | [
"def",
"mad_scaling",
"(",
"signal",
")",
":",
"shift",
"=",
"np",
".",
"median",
"(",
"signal",
")",
"scale",
"=",
"np",
".",
"median",
"(",
"np",
".",
"abs",
"(",
"signal",
"-",
"shift",
")",
")",
"return",
"(",
"signal",
"-",
"shift",
")",
"/"... | [
8,
0
] | [
14,
35
] | python | en | ['en', 'error', 'th'] | False |
get_fast5_fiveprime | (read_id, fast5_fns, signal_size, include_internal=False) |
Open fast5 file and return final signal_size measurements
(corresponding to 5' end of an RNA signal). Signals
are MAD scaled before the end is cropped.
|
Open fast5 file and return final signal_size measurements
(corresponding to 5' end of an RNA signal). Signals
are MAD scaled before the end is cropped.
| def get_fast5_fiveprime(read_id, fast5_fns, signal_size, include_internal=False):
'''
Open fast5 file and return final signal_size measurements
(corresponding to 5' end of an RNA signal). Signals
are MAD scaled before the end is cropped.
'''
for fast5_fn in fast5_fns:
with MultiFast5File... | [
"def",
"get_fast5_fiveprime",
"(",
"read_id",
",",
"fast5_fns",
",",
"signal_size",
",",
"include_internal",
"=",
"False",
")",
":",
"for",
"fast5_fn",
"in",
"fast5_fns",
":",
"with",
"MultiFast5File",
"(",
"fast5_fn",
")",
"as",
"f5",
":",
"try",
":",
"read... | [
34,
0
] | [
61,
38
] | python | en | ['en', 'error', 'th'] | False |
add_noise | (mean, stdv) |
Add normally distributed noise to a signal (useful for data augmentation during training)
|
Add normally distributed noise to a signal (useful for data augmentation during training)
| def add_noise(mean, stdv):
'''
Add normally distributed noise to a signal (useful for data augmentation during training)
'''
mean = mean + np.random.normal(loc=0, scale=stdv, size=mean.shape)
return mean | [
"def",
"add_noise",
"(",
"mean",
",",
"stdv",
")",
":",
"mean",
"=",
"mean",
"+",
"np",
".",
"random",
".",
"normal",
"(",
"loc",
"=",
"0",
",",
"scale",
"=",
"stdv",
",",
"size",
"=",
"mean",
".",
"shape",
")",
"return",
"mean"
] | [
64,
0
] | [
69,
15
] | python | en | ['en', 'error', 'th'] | False |
get_noise_signal | (signal_size, random_type=None) |
copied from DeepBinner balance module, creates one of four types of totally random
negative signal for training.
|
copied from DeepBinner balance module, creates one of four types of totally random
negative signal for training.
| def get_noise_signal(signal_size, random_type=None):
'''
copied from DeepBinner balance module, creates one of four types of totally random
negative signal for training.
'''
if random_type is None:
random_type = random.choice(['flat', 'gaussian', 'multi_gaussian', 'perlin'])
signal = []
... | [
"def",
"get_noise_signal",
"(",
"signal_size",
",",
"random_type",
"=",
"None",
")",
":",
"if",
"random_type",
"is",
"None",
":",
"random_type",
"=",
"random",
".",
"choice",
"(",
"[",
"'flat'",
",",
"'gaussian'",
",",
"'multi_gaussian'",
",",
"'perlin'",
"]... | [
72,
0
] | [
106,
56
] | python | en | ['en', 'error', 'th'] | False |
random_bincount_arr | (size, arr_sum, replace=False) |
Creates an integer array with duplications and deletions
which can be used to augment training data.
|
Creates an integer array with duplications and deletions
which can be used to augment training data.
| def random_bincount_arr(size, arr_sum, replace=False):
'''
Creates an integer array with duplications and deletions
which can be used to augment training data.
'''
while True:
# something is dodgy with threading and np.random.choice
idx = np.arange(int(size), dtype='i')
idx =... | [
"def",
"random_bincount_arr",
"(",
"size",
",",
"arr_sum",
",",
"replace",
"=",
"False",
")",
":",
"while",
"True",
":",
"# something is dodgy with threading and np.random.choice",
"idx",
"=",
"np",
".",
"arange",
"(",
"int",
"(",
"size",
")",
",",
"dtype",
"=... | [
109,
0
] | [
120,
48
] | python | en | ['en', 'error', 'th'] | False |
random_dup_del | (signal, min_frac=0, max_frac=0.33) |
Augment training data by duplicating some signal points and deleting others.
Should help prevent overfitting of training data
|
Augment training data by duplicating some signal points and deleting others.
Should help prevent overfitting of training data
| def random_dup_del(signal, min_frac=0, max_frac=0.33):
'''
Augment training data by duplicating some signal points and deleting others.
Should help prevent overfitting of training data
'''
signal = signal.squeeze()
sig_len = len(signal)
frac = np.random.uniform(min_frac, max_frac)
n_dups... | [
"def",
"random_dup_del",
"(",
"signal",
",",
"min_frac",
"=",
"0",
",",
"max_frac",
"=",
"0.33",
")",
":",
"signal",
"=",
"signal",
".",
"squeeze",
"(",
")",
"sig_len",
"=",
"len",
"(",
"signal",
")",
"frac",
"=",
"np",
".",
"random",
".",
"uniform",... | [
123,
0
] | [
137,
17
] | python | en | ['en', 'error', 'th'] | False |
HtmlTreeBranch.staircase_text | (self) |
produces representation of a node in staircase-like format:
html
body.main-section
p#intro
|
produces representation of a node in staircase-like format: | def staircase_text(self) -> str:
"""
produces representation of a node in staircase-like format:
html
body.main-section
p#intro
"""
res = "\n"
indent = " " * 4
for t in self.tags:
res += indent + t.text() + "\n... | [
"def",
"staircase_text",
"(",
"self",
")",
"->",
"str",
":",
"res",
"=",
"\"\\n\"",
"indent",
"=",
"\" \"",
"*",
"4",
"for",
"t",
"in",
"self",
".",
"tags",
":",
"res",
"+=",
"indent",
"+",
"t",
".",
"text",
"(",
")",
"+",
"\"\\n\"",
"indent",
"+... | [
29,
4
] | [
43,
18
] | python | en | ['en', 'error', 'th'] | False |
HtmlTreeBranch.text | (self) |
produces one-line representation of branch:
html body.main-section p#intro
|
produces one-line representation of branch: | def text(self) -> str:
"""
produces one-line representation of branch:
html body.main-section p#intro
"""
return " ".join(t.text() for t in self.tags) | [
"def",
"text",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\" \"",
".",
"join",
"(",
"t",
".",
"text",
"(",
")",
"for",
"t",
"in",
"self",
".",
"tags",
")"
] | [
45,
4
] | [
51,
52
] | python | en | ['en', 'error', 'th'] | False |
migrate_from | (
old_root: Path,
new_root: Path,
manifest: List[str],
do_not_migrate_settings: List[str],
) |
Copy all the files in "manifest" to the new config directory.
|
Copy all the files in "manifest" to the new config directory.
| def migrate_from(
old_root: Path,
new_root: Path,
manifest: List[str],
do_not_migrate_settings: List[str],
):
"""
Copy all the files in "manifest" to the new config directory.
"""
if old_root == new_root:
print("same as new path, exiting")
return 1
if not old_root.is_... | [
"def",
"migrate_from",
"(",
"old_root",
":",
"Path",
",",
"new_root",
":",
"Path",
",",
"manifest",
":",
"List",
"[",
"str",
"]",
",",
"do_not_migrate_settings",
":",
"List",
"[",
"str",
"]",
",",
")",
":",
"if",
"old_root",
"==",
"new_root",
":",
"pri... | [
120,
0
] | [
154,
12
] | python | en | ['en', 'error', 'th'] | False |
GISLookup._check_geo_field | (cls, opts, lookup) |
Utility for checking the given lookup with the given model options.
The lookup is a string either specifying the geographic field, e.g.
'point, 'the_geom', or a related lookup on a geographic field like
'address__point'.
If a BaseSpatialField exists according to the given looku... |
Utility for checking the given lookup with the given model options.
The lookup is a string either specifying the geographic field, e.g.
'point, 'the_geom', or a related lookup on a geographic field like
'address__point'. | def _check_geo_field(cls, opts, lookup):
"""
Utility for checking the given lookup with the given model options.
The lookup is a string either specifying the geographic field, e.g.
'point, 'the_geom', or a related lookup on a geographic field like
'address__point'.
If a ... | [
"def",
"_check_geo_field",
"(",
"cls",
",",
"opts",
",",
"lookup",
")",
":",
"from",
"django",
".",
"contrib",
".",
"gis",
".",
"db",
".",
"models",
".",
"fields",
"import",
"BaseSpatialField",
"# This takes into account the situation where the lookup is a",
"# look... | [
31,
4
] | [
68,
24
] | python | en | ['en', 'error', 'th'] | False |
GISLookup.process_band_indices | (self, only_lhs=False) |
Extract the lhs band index from the band transform class and the rhs
band index from the input tuple.
|
Extract the lhs band index from the band transform class and the rhs
band index from the input tuple.
| def process_band_indices(self, only_lhs=False):
"""
Extract the lhs band index from the band transform class and the rhs
band index from the input tuple.
"""
# PostGIS band indices are 1-based, so the band index needs to be
# increased to be consistent with the GDALRaster... | [
"def",
"process_band_indices",
"(",
"self",
",",
"only_lhs",
"=",
"False",
")",
":",
"# PostGIS band indices are 1-based, so the band index needs to be",
"# increased to be consistent with the GDALRaster band indices.",
"if",
"only_lhs",
":",
"self",
".",
"band_rhs",
"=",
"1",
... | [
70,
4
] | [
91,
53
] | python | en | ['en', 'error', 'th'] | False |
Block.set_meta_options | (self, opts) |
Update this block's meta options (out of the ones designated as mutable) from the given dict.
Used by the StreamField constructor to pass on kwargs that are to be handled by the block,
since the block object has already been created by that point, e.g.:
body = StreamField(SomeStreamBloc... |
Update this block's meta options (out of the ones designated as mutable) from the given dict.
Used by the StreamField constructor to pass on kwargs that are to be handled by the block,
since the block object has already been created by that point, e.g.:
body = StreamField(SomeStreamBloc... | def set_meta_options(self, opts):
"""
Update this block's meta options (out of the ones designated as mutable) from the given dict.
Used by the StreamField constructor to pass on kwargs that are to be handled by the block,
since the block object has already been created by that point, e.... | [
"def",
"set_meta_options",
"(",
"self",
",",
"opts",
")",
":",
"for",
"attr",
",",
"value",
"in",
"opts",
".",
"items",
"(",
")",
":",
"if",
"attr",
"in",
"self",
".",
"MUTABLE_META_ATTRIBUTES",
":",
"setattr",
"(",
"self",
".",
"meta",
",",
"attr",
... | [
94,
4
] | [
105,
89
] | python | en | ['en', 'error', 'th'] | False |
Block.value_omitted_from_data | (self, data, files, name) |
Used only for top-level blocks wrapped by BlockWidget (i.e.: typically only StreamBlock)
to inform ModelForm logic on Django >=1.10.2 whether the field is absent from the form
submission (and should therefore revert to the field default).
|
Used only for top-level blocks wrapped by BlockWidget (i.e.: typically only StreamBlock)
to inform ModelForm logic on Django >=1.10.2 whether the field is absent from the form
submission (and should therefore revert to the field default).
| def value_omitted_from_data(self, data, files, name):
"""
Used only for top-level blocks wrapped by BlockWidget (i.e.: typically only StreamBlock)
to inform ModelForm logic on Django >=1.10.2 whether the field is absent from the form
submission (and should therefore revert to the field d... | [
"def",
"value_omitted_from_data",
"(",
"self",
",",
"data",
",",
"files",
",",
"name",
")",
":",
"return",
"name",
"not",
"in",
"data"
] | [
110,
4
] | [
116,
31
] | python | en | ['en', 'error', 'th'] | False |
Block.bind | (self, value, prefix=None, errors=None) |
Return a BoundBlock which represents the association of this block definition with a value
and a prefix (and optionally, a ValidationError to be rendered).
BoundBlock primarily exists as a convenience to allow rendering within templates:
bound_block.render() rather than blockdef.render(... |
Return a BoundBlock which represents the association of this block definition with a value
and a prefix (and optionally, a ValidationError to be rendered).
BoundBlock primarily exists as a convenience to allow rendering within templates:
bound_block.render() rather than blockdef.render(... | def bind(self, value, prefix=None, errors=None):
"""
Return a BoundBlock which represents the association of this block definition with a value
and a prefix (and optionally, a ValidationError to be rendered).
BoundBlock primarily exists as a convenience to allow rendering within template... | [
"def",
"bind",
"(",
"self",
",",
"value",
",",
"prefix",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"return",
"BoundBlock",
"(",
"self",
",",
"value",
",",
"prefix",
"=",
"prefix",
",",
"errors",
"=",
"errors",
")"
] | [
118,
4
] | [
126,
68
] | python | en | ['en', 'error', 'th'] | False |
Block.get_default | (self) |
Return this block's default value (conventionally found in self.meta.default),
converted to the value type expected by this block. This caters for the case
where that value type is not something that can be expressed statically at
model definition type (e.g. something like StructValue w... |
Return this block's default value (conventionally found in self.meta.default),
converted to the value type expected by this block. This caters for the case
where that value type is not something that can be expressed statically at
model definition type (e.g. something like StructValue w... | def get_default(self):
"""
Return this block's default value (conventionally found in self.meta.default),
converted to the value type expected by this block. This caters for the case
where that value type is not something that can be expressed statically at
model definition type ... | [
"def",
"get_default",
"(",
"self",
")",
":",
"return",
"self",
".",
"meta",
".",
"default"
] | [
128,
4
] | [
136,
32
] | python | en | ['en', 'error', 'th'] | False |
Block.clean | (self, value) |
Validate value and return a cleaned version of it, or throw a ValidationError if validation fails.
The thrown ValidationError instance will subsequently be passed to render() to display the
error message; the ValidationError must therefore include all detail necessary to perform that
re... |
Validate value and return a cleaned version of it, or throw a ValidationError if validation fails.
The thrown ValidationError instance will subsequently be passed to render() to display the
error message; the ValidationError must therefore include all detail necessary to perform that
re... | def clean(self, value):
"""
Validate value and return a cleaned version of it, or throw a ValidationError if validation fails.
The thrown ValidationError instance will subsequently be passed to render() to display the
error message; the ValidationError must therefore include all detail n... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
138,
4
] | [
147,
20
] | python | en | ['en', 'error', 'th'] | False |
Block.to_python | (self, value) |
Convert 'value' from a simple (JSON-serialisable) value to a (possibly complex) Python value to be
used in the rest of the block API and within front-end templates . In simple cases this might be
the value itself; alternatively, it might be a 'smart' version of the value which behaves mostly
... |
Convert 'value' from a simple (JSON-serialisable) value to a (possibly complex) Python value to be
used in the rest of the block API and within front-end templates . In simple cases this might be
the value itself; alternatively, it might be a 'smart' version of the value which behaves mostly
... | def to_python(self, value):
"""
Convert 'value' from a simple (JSON-serialisable) value to a (possibly complex) Python value to be
used in the rest of the block API and within front-end templates . In simple cases this might be
the value itself; alternatively, it might be a 'smart' versi... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
149,
4
] | [
158,
20
] | python | en | ['en', 'error', 'th'] | False |
Block.bulk_to_python | (self, values) |
Apply the to_python conversion to a list of values. The default implementation simply
iterates over the list; subclasses may optimise this, e.g. by combining database lookups
into a single query.
|
Apply the to_python conversion to a list of values. The default implementation simply
iterates over the list; subclasses may optimise this, e.g. by combining database lookups
into a single query.
| def bulk_to_python(self, values):
"""
Apply the to_python conversion to a list of values. The default implementation simply
iterates over the list; subclasses may optimise this, e.g. by combining database lookups
into a single query.
"""
return [self.to_python(value) for ... | [
"def",
"bulk_to_python",
"(",
"self",
",",
"values",
")",
":",
"return",
"[",
"self",
".",
"to_python",
"(",
"value",
")",
"for",
"value",
"in",
"values",
"]"
] | [
160,
4
] | [
166,
58
] | python | en | ['en', 'error', 'th'] | False |
Block.get_prep_value | (self, value) |
The reverse of to_python; convert the python value into JSON-serialisable form.
|
The reverse of to_python; convert the python value into JSON-serialisable form.
| def get_prep_value(self, value):
"""
The reverse of to_python; convert the python value into JSON-serialisable form.
"""
return value | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
168,
4
] | [
172,
20
] | python | en | ['en', 'error', 'th'] | False |
Block.get_form_state | (self, value) |
Convert a python value for this block into a JSON-serialisable representation containing
all the data needed to present the value in a form field, to be received by the block's
client-side component. Examples of where this conversion is not trivial include rich text
(where it needs to b... |
Convert a python value for this block into a JSON-serialisable representation containing
all the data needed to present the value in a form field, to be received by the block's
client-side component. Examples of where this conversion is not trivial include rich text
(where it needs to b... | def get_form_state(self, value):
"""
Convert a python value for this block into a JSON-serialisable representation containing
all the data needed to present the value in a form field, to be received by the block's
client-side component. Examples of where this conversion is not trivial in... | [
"def",
"get_form_state",
"(",
"self",
",",
"value",
")",
":",
"return",
"value"
] | [
174,
4
] | [
183,
20
] | python | en | ['en', 'error', 'th'] | False |
Block.get_context | (self, value, parent_context=None) |
Return a dict of context variables (derived from the block value and combined with the parent_context)
to be used as the template context when rendering this value through a template.
|
Return a dict of context variables (derived from the block value and combined with the parent_context)
to be used as the template context when rendering this value through a template.
| def get_context(self, value, parent_context=None):
"""
Return a dict of context variables (derived from the block value and combined with the parent_context)
to be used as the template context when rendering this value through a template.
"""
context = parent_context or {}
... | [
"def",
"get_context",
"(",
"self",
",",
"value",
",",
"parent_context",
"=",
"None",
")",
":",
"context",
"=",
"parent_context",
"or",
"{",
"}",
"context",
".",
"update",
"(",
"{",
"'self'",
":",
"value",
",",
"self",
".",
"TEMPLATE_VAR",
":",
"value",
... | [
185,
4
] | [
196,
22
] | python | en | ['en', 'error', 'th'] | False |
Block.get_template | (self, context=None) |
Return the template to use for rendering the block if specified on meta class.
This extraction was added to make dynamic templates possible if you override this method
|
Return the template to use for rendering the block if specified on meta class.
This extraction was added to make dynamic templates possible if you override this method
| def get_template(self, context=None):
"""
Return the template to use for rendering the block if specified on meta class.
This extraction was added to make dynamic templates possible if you override this method
"""
return getattr(self.meta, 'template', None) | [
"def",
"get_template",
"(",
"self",
",",
"context",
"=",
"None",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"meta",
",",
"'template'",
",",
"None",
")"
] | [
198,
4
] | [
203,
51
] | python | en | ['en', 'error', 'th'] | False |
Block.render | (self, value, context=None) |
Return a text rendering of 'value', suitable for display on templates. By default, this will
use a template (with the passed context, supplemented by the result of get_context) if a
'template' property is specified on the block, and fall back on render_basic otherwise.
|
Return a text rendering of 'value', suitable for display on templates. By default, this will
use a template (with the passed context, supplemented by the result of get_context) if a
'template' property is specified on the block, and fall back on render_basic otherwise.
| def render(self, value, context=None):
"""
Return a text rendering of 'value', suitable for display on templates. By default, this will
use a template (with the passed context, supplemented by the result of get_context) if a
'template' property is specified on the block, and fall back on... | [
"def",
"render",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"template",
"=",
"self",
".",
"get_template",
"(",
"context",
"=",
"context",
")",
"if",
"not",
"template",
":",
"return",
"self",
".",
"render_basic",
"(",
"value",
","... | [
205,
4
] | [
220,
65
] | python | en | ['en', 'error', 'th'] | False |
Block.get_api_representation | (self, value, context=None) |
Can be used to customise the API response and defaults to the value returned by get_prep_value.
|
Can be used to customise the API response and defaults to the value returned by get_prep_value.
| def get_api_representation(self, value, context=None):
"""
Can be used to customise the API response and defaults to the value returned by get_prep_value.
"""
return self.get_prep_value(value) | [
"def",
"get_api_representation",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"return",
"self",
".",
"get_prep_value",
"(",
"value",
")"
] | [
222,
4
] | [
226,
41
] | python | en | ['en', 'error', 'th'] | False |
Block.render_basic | (self, value, context=None) |
Return a text rendering of 'value', suitable for display on templates. render() will fall back on
this if the block does not define a 'template' property.
|
Return a text rendering of 'value', suitable for display on templates. render() will fall back on
this if the block does not define a 'template' property.
| def render_basic(self, value, context=None):
"""
Return a text rendering of 'value', suitable for display on templates. render() will fall back on
this if the block does not define a 'template' property.
"""
return force_str(value) | [
"def",
"render_basic",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"return",
"force_str",
"(",
"value",
")"
] | [
228,
4
] | [
233,
31
] | python | en | ['en', 'error', 'th'] | False |
Block.get_searchable_content | (self, value) |
Returns a list of strings containing text content within this block to be used in a search engine.
|
Returns a list of strings containing text content within this block to be used in a search engine.
| def get_searchable_content(self, value):
"""
Returns a list of strings containing text content within this block to be used in a search engine.
"""
return [] | [
"def",
"get_searchable_content",
"(",
"self",
",",
"value",
")",
":",
"return",
"[",
"]"
] | [
235,
4
] | [
239,
17
] | python | en | ['en', 'error', 'th'] | False |
Block.check | (self, **kwargs) |
Hook for the Django system checks framework -
returns a list of django.core.checks.Error objects indicating validity errors in the block
|
Hook for the Django system checks framework -
returns a list of django.core.checks.Error objects indicating validity errors in the block
| def check(self, **kwargs):
"""
Hook for the Django system checks framework -
returns a list of django.core.checks.Error objects indicating validity errors in the block
"""
return [] | [
"def",
"check",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"]"
] | [
241,
4
] | [
246,
17
] | python | en | ['en', 'error', 'th'] | False |
Block._check_name | (self, **kwargs) |
Helper method called by container blocks as part of the system checks framework,
to validate that this block's name is a valid identifier.
(Not called universally, because not all blocks need names)
|
Helper method called by container blocks as part of the system checks framework,
to validate that this block's name is a valid identifier.
(Not called universally, because not all blocks need names)
| def _check_name(self, **kwargs):
"""
Helper method called by container blocks as part of the system checks framework,
to validate that this block's name is a valid identifier.
(Not called universally, because not all blocks need names)
"""
errors = []
if not self.... | [
"def",
"_check_name",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"name",
":",
"errors",
".",
"append",
"(",
"checks",
".",
"Error",
"(",
"\"Block name %r is invalid\"",
"%",
"self",
".",
"name",
... | [
248,
4
] | [
297,
21
] | python | en | ['en', 'error', 'th'] | False |
Block.id_for_label | (self, prefix) |
Return the ID to be used as the 'for' attribute of <label> elements that refer to this block,
when the given field prefix is in use. Return None if no 'for' attribute should be used.
|
Return the ID to be used as the 'for' attribute of <label> elements that refer to this block,
when the given field prefix is in use. Return None if no 'for' attribute should be used.
| def id_for_label(self, prefix):
"""
Return the ID to be used as the 'for' attribute of <label> elements that refer to this block,
when the given field prefix is in use. Return None if no 'for' attribute should be used.
"""
return None | [
"def",
"id_for_label",
"(",
"self",
",",
"prefix",
")",
":",
"return",
"None"
] | [
299,
4
] | [
304,
19
] | python | en | ['en', 'error', 'th'] | False |
Block.required | (self) |
Flag used to determine whether labels for this block should display a 'required' asterisk.
False by default, since Block does not provide any validation of its own - it's up to subclasses
to define what required-ness means.
|
Flag used to determine whether labels for this block should display a 'required' asterisk.
False by default, since Block does not provide any validation of its own - it's up to subclasses
to define what required-ness means.
| def required(self):
"""
Flag used to determine whether labels for this block should display a 'required' asterisk.
False by default, since Block does not provide any validation of its own - it's up to subclasses
to define what required-ness means.
"""
return False | [
"def",
"required",
"(",
"self",
")",
":",
"return",
"False"
] | [
307,
4
] | [
313,
20
] | python | en | ['en', 'error', 'th'] | False |
Block.__eq__ | (self, other) |
Implement equality on block objects so that two blocks with matching definitions are considered
equal. Block objects are intended to be immutable with the exception of set_name() and any meta
attributes identified in MUTABLE_META_ATTRIBUTES, so checking these along with the result of
de... |
Implement equality on block objects so that two blocks with matching definitions are considered
equal. Block objects are intended to be immutable with the exception of set_name() and any meta
attributes identified in MUTABLE_META_ATTRIBUTES, so checking these along with the result of
de... | def __eq__(self, other):
"""
Implement equality on block objects so that two blocks with matching definitions are considered
equal. Block objects are intended to be immutable with the exception of set_name() and any meta
attributes identified in MUTABLE_META_ATTRIBUTES, so checking these... | [
"def",
"__eq__",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"Block",
")",
":",
"# if the other object isn't a block at all, it clearly isn't equal.",
"return",
"False",
"# Note that we do not require the two blocks to be of the exact sa... | [
343,
4
] | [
397,
9
] | python | en | ['en', 'error', 'th'] | False |
BoundBlock.render_as_block | (self, context=None) |
Alias for render; the include_block tag will specifically check for the presence of a method
with this name. (This is because {% include_block %} is just as likely to be invoked on a bare
value as a BoundBlock. If we looked for a `render` method instead, we'd run the risk of finding
an ... |
Alias for render; the include_block tag will specifically check for the presence of a method
with this name. (This is because {% include_block %} is just as likely to be invoked on a bare
value as a BoundBlock. If we looked for a `render` method instead, we'd run the risk of finding
an ... | def render_as_block(self, context=None):
"""
Alias for render; the include_block tag will specifically check for the presence of a method
with this name. (This is because {% include_block %} is just as likely to be invoked on a bare
value as a BoundBlock. If we looked for a `render` meth... | [
"def",
"render_as_block",
"(",
"self",
",",
"context",
"=",
"None",
")",
":",
"return",
"self",
".",
"block",
".",
"render",
"(",
"self",
".",
"value",
",",
"context",
"=",
"context",
")"
] | [
410,
4
] | [
418,
61
] | python | en | ['en', 'error', 'th'] | False |
BoundBlock.__str__ | (self) | Render the value according to the block's native rendering | Render the value according to the block's native rendering | def __str__(self):
"""Render the value according to the block's native rendering"""
return self.block.render(self.value) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"self",
".",
"block",
".",
"render",
"(",
"self",
".",
"value",
")"
] | [
423,
4
] | [
425,
44
] | python | en | ['en', 'en', 'en'] | True |
Permute.__init__ | (self, n) |
Init a Permute object. Randomly generate a mapping, e.g. [0,1,2] -> [1,0,2]
|
Init a Permute object. Randomly generate a mapping, e.g. [0,1,2] -> [1,0,2]
| def __init__(self, n):
"""
Init a Permute object. Randomly generate a mapping, e.g. [0,1,2] -> [1,0,2]
"""
m = list(range(n))
for end in xrange(n - 1, 0, -1):
r = random.randint(0, end)
tmp = m[end]
m[end] = m[r]
m[r] = tmp
... | [
"def",
"__init__",
"(",
"self",
",",
"n",
")",
":",
"m",
"=",
"list",
"(",
"range",
"(",
"n",
")",
")",
"for",
"end",
"in",
"xrange",
"(",
"n",
"-",
"1",
",",
"0",
",",
"-",
"1",
")",
":",
"r",
"=",
"random",
".",
"randint",
"(",
"0",
","... | [
40,
4
] | [
50,
24
] | python | en | ['en', 'error', 'th'] | False |
Permute.permute | (self, ba) |
Permute the bitarray ba inplace.
|
Permute the bitarray ba inplace.
| def permute(self, ba):
"""
Permute the bitarray ba inplace.
"""
c = ba.copy()
for i in xrange(len(self.mapping)):
ba[i] = c[self.mapping[i]]
return ba | [
"def",
"permute",
"(",
"self",
",",
"ba",
")",
":",
"c",
"=",
"ba",
".",
"copy",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"self",
".",
"mapping",
")",
")",
":",
"ba",
"[",
"i",
"]",
"=",
"c",
"[",
"self",
".",
"mapping",
"[",
... | [
52,
4
] | [
59,
17
] | python | en | ['en', 'error', 'th'] | False |
Permute.revert | (self, ba) |
Reversely permute the bitarray ba inplace.
|
Reversely permute the bitarray ba inplace.
| def revert(self, ba):
"""
Reversely permute the bitarray ba inplace.
"""
c = ba.copy()
for i in xrange(len(self.mapping)):
ba[self.mapping[i]] = c[i]
return ba | [
"def",
"revert",
"(",
"self",
",",
"ba",
")",
":",
"c",
"=",
"ba",
".",
"copy",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"len",
"(",
"self",
".",
"mapping",
")",
")",
":",
"ba",
"[",
"self",
".",
"mapping",
"[",
"i",
"]",
"]",
"=",
"c",
... | [
61,
4
] | [
68,
17
] | python | en | ['en', 'error', 'th'] | False |
Permute.search_revert | (self, bas, ba, beam_size) |
ba: query bitarray
bas: a sorted list of tuples of (permuted bitarray, original bitarray)
return : query bitarray's beam-size neighbours (unpermuted bitarray)
|
ba: query bitarray
bas: a sorted list of tuples of (permuted bitarray, original bitarray)
return : query bitarray's beam-size neighbours (unpermuted bitarray)
| def search_revert(self, bas, ba, beam_size):
"""
ba: query bitarray
bas: a sorted list of tuples of (permuted bitarray, original bitarray)
return : query bitarray's beam-size neighbours (unpermuted bitarray)
"""
pba = ba.copy()
self.permute(pba)
assert(bea... | [
"def",
"search_revert",
"(",
"self",
",",
"bas",
",",
"ba",
",",
"beam_size",
")",
":",
"pba",
"=",
"ba",
".",
"copy",
"(",
")",
"self",
".",
"permute",
"(",
"pba",
")",
"assert",
"(",
"beam_size",
"%",
"2",
"==",
"0",
")",
"half_beam",
"=",
"bea... | [
70,
4
] | [
91,
18
] | python | en | ['en', 'error', 'th'] | False |
Lamb.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... | [
81,
4
] | [
153,
19
] | python | en | ['en', 'en', 'en'] | True |
StaticFilesHandler._should_handle | (self, path) |
Checks if the path should be handled. Ignores the path if:
* the host is provided as part of the base_url
* the request's path isn't under the media path (or equal)
|
Checks if the path should be handled. Ignores the path if: | def _should_handle(self, path):
"""
Checks if the path should be handled. Ignores the path if:
* the host is provided as part of the base_url
* the request's path isn't under the media path (or equal)
"""
return path.startswith(self.base_url[2]) and not self.base_url[1] | [
"def",
"_should_handle",
"(",
"self",
",",
"path",
")",
":",
"return",
"path",
".",
"startswith",
"(",
"self",
".",
"base_url",
"[",
"2",
"]",
")",
"and",
"not",
"self",
".",
"base_url",
"[",
"1",
"]"
] | [
26,
4
] | [
33,
73
] | python | en | ['en', 'error', 'th'] | False |
StaticFilesHandler.file_path | (self, url) |
Returns the relative path to the media file on disk for the given URL.
|
Returns the relative path to the media file on disk for the given URL.
| def file_path(self, url):
"""
Returns the relative path to the media file on disk for the given URL.
"""
relative_url = url[len(self.base_url[2]):]
return url2pathname(relative_url) | [
"def",
"file_path",
"(",
"self",
",",
"url",
")",
":",
"relative_url",
"=",
"url",
"[",
"len",
"(",
"self",
".",
"base_url",
"[",
"2",
"]",
")",
":",
"]",
"return",
"url2pathname",
"(",
"relative_url",
")"
] | [
35,
4
] | [
40,
41
] | python | en | ['en', 'error', 'th'] | False |
StaticFilesHandler.serve | (self, request) |
Actually serves the request path.
|
Actually serves the request path.
| def serve(self, request):
"""
Actually serves the request path.
"""
return serve(request, self.file_path(request.path), insecure=True) | [
"def",
"serve",
"(",
"self",
",",
"request",
")",
":",
"return",
"serve",
"(",
"request",
",",
"self",
".",
"file_path",
"(",
"request",
".",
"path",
")",
",",
"insecure",
"=",
"True",
")"
] | [
42,
4
] | [
46,
74
] | python | en | ['en', 'error', 'th'] | False |
ModelBackend.user_can_authenticate | (self, user) |
Reject users with is_active=False. Custom user models that don't have
that attribute are allowed.
|
Reject users with is_active=False. Custom user models that don't have
that attribute are allowed.
| def user_can_authenticate(self, user):
"""
Reject users with is_active=False. Custom user models that don't have
that attribute are allowed.
"""
is_active = getattr(user, 'is_active', None)
return is_active or is_active is None | [
"def",
"user_can_authenticate",
"(",
"self",
",",
"user",
")",
":",
"is_active",
"=",
"getattr",
"(",
"user",
",",
"'is_active'",
",",
"None",
")",
"return",
"is_active",
"or",
"is_active",
"is",
"None"
] | [
26,
4
] | [
32,
45
] | python | en | ['en', 'error', 'th'] | False |
ModelBackend._get_permissions | (self, user_obj, obj, from_name) |
Returns the permissions of `user_obj` from `from_name`. `from_name` can
be either "group" or "user" to return permissions from
`_get_group_permissions` or `_get_user_permissions` respectively.
|
Returns the permissions of `user_obj` from `from_name`. `from_name` can
be either "group" or "user" to return permissions from
`_get_group_permissions` or `_get_user_permissions` respectively.
| def _get_permissions(self, user_obj, obj, from_name):
"""
Returns the permissions of `user_obj` from `from_name`. `from_name` can
be either "group" or "user" to return permissions from
`_get_group_permissions` or `_get_user_permissions` respectively.
"""
if not user_obj.i... | [
"def",
"_get_permissions",
"(",
"self",
",",
"user_obj",
",",
"obj",
",",
"from_name",
")",
":",
"if",
"not",
"user_obj",
".",
"is_active",
"or",
"user_obj",
".",
"is_anonymous",
"or",
"obj",
"is",
"not",
"None",
":",
"return",
"set",
"(",
")",
"perm_cac... | [
42,
4
] | [
59,
49
] | python | en | ['en', 'error', 'th'] | False |
ModelBackend.get_user_permissions | (self, user_obj, obj=None) |
Returns a set of permission strings the user `user_obj` has from their
`user_permissions`.
|
Returns a set of permission strings the user `user_obj` has from their
`user_permissions`.
| def get_user_permissions(self, user_obj, obj=None):
"""
Returns a set of permission strings the user `user_obj` has from their
`user_permissions`.
"""
return self._get_permissions(user_obj, obj, 'user') | [
"def",
"get_user_permissions",
"(",
"self",
",",
"user_obj",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"_get_permissions",
"(",
"user_obj",
",",
"obj",
",",
"'user'",
")"
] | [
61,
4
] | [
66,
59
] | python | en | ['en', 'error', 'th'] | False |
ModelBackend.get_group_permissions | (self, user_obj, obj=None) |
Returns a set of permission strings the user `user_obj` has from the
groups they belong.
|
Returns a set of permission strings the user `user_obj` has from the
groups they belong.
| def get_group_permissions(self, user_obj, obj=None):
"""
Returns a set of permission strings the user `user_obj` has from the
groups they belong.
"""
return self._get_permissions(user_obj, obj, 'group') | [
"def",
"get_group_permissions",
"(",
"self",
",",
"user_obj",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"_get_permissions",
"(",
"user_obj",
",",
"obj",
",",
"'group'",
")"
] | [
68,
4
] | [
73,
60
] | python | en | ['en', 'error', 'th'] | False |
ModelBackend.has_module_perms | (self, user_obj, app_label) |
Returns True if user_obj has any permissions in the given app_label.
|
Returns True if user_obj has any permissions in the given app_label.
| def has_module_perms(self, user_obj, app_label):
"""
Returns True if user_obj has any permissions in the given app_label.
"""
if not user_obj.is_active:
return False
for perm in self.get_all_permissions(user_obj):
if perm[:perm.index('.')] == app_label:
... | [
"def",
"has_module_perms",
"(",
"self",
",",
"user_obj",
",",
"app_label",
")",
":",
"if",
"not",
"user_obj",
".",
"is_active",
":",
"return",
"False",
"for",
"perm",
"in",
"self",
".",
"get_all_permissions",
"(",
"user_obj",
")",
":",
"if",
"perm",
"[",
... | [
88,
4
] | [
97,
20
] | python | en | ['en', 'error', 'th'] | False |
RemoteUserBackend.authenticate | (self, request, remote_user) |
The username passed as ``remote_user`` is considered trusted. This
method simply returns the ``User`` object with the given username,
creating a new ``User`` object if ``create_unknown_user`` is ``True``.
Returns None if ``create_unknown_user`` is ``False`` and a ``User``
obje... |
The username passed as ``remote_user`` is considered trusted. This
method simply returns the ``User`` object with the given username,
creating a new ``User`` object if ``create_unknown_user`` is ``True``. | def authenticate(self, request, remote_user):
"""
The username passed as ``remote_user`` is considered trusted. This
method simply returns the ``User`` object with the given username,
creating a new ``User`` object if ``create_unknown_user`` is ``True``.
Returns None if ``creat... | [
"def",
"authenticate",
"(",
"self",
",",
"request",
",",
"remote_user",
")",
":",
"if",
"not",
"remote_user",
":",
"return",
"user",
"=",
"None",
"username",
"=",
"self",
".",
"clean_username",
"(",
"remote_user",
")",
"# Note that this could be accomplished in on... | [
127,
4
] | [
155,
65
] | python | en | ['en', 'error', 'th'] | False |
RemoteUserBackend.clean_username | (self, username) |
Performs any cleaning on the "username" prior to using it to get or
create the user object. Returns the cleaned username.
By default, returns the username unchanged.
|
Performs any cleaning on the "username" prior to using it to get or
create the user object. Returns the cleaned username. | def clean_username(self, username):
"""
Performs any cleaning on the "username" prior to using it to get or
create the user object. Returns the cleaned username.
By default, returns the username unchanged.
"""
return username | [
"def",
"clean_username",
"(",
"self",
",",
"username",
")",
":",
"return",
"username"
] | [
157,
4
] | [
164,
23
] | python | en | ['en', 'error', 'th'] | False |
RemoteUserBackend.configure_user | (self, user) |
Configures a user after creation and returns the updated user.
By default, returns the user unmodified.
|
Configures a user after creation and returns the updated user. | def configure_user(self, user):
"""
Configures a user after creation and returns the updated user.
By default, returns the user unmodified.
"""
return user | [
"def",
"configure_user",
"(",
"self",
",",
"user",
")",
":",
"return",
"user"
] | [
166,
4
] | [
172,
19
] | python | en | ['en', 'error', 'th'] | False |
format_email_subject | (email_subject: str) |
Escape CR and LF characters.
|
Escape CR and LF characters.
| def format_email_subject(email_subject: str) -> str:
"""
Escape CR and LF characters.
"""
return email_subject.replace("\n", "\\n").replace("\r", "\\r") | [
"def",
"format_email_subject",
"(",
"email_subject",
":",
"str",
")",
"->",
"str",
":",
"return",
"email_subject",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"\\\\n\"",
")",
".",
"replace",
"(",
"\"\\r\"",
",",
"\"\\\\r\"",
")"
] | [
15,
0
] | [
19,
66
] | python | en | ['en', 'error', 'th'] | False |
Videos._can_paginate | (self) |
Kwargs must include user_id or game_id
:return: If resource can paginate
|
Kwargs must include user_id or game_id
:return: If resource can paginate
| def _can_paginate(self) -> bool:
"""
Kwargs must include user_id or game_id
:return: If resource can paginate
"""
# todo: maybe raise VideosAPIException('A user_id or a game_id must be specified.')
return len([key for key in self._kwargs.keys() if key in ['user_id', 'game... | [
"def",
"_can_paginate",
"(",
"self",
")",
"->",
"bool",
":",
"# todo: maybe raise VideosAPIException('A user_id or a game_id must be specified.')",
"return",
"len",
"(",
"[",
"key",
"for",
"key",
"in",
"self",
".",
"_kwargs",
".",
"keys",
"(",
")",
"if",
"key",
"i... | [
47,
4
] | [
53,
94
] | python | en | ['en', 'error', 'th'] | False |
Videos._cache_videos | (self, videos: List['helix.Video']) |
Custom video cache
Cache individual videos
:param videos: Helix videos
:return: None
|
Custom video cache
Cache individual videos
:param videos: Helix videos
:return: None
| def _cache_videos(self, videos: List['helix.Video']) -> None:
"""
Custom video cache
Cache individual videos
:param videos: Helix videos
:return: None
"""
if self._api.use_cache:
for video in videos:
API.SHARED_CACHE.set(f'{Videos.CACHE... | [
"def",
"_cache_videos",
"(",
"self",
",",
"videos",
":",
"List",
"[",
"'helix.Video'",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"_api",
".",
"use_cache",
":",
"for",
"video",
"in",
"videos",
":",
"API",
".",
"SHARED_CACHE",
".",
"set",
"(",
"f... | [
55,
4
] | [
64,
84
] | python | en | ['en', 'error', 'th'] | False |
Videos._handle_pagination_response | (self, response: dict) |
Custom handling for video pagination
:param response: API response data
:return: Videos
|
Custom handling for video pagination
:param response: API response data
:return: Videos
| def _handle_pagination_response(self, response: dict) -> List['helix.Video']:
"""
Custom handling for video pagination
:param response: API response data
:return: Videos
"""
videos: List['helix.Video'] = [helix.Video(api=self._api, data=video) for video in response['data'... | [
"def",
"_handle_pagination_response",
"(",
"self",
",",
"response",
":",
"dict",
")",
"->",
"List",
"[",
"'helix.Video'",
"]",
":",
"videos",
":",
"List",
"[",
"'helix.Video'",
"]",
"=",
"[",
"helix",
".",
"Video",
"(",
"api",
"=",
"self",
".",
"_api",
... | [
66,
4
] | [
75,
21
] | python | en | ['en', 'error', 'th'] | False |
Videos._next_videos_page | (self, ignore_cache: bool = False) |
Video pagination
:param ignore_cache: Ignore API cache
:return: Videos
|
Video pagination
:param ignore_cache: Ignore API cache
:return: Videos
| def _next_videos_page(self, ignore_cache: bool = False) -> List['helix.Video']:
"""
Video pagination
:param ignore_cache: Ignore API cache
:return: Videos
"""
response: dict = self._next_page(ignore_cache=ignore_cache)
return self._handle_pagination_response(resp... | [
"def",
"_next_videos_page",
"(",
"self",
",",
"ignore_cache",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"'helix.Video'",
"]",
":",
"response",
":",
"dict",
"=",
"self",
".",
"_next_page",
"(",
"ignore_cache",
"=",
"ignore_cache",
")",
"return",
"s... | [
77,
4
] | [
85,
57
] | python | en | ['en', 'error', 'th'] | False |
Videos._cache_download | (self, video_ids: List[int]) |
Fetch data from cache
:param video_ids: Lookup the video ids
:return: Cache hits (video ids)
|
Fetch data from cache
:param video_ids: Lookup the video ids
:return: Cache hits (video ids)
| def _cache_download(self, video_ids: List[int]) -> List[int]:
"""
Fetch data from cache
:param video_ids: Lookup the video ids
:return: Cache hits (video ids)
"""
cache_hits: list = []
for video_id in video_ids:
cache_data: dict = API.SHARED_CACHE.get(... | [
"def",
"_cache_download",
"(",
"self",
",",
"video_ids",
":",
"List",
"[",
"int",
"]",
")",
"->",
"List",
"[",
"int",
"]",
":",
"cache_hits",
":",
"list",
"=",
"[",
"]",
"for",
"video_id",
"in",
"video_ids",
":",
"cache_data",
":",
"dict",
"=",
"API"... | [
87,
4
] | [
100,
25
] | python | en | ['en', 'error', 'th'] | False |
Videos._download_video_ids | (self) |
Download videos by list of video IDs
:return:
|
Download videos by list of video IDs
:return:
| def _download_video_ids(self) -> None:
"""
Download videos by list of video IDs
:return:
"""
# Custom cache lookup
if self._api.use_cache:
cache_hits: List[int] = self._cache_download(self._kwargs['id'])
# Removed cached ids from kwargs
... | [
"def",
"_download_video_ids",
"(",
"self",
")",
"->",
"None",
":",
"# Custom cache lookup",
"if",
"self",
".",
"_api",
".",
"use_cache",
":",
"cache_hits",
":",
"List",
"[",
"int",
"]",
"=",
"self",
".",
"_cache_download",
"(",
"self",
".",
"_kwargs",
"[",... | [
102,
4
] | [
131,
109
] | python | en | ['en', 'error', 'th'] | False |
SWATS.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... | [
85,
4
] | [
198,
19
] | python | en | ['en', 'en', 'en'] | True |
TestSurveySpecValidation.test_use_saved_encrypted_default | (self) |
Save is allowed, the $encrypted$ replacement is done
|
Save is allowed, the $encrypted$ replacement is done
| def test_use_saved_encrypted_default(self):
"""
Save is allowed, the $encrypted$ replacement is done
"""
view = JobTemplateSurveySpec()
old = {
"name": "old survey",
"description": "foobar",
"spec": [
{
"ques... | [
"def",
"test_use_saved_encrypted_default",
"(",
"self",
")",
":",
"view",
"=",
"JobTemplateSurveySpec",
"(",
")",
"old",
"=",
"{",
"\"name\"",
":",
"\"old survey\"",
",",
"\"description\"",
":",
"\"foobar\"",
",",
"\"spec\"",
":",
"[",
"{",
"\"question_description... | [
171,
4
] | [
214,
9
] | python | en | ['en', 'error', 'th'] | False |
TestSurveySpecValidation.test_use_saved_empty_string_default | (self) |
Save is allowed, the $encrypted$ replacement is done with empty string
The empty string value for default is unencrypted,
unlike all other password questions
|
Save is allowed, the $encrypted$ replacement is done with empty string
The empty string value for default is unencrypted,
unlike all other password questions
| def test_use_saved_empty_string_default(self):
"""
Save is allowed, the $encrypted$ replacement is done with empty string
The empty string value for default is unencrypted,
unlike all other password questions
"""
view = JobTemplateSurveySpec()
old = {
... | [
"def",
"test_use_saved_empty_string_default",
"(",
"self",
")",
":",
"view",
"=",
"JobTemplateSurveySpec",
"(",
")",
"old",
"=",
"{",
"\"name\"",
":",
"\"old survey\"",
",",
"\"description\"",
":",
"\"foobar\"",
",",
"\"spec\"",
":",
"[",
"{",
"\"question_descript... | [
216,
4
] | [
260,
9
] | python | en | ['en', 'error', 'th'] | False |
TestSurveySpecValidation.test_survey_spec_element_number_empty_default | (self, _type) | Assert that empty default is allowed for answer. | Assert that empty default is allowed for answer. | def test_survey_spec_element_number_empty_default(self, _type):
"""Assert that empty default is allowed for answer."""
spec = self.spec_from_element({'type': _type, 'default': ''})
r = JobTemplateSurveySpec._validate_spec_data(spec, {})
assert r is None | [
"def",
"test_survey_spec_element_number_empty_default",
"(",
"self",
",",
"_type",
")",
":",
"spec",
"=",
"self",
".",
"spec_from_element",
"(",
"{",
"'type'",
":",
"_type",
",",
"'default'",
":",
"''",
"}",
")",
"r",
"=",
"JobTemplateSurveySpec",
".",
"_valid... | [
312,
4
] | [
316,
24
] | python | en | ['en', 'en', 'en'] | True |
UncertainTestCase.test_castable_to_floating_point | (self) |
float(Uncertain(int(x))) should not raise.
|
float(Uncertain(int(x))) should not raise.
| def test_castable_to_floating_point(self):
"""
float(Uncertain(int(x))) should not raise.
"""
x = Uncertain(int(0), int(0))
self.assertFalse(isinstance(x.value, float))
self.assertFalse(isinstance(x.error, float))
float(x) | [
"def",
"test_castable_to_floating_point",
"(",
"self",
")",
":",
"x",
"=",
"Uncertain",
"(",
"int",
"(",
"0",
")",
",",
"int",
"(",
"0",
")",
")",
"self",
".",
"assertFalse",
"(",
"isinstance",
"(",
"x",
".",
"value",
",",
"float",
")",
")",
"self",
... | [
4,
4
] | [
11,
16
] | python | en | ['en', 'error', 'th'] | False |
CaseInsensitiveDict.lower_items | (self) | Like iteritems(), but with all lowercase keys. | Like iteritems(), but with all lowercase keys. | def lower_items(self):
"""Like iteritems(), but with all lowercase keys."""
return (
(lowerkey, keyval[1])
for (lowerkey, keyval)
in self._store.items()
) | [
"def",
"lower_items",
"(",
"self",
")",
":",
"return",
"(",
"(",
"lowerkey",
",",
"keyval",
"[",
"1",
"]",
")",
"for",
"(",
"lowerkey",
",",
"keyval",
")",
"in",
"self",
".",
"_store",
".",
"items",
"(",
")",
")"
] | [
64,
4
] | [
70,
9
] | python | en | ['en', 'en', 'en'] | True |
inject_into_urllib3 | () |
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
|
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
| def inject_into_urllib3():
"""
Monkey-patch urllib3 with SecureTransport-backed SSL-support.
"""
util.SSLContext = SecureTransportContext
util.ssl_.SSLContext = SecureTransportContext
util.HAS_SNI = HAS_SNI
util.ssl_.HAS_SNI = HAS_SNI
util.IS_SECURETRANSPORT = True
util.ssl_.IS_SECUR... | [
"def",
"inject_into_urllib3",
"(",
")",
":",
"util",
".",
"SSLContext",
"=",
"SecureTransportContext",
"util",
".",
"ssl_",
".",
"SSLContext",
"=",
"SecureTransportContext",
"util",
".",
"HAS_SNI",
"=",
"HAS_SNI",
"util",
".",
"ssl_",
".",
"HAS_SNI",
"=",
"HAS... | [
186,
0
] | [
195,
39
] | python | en | ['en', 'error', 'th'] | False |
extract_from_urllib3 | () |
Undo monkey-patching by :func:`inject_into_urllib3`.
|
Undo monkey-patching by :func:`inject_into_urllib3`.
| def extract_from_urllib3():
"""
Undo monkey-patching by :func:`inject_into_urllib3`.
"""
util.SSLContext = orig_util_SSLContext
util.ssl_.SSLContext = orig_util_SSLContext
util.HAS_SNI = orig_util_HAS_SNI
util.ssl_.HAS_SNI = orig_util_HAS_SNI
util.IS_SECURETRANSPORT = False
util.ssl_... | [
"def",
"extract_from_urllib3",
"(",
")",
":",
"util",
".",
"SSLContext",
"=",
"orig_util_SSLContext",
"util",
".",
"ssl_",
".",
"SSLContext",
"=",
"orig_util_SSLContext",
"util",
".",
"HAS_SNI",
"=",
"orig_util_HAS_SNI",
"util",
".",
"ssl_",
".",
"HAS_SNI",
"=",... | [
198,
0
] | [
207,
40
] | python | en | ['en', 'error', 'th'] | False |
_read_callback | (connection_id, data_buffer, data_length_pointer) |
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
|
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
| def _read_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport read callback. This is called by ST to request that data
be returned from the socket.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_socket is ... | [
"def",
"_read_callback",
"(",
"connection_id",
",",
"data_buffer",
",",
"data_length_pointer",
")",
":",
"wrapped_socket",
"=",
"None",
"try",
":",
"wrapped_socket",
"=",
"_connection_refs",
".",
"get",
"(",
"connection_id",
")",
"if",
"wrapped_socket",
"is",
"Non... | [
210,
0
] | [
262,
43
] | python | en | ['en', 'error', 'th'] | False |
_write_callback | (connection_id, data_buffer, data_length_pointer) |
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
|
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
| def _write_callback(connection_id, data_buffer, data_length_pointer):
"""
SecureTransport write callback. This is called by ST to request that data
actually be sent on the network.
"""
wrapped_socket = None
try:
wrapped_socket = _connection_refs.get(connection_id)
if wrapped_sock... | [
"def",
"_write_callback",
"(",
"connection_id",
",",
"data_buffer",
",",
"data_length_pointer",
")",
":",
"wrapped_socket",
"=",
"None",
"try",
":",
"wrapped_socket",
"=",
"_connection_refs",
".",
"get",
"(",
"connection_id",
")",
"if",
"wrapped_socket",
"is",
"No... | [
265,
0
] | [
313,
43
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket._raise_on_error | (self) |
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those exceptions.
It also correctly force... |
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those exceptions. | def _raise_on_error(self):
"""
A context manager that can be used to wrap calls that do I/O from
SecureTransport. If any of the I/O callbacks hit an exception, this
context manager will correctly propagate the exception after the fact.
This avoids silently swallowing those except... | [
"def",
"_raise_on_error",
"(",
"self",
")",
":",
"self",
".",
"_exception",
"=",
"None",
"# We explicitly don't catch around this yield because in the unlikely",
"# event that an exception was hit in the block we don't want to swallow",
"# it.",
"yield",
"if",
"self",
".",
"_exce... | [
350,
4
] | [
368,
27
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket._set_ciphers | (self) |
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freaking nightmare.
|
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freaking nightmare.
| def _set_ciphers(self):
"""
Sets up the allowed ciphers. By default this matches the set in
util.ssl_.DEFAULT_CIPHERS, at least as supported by macOS. This is done
custom and doesn't allow changing at this time, mostly because parsing
OpenSSL cipher strings is going to be a freak... | [
"def",
"_set_ciphers",
"(",
"self",
")",
":",
"ciphers",
"=",
"(",
"Security",
".",
"SSLCipherSuite",
"*",
"len",
"(",
"CIPHER_SUITES",
")",
")",
"(",
"*",
"CIPHER_SUITES",
")",
"result",
"=",
"Security",
".",
"SSLSetEnabledCiphers",
"(",
"self",
".",
"con... | [
370,
4
] | [
381,
32
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket._set_alpn_protocols | (self, protocols) |
Sets up the ALPN protocols on the context.
|
Sets up the ALPN protocols on the context.
| def _set_alpn_protocols(self, protocols):
"""
Sets up the ALPN protocols on the context.
"""
if not protocols:
return
protocols_arr = _create_cfstring_array(protocols)
try:
result = Security.SSLSetALPNProtocols(self.context, protocols_arr)
... | [
"def",
"_set_alpn_protocols",
"(",
"self",
",",
"protocols",
")",
":",
"if",
"not",
"protocols",
":",
"return",
"protocols_arr",
"=",
"_create_cfstring_array",
"(",
"protocols",
")",
"try",
":",
"result",
"=",
"Security",
".",
"SSLSetALPNProtocols",
"(",
"self",... | [
383,
4
] | [
394,
51
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket._custom_validate | (self, verify, trust_bundle) |
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
Raises an SSLError if the connection is not trusted.
|
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
Raises an SSLError if the connection is not trusted.
| def _custom_validate(self, verify, trust_bundle):
"""
Called when we have set custom validation. We do this in two cases:
first, when cert validation is entirely disabled; and second, when
using a custom trust DB.
Raises an SSLError if the connection is not trusted.
"""
... | [
"def",
"_custom_validate",
"(",
"self",
",",
"verify",
",",
"trust_bundle",
")",
":",
"# If we disabled cert validation, just say: cool.",
"if",
"not",
"verify",
":",
"return",
"successes",
"=",
"(",
"SecurityConst",
".",
"kSecTrustResultUnspecified",
",",
"SecurityCons... | [
396,
4
] | [
429,
68
] | python | en | ['en', 'error', 'th'] | False |
WrappedSocket.handshake | (
self,
server_hostname,
verify,
trust_bundle,
min_version,
max_version,
client_cert,
client_key,
client_key_passphrase,
alpn_protocols,
) |
Actually performs the TLS handshake. This is run automatically by
wrapped socket, and shouldn't be needed in user code.
|
Actually performs the TLS handshake. This is run automatically by
wrapped socket, and shouldn't be needed in user code.
| def handshake(
self,
server_hostname,
verify,
trust_bundle,
min_version,
max_version,
client_cert,
client_key,
client_key_passphrase,
alpn_protocols,
):
"""
Actually performs the TLS handshake. This is run automatically ... | [
"def",
"handshake",
"(",
"self",
",",
"server_hostname",
",",
"verify",
",",
"trust_bundle",
",",
"min_version",
",",
"max_version",
",",
"client_cert",
",",
"client_key",
",",
"client_key_passphrase",
",",
"alpn_protocols",
",",
")",
":",
"# First, we do the initia... | [
471,
4
] | [
562,
25
] | python | en | ['en', 'error', 'th'] | False |
SecureTransportContext.check_hostname | (self) |
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
|
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
| def check_hostname(self):
"""
SecureTransport cannot have its hostname checking disabled. For more,
see the comment on getpeercert() in this file.
"""
return True | [
"def",
"check_hostname",
"(",
"self",
")",
":",
"return",
"True"
] | [
801,
4
] | [
806,
19
] | 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.