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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
sec2days | (seconds) | Seconds to number of days | Seconds to number of days | def sec2days(seconds):
"""Seconds to number of days"""
return seconds / (24.0 * 3600) | [
"def",
"sec2days",
"(",
"seconds",
")",
":",
"return",
"seconds",
"/",
"(",
"24.0",
"*",
"3600",
")"
] | [
159,
0
] | [
161,
34
] | python | en | ['en', 'en', 'en'] | True |
sec2hms | (seconds) | Seconds to hours, minutes, seconds | Seconds to hours, minutes, seconds | def sec2hms(seconds):
"""Seconds to hours, minutes, seconds"""
hours, seconds = divmod(seconds, 60**2)
minutes, seconds = divmod(seconds, 60)
return (int(hours), int(minutes), seconds) | [
"def",
"sec2hms",
"(",
"seconds",
")",
":",
"hours",
",",
"seconds",
"=",
"divmod",
"(",
"seconds",
",",
"60",
"**",
"2",
")",
"minutes",
",",
"seconds",
"=",
"divmod",
"(",
"seconds",
",",
"60",
")",
"return",
"(",
"int",
"(",
"hours",
")",
",",
... | [
164,
0
] | [
168,
46
] | python | en | ['en', 'en', 'en'] | True |
altaz | (mjds, ra, dec, lat=CORE_LAT) | Calculates the azimuth and elevation of source from time and position
on sky. Takes MJD in seconds and ra, dec in degrees. Returns (alt, az) in
degrees. | Calculates the azimuth and elevation of source from time and position
on sky. Takes MJD in seconds and ra, dec in degrees. Returns (alt, az) in
degrees. | def altaz(mjds, ra, dec, lat=CORE_LAT):
"""Calculates the azimuth and elevation of source from time and position
on sky. Takes MJD in seconds and ra, dec in degrees. Returns (alt, az) in
degrees."""
# compute hour angle in degrees
ha = mjds2lst(mjds) - ra
if (ha < 0):
ha = ha + 360
... | [
"def",
"altaz",
"(",
"mjds",
",",
"ra",
",",
"dec",
",",
"lat",
"=",
"CORE_LAT",
")",
":",
"# compute hour angle in degrees",
"ha",
"=",
"mjds2lst",
"(",
"mjds",
")",
"-",
"ra",
"if",
"(",
"ha",
"<",
"0",
")",
":",
"ha",
"=",
"ha",
"+",
"360",
"#... | [
171,
0
] | [
200,
36
] | python | en | ['en', 'en', 'en'] | True |
ratohms | (radegs) | Convert RA in decimal degrees format to hours, minutes,
seconds format.
Keyword arguments:
radegs -- RA in degrees format
Return value:
ra -- tuple of 3 values, [hours,minutes,seconds]
| Convert RA in decimal degrees format to hours, minutes,
seconds format. | def ratohms(radegs):
"""Convert RA in decimal degrees format to hours, minutes,
seconds format.
Keyword arguments:
radegs -- RA in degrees format
Return value:
ra -- tuple of 3 values, [hours,minutes,seconds]
"""
radegs %= 360
raseconds = radegs * 3600 / 15.0
return sec2hms(r... | [
"def",
"ratohms",
"(",
"radegs",
")",
":",
"radegs",
"%=",
"360",
"raseconds",
"=",
"radegs",
"*",
"3600",
"/",
"15.0",
"return",
"sec2hms",
"(",
"raseconds",
")"
] | [
203,
0
] | [
217,
29
] | python | en | ['en', 'en', 'en'] | True |
dectodms | (decdegs) | Convert Declination in decimal degrees format to hours, minutes,
seconds format.
Keyword arguments:
decdegs -- Dec. in degrees format
Return value:
dec -- list of 3 values, [degrees,minutes,seconds]
| Convert Declination in decimal degrees format to hours, minutes,
seconds format. | def dectodms(decdegs):
"""Convert Declination in decimal degrees format to hours, minutes,
seconds format.
Keyword arguments:
decdegs -- Dec. in degrees format
Return value:
dec -- list of 3 values, [degrees,minutes,seconds]
"""
sign = -1 if decdegs < 0 else 1
decdegs = abs(decde... | [
"def",
"dectodms",
"(",
"decdegs",
")",
":",
"sign",
"=",
"-",
"1",
"if",
"decdegs",
"<",
"0",
"else",
"1",
"decdegs",
"=",
"abs",
"(",
"decdegs",
")",
"if",
"decdegs",
">",
"90",
":",
"raise",
"ValueError",
"(",
"\"coordinate out of range\"",
")",
"de... | [
220,
0
] | [
257,
29
] | python | en | ['en', 'en', 'en'] | True |
propagate_sign | (val1, val2, val3) |
casacore (reasonably enough) demands that a minus sign (if required)
comes at the start of the quantity. Thus "-0D30M" rather than "0D-30M".
Python regards "-0" as equal to "0"; we need to split off a separate sign
field.
If more than one of our inputs is negative, it's not clear what the user
... |
casacore (reasonably enough) demands that a minus sign (if required)
comes at the start of the quantity. Thus "-0D30M" rather than "0D-30M".
Python regards "-0" as equal to "0"; we need to split off a separate sign
field. | def propagate_sign(val1, val2, val3):
"""
casacore (reasonably enough) demands that a minus sign (if required)
comes at the start of the quantity. Thus "-0D30M" rather than "0D-30M".
Python regards "-0" as equal to "0"; we need to split off a separate sign
field.
If more than one of our inputs ... | [
"def",
"propagate_sign",
"(",
"val1",
",",
"val2",
",",
"val3",
")",
":",
"signs",
"=",
"[",
"x",
"<",
"0",
"for",
"x",
"in",
"(",
"val1",
",",
"val2",
",",
"val3",
")",
"]",
"if",
"signs",
".",
"count",
"(",
"True",
")",
"==",
"0",
":",
"sig... | [
260,
0
] | [
284,
33
] | python | en | ['en', 'error', 'th'] | False |
hmstora | (rah, ram, ras) | Convert RA in hours, minutes, seconds format to decimal
degrees format.
Keyword arguments:
rah,ram,ras -- RA values (h,m,s)
Return value:
radegs -- RA in decimal degrees
| Convert RA in hours, minutes, seconds format to decimal
degrees format. | def hmstora(rah, ram, ras):
"""Convert RA in hours, minutes, seconds format to decimal
degrees format.
Keyword arguments:
rah,ram,ras -- RA values (h,m,s)
Return value:
radegs -- RA in decimal degrees
"""
sign, rah, ram, ras = propagate_sign(rah, ram, ras)
ra = quantity("%s%dH%dM%... | [
"def",
"hmstora",
"(",
"rah",
",",
"ram",
",",
"ras",
")",
":",
"sign",
",",
"rah",
",",
"ram",
",",
"ras",
"=",
"propagate_sign",
"(",
"rah",
",",
"ram",
",",
"ras",
")",
"ra",
"=",
"quantity",
"(",
"\"%s%dH%dM%f\"",
"%",
"(",
"sign",
",",
"rah"... | [
286,
0
] | [
301,
13
] | python | en | ['en', 'en', 'en'] | True |
dmstodec | (decd, decm, decs) | Convert Dec in degrees, minutes, seconds format to decimal
degrees format.
Keyword arguments:
decd, decm, decs -- list of Dec values (d,m,s)
Return value:
decdegs -- Dec in decimal degrees
| Convert Dec in degrees, minutes, seconds format to decimal
degrees format. | def dmstodec(decd, decm, decs):
"""Convert Dec in degrees, minutes, seconds format to decimal
degrees format.
Keyword arguments:
decd, decm, decs -- list of Dec values (d,m,s)
Return value:
decdegs -- Dec in decimal degrees
"""
sign, decd, decm, decs = propagate_sign(decd, decm, decs)... | [
"def",
"dmstodec",
"(",
"decd",
",",
"decm",
",",
"decs",
")",
":",
"sign",
",",
"decd",
",",
"decm",
",",
"decs",
"=",
"propagate_sign",
"(",
"decd",
",",
"decm",
",",
"decs",
")",
"dec",
"=",
"quantity",
"(",
"\"%s%dD%dM%f\"",
"%",
"(",
"sign",
"... | [
304,
0
] | [
319,
14
] | python | en | ['en', 'ca', 'en'] | True |
angsep | (ra1, dec1, ra2, dec2) | Find the angular separation of two sources, in arcseconds,
using the proper spherical trig formula
Keyword arguments:
ra1,dec1 - RA and Dec of the first source, in decimal degrees
ra2,dec2 - RA and Dec of the second source, in decimal degrees
Return value:
angsep - Angular separation, in arcse... | Find the angular separation of two sources, in arcseconds,
using the proper spherical trig formula | def angsep(ra1, dec1, ra2, dec2):
"""Find the angular separation of two sources, in arcseconds,
using the proper spherical trig formula
Keyword arguments:
ra1,dec1 - RA and Dec of the first source, in decimal degrees
ra2,dec2 - RA and Dec of the second source, in decimal degrees
Return value:
... | [
"def",
"angsep",
"(",
"ra1",
",",
"dec1",
",",
"ra2",
",",
"dec2",
")",
":",
"b",
"=",
"(",
"math",
".",
"pi",
"/",
"2",
")",
"-",
"math",
".",
"radians",
"(",
"dec1",
")",
"c",
"=",
"(",
"math",
".",
"pi",
"/",
"2",
")",
"-",
"math",
"."... | [
322,
0
] | [
345,
47
] | python | en | ['en', 'en', 'en'] | True |
alphasep | (ra1, ra2, dec1, dec2) | Find the angular separation of two sources in RA, in arcseconds
Keyword arguments:
ra1,dec1 - RA and Dec of the first source, in decimal degrees
ra2,dec2 - RA and Dec of the second source, in decimal degrees
Return value:
angsep - Angular separation, in arcseconds
| Find the angular separation of two sources in RA, in arcseconds | def alphasep(ra1, ra2, dec1, dec2):
"""Find the angular separation of two sources in RA, in arcseconds
Keyword arguments:
ra1,dec1 - RA and Dec of the first source, in decimal degrees
ra2,dec2 - RA and Dec of the second source, in decimal degrees
Return value:
angsep - Angular separation, in a... | [
"def",
"alphasep",
"(",
"ra1",
",",
"ra2",
",",
"dec1",
",",
"dec2",
")",
":",
"return",
"3600",
"*",
"(",
"ra1",
"-",
"ra2",
")",
"*",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"(",
"dec1",
"+",
"dec2",
")",
"/",
"2.0",
")",
")"
... | [
348,
0
] | [
360,
75
] | python | en | ['en', 'en', 'en'] | True |
deltasep | (dec1, dec2) | Find the angular separation of two sources in Dec, in arcseconds
Keyword arguments:
dec1 - Dec of the first source, in decimal degrees
dec2 - Dec of the second source, in decimal degrees
Return value:
angsep - Angular separation, in arcseconds
| Find the angular separation of two sources in Dec, in arcseconds | def deltasep(dec1, dec2):
"""Find the angular separation of two sources in Dec, in arcseconds
Keyword arguments:
dec1 - Dec of the first source, in decimal degrees
dec2 - Dec of the second source, in decimal degrees
Return value:
angsep - Angular separation, in arcseconds
"""
return ... | [
"def",
"deltasep",
"(",
"dec1",
",",
"dec2",
")",
":",
"return",
"3600",
"*",
"(",
"dec1",
"-",
"dec2",
")"
] | [
363,
0
] | [
375,
31
] | python | en | ['en', 'en', 'en'] | True |
alpha | (l, m, alpha0, delta0) | Convert a coordinate in l,m into an coordinate in RA
Keyword arguments:
l,m -- direction cosines, given by (offset in cells) x cellsi (radians)
alpha_0, delta_0 -- centre of the field
Return value:
alpha -- RA in decimal degrees
| Convert a coordinate in l,m into an coordinate in RA | def alpha(l, m, alpha0, delta0):
"""Convert a coordinate in l,m into an coordinate in RA
Keyword arguments:
l,m -- direction cosines, given by (offset in cells) x cellsi (radians)
alpha_0, delta_0 -- centre of the field
Return value:
alpha -- RA in decimal degrees
"""
return (alpha0 + ... | [
"def",
"alpha",
"(",
"l",
",",
"m",
",",
"alpha0",
",",
"delta0",
")",
":",
"return",
"(",
"alpha0",
"+",
"(",
"math",
".",
"degrees",
"(",
"math",
".",
"atan2",
"(",
"l",
",",
"(",
"(",
"math",
".",
"sqrt",
"(",
"1",
"-",
"(",
"l",
"*",
"l... | [
379,
0
] | [
391,
49
] | python | en | ['en', 'en', 'it'] | True |
alpha_inflate | (theta, decl) | Compute the ra expansion for a given theta at a given declination
Keyword arguments:
theta, decl are both in decimal degrees.
Return value:
alpha -- RA inflation in decimal degrees
For a derivation, see MSR TR 2006 52, Section 2.1
http://research.microsoft.com/apps/pubs/default.aspx?i... | Compute the ra expansion for a given theta at a given declination
Keyword arguments:
theta, decl are both in decimal degrees.
Return value:
alpha -- RA inflation in decimal degrees | def alpha_inflate(theta, decl):
"""Compute the ra expansion for a given theta at a given declination
Keyword arguments:
theta, decl are both in decimal degrees.
Return value:
alpha -- RA inflation in decimal degrees
For a derivation, see MSR TR 2006 52, Section 2.1
http://research... | [
"def",
"alpha_inflate",
"(",
"theta",
",",
"decl",
")",
":",
"if",
"abs",
"(",
"decl",
")",
"+",
"theta",
">",
"89.9",
":",
"return",
"180.0",
"else",
":",
"return",
"math",
".",
"degrees",
"(",
"abs",
"(",
"math",
".",
"atan",
"(",
"math",
".",
... | [
393,
0
] | [
409,
168
] | python | en | ['en', 'en', 'en'] | True |
delta | (l, m, delta0) | Convert a coordinate in l, m into an coordinate in Dec
Keyword arguments:
l, m -- direction cosines, given by (offset in cells) x cellsi (radians)
alpha_0, delta_0 -- centre of the field
Return value:
delta -- Dec in decimal degrees
| Convert a coordinate in l, m into an coordinate in Dec | def delta(l, m, delta0):
"""Convert a coordinate in l, m into an coordinate in Dec
Keyword arguments:
l, m -- direction cosines, given by (offset in cells) x cellsi (radians)
alpha_0, delta_0 -- centre of the field
Return value:
delta -- Dec in decimal degrees
"""
return math.degrees(m... | [
"def",
"delta",
"(",
"l",
",",
"m",
",",
"delta0",
")",
":",
"return",
"math",
".",
"degrees",
"(",
"math",
".",
"asin",
"(",
"m",
"*",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"delta0",
")",
")",
"+",
"(",
"math",
".",
"sqrt",
"... | [
412,
0
] | [
424,
68
] | python | co | ['en', 'co', 'it'] | False |
l | (ra, dec, cra, incr) | Convert a coordinate in RA,Dec into a direction cosine l
Keyword arguments:
ra,dec -- Source location
cra -- RA centre of the field
incr -- number of degrees per pixel (negative in the case of RA)
Return value:
l -- Direction cosine
| Convert a coordinate in RA,Dec into a direction cosine l | def l(ra, dec, cra, incr):
"""Convert a coordinate in RA,Dec into a direction cosine l
Keyword arguments:
ra,dec -- Source location
cra -- RA centre of the field
incr -- number of degrees per pixel (negative in the case of RA)
Return value:
l -- Direction cosine
"""
return ((math.... | [
"def",
"l",
"(",
"ra",
",",
"dec",
",",
"cra",
",",
"incr",
")",
":",
"return",
"(",
"(",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"dec",
")",
")",
"*",
"math",
".",
"sin",
"(",
"math",
".",
"radians",
"(",
"ra",
"-",
"cra",
")... | [
427,
0
] | [
440,
33
] | python | it | ['it', 'co', 'it'] | True |
m | (ra, dec, cra, cdec, incr) | Convert a coordinate in RA,Dec into a direction cosine m
Keyword arguments:
ra,dec -- Source location
cra,cdec -- centre of the field
incr -- number of degrees per pixel
Return value:
m -- direction cosine
| Convert a coordinate in RA,Dec into a direction cosine m | def m(ra, dec, cra, cdec, incr):
"""Convert a coordinate in RA,Dec into a direction cosine m
Keyword arguments:
ra,dec -- Source location
cra,cdec -- centre of the field
incr -- number of degrees per pixel
Return value:
m -- direction cosine
"""
return ((math.sin(math.radians(dec)... | [
"def",
"m",
"(",
"ra",
",",
"dec",
",",
"cra",
",",
"cdec",
",",
"incr",
")",
":",
"return",
"(",
"(",
"math",
".",
"sin",
"(",
"math",
".",
"radians",
"(",
"dec",
")",
")",
"*",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"cdec",
... | [
443,
0
] | [
457,
66
] | python | co | ['it', 'co', 'en'] | False |
lm_to_radec | (ra0, dec0, l, m) |
Find the l direction cosine in a radio image, given an RA and Dec and the
field centre
|
Find the l direction cosine in a radio image, given an RA and Dec and the
field centre
| def lm_to_radec(ra0, dec0, l, m):
"""
Find the l direction cosine in a radio image, given an RA and Dec and the
field centre
"""
# This function should be the inverse of radec_to_lmn, but it is
# not. There is likely an error here.
sind0 = math.sin(dec0)
cosd0 = math.cos(dec0)
dl = ... | [
"def",
"lm_to_radec",
"(",
"ra0",
",",
"dec0",
",",
"l",
",",
"m",
")",
":",
"# This function should be the inverse of radec_to_lmn, but it is",
"# not. There is likely an error here.",
"sind0",
"=",
"math",
".",
"sin",
"(",
"dec0",
")",
"cosd0",
"=",
"math",
".",
... | [
461,
0
] | [
493,
20
] | python | en | ['en', 'error', 'th'] | False |
eq_to_gal | (ra, dec) | Find the Galactic co-ordinates of a source given the equatorial
co-ordinates
Keyword arguments:
(alpha,delta) -- RA, Dec in decimal degrees
Return value:
(l,b) -- Galactic longitude and latitude, in decimal degrees
| Find the Galactic co-ordinates of a source given the equatorial
co-ordinates | def eq_to_gal(ra, dec):
"""Find the Galactic co-ordinates of a source given the equatorial
co-ordinates
Keyword arguments:
(alpha,delta) -- RA, Dec in decimal degrees
Return value:
(l,b) -- Galactic longitude and latitude, in decimal degrees
"""
dm = measures()
result = dm.measur... | [
"def",
"eq_to_gal",
"(",
"ra",
",",
"dec",
")",
":",
"dm",
"=",
"measures",
"(",
")",
"result",
"=",
"dm",
".",
"measure",
"(",
"dm",
".",
"direction",
"(",
"\"J200\"",
",",
"\"%fdeg\"",
"%",
"ra",
",",
"\"%fdeg\"",
"%",
"dec",
")",
",",
"\"GALACTI... | [
509,
0
] | [
529,
23
] | python | en | ['en', 'en', 'en'] | True |
gal_to_eq | (lon_l, lat_b) | Find the Galactic co-ordinates of a source given the equatorial
co-ordinates
Keyword arguments:
(l, b) -- Galactic longitude and latitude, in decimal degrees
Return value:
(alpha, delta) -- RA, Dec in decimal degrees
| Find the Galactic co-ordinates of a source given the equatorial
co-ordinates | def gal_to_eq(lon_l, lat_b):
"""Find the Galactic co-ordinates of a source given the equatorial
co-ordinates
Keyword arguments:
(l, b) -- Galactic longitude and latitude, in decimal degrees
Return value:
(alpha, delta) -- RA, Dec in decimal degrees
"""
dm = measures()
result = dm... | [
"def",
"gal_to_eq",
"(",
"lon_l",
",",
"lat_b",
")",
":",
"dm",
"=",
"measures",
"(",
")",
"result",
"=",
"dm",
".",
"measure",
"(",
"dm",
".",
"direction",
"(",
"\"GALACTIC\"",
",",
"\"%fdeg\"",
"%",
"lon_l",
",",
"\"%fdeg\"",
"%",
"lat_b",
")",
","... | [
532,
0
] | [
552,
18
] | python | en | ['en', 'en', 'en'] | True |
eq_to_cart | (ra, dec) | Find the cartesian co-ordinates on the unit sphere given the eq. co-ords.
ra, dec should be in degrees.
| Find the cartesian co-ordinates on the unit sphere given the eq. co-ords. | def eq_to_cart(ra, dec):
"""Find the cartesian co-ordinates on the unit sphere given the eq. co-ords.
ra, dec should be in degrees.
"""
return (math.cos(math.radians(dec)) * math.cos(math.radians(ra)), # Cartesian x
math.cos(math.radians(dec)) * math.sin(math.radians(ra)), # Cartesian... | [
"def",
"eq_to_cart",
"(",
"ra",
",",
"dec",
")",
":",
"return",
"(",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"dec",
")",
")",
"*",
"math",
".",
"cos",
"(",
"math",
".",
"radians",
"(",
"ra",
")",
")",
",",
"# Cartesian x",
"math",
... | [
555,
0
] | [
562,
40
] | python | en | ['en', 'en', 'en'] | True |
coordsystem | (name) | Given a string, return a constant from class CoordSystem. | Given a string, return a constant from class CoordSystem. | def coordsystem(name):
"""Given a string, return a constant from class CoordSystem."""
mappings = {
'j2000': CoordSystem.FK5,
'fk5': CoordSystem.FK5,
CoordSystem.FK5.lower(): CoordSystem.FK5,
'b1950': CoordSystem.FK4,
'fk4': CoordSystem.FK4,
CoordSystem.FK4.lower(... | [
"def",
"coordsystem",
"(",
"name",
")",
":",
"mappings",
"=",
"{",
"'j2000'",
":",
"CoordSystem",
".",
"FK5",
",",
"'fk5'",
":",
"CoordSystem",
".",
"FK5",
",",
"CoordSystem",
".",
"FK5",
".",
"lower",
"(",
")",
":",
"CoordSystem",
".",
"FK5",
",",
"... | [
572,
0
] | [
582,
33
] | python | en | ['en', 'en', 'en'] | True |
convert_coordsystem | (ra, dec, insys, outsys) |
Convert RA & dec (given in decimal degrees) between equinoxes.
|
Convert RA & dec (given in decimal degrees) between equinoxes.
| def convert_coordsystem(ra, dec, insys, outsys):
"""
Convert RA & dec (given in decimal degrees) between equinoxes.
"""
dm = measures()
if insys == CoordSystem.FK4:
insys = "B1950"
elif insys == CoordSystem.FK5:
insys = "J2000"
else:
raise Exception("Unknown Coordina... | [
"def",
"convert_coordsystem",
"(",
"ra",
",",
"dec",
",",
"insys",
",",
"outsys",
")",
":",
"dm",
"=",
"measures",
"(",
")",
"if",
"insys",
"==",
"CoordSystem",
".",
"FK4",
":",
"insys",
"=",
"\"B1950\"",
"elif",
"insys",
"==",
"CoordSystem",
".",
"FK5... | [
585,
0
] | [
613,
18
] | python | en | ['en', 'error', 'th'] | False |
WCS.p2s | (self, pixpos) |
Pixel to Spatial coordinate conversion.
Args:
pixpos (tuple): [x, y] pixel position
Returns:
tuple: ra (float) Right ascension corresponding to position [x, y]
dec (float) Declination corresponding to position [x, y]
|
Pixel to Spatial coordinate conversion. | def p2s(self, pixpos):
"""
Pixel to Spatial coordinate conversion.
Args:
pixpos (tuple): [x, y] pixel position
Returns:
tuple: ra (float) Right ascension corresponding to position [x, y]
dec (float) Declination corresponding to position [x, y... | [
"def",
"p2s",
"(",
"self",
",",
"pixpos",
")",
":",
"ra",
",",
"dec",
"=",
"self",
".",
"wcs",
".",
"wcs_pix2world",
"(",
"pixpos",
"[",
"0",
"]",
",",
"pixpos",
"[",
"1",
"]",
",",
"self",
".",
"ORIGIN",
")",
"if",
"math",
".",
"isnan",
"(",
... | [
656,
4
] | [
670,
36
] | python | en | ['en', 'error', 'th'] | False |
WCS.s2p | (self, spatialpos) |
Spatial to Pixel coordinate conversion.
Args:
pixpos (tuple): [ra, dec] spatial position
Returns:
tuple: X pixel value corresponding to position [ra, dec],
Y pixel value corresponding to position [ra, dec]
|
Spatial to Pixel coordinate conversion. | def s2p(self, spatialpos):
"""
Spatial to Pixel coordinate conversion.
Args:
pixpos (tuple): [ra, dec] spatial position
Returns:
tuple: X pixel value corresponding to position [ra, dec],
Y pixel value corresponding to position [ra, dec]
... | [
"def",
"s2p",
"(",
"self",
",",
"spatialpos",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"wcs",
".",
"wcs_world2pix",
"(",
"spatialpos",
"[",
"0",
"]",
",",
"spatialpos",
"[",
"1",
"]",
",",
"self",
".",
"ORIGIN",
")",
"if",
"math",
".",
"isnan",... | [
672,
4
] | [
686,
33
] | python | en | ['en', 'error', 'th'] | False |
run_migrations_offline | () | Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the given string to the
script output.... | Run migrations in 'offline' mode. | def run_migrations_offline():
"""Run migrations in 'offline' mode.
This configures the context with just a URL
and not an Engine, though an Engine is acceptable
here as well. By skipping the Engine creation
we don't even need a DBAPI to be available.
Calls to context.execute() here emit the g... | [
"def",
"run_migrations_offline",
"(",
")",
":",
"url",
"=",
"get_url",
"(",
")",
"context",
".",
"configure",
"(",
"url",
"=",
"url",
",",
"target_metadata",
"=",
"target_metadata",
",",
"literal_binds",
"=",
"True",
")",
"with",
"context",
".",
"begin_trans... | [
39,
0
] | [
56,
32
] | python | en | ['en', 'nl', 'en'] | True |
run_migrations_online | () | Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
| Run migrations in 'online' mode. | def run_migrations_online():
"""Run migrations in 'online' mode.
In this scenario we need to create an Engine
and associate a connection with the context.
"""
connectable = engine_from_config(
config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=po... | [
"def",
"run_migrations_online",
"(",
")",
":",
"connectable",
"=",
"engine_from_config",
"(",
"config",
".",
"get_section",
"(",
"config",
".",
"config_ini_section",
")",
",",
"prefix",
"=",
"'sqlalchemy.'",
",",
"poolclass",
"=",
"pool",
".",
"NullPool",
")",
... | [
59,
0
] | [
78,
36
] | python | en | ['en', 'nl', 'it'] | False |
HttpResponseBase.serialize_headers | (self) | HTTP headers as a bytestring. | HTTP headers as a bytestring. | def serialize_headers(self):
"""HTTP headers as a bytestring."""
def to_bytes(val, encoding):
return val if isinstance(val, bytes) else val.encode(encoding)
headers = [
(b': '.join([to_bytes(key, 'ascii'), to_bytes(value, 'latin-1')]))
for key, value in self.... | [
"def",
"serialize_headers",
"(",
"self",
")",
":",
"def",
"to_bytes",
"(",
"val",
",",
"encoding",
")",
":",
"return",
"val",
"if",
"isinstance",
"(",
"val",
",",
"bytes",
")",
"else",
"val",
".",
"encode",
"(",
"encoding",
")",
"headers",
"=",
"[",
... | [
93,
4
] | [
102,
36
] | python | en | ['en', 'sv', 'en'] | True |
HttpResponseBase._convert_to_charset | (self, value, charset, mime_encode=False) | Converts headers key/value to ascii/latin-1 native strings.
`charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and
`value` can't be represented in the given charset, MIME-encoding
is applied.
| Converts headers key/value to ascii/latin-1 native strings. | def _convert_to_charset(self, value, charset, mime_encode=False):
"""Converts headers key/value to ascii/latin-1 native strings.
`charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and
`value` can't be represented in the given charset, MIME-encoding
is applied.
"""
... | [
"def",
"_convert_to_charset",
"(",
"self",
",",
"value",
",",
"charset",
",",
"mime_encode",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"bytes",
",",
"six",
".",
"text_type",
")",
")",
":",
"value",
"=",
"str",
"(",
"v... | [
113,
4
] | [
147,
20
] | python | en | ['en', 'en', 'en'] | True |
HttpResponseBase.has_header | (self, header) | Case-insensitive check for a header. | Case-insensitive check for a header. | def has_header(self, header):
"""Case-insensitive check for a header."""
return header.lower() in self._headers | [
"def",
"has_header",
"(",
"self",
",",
"header",
")",
":",
"return",
"header",
".",
"lower",
"(",
")",
"in",
"self",
".",
"_headers"
] | [
163,
4
] | [
165,
46
] | python | en | ['en', 'en', 'en'] | True |
HttpResponseBase.set_cookie | (self, key, value='', max_age=None, expires=None, path='/',
domain=None, secure=False, httponly=False) |
Sets a cookie.
``expires`` can be:
- a string in the correct format,
- a naive ``datetime.datetime`` object in UTC,
- an aware ``datetime.datetime`` object in any time zone.
If it is a ``datetime.datetime`` object then ``max_age`` will be calculated.
|
Sets a cookie. | def set_cookie(self, key, value='', max_age=None, expires=None, path='/',
domain=None, secure=False, httponly=False):
"""
Sets a cookie.
``expires`` can be:
- a string in the correct format,
- a naive ``datetime.datetime`` object in UTC,
- an aware ``d... | [
"def",
"set_cookie",
"(",
"self",
",",
"key",
",",
"value",
"=",
"''",
",",
"max_age",
"=",
"None",
",",
"expires",
"=",
"None",
",",
"path",
"=",
"'/'",
",",
"domain",
"=",
"None",
",",
"secure",
"=",
"False",
",",
"httponly",
"=",
"False",
")",
... | [
175,
4
] | [
217,
48
] | python | en | ['en', 'error', 'th'] | False |
HttpResponseBase.setdefault | (self, key, value) | Sets a header unless it has already been set. | Sets a header unless it has already been set. | def setdefault(self, key, value):
"""Sets a header unless it has already been set."""
if key not in self:
self[key] = value | [
"def",
"setdefault",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"not",
"in",
"self",
":",
"self",
"[",
"key",
"]",
"=",
"value"
] | [
219,
4
] | [
222,
29
] | python | en | ['en', 'lb', 'en'] | True |
HttpResponseBase.make_bytes | (self, value) | Turn a value into a bytestring encoded in the output charset. | Turn a value into a bytestring encoded in the output charset. | def make_bytes(self, value):
"""Turn a value into a bytestring encoded in the output charset."""
# Per PEP 3333, this response body must be bytes. To avoid returning
# an instance of a subclass, this function returns `bytes(value)`.
# This doesn't make a copy when `value` already contain... | [
"def",
"make_bytes",
"(",
"self",
",",
"value",
")",
":",
"# Per PEP 3333, this response body must be bytes. To avoid returning",
"# an instance of a subclass, this function returns `bytes(value)`.",
"# This doesn't make a copy when `value` already contains bytes.",
"# Handle string types -- w... | [
234,
4
] | [
249,
47
] | python | en | ['en', 'en', 'en'] | True |
HttpResponse.serialize | (self) | Full HTTP message, including headers, as a bytestring. | Full HTTP message, including headers, as a bytestring. | def serialize(self):
"""Full HTTP message, including headers, as a bytestring."""
return self.serialize_headers() + b'\r\n\r\n' + self.content | [
"def",
"serialize",
"(",
"self",
")",
":",
"return",
"self",
".",
"serialize_headers",
"(",
")",
"+",
"b'\\r\\n\\r\\n'",
"+",
"self",
".",
"content"
] | [
311,
4
] | [
313,
68
] | python | en | ['en', 'en', 'en'] | True |
test_global_creation_always_possible | (all_views) | To not make life very difficult for clients, this test
asserts that all creatable resources can be created by
POSTing to the global resource list
| To not make life very difficult for clients, this test
asserts that all creatable resources can be created by
POSTing to the global resource list
| def test_global_creation_always_possible(all_views):
"""To not make life very difficult for clients, this test
asserts that all creatable resources can be created by
POSTing to the global resource list
"""
views_by_model = {}
for View in all_views:
if not getattr(View, 'deprecated', Fals... | [
"def",
"test_global_creation_always_possible",
"(",
"all_views",
")",
":",
"views_by_model",
"=",
"{",
"}",
"for",
"View",
"in",
"all_views",
":",
"if",
"not",
"getattr",
"(",
"View",
",",
"'deprecated'",
",",
"False",
")",
"and",
"issubclass",
"(",
"View",
... | [
67,
0
] | [
92,
9
] | python | en | ['en', 'en', 'en'] | True |
pre_validate_blocks_multiprocessing | (
constants: ConsensusConstants,
constants_json: Dict,
block_records: BlockchainInterface,
blocks: Sequence[Union[FullBlock, HeaderBlock]],
pool: ProcessPoolExecutor,
check_filter: bool,
npc_results: Dict[uint32, NPCResult],
get_block_generator: Optional[Callable],
batch_size: int,
) |
This method must be called under the blockchain lock
If all the full blocks pass pre-validation, (only validates header), returns the list of required iters.
if any validation issue occurs, returns False.
Args:
check_filter:
constants_json:
pool:
constants:
bloc... |
This method must be called under the blockchain lock
If all the full blocks pass pre-validation, (only validates header), returns the list of required iters.
if any validation issue occurs, returns False. | async def pre_validate_blocks_multiprocessing(
constants: ConsensusConstants,
constants_json: Dict,
block_records: BlockchainInterface,
blocks: Sequence[Union[FullBlock, HeaderBlock]],
pool: ProcessPoolExecutor,
check_filter: bool,
npc_results: Dict[uint32, NPCResult],
get_block_generato... | [
"async",
"def",
"pre_validate_blocks_multiprocessing",
"(",
"constants",
":",
"ConsensusConstants",
",",
"constants_json",
":",
"Dict",
",",
"block_records",
":",
"BlockchainInterface",
",",
"blocks",
":",
"Sequence",
"[",
"Union",
"[",
"FullBlock",
",",
"HeaderBlock"... | [
124,
0
] | [
305,
5
] | python | en | ['en', 'error', 'th'] | False |
_lazy_re_compile | (regex, flags=0) | Lazily compile a regex with flags. | Lazily compile a regex with flags. | def _lazy_re_compile(regex, flags=0):
"""Lazily compile a regex with flags."""
def _compile():
# Compile the regex if it was not passed pre-compiled.
if isinstance(regex, six.string_types):
return re.compile(regex, flags)
else:
assert not flags, "flags must be emp... | [
"def",
"_lazy_re_compile",
"(",
"regex",
",",
"flags",
"=",
"0",
")",
":",
"def",
"_compile",
"(",
")",
":",
"# Compile the regex if it was not passed pre-compiled.",
"if",
"isinstance",
"(",
"regex",
",",
"six",
".",
"string_types",
")",
":",
"return",
"re",
... | [
18,
0
] | [
27,
37
] | python | en | ['en', 'en', 'en'] | True |
ip_address_validators | (protocol, unpack_ipv4) |
Depending on the given parameters returns the appropriate validators for
the GenericIPAddressField.
This code is here, because it is exactly the same for the model and the form field.
|
Depending on the given parameters returns the appropriate validators for
the GenericIPAddressField. | def ip_address_validators(protocol, unpack_ipv4):
"""
Depending on the given parameters returns the appropriate validators for
the GenericIPAddressField.
This code is here, because it is exactly the same for the model and the form field.
"""
if protocol != 'both' and unpack_ipv4:
raise ... | [
"def",
"ip_address_validators",
"(",
"protocol",
",",
"unpack_ipv4",
")",
":",
"if",
"protocol",
"!=",
"'both'",
"and",
"unpack_ipv4",
":",
"raise",
"ValueError",
"(",
"\"You can only use `unpack_ipv4` if `protocol` is set to 'both'\"",
")",
"try",
":",
"return",
"ip_ad... | [
281,
0
] | [
295,
70
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_testing_status_message | (self) |
Tests if codeship testing status is mapped correctly
|
Tests if codeship testing status is mapped correctly
| def test_codeship_build_in_testing_status_message(self) -> None:
"""
Tests if codeship testing status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started."
self.check_webhook("t... | [
"def",
"test_codeship_build_in_testing_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch started.\"",
"self",
".",
"check_webhook",
"(",
"\"testing_bui... | [
9,
4
] | [
14,
73
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_error_status_message | (self) |
Tests if codeship error status is mapped correctly
|
Tests if codeship error status is mapped correctly
| def test_codeship_build_in_error_status_message(self) -> None:
"""
Tests if codeship error status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed."
self.check_webhook("error_... | [
"def",
"test_codeship_build_in_error_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch failed.\"",
"self",
".",
"check_webhook",
"(",
"\"error_build\""... | [
16,
4
] | [
21,
71
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_success_status_message | (self) |
Tests if codeship success status is mapped correctly
|
Tests if codeship success status is mapped correctly
| def test_codeship_build_in_success_status_message(self) -> None:
"""
Tests if codeship success status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded."
self.check_webhook(... | [
"def",
"test_codeship_build_in_success_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch succeeded.\"",
"self",
".",
"check_webhook",
"(",
"\"success_b... | [
23,
4
] | [
28,
73
] | python | en | ['en', 'error', 'th'] | False |
CodeshipHookTests.test_codeship_build_in_other_status_status_message | (self) |
Tests if codeship other status is mapped correctly
|
Tests if codeship other status is mapped correctly
| def test_codeship_build_in_other_status_status_message(self) -> None:
"""
Tests if codeship other status is mapped correctly
"""
expected_message = "[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status."
... | [
"def",
"test_codeship_build_in_other_status_status_message",
"(",
"self",
")",
"->",
"None",
":",
"expected_message",
"=",
"\"[Build](https://www.codeship.com/projects/10213/builds/973711) triggered by beanieboi on master branch has some_other_status status.\"",
"self",
".",
"check_webhook... | [
30,
4
] | [
35,
78
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublish.test_unpublish_view | (self) |
This tests that the unpublish view responds with an unpublish confirm page
|
This tests that the unpublish view responds with an unpublish confirm page
| def test_unpublish_view(self):
"""
This tests that the unpublish view responds with an unpublish confirm page
"""
# Get unpublish page
response = self.client.get(reverse('wagtailadmin_pages:unpublish', args=(self.page.id, )))
# Check that the user received an unpublish c... | [
"def",
"test_unpublish_view",
"(",
"self",
")",
":",
"# Get unpublish page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:unpublish'",
",",
"args",
"=",
"(",
"self",
".",
"page",
".",
"id",
",",
")",
")",
")... | [
28,
4
] | [
37,
86
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublish.test_unpublish_view_invalid_page_id | (self) |
This tests that the unpublish view returns an error if the page id is invalid
|
This tests that the unpublish view returns an error if the page id is invalid
| def test_unpublish_view_invalid_page_id(self):
"""
This tests that the unpublish view returns an error if the page id is invalid
"""
# Get unpublish page
response = self.client.get(reverse('wagtailadmin_pages:unpublish', args=(12345, )))
# Check that the user received a ... | [
"def",
"test_unpublish_view_invalid_page_id",
"(",
"self",
")",
":",
"# Get unpublish page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:unpublish'",
",",
"args",
"=",
"(",
"12345",
",",
")",
")",
")",
"# Check t... | [
39,
4
] | [
47,
51
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublish.test_unpublish_view_bad_permissions | (self) |
This tests that the unpublish view doesn't allow users without unpublish permissions
|
This tests that the unpublish view doesn't allow users without unpublish permissions
| def test_unpublish_view_bad_permissions(self):
"""
This tests that the unpublish view doesn't allow users without unpublish permissions
"""
# Remove privileges from user
self.user.is_superuser = False
self.user.user_permissions.add(
Permission.objects.get(cont... | [
"def",
"test_unpublish_view_bad_permissions",
"(",
"self",
")",
":",
"# Remove privileges from user",
"self",
".",
"user",
".",
"is_superuser",
"=",
"False",
"self",
".",
"user",
".",
"user_permissions",
".",
"add",
"(",
"Permission",
".",
"objects",
".",
"get",
... | [
49,
4
] | [
64,
51
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublish.test_unpublish_view_post | (self) |
This posts to the unpublish view and checks that the page was unpublished
|
This posts to the unpublish view and checks that the page was unpublished
| def test_unpublish_view_post(self):
"""
This posts to the unpublish view and checks that the page was unpublished
"""
# Connect a mock signal handler to page_unpublished signal
mock_handler = mock.MagicMock()
page_unpublished.connect(mock_handler)
# Post to the u... | [
"def",
"test_unpublish_view_post",
"(",
"self",
")",
":",
"# Connect a mock signal handler to page_unpublished signal",
"mock_handler",
"=",
"mock",
".",
"MagicMock",
"(",
")",
"page_unpublished",
".",
"connect",
"(",
"mock_handler",
")",
"# Post to the unpublish page",
"re... | [
66,
4
] | [
89,
78
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublish.test_unpublish_descendants_view | (self) |
This tests that the unpublish view responds with an unpublish confirm page that does not contain the form field 'include_descendants'
|
This tests that the unpublish view responds with an unpublish confirm page that does not contain the form field 'include_descendants'
| def test_unpublish_descendants_view(self):
"""
This tests that the unpublish view responds with an unpublish confirm page that does not contain the form field 'include_descendants'
"""
# Get unpublish page
response = self.client.get(reverse('wagtailadmin_pages:unpublish', args=(s... | [
"def",
"test_unpublish_descendants_view",
"(",
"self",
")",
":",
"# Get unpublish page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:unpublish'",
",",
"args",
"=",
"(",
"self",
".",
"page",
".",
"id",
",",
")",... | [
130,
4
] | [
141,
122
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublishIncludingDescendants.test_unpublish_descendants_view | (self) |
This tests that the unpublish view responds with an unpublish confirm page that contains the form field 'include_descendants'
|
This tests that the unpublish view responds with an unpublish confirm page that contains the form field 'include_descendants'
| def test_unpublish_descendants_view(self):
"""
This tests that the unpublish view responds with an unpublish confirm page that contains the form field 'include_descendants'
"""
# Get unpublish page
response = self.client.get(reverse('wagtailadmin_pages:unpublish', args=(self.test... | [
"def",
"test_unpublish_descendants_view",
"(",
"self",
")",
":",
"# Get unpublish page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_pages:unpublish'",
",",
"args",
"=",
"(",
"self",
".",
"test_page",
".",
"id",
",",
... | [
176,
4
] | [
187,
119
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublishIncludingDescendants.test_unpublish_include_children_view_post | (self) |
This posts to the unpublish view and checks that the page and its descendants were unpublished
|
This posts to the unpublish view and checks that the page and its descendants were unpublished
| def test_unpublish_include_children_view_post(self):
"""
This posts to the unpublish view and checks that the page and its descendants were unpublished
"""
# Post to the unpublish page
response = self.client.post(reverse('wagtailadmin_pages:unpublish', args=(self.test_page.id, ))... | [
"def",
"test_unpublish_include_children_view_post",
"(",
"self",
")",
":",
"# Post to the unpublish page",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_pages:unpublish'",
",",
"args",
"=",
"(",
"self",
".",
"test_page",
".... | [
189,
4
] | [
204,
89
] | python | en | ['en', 'error', 'th'] | False |
TestPageUnpublishIncludingDescendants.test_unpublish_not_include_children_view_post | (self) |
This posts to the unpublish view and checks that the page was unpublished but its descendants were not
|
This posts to the unpublish view and checks that the page was unpublished but its descendants were not
| def test_unpublish_not_include_children_view_post(self):
"""
This posts to the unpublish view and checks that the page was unpublished but its descendants were not
"""
# Post to the unpublish page
response = self.client.post(reverse('wagtailadmin_pages:unpublish', args=(self.test... | [
"def",
"test_unpublish_not_include_children_view_post",
"(",
"self",
")",
":",
"# Post to the unpublish page",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_pages:unpublish'",
",",
"args",
"=",
"(",
"self",
".",
"test_page",
... | [
206,
4
] | [
221,
88
] | python | en | ['en', 'error', 'th'] | False |
Command.sync_apps | (self, connection, app_labels) | Run the old syncdb-style operation on a list of app_labels. | Run the old syncdb-style operation on a list of app_labels. | def sync_apps(self, connection, app_labels):
"""Run the old syncdb-style operation on a list of app_labels."""
with connection.cursor() as cursor:
tables = connection.introspection.table_names(cursor)
# Build the manifest of apps and models that are to be synchronized.
all_m... | [
"def",
"sync_apps",
"(",
"self",
",",
"connection",
",",
"app_labels",
")",
":",
"with",
"connection",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"tables",
"=",
"connection",
".",
"introspection",
".",
"table_names",
"(",
"cursor",
")",
"# Build the manif... | [
263,
4
] | [
310,
66
] | python | en | ['en', 'en', 'en'] | True |
CharSetProber.filter_international_words | (buf) |
We define three types of bytes:
alphabet: english alphabets [a-zA-Z]
international: international characters [\x80-\xFF]
marker: everything else [^a-zA-Z\x80-\xFF]
The input buffer can be thought to contain a series of words delimited
by markers. This function works to ... |
We define three types of bytes:
alphabet: english alphabets [a-zA-Z]
international: international characters [\x80-\xFF]
marker: everything else [^a-zA-Z\x80-\xFF] | def filter_international_words(buf):
"""
We define three types of bytes:
alphabet: english alphabets [a-zA-Z]
international: international characters [\x80-\xFF]
marker: everything else [^a-zA-Z\x80-\xFF]
The input buffer can be thought to contain a series of words delim... | [
"def",
"filter_international_words",
"(",
"buf",
")",
":",
"filtered",
"=",
"bytearray",
"(",
")",
"# This regex expression filters out only words that have at-least one",
"# international character. The word may include one marker character at",
"# the end.",
"words",
"=",
"re",
"... | [
66,
4
] | [
100,
23
] | python | en | ['en', 'error', 'th'] | False |
CharSetProber.filter_with_english_letters | (buf) |
Returns a copy of ``buf`` that retains only the sequences of English
alphabet and high byte characters that are not between <> characters.
Also retains English alphabet and high byte characters immediately
before occurrences of >.
This filter can be applied to all scripts which... |
Returns a copy of ``buf`` that retains only the sequences of English
alphabet and high byte characters that are not between <> characters.
Also retains English alphabet and high byte characters immediately
before occurrences of >. | def filter_with_english_letters(buf):
"""
Returns a copy of ``buf`` that retains only the sequences of English
alphabet and high byte characters that are not between <> characters.
Also retains English alphabet and high byte characters immediately
before occurrences of >.
... | [
"def",
"filter_with_english_letters",
"(",
"buf",
")",
":",
"filtered",
"=",
"bytearray",
"(",
")",
"in_tag",
"=",
"False",
"prev",
"=",
"0",
"for",
"curr",
"in",
"range",
"(",
"len",
"(",
"buf",
")",
")",
":",
"# Slice here to get bytes instead of an int with... | [
103,
4
] | [
144,
23
] | python | en | ['en', 'error', 'th'] | False |
opener_for | (ca_bundle=None) | Get a urlopen() replacement that uses ca_bundle for verification | Get a urlopen() replacement that uses ca_bundle for verification | def opener_for(ca_bundle=None):
"""Get a urlopen() replacement that uses ca_bundle for verification"""
return urllib.request.build_opener(
VerifyingHTTPSHandler(ca_bundle or find_ca_bundle())
).open | [
"def",
"opener_for",
"(",
"ca_bundle",
"=",
"None",
")",
":",
"return",
"urllib",
".",
"request",
".",
"build_opener",
"(",
"VerifyingHTTPSHandler",
"(",
"ca_bundle",
"or",
"find_ca_bundle",
"(",
")",
")",
")",
".",
"open"
] | [
210,
0
] | [
214,
10
] | python | en | ['en', 'en', 'en'] | True |
find_ca_bundle | () | Return an existing CA bundle path, or None | Return an existing CA bundle path, or None | def find_ca_bundle():
"""Return an existing CA bundle path, or None"""
extant_cert_paths = filter(os.path.isfile, cert_paths)
return (
get_win_certfile()
or next(extant_cert_paths, None)
or _certifi_where()
) | [
"def",
"find_ca_bundle",
"(",
")",
":",
"extant_cert_paths",
"=",
"filter",
"(",
"os",
".",
"path",
".",
"isfile",
",",
"cert_paths",
")",
"return",
"(",
"get_win_certfile",
"(",
")",
"or",
"next",
"(",
"extant_cert_paths",
",",
"None",
")",
"or",
"_certif... | [
251,
0
] | [
258,
5
] | python | en | ['en', 'en', 'en'] | True |
BlazeMeterUploader.prepare | (self) |
Read options for uploading, check that they're sane
|
Read options for uploading, check that they're sane
| def prepare(self):
"""
Read options for uploading, check that they're sane
"""
super(BlazeMeterUploader, self).prepare()
self.send_interval = dehumanize_time(self.settings.get("send-interval", self.send_interval))
self.send_monitoring = self.settings.get("send-monitoring... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"BlazeMeterUploader",
",",
"self",
")",
".",
"prepare",
"(",
")",
"self",
".",
"send_interval",
"=",
"dehumanize_time",
"(",
"self",
".",
"settings",
".",
"get",
"(",
"\"send-interval\"",
",",
"self",
... | [
72,
4
] | [
137,
42
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.startup | (self) |
Initiate online test
|
Initiate online test
| def startup(self):
"""
Initiate online test
"""
super(BlazeMeterUploader, self).startup()
self._user.log = self.log.getChild(self.__class__.__name__)
if not self._session:
url = self._start_online()
self.log.info("Started data feeding: %s", url)
... | [
"def",
"startup",
"(",
"self",
")",
":",
"super",
"(",
"BlazeMeterUploader",
",",
"self",
")",
".",
"startup",
"(",
")",
"self",
".",
"_user",
".",
"log",
"=",
"self",
".",
"log",
".",
"getChild",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
... | [
139,
4
] | [
154,
68
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader._start_online | (self) |
Start online test
|
Start online test | def _start_online(self):
"""
Start online test
"""
self.log.info("Initiating data feeding...")
if self._test['id']:
self._session, self._master = self._test.start_external()
else:
self._session, self._master, self.results_url = self._test.start_a... | [
"def",
"_start_online",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Initiating data feeding...\"",
")",
"if",
"self",
".",
"_test",
"[",
"'id'",
"]",
":",
"self",
".",
"_session",
",",
"self",
".",
"_master",
"=",
"self",
".",
"_tes... | [
156,
4
] | [
174,
31
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.__get_jtls_and_more | (self) |
Compress all files in artifacts dir to single zipfile
:rtype: (io.BytesIO,dict)
|
Compress all files in artifacts dir to single zipfile
:rtype: (io.BytesIO,dict)
| def __get_jtls_and_more(self):
"""
Compress all files in artifacts dir to single zipfile
:rtype: (io.BytesIO,dict)
"""
mfile = BytesIO()
listing = {}
logs = set()
for handler in self.engine.log.parent.handlers:
if isinstance(handler, logging.F... | [
"def",
"__get_jtls_and_more",
"(",
"self",
")",
":",
"mfile",
"=",
"BytesIO",
"(",
")",
"listing",
"=",
"{",
"}",
"logs",
"=",
"set",
"(",
")",
"for",
"handler",
"in",
"self",
".",
"engine",
".",
"log",
".",
"parent",
".",
"handlers",
":",
"if",
"i... | [
176,
4
] | [
208,
29
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.__upload_artifacts | (self) |
If token provided, upload artifacts folder contents and bzt.log
|
If token provided, upload artifacts folder contents and bzt.log
| def __upload_artifacts(self):
"""
If token provided, upload artifacts folder contents and bzt.log
"""
if not self._session.token:
return
worker_index = self.engine.config.get('modules').get('shellexec').get('env').get('TAURUS_INDEX_ALL')
if worker_index:
... | [
"def",
"__upload_artifacts",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_session",
".",
"token",
":",
"return",
"worker_index",
"=",
"self",
".",
"engine",
".",
"config",
".",
"get",
"(",
"'modules'",
")",
".",
"get",
"(",
"'shellexec'",
")",
".... | [
210,
4
] | [
240,
79
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.post_process | (self) |
Upload results if possible
|
Upload results if possible
| def post_process(self):
"""
Upload results if possible
"""
if not self._session:
self.log.debug("No feeding session obtained, nothing to finalize")
return
self.log.debug("KPI bulk buffer len in post-proc: %s", len(self.kpi_buffer))
try:
... | [
"def",
"post_process",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_session",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"No feeding session obtained, nothing to finalize\"",
")",
"return",
"self",
".",
"log",
".",
"debug",
"(",
"\"KPI bulk buffer len i... | [
242,
4
] | [
265,
69
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.end_online | (self) |
Finish online test
|
Finish online test
| def end_online(self):
"""
Finish online test
"""
if not self._session:
self.log.debug("Feeding not started, so not stopping")
else:
self.log.info("Ending data feeding...")
if self._user.token:
self._session.stop()
el... | [
"def",
"end_online",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_session",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Feeding not started, so not stopping\"",
")",
"else",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Ending data feeding...\"",
")... | [
303,
4
] | [
314,
46
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.check | (self) |
Send data if any in buffer
|
Send data if any in buffer
| def check(self):
"""
Send data if any in buffer
"""
self.log.debug("KPI bulk buffer len: %s", len(self.kpi_buffer))
if self.last_dispatch < (time.time() - self.send_interval):
self.last_dispatch = time.time()
if self.send_data and len(self.kpi_buffer):
... | [
"def",
"check",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"KPI bulk buffer len: %s\"",
",",
"len",
"(",
"self",
".",
"kpi_buffer",
")",
")",
"if",
"self",
".",
"last_dispatch",
"<",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self... | [
332,
4
] | [
345,
54
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.__send_data | (self, data, do_check=True, is_final=False) |
:type data: list[bzt.modules.aggregator.DataPoint]
|
:type data: list[bzt.modules.aggregator.DataPoint]
| def __send_data(self, data, do_check=True, is_final=False):
"""
:type data: list[bzt.modules.aggregator.DataPoint]
"""
if not self._session:
return
self.engine.aggregator.converter(data)
serialized = self._dpoint_serializer.get_kpi_body(data, is_final)
... | [
"def",
"__send_data",
"(",
"self",
",",
"data",
",",
"do_check",
"=",
"True",
",",
"is_final",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"_session",
":",
"return",
"self",
".",
"engine",
".",
"aggregator",
".",
"converter",
"(",
"data",
")",
... | [
347,
4
] | [
357,
57
] | python | en | ['en', 'error', 'th'] | False |
BlazeMeterUploader.aggregated_second | (self, data) |
Send online data
:param data: DataPoint
|
Send online data
:param data: DataPoint
| def aggregated_second(self, data):
"""
Send online data
:param data: DataPoint
"""
if self.send_data:
self.kpi_buffer.append(data) | [
"def",
"aggregated_second",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"send_data",
":",
"self",
".",
"kpi_buffer",
".",
"append",
"(",
"data",
")"
] | [
359,
4
] | [
365,
40
] | python | en | ['en', 'error', 'th'] | False |
MonitoringBuffer.get_monitoring_json | (self, session) |
:type session: Session
|
:type session: Session
| def get_monitoring_json(self, session):
"""
:type session: Session
"""
results = {}
hosts = []
kpis = {}
for source, buff in iteritems(self.data):
for timestamp, item in iteritems(buff):
if source == 'local':
source... | [
"def",
"get_monitoring_json",
"(",
"self",
",",
"session",
")",
":",
"results",
"=",
"{",
"}",
"hosts",
"=",
"[",
"]",
"kpis",
"=",
"{",
"}",
"for",
"source",
",",
"buff",
"in",
"iteritems",
"(",
"self",
".",
"data",
")",
":",
"for",
"timestamp",
"... | [
444,
4
] | [
520,
9
] | python | en | ['en', 'error', 'th'] | False |
DatapointSerializer.__init__ | (self, owner) |
:type owner: BlazeMeterUploader
|
:type owner: BlazeMeterUploader
| def __init__(self, owner):
"""
:type owner: BlazeMeterUploader
"""
super(DatapointSerializer, self).__init__()
self.owner = owner
self.multi = 1000 | [
"def",
"__init__",
"(",
"self",
",",
"owner",
")",
":",
"super",
"(",
"DatapointSerializer",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"owner",
"=",
"owner",
"self",
".",
"multi",
"=",
"1000"
] | [
524,
4
] | [
530,
25
] | python | en | ['en', 'error', 'th'] | False |
register_range | (pgrange, pyrange, conn_or_curs, globally=False) | Create and register an adapter and the typecasters to convert between
a PostgreSQL |range|_ type and a PostgreSQL `Range` subclass.
:param pgrange: the name of the PostgreSQL |range| type. Can be
schema-qualified
:param pyrange: a `Range` strict subclass, or just a name to give to a new
cla... | Create and register an adapter and the typecasters to convert between
a PostgreSQL |range|_ type and a PostgreSQL `Range` subclass. | def register_range(pgrange, pyrange, conn_or_curs, globally=False):
"""Create and register an adapter and the typecasters to convert between
a PostgreSQL |range|_ type and a PostgreSQL `Range` subclass.
:param pgrange: the name of the PostgreSQL |range| type. Can be
schema-qualified
:param pyra... | [
"def",
"register_range",
"(",
"pgrange",
",",
"pyrange",
",",
"conn_or_curs",
",",
"globally",
"=",
"False",
")",
":",
"caster",
"=",
"RangeCaster",
".",
"_from_db",
"(",
"pgrange",
",",
"pyrange",
",",
"conn_or_curs",
")",
"caster",
".",
"_register",
"(",
... | [
194,
0
] | [
222,
17
] | python | en | ['en', 'en', 'en'] | True |
Range.lower | (self) | The lower bound of the range. `!None` if empty or unbound. | The lower bound of the range. `!None` if empty or unbound. | def lower(self):
"""The lower bound of the range. `!None` if empty or unbound."""
return self._lower | [
"def",
"lower",
"(",
"self",
")",
":",
"return",
"self",
".",
"_lower"
] | [
64,
4
] | [
66,
26
] | python | en | ['en', 'en', 'en'] | True |
Range.upper | (self) | The upper bound of the range. `!None` if empty or unbound. | The upper bound of the range. `!None` if empty or unbound. | def upper(self):
"""The upper bound of the range. `!None` if empty or unbound."""
return self._upper | [
"def",
"upper",
"(",
"self",
")",
":",
"return",
"self",
".",
"_upper"
] | [
69,
4
] | [
71,
26
] | python | en | ['en', 'en', 'en'] | True |
Range.isempty | (self) | `!True` if the range is empty. | `!True` if the range is empty. | def isempty(self):
"""`!True` if the range is empty."""
return self._bounds is None | [
"def",
"isempty",
"(",
"self",
")",
":",
"return",
"self",
".",
"_bounds",
"is",
"None"
] | [
74,
4
] | [
76,
35
] | python | en | ['en', 'sr', 'en'] | True |
Range.lower_inf | (self) | `!True` if the range doesn't have a lower bound. | `!True` if the range doesn't have a lower bound. | def lower_inf(self):
"""`!True` if the range doesn't have a lower bound."""
if self._bounds is None:
return False
return self._lower is None | [
"def",
"lower_inf",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bounds",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"_lower",
"is",
"None"
] | [
79,
4
] | [
83,
34
] | python | en | ['en', 'en', 'en'] | True |
Range.upper_inf | (self) | `!True` if the range doesn't have an upper bound. | `!True` if the range doesn't have an upper bound. | def upper_inf(self):
"""`!True` if the range doesn't have an upper bound."""
if self._bounds is None:
return False
return self._upper is None | [
"def",
"upper_inf",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bounds",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"_upper",
"is",
"None"
] | [
86,
4
] | [
90,
34
] | python | en | ['en', 'en', 'en'] | True |
Range.lower_inc | (self) | `!True` if the lower bound is included in the range. | `!True` if the lower bound is included in the range. | def lower_inc(self):
"""`!True` if the lower bound is included in the range."""
if self._bounds is None or self._lower is None:
return False
return self._bounds[0] == '[' | [
"def",
"lower_inc",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bounds",
"is",
"None",
"or",
"self",
".",
"_lower",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"_bounds",
"[",
"0",
"]",
"==",
"'['"
] | [
93,
4
] | [
97,
37
] | python | en | ['en', 'en', 'en'] | True |
Range.upper_inc | (self) | `!True` if the upper bound is included in the range. | `!True` if the upper bound is included in the range. | def upper_inc(self):
"""`!True` if the upper bound is included in the range."""
if self._bounds is None or self._upper is None:
return False
return self._bounds[1] == ']' | [
"def",
"upper_inc",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bounds",
"is",
"None",
"or",
"self",
".",
"_upper",
"is",
"None",
":",
"return",
"False",
"return",
"self",
".",
"_bounds",
"[",
"1",
"]",
"==",
"']'"
] | [
100,
4
] | [
104,
37
] | python | en | ['en', 'en', 'en'] | True |
RangeCaster._create_ranges | (self, pgrange, pyrange) | Create Range and RangeAdapter classes if needed. | Create Range and RangeAdapter classes if needed. | def _create_ranges(self, pgrange, pyrange):
"""Create Range and RangeAdapter classes if needed."""
# if got a string create a new RangeAdapter concrete type (with a name)
# else take it as an adapter. Passing an adapter should be considered
# an implementation detail and is not documente... | [
"def",
"_create_ranges",
"(",
"self",
",",
"pgrange",
",",
"pyrange",
")",
":",
"# if got a string create a new RangeAdapter concrete type (with a name)",
"# else take it as an adapter. Passing an adapter should be considered",
"# an implementation detail and is not documented. It is current... | [
294,
4
] | [
327,
68
] | python | en | ['en', 'sn', 'en'] | True |
RangeCaster._from_db | (self, name, pyrange, conn_or_curs) | Return a `RangeCaster` instance for the type *pgrange*.
Raise `ProgrammingError` if the type is not found.
| Return a `RangeCaster` instance for the type *pgrange*. | def _from_db(self, name, pyrange, conn_or_curs):
"""Return a `RangeCaster` instance for the type *pgrange*.
Raise `ProgrammingError` if the type is not found.
"""
from psycopg2.extensions import STATUS_IN_TRANSACTION
from psycopg2.extras import _solve_conn_curs
conn, cur... | [
"def",
"_from_db",
"(",
"self",
",",
"name",
",",
"pyrange",
",",
"conn_or_curs",
")",
":",
"from",
"psycopg2",
".",
"extensions",
"import",
"STATUS_IN_TRANSACTION",
"from",
"psycopg2",
".",
"extras",
"import",
"_solve_conn_curs",
"conn",
",",
"curs",
"=",
"_s... | [
330,
4
] | [
383,
59
] | python | en | ['en', 'no', 'en'] | True |
Subversion.get_revision | (cls, location) |
Return the maximum revision for all files under a given location
|
Return the maximum revision for all files under a given location
| def get_revision(cls, location):
"""
Return the maximum revision for all files under a given location
"""
# Note: taken from setuptools.command.egg_info
revision = 0
for base, dirs, _ in os.walk(location):
if cls.dirname not in dirs:
dirs[:] =... | [
"def",
"get_revision",
"(",
"cls",
",",
"location",
")",
":",
"# Note: taken from setuptools.command.egg_info",
"revision",
"=",
"0",
"for",
"base",
",",
"dirs",
",",
"_",
"in",
"os",
".",
"walk",
"(",
"location",
")",
":",
"if",
"cls",
".",
"dirname",
"no... | [
52,
4
] | [
77,
23
] | python | en | ['en', 'error', 'th'] | False |
Subversion.get_netloc_and_auth | (cls, netloc, scheme) |
This override allows the auth information to be passed to svn via the
--username and --password options instead of via the URL.
|
This override allows the auth information to be passed to svn via the
--username and --password options instead of via the URL.
| def get_netloc_and_auth(cls, netloc, scheme):
"""
This override allows the auth information to be passed to svn via the
--username and --password options instead of via the URL.
"""
if scheme == 'ssh':
# The --username and --password options can't be used for
... | [
"def",
"get_netloc_and_auth",
"(",
"cls",
",",
"netloc",
",",
"scheme",
")",
":",
"if",
"scheme",
"==",
"'ssh'",
":",
"# The --username and --password options can't be used for",
"# svn+ssh URLs, so keep the auth information in the URL.",
"return",
"super",
"(",
"Subversion",... | [
80,
4
] | [
90,
45
] | python | en | ['en', 'error', 'th'] | False |
Subversion.is_commit_id_equal | (cls, dest, name) | Always assume the versions don't match | Always assume the versions don't match | def is_commit_id_equal(cls, dest, name):
"""Always assume the versions don't match"""
return False | [
"def",
"is_commit_id_equal",
"(",
"cls",
",",
"dest",
",",
"name",
")",
":",
"return",
"False"
] | [
184,
4
] | [
186,
20
] | python | en | ['en', 'en', 'en'] | True |
Subversion.call_vcs_version | (self) | Query the version of the currently installed Subversion client.
:return: A tuple containing the parts of the version information or
``()`` if the version returned from ``svn`` could not be parsed.
:raises: BadCommand: If ``svn`` is not installed.
| Query the version of the currently installed Subversion client. | def call_vcs_version(self):
# type: () -> Tuple[int, ...]
"""Query the version of the currently installed Subversion client.
:return: A tuple containing the parts of the version information or
``()`` if the version returned from ``svn`` could not be parsed.
:raises: BadComma... | [
"def",
"call_vcs_version",
"(",
"self",
")",
":",
"# type: () -> Tuple[int, ...]",
"# Example versions:",
"# svn, version 1.10.3 (r1842928)",
"# compiled Feb 25 2019, 14:20:39 on x86_64-apple-darwin17.0.0",
"# svn, version 1.7.14 (r1542130)",
"# compiled Mar 28 2018, 08:49:13 on ... | [
203,
4
] | [
231,
29
] | python | en | ['en', 'en', 'en'] | True |
Subversion.get_vcs_version | (self) | Return the version of the currently installed Subversion client.
If the version of the Subversion client has already been queried,
a cached value will be used.
:return: A tuple containing the parts of the version information or
``()`` if the version returned from ``svn`` could not ... | Return the version of the currently installed Subversion client. | def get_vcs_version(self):
# type: () -> Tuple[int, ...]
"""Return the version of the currently installed Subversion client.
If the version of the Subversion client has already been queried,
a cached value will be used.
:return: A tuple containing the parts of the version infor... | [
"def",
"get_vcs_version",
"(",
"self",
")",
":",
"# type: () -> Tuple[int, ...]",
"if",
"self",
".",
"_vcs_version",
"is",
"not",
"None",
":",
"# Use cached version, if available.",
"# If parsing the version failed previously (empty tuple),",
"# do not attempt to parse it again.",
... | [
233,
4
] | [
252,
26
] | python | en | ['en', 'en', 'en'] | True |
Subversion.get_remote_call_options | (self) | Return options to be used on calls to Subversion that contact the server.
These options are applicable for the following ``svn`` subcommands used
in this class.
- checkout
- export
- switch
- update
:return: A list of command line arguments to p... | Return options to be used on calls to Subversion that contact the server. | def get_remote_call_options(self):
# type: () -> CommandArgs
"""Return options to be used on calls to Subversion that contact the server.
These options are applicable for the following ``svn`` subcommands used
in this class.
- checkout
- export
- swi... | [
"def",
"get_remote_call_options",
"(",
"self",
")",
":",
"# type: () -> CommandArgs",
"if",
"not",
"self",
".",
"use_interactive",
":",
"# --non-interactive switch is available since Subversion 0.14.4.",
"# Subversion < 1.8 runs in interactive mode by default.",
"return",
"[",
"'--... | [
254,
4
] | [
285,
17
] | python | en | ['en', 'en', 'en'] | True |
Subversion.export | (self, location, url) | Export the svn repository at the url to the destination location | Export the svn repository at the url to the destination location | def export(self, location, url):
# type: (str, HiddenText) -> None
"""Export the svn repository at the url to the destination location"""
url, rev_options = self.get_url_rev_options(url)
logger.info('Exporting svn repository %s to %s', url, location)
with indent_log():
... | [
"def",
"export",
"(",
"self",
",",
"location",
",",
"url",
")",
":",
"# type: (str, HiddenText) -> None",
"url",
",",
"rev_options",
"=",
"self",
".",
"get_url_rev_options",
"(",
"url",
")",
"logger",
".",
"info",
"(",
"'Exporting svn repository %s to %s'",
",",
... | [
287,
4
] | [
302,
38
] | python | en | ['en', 'en', 'en'] | True |
get_concrete_descendants | (model_class, inclusive=True) | Retrieves non-abstract descendants of the given model class. If `inclusive` is set to
True, includes model_class | Retrieves non-abstract descendants of the given model class. If `inclusive` is set to
True, includes model_class | def get_concrete_descendants(model_class, inclusive=True):
"""Retrieves non-abstract descendants of the given model class. If `inclusive` is set to
True, includes model_class"""
subclasses = model_class.__subclasses__()
if subclasses:
for subclass in subclasses:
yield from get_concre... | [
"def",
"get_concrete_descendants",
"(",
"model_class",
",",
"inclusive",
"=",
"True",
")",
":",
"subclasses",
"=",
"model_class",
".",
"__subclasses__",
"(",
")",
"if",
"subclasses",
":",
"for",
"subclass",
"in",
"subclasses",
":",
"yield",
"from",
"get_concrete... | [
6,
0
] | [
14,
25
] | python | en | ['en', 'en', 'en'] | True |
fromfile | (file_h) |
Given a string file name, returns a GEOSGeometry. The file may contain WKB,
WKT, or HEX.
|
Given a string file name, returns a GEOSGeometry. The file may contain WKB,
WKT, or HEX.
| def fromfile(file_h):
"""
Given a string file name, returns a GEOSGeometry. The file may contain WKB,
WKT, or HEX.
"""
# If given a file name, get a real handle.
if isinstance(file_h, six.string_types):
with open(file_h, 'rb') as file_h:
buf = file_h.read()
else:
... | [
"def",
"fromfile",
"(",
"file_h",
")",
":",
"# If given a file name, get a real handle.",
"if",
"isinstance",
"(",
"file_h",
",",
"six",
".",
"string_types",
")",
":",
"with",
"open",
"(",
"file_h",
",",
"'rb'",
")",
"as",
"file_h",
":",
"buf",
"=",
"file_h"... | [
4,
0
] | [
27,
44
] | python | en | ['en', 'error', 'th'] | False |
fromstr | (string, **kwargs) | Given a string value, returns a GEOSGeometry object. | Given a string value, returns a GEOSGeometry object. | def fromstr(string, **kwargs):
"Given a string value, returns a GEOSGeometry object."
return GEOSGeometry(string, **kwargs) | [
"def",
"fromstr",
"(",
"string",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"GEOSGeometry",
"(",
"string",
",",
"*",
"*",
"kwargs",
")"
] | [
30,
0
] | [
32,
41
] | python | en | ['en', 'en', 'en'] | True |
one_click_unsubscribe_link | (user_profile: UserProfile, email_type: str) |
Generate a unique link that a logged-out user can visit to unsubscribe from
Zulip e-mails without having to first log in.
|
Generate a unique link that a logged-out user can visit to unsubscribe from
Zulip e-mails without having to first log in.
| def one_click_unsubscribe_link(user_profile: UserProfile, email_type: str) -> str:
"""
Generate a unique link that a logged-out user can visit to unsubscribe from
Zulip e-mails without having to first log in.
"""
return create_confirmation_link(
user_profile, Confirmation.UNSUBSCRIBE, url_ar... | [
"def",
"one_click_unsubscribe_link",
"(",
"user_profile",
":",
"UserProfile",
",",
"email_type",
":",
"str",
")",
"->",
"str",
":",
"return",
"create_confirmation_link",
"(",
"user_profile",
",",
"Confirmation",
".",
"UNSUBSCRIBE",
",",
"url_args",
"=",
"{",
"\"em... | [
162,
0
] | [
169,
5
] | python | en | ['en', 'error', 'th'] | False |
validate_key | (creation_key: Optional[str]) | Get the record for this key, raising InvalidCreationKey if non-None but invalid. | Get the record for this key, raising InvalidCreationKey if non-None but invalid. | def validate_key(creation_key: Optional[str]) -> Optional["RealmCreationKey"]:
"""Get the record for this key, raising InvalidCreationKey if non-None but invalid."""
if creation_key is None:
return None
try:
key_record = RealmCreationKey.objects.get(creation_key=creation_key)
except Real... | [
"def",
"validate_key",
"(",
"creation_key",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"Optional",
"[",
"\"RealmCreationKey\"",
"]",
":",
"if",
"creation_key",
"is",
"None",
":",
"return",
"None",
"try",
":",
"key_record",
"=",
"RealmCreationKey",
".",
"ob... | [
181,
0
] | [
192,
21
] | python | en | ['en', 'en', 'en'] | True |
objective.__init__ | (self,
results_path=None, results=pd.DataFrame(),
domain_path=None, domain=pd.DataFrame(),
exindex_path=None, exindex=pd.DataFrame(),
target=-1, gpu=False, computational_objective=None) |
Parameters
----------
results_path : str, optional
Path to experimental results.
results : pandas.DataFrame, optional
Experimental results with X values matching the domain.
domain_path : str, optional
Path to experimental domain.
... |
Parameters
----------
results_path : str, optional
Path to experimental results.
results : pandas.DataFrame, optional
Experimental results with X values matching the domain.
domain_path : str, optional
Path to experimental domain.
... | def __init__(self,
results_path=None, results=pd.DataFrame(),
domain_path=None, domain=pd.DataFrame(),
exindex_path=None, exindex=pd.DataFrame(),
target=-1, gpu=False, computational_objective=None):
"""
Parameters
----------
... | [
"def",
"__init__",
"(",
"self",
",",
"results_path",
"=",
"None",
",",
"results",
"=",
"pd",
".",
"DataFrame",
"(",
")",
",",
"domain_path",
"=",
"None",
",",
"domain",
"=",
"pd",
".",
"DataFrame",
"(",
")",
",",
"exindex_path",
"=",
"None",
",",
"ex... | [
22,
4
] | [
116,
42
] | python | en | ['en', 'error', 'th'] | False |
objective.get_results | (self, domain_points, append=False) | Returns target values corresponding to domain_points.
Parameters
----------
domain_points : pandas.DataFrame
Points from experiment index to retrieve responses for. If the
objective is a computational function, run function and return
responses.
... | Returns target values corresponding to domain_points.
Parameters
----------
domain_points : pandas.DataFrame
Points from experiment index to retrieve responses for. If the
objective is a computational function, run function and return
responses.
... | def get_results(self, domain_points, append=False):
"""Returns target values corresponding to domain_points.
Parameters
----------
domain_points : pandas.DataFrame
Points from experiment index to retrieve responses for. If the
objective is a computationa... | [
"def",
"get_results",
"(",
"self",
",",
"domain_points",
",",
"append",
"=",
"False",
")",
":",
"# Computational objective",
"if",
"self",
".",
"computational_objective",
"!=",
"None",
":",
"new_results",
"=",
"[",
"]",
"for",
"point",
"in",
"domain_points",
"... | [
120,
4
] | [
190,
20
] | python | en | ['en', 'en', 'en'] | True |
objective.clear_results | (self) | Clear results and reset X and y.
Returns
----------
None
| Clear results and reset X and y.
Returns
----------
None
| def clear_results(self):
"""Clear results and reset X and y.
Returns
----------
None
"""
self.results = pd.DataFrame()
self.X = to_torch([], gpu=self.gpu)
self.y = to_torch([], gpu=self.gpu) | [
"def",
"clear_results",
"(",
"self",
")",
":",
"self",
".",
"results",
"=",
"pd",
".",
"DataFrame",
"(",
")",
"self",
".",
"X",
"=",
"to_torch",
"(",
"[",
"]",
",",
"gpu",
"=",
"self",
".",
"gpu",
")",
"self",
".",
"y",
"=",
"to_torch",
"(",
"[... | [
194,
4
] | [
204,
43
] | python | en | ['en', 'en', 'en'] | True |
objective.results_input | (self) | Return unstandardized results.
Returns
----------
pandas.DataFrame
Unstandardized results.
| Return unstandardized results.
Returns
----------
pandas.DataFrame
Unstandardized results.
| def results_input(self):
"""Return unstandardized results.
Returns
----------
pandas.DataFrame
Unstandardized results.
"""
if len(self.results) == 0:
results = self.results
else:
results = self.scaler.unstandar... | [
"def",
"results_input",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"results",
")",
"==",
"0",
":",
"results",
"=",
"self",
".",
"results",
"else",
":",
"results",
"=",
"self",
".",
"scaler",
".",
"unstandardize_target",
"(",
"self",
".",
"... | [
208,
4
] | [
222,
22
] | python | en | ['mt', 'fy', 'en'] | False |
LogstashFormatter.reformat_data_for_log | (self, raw_data, kind=None) |
Process dictionaries from various contexts (job events, activity stream
changes, etc.) to give meaningful information
Output a dictionary which will be passed in logstash or syslog format
to the logging receiver
|
Process dictionaries from various contexts (job events, activity stream
changes, etc.) to give meaningful information
Output a dictionary which will be passed in logstash or syslog format
to the logging receiver
| def reformat_data_for_log(self, raw_data, kind=None):
"""
Process dictionaries from various contexts (job events, activity stream
changes, etc.) to give meaningful information
Output a dictionary which will be passed in logstash or syslog format
to the logging receiver
""... | [
"def",
"reformat_data_for_log",
"(",
"self",
",",
"raw_data",
",",
"kind",
"=",
"None",
")",
":",
"if",
"kind",
"==",
"'activity_stream'",
":",
"try",
":",
"raw_data",
"[",
"'changes'",
"]",
"=",
"json",
".",
"loads",
"(",
"raw_data",
".",
"get",
"(",
... | [
151,
4
] | [
252,
27
] | python | en | ['en', 'error', 'th'] | False |
xor_hex_strings | (bytes_a: str, bytes_b: str) | Given two hex strings of equal length, return a hex string with
the bitwise xor of the two hex strings. | Given two hex strings of equal length, return a hex string with
the bitwise xor of the two hex strings. | def xor_hex_strings(bytes_a: str, bytes_b: str) -> str:
"""Given two hex strings of equal length, return a hex string with
the bitwise xor of the two hex strings."""
assert len(bytes_a) == len(bytes_b)
return "".join(f"{int(x, 16) ^ int(y, 16):x}" for x, y in zip(bytes_a, bytes_b)) | [
"def",
"xor_hex_strings",
"(",
"bytes_a",
":",
"str",
",",
"bytes_b",
":",
"str",
")",
"->",
"str",
":",
"assert",
"len",
"(",
"bytes_a",
")",
"==",
"len",
"(",
"bytes_b",
")",
"return",
"\"\"",
".",
"join",
"(",
"f\"{int(x, 16) ^ int(y, 16):x}\"",
"for",
... | [
13,
0
] | [
17,
84
] | python | en | ['en', 'en', 'en'] | True |
ascii_to_hex | (input_string: str) | Given an ascii string, encode it as a hex string | Given an ascii string, encode it as a hex string | def ascii_to_hex(input_string: str) -> str:
"""Given an ascii string, encode it as a hex string"""
return input_string.encode().hex() | [
"def",
"ascii_to_hex",
"(",
"input_string",
":",
"str",
")",
"->",
"str",
":",
"return",
"input_string",
".",
"encode",
"(",
")",
".",
"hex",
"(",
")"
] | [
20,
0
] | [
22,
38
] | python | en | ['en', 'en', 'en'] | True |
hex_to_ascii | (input_string: str) | Given a hex array, decode it back to a string | Given a hex array, decode it back to a string | def hex_to_ascii(input_string: str) -> str:
"""Given a hex array, decode it back to a string"""
return bytes.fromhex(input_string).decode() | [
"def",
"hex_to_ascii",
"(",
"input_string",
":",
"str",
")",
"->",
"str",
":",
"return",
"bytes",
".",
"fromhex",
"(",
"input_string",
")",
".",
"decode",
"(",
")"
] | [
25,
0
] | [
27,
47
] | python | en | ['en', 'en', 'en'] | True |
Ghostscript | (tile, size, fp, scale=1) | Render an image using Ghostscript | Render an image using Ghostscript | def Ghostscript(tile, size, fp, scale=1):
"""Render an image using Ghostscript"""
# Unpack decoder tile
decoder, tile, offset, data = tile[0]
length, bbox = data
# Hack to support hi-res rendering
scale = int(scale) or 1
# orig_size = size
# orig_bbox = bbox
size = (size[0] * scale... | [
"def",
"Ghostscript",
"(",
"tile",
",",
"size",
",",
"fp",
",",
"scale",
"=",
"1",
")",
":",
"# Unpack decoder tile",
"decoder",
",",
"tile",
",",
"offset",
",",
"data",
"=",
"tile",
"[",
"0",
"]",
"length",
",",
"bbox",
"=",
"data",
"# Hack to support... | [
63,
0
] | [
155,
13
] | python | af | ['de', 'af', 'en'] | False |
_save | (im, fp, filename, eps=1) | EPS Writer for the Python Imaging Library. | EPS Writer for the Python Imaging Library. | def _save(im, fp, filename, eps=1):
"""EPS Writer for the Python Imaging Library."""
#
# make sure image data is available
im.load()
#
# determine PostScript image mode
if im.mode == "L":
operator = (8, 1, "image")
elif im.mode == "RGB":
operator = (8, 3, "false 3 color... | [
"def",
"_save",
"(",
"im",
",",
"fp",
",",
"filename",
",",
"eps",
"=",
"1",
")",
":",
"#",
"# make sure image data is available",
"im",
".",
"load",
"(",
")",
"#",
"# determine PostScript image mode",
"if",
"im",
".",
"mode",
"==",
"\"L\"",
":",
"operator... | [
346,
0
] | [
405,
23
] | python | en | ['en', 'en', 'en'] | True |
LofarHdf5Image._beamsizeparse | (self, source) | Read and return the beam properties bmaj, bmin and bpa values from
the fits header
| Read and return the beam properties bmaj, bmin and bpa values from
the fits header
| def _beamsizeparse(self, source):
"""Read and return the beam properties bmaj, bmin and bpa values from
the fits header
"""
# todo: this data is not present in the h5 lofar example file in the data repo
pass | [
"def",
"_beamsizeparse",
"(",
"self",
",",
"source",
")",
":",
"# todo: this data is not present in the h5 lofar example file in the data repo",
"pass"
] | [
73,
4
] | [
78,
12
] | python | en | ['en', 'en', 'en'] | True |
CMCEntity.ContainmentTree | (self) |
Removing storage component from M1000e and FX2 model chassis
:return: JSON
|
Removing storage component from M1000e and FX2 model chassis
:return: JSON
| def ContainmentTree(self):
"""
Removing storage component from M1000e and FX2 model chassis
:return: JSON
"""
device_json = self.get_json_device()
ctree = self._build_ctree(self.protofactory.ctree, device_json)
cmcmodel = self.entityjson['System'][0]["Model... | [
"def",
"ContainmentTree",
"(",
"self",
")",
":",
"device_json",
"=",
"self",
".",
"get_json_device",
"(",
")",
"ctree",
"=",
"self",
".",
"_build_ctree",
"(",
"self",
".",
"protofactory",
".",
"ctree",
",",
"device_json",
")",
"cmcmodel",
"=",
"self",
".",... | [
921,
4
] | [
934,
20
] | python | en | ['en', 'ja', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.