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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
_download_srtm_file_unlocked | (zone) | Checks if the srtm data is in the directory and if not, download it.
| Checks if the srtm data is in the directory and if not, download it.
| def _download_srtm_file_unlocked(zone):
"""Checks if the srtm data is in the directory and if not, download it.
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(tmpdir)
outpath = os.path.join(tmpdir, 'srtm_' + zone + '.tif')
# check if extracted file exists already
if os.pat... | [
"def",
"_download_srtm_file_unlocked",
"(",
"zone",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"outpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tmpdir",
",",
"'srtm_'",
"+",... | [
873,
0
] | [
903,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_nasadem_file_unlocked | (zone) | Checks if the NASADEM data is in the directory and if not, download it.
| Checks if the NASADEM data is in the directory and if not, download it.
| def _download_nasadem_file_unlocked(zone):
"""Checks if the NASADEM data is in the directory and if not, download it.
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(tmpdir)
wwwfile = ('https://e4ftl01.cr.usgs.gov/MEASURES/NASADEM_HGT.001/'
'2000.02.11/NASADEM_HGT_{}.... | [
"def",
"_download_nasadem_file_unlocked",
"(",
"zone",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"wwwfile",
"=",
"(",
"'https://e4ftl01.cr.usgs.gov/MEASURES/NASADEM_HGT.001/'",
"'2000.02.11/N... | [
911,
0
] | [
942,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_tandem_file_unlocked | (zone) | Checks if the tandem data is in the directory and if not, download it.
| Checks if the tandem data is in the directory and if not, download it.
| def _download_tandem_file_unlocked(zone):
"""Checks if the tandem data is in the directory and if not, download it.
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(tmpdir)
bname = zone.split('/')[-1] + '_DEM.tif'
wwwfile = ('https://download.geoservice.dlr.de/TDM90/files/'
... | [
"def",
"_download_tandem_file_unlocked",
"(",
"zone",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"bname",
"=",
"zone",
".",
"split",
"(",
"'/'",
")",
"[",
"-",
"1",
"]",
"+",
... | [
950,
0
] | [
988,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_dem3_viewpano_unlocked | (zone) | Checks if the DEM3 data is in the directory and if not, download it.
| Checks if the DEM3 data is in the directory and if not, download it.
| def _download_dem3_viewpano_unlocked(zone):
"""Checks if the DEM3 data is in the directory and if not, download it.
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(tmpdir)
outpath = os.path.join(tmpdir, zone + '.tif')
extract_dir = os.path.join(tmpdir, 'tmp_' + zone)
mkdir(e... | [
"def",
"_download_dem3_viewpano_unlocked",
"(",
"zone",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"outpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tmpdir",
",",
"zone",
"+"... | [
996,
0
] | [
1082,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_aster_file_unlocked | (zone) | Checks if the ASTER data is in the directory and if not, download it.
| Checks if the ASTER data is in the directory and if not, download it.
| def _download_aster_file_unlocked(zone):
"""Checks if the ASTER data is in the directory and if not, download it.
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(tmpdir)
wwwfile = ('https://e4ftl01.cr.usgs.gov/ASTER_B/ASTT/ASTGTM.003/'
'2000.03.01/{}.zip'.format(zone)... | [
"def",
"_download_aster_file_unlocked",
"(",
"zone",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"wwwfile",
"=",
"(",
"'https://e4ftl01.cr.usgs.gov/ASTER_B/ASTT/ASTGTM.003/'",
"'2000.03.01/{}.z... | [
1090,
0
] | [
1120,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_topo_file_from_cluster_unlocked | (fname) | Checks if the special topo data is in the directory and if not,
download it from the cluster.
| Checks if the special topo data is in the directory and if not,
download it from the cluster.
| def _download_topo_file_from_cluster_unlocked(fname):
"""Checks if the special topo data is in the directory and if not,
download it from the cluster.
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(tmpdir)
outpath = os.path.join(tmpdir, fname)
url = 'https://cluster.klima.... | [
"def",
"_download_topo_file_from_cluster_unlocked",
"(",
"fname",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"outpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tmpdir",
",",
"fn... | [
1128,
0
] | [
1150,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_copdem_file_unlocked | (cppfile, tilename) | Checks if Copernicus DEM file is in the directory, if not download it.
cppfile : name of the tarfile to download
tilename : name of folder and tif file within the cppfile
| Checks if Copernicus DEM file is in the directory, if not download it. | def _download_copdem_file_unlocked(cppfile, tilename):
"""Checks if Copernicus DEM file is in the directory, if not download it.
cppfile : name of the tarfile to download
tilename : name of folder and tif file within the cppfile
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(... | [
"def",
"_download_copdem_file_unlocked",
"(",
"cppfile",
",",
"tilename",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"# tarfiles are extracted in directories per each tile",
"fpath",
"=",
"'... | [
1158,
0
] | [
1203,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_aw3d30_file_unlocked | (fullzone) | Checks if the AW3D30 data is in the directory and if not, download it.
| Checks if the AW3D30 data is in the directory and if not, download it.
| def _download_aw3d30_file_unlocked(fullzone):
"""Checks if the AW3D30 data is in the directory and if not, download it.
"""
# extract directory
tmpdir = cfg.PATHS['tmp_dir']
mkdir(tmpdir)
# tarfiles are extracted in directories per each tile
tile = fullzone.split('/')[1]
demfile = os.p... | [
"def",
"_download_aw3d30_file_unlocked",
"(",
"fullzone",
")",
":",
"# extract directory",
"tmpdir",
"=",
"cfg",
".",
"PATHS",
"[",
"'tmp_dir'",
"]",
"mkdir",
"(",
"tmpdir",
")",
"# tarfiles are extracted in directories per each tile",
"tile",
"=",
"fullzone",
".",
"s... | [
1211,
0
] | [
1251,
18
] | python | en | ['en', 'en', 'en'] | True |
_download_mapzen_file_unlocked | (zone) | Checks if the mapzen data is in the directory and if not, download it.
| Checks if the mapzen data is in the directory and if not, download it.
| def _download_mapzen_file_unlocked(zone):
"""Checks if the mapzen data is in the directory and if not, download it.
"""
bucket = 'elevation-tiles-prod'
prefix = 'geotiff'
url = 'http://s3.amazonaws.com/%s/%s/%s' % (bucket, prefix, zone)
# That's all
return file_downloader(url, timeout=180) | [
"def",
"_download_mapzen_file_unlocked",
"(",
"zone",
")",
":",
"bucket",
"=",
"'elevation-tiles-prod'",
"prefix",
"=",
"'geotiff'",
"url",
"=",
"'http://s3.amazonaws.com/%s/%s/%s'",
"%",
"(",
"bucket",
",",
"prefix",
",",
"zone",
")",
"# That's all",
"return",
"fil... | [
1259,
0
] | [
1267,
44
] | python | en | ['en', 'en', 'en'] | True |
get_prepro_base_url | (base_url=None, rgi_version=None, border=None,
prepro_level=None) | Extended base url where to find the desired gdirs. | Extended base url where to find the desired gdirs. | def get_prepro_base_url(base_url=None, rgi_version=None, border=None,
prepro_level=None):
"""Extended base url where to find the desired gdirs."""
if base_url is None:
if prepro_level <= 2:
base_url = GDIR_L1L2_URL
else:
base_url = GDIR_L3L5_URL
... | [
"def",
"get_prepro_base_url",
"(",
"base_url",
"=",
"None",
",",
"rgi_version",
"=",
"None",
",",
"border",
"=",
"None",
",",
"prepro_level",
"=",
"None",
")",
":",
"if",
"base_url",
"is",
"None",
":",
"if",
"prepro_level",
"<=",
"2",
":",
"base_url",
"=... | [
1276,
0
] | [
1299,
14
] | python | en | ['en', 'en', 'en'] | True |
get_geodetic_mb_dataframe | (file_path=None) | Fetches the reference geodetic dataframe for calibration.
Currently that's the data from Hughonnet et al 2021, corrected for
outliers and with void filled. The data preparation script is
available at
https://nbviewer.jupyter.org/urls/cluster.klima.uni-bremen.de/~oggm/geodetic_ref_mb/convert.ipynb
... | Fetches the reference geodetic dataframe for calibration. | def get_geodetic_mb_dataframe(file_path=None):
"""Fetches the reference geodetic dataframe for calibration.
Currently that's the data from Hughonnet et al 2021, corrected for
outliers and with void filled. The data preparation script is
available at
https://nbviewer.jupyter.org/urls/cluster.klima.u... | [
"def",
"get_geodetic_mb_dataframe",
"(",
"file_path",
"=",
"None",
")",
":",
"# fetch the file online or read custom file",
"if",
"file_path",
"is",
"None",
":",
"base_url",
"=",
"'https://cluster.klima.uni-bremen.de/~oggm/geodetic_ref_mb/'",
"file_name",
"=",
"'hugonnet_2021_d... | [
1315,
0
] | [
1357,
13
] | python | en | ['en', 'en', 'en'] | True |
srtm_zone | (lon_ex, lat_ex) | Returns a list of SRTM zones covering the desired extent.
| Returns a list of SRTM zones covering the desired extent.
| def srtm_zone(lon_ex, lat_ex):
"""Returns a list of SRTM zones covering the desired extent.
"""
# SRTM are sorted in tiles of 5 degrees
srtm_x0 = -180.
srtm_y0 = 60.
srtm_dx = 5.
srtm_dy = -5.
# quick n dirty solution to be sure that we will cover the whole range
mi, ma = np.min(lo... | [
"def",
"srtm_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"# SRTM are sorted in tiles of 5 degrees",
"srtm_x0",
"=",
"-",
"180.",
"srtm_y0",
"=",
"60.",
"srtm_dx",
"=",
"5.",
"srtm_dy",
"=",
"-",
"5.",
"# quick n dirty solution to be sure that we will cover the whole ... | [
1360,
0
] | [
1387,
35
] | python | en | ['en', 'en', 'en'] | True |
tandem_zone | (lon_ex, lat_ex) | Returns a list of TanDEM-X zones covering the desired extent.
| Returns a list of TanDEM-X zones covering the desired extent.
| def tandem_zone(lon_ex, lat_ex):
"""Returns a list of TanDEM-X zones covering the desired extent.
"""
# Files are one by one tiles, so lets loop over them
# For higher lats they are stored in steps of 2 and 4. My code below
# is probably giving more files than needed but better safe than sorry
... | [
"def",
"tandem_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"# Files are one by one tiles, so lets loop over them",
"# For higher lats they are stored in steps of 2 and 4. My code below",
"# is probably giving more files than needed but better safe than sorry",
"lat_tiles",
"=",
"np",
... | [
1417,
0
] | [
1440,
35
] | python | en | ['en', 'en', 'en'] | True |
aw3d30_zone | (lon_ex, lat_ex) | Returns a list of AW3D30 zones covering the desired extent.
| Returns a list of AW3D30 zones covering the desired extent.
| def aw3d30_zone(lon_ex, lat_ex):
"""Returns a list of AW3D30 zones covering the desired extent.
"""
# Files are one by one tiles, so lets loop over them
lon_tiles = np.arange(np.floor(lon_ex[0]), np.ceil(lon_ex[1]+1e-9),
dtype=int)
lat_tiles = np.arange(np.floor(lat_ex[0])... | [
"def",
"aw3d30_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"# Files are one by one tiles, so lets loop over them",
"lon_tiles",
"=",
"np",
".",
"arange",
"(",
"np",
".",
"floor",
"(",
"lon_ex",
"[",
"0",
"]",
")",
",",
"np",
".",
"ceil",
"(",
"lon_ex",
... | [
1471,
0
] | [
1484,
35
] | python | en | ['en', 'en', 'en'] | True |
arcticdem_zone | (lon_ex, lat_ex) | Returns a list of Arctic-DEM zones covering the desired extent.
| Returns a list of Arctic-DEM zones covering the desired extent.
| def arcticdem_zone(lon_ex, lat_ex):
"""Returns a list of Arctic-DEM zones covering the desired extent.
"""
gdf = gpd.read_file(get_demo_file('ArcticDEM_Tile_Index_Rel7_by_tile.shp'))
p = _extent_to_polygon(lon_ex, lat_ex, to_crs=gdf.crs)
gdf = gdf.loc[gdf.intersects(p)]
return gdf.tile.values i... | [
"def",
"arcticdem_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"gdf",
"=",
"gpd",
".",
"read_file",
"(",
"get_demo_file",
"(",
"'ArcticDEM_Tile_Index_Rel7_by_tile.shp'",
")",
")",
"p",
"=",
"_extent_to_polygon",
"(",
"lon_ex",
",",
"lat_ex",
",",
"to_crs",
"... | [
1500,
0
] | [
1507,
50
] | python | en | ['en', 'en', 'en'] | True |
rema_zone | (lon_ex, lat_ex) | Returns a list of REMA-DEM zones covering the desired extent.
| Returns a list of REMA-DEM zones covering the desired extent.
| def rema_zone(lon_ex, lat_ex):
"""Returns a list of REMA-DEM zones covering the desired extent.
"""
gdf = gpd.read_file(get_demo_file('REMA_Tile_Index_Rel1.1.shp'))
p = _extent_to_polygon(lon_ex, lat_ex, to_crs=gdf.crs)
gdf = gdf.loc[gdf.intersects(p)]
return gdf.tile.values if len(gdf) > 0 els... | [
"def",
"rema_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"gdf",
"=",
"gpd",
".",
"read_file",
"(",
"get_demo_file",
"(",
"'REMA_Tile_Index_Rel1.1.shp'",
")",
")",
"p",
"=",
"_extent_to_polygon",
"(",
"lon_ex",
",",
"lat_ex",
",",
"to_crs",
"=",
"gdf",
"... | [
1510,
0
] | [
1517,
50
] | python | en | ['en', 'en', 'en'] | True |
alaska_dem_zone | (lon_ex, lat_ex) | Returns a list of Alaska-DEM zones covering the desired extent.
| Returns a list of Alaska-DEM zones covering the desired extent.
| def alaska_dem_zone(lon_ex, lat_ex):
"""Returns a list of Alaska-DEM zones covering the desired extent.
"""
gdf = gpd.read_file(get_demo_file('Alaska_albers_V3_tiles.shp'))
p = _extent_to_polygon(lon_ex, lat_ex, to_crs=gdf.crs)
gdf = gdf.loc[gdf.intersects(p)]
return gdf.tile.values if len(gdf)... | [
"def",
"alaska_dem_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"gdf",
"=",
"gpd",
".",
"read_file",
"(",
"get_demo_file",
"(",
"'Alaska_albers_V3_tiles.shp'",
")",
")",
"p",
"=",
"_extent_to_polygon",
"(",
"lon_ex",
",",
"lat_ex",
",",
"to_crs",
"=",
"gdf... | [
1520,
0
] | [
1527,
50
] | python | en | ['en', 'en', 'en'] | True |
copdem_zone | (lon_ex, lat_ex) | Returns a list of Copernicus DEM tarfile and tilename tuples
| Returns a list of Copernicus DEM tarfile and tilename tuples
| def copdem_zone(lon_ex, lat_ex):
"""Returns a list of Copernicus DEM tarfile and tilename tuples
"""
# path to the lookup shapefiles
gdf = gpd.read_file(get_demo_file('RGI60_COPDEM_lookup.shp'))
# intersect with lat lon extents
p = _extent_to_polygon(lon_ex, lat_ex, to_crs=gdf.crs)
gdf = g... | [
"def",
"copdem_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"# path to the lookup shapefiles",
"gdf",
"=",
"gpd",
".",
"read_file",
"(",
"get_demo_file",
"(",
"'RGI60_COPDEM_lookup.shp'",
")",
")",
"# intersect with lat lon extents",
"p",
"=",
"_extent_to_polygon",
... | [
1530,
0
] | [
1553,
16
] | python | en | ['en', 'sm', 'en'] | True |
dem3_viewpano_zone | (lon_ex, lat_ex) | Returns a list of DEM3 zones covering the desired extent.
http://viewfinderpanoramas.org/Coverage%20map%20viewfinderpanoramas_org3.htm
| Returns a list of DEM3 zones covering the desired extent. | def dem3_viewpano_zone(lon_ex, lat_ex):
"""Returns a list of DEM3 zones covering the desired extent.
http://viewfinderpanoramas.org/Coverage%20map%20viewfinderpanoramas_org3.htm
"""
for _f in DEM3REG.keys():
if (np.min(lon_ex) >= DEM3REG[_f][0]) and \
(np.max(lon_ex) <= DEM3REG[_f]... | [
"def",
"dem3_viewpano_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"for",
"_f",
"in",
"DEM3REG",
".",
"keys",
"(",
")",
":",
"if",
"(",
"np",
".",
"min",
"(",
"lon_ex",
")",
">=",
"DEM3REG",
"[",
"_f",
"]",
"[",
"0",
"]",
")",
"and",
"(",
"np... | [
1556,
0
] | [
1639,
35
] | python | en | ['en', 'en', 'en'] | True |
aster_zone | (lon_ex, lat_ex) | Returns a list of ASTGTMV3 zones covering the desired extent.
ASTER v3 tiles are 1 degree x 1 degree
N50 contains 50 to 50.9
E10 contains 10 to 10.9
S70 contains -69.99 to -69.0
W20 contains -19.99 to -19.0
| Returns a list of ASTGTMV3 zones covering the desired extent. | def aster_zone(lon_ex, lat_ex):
"""Returns a list of ASTGTMV3 zones covering the desired extent.
ASTER v3 tiles are 1 degree x 1 degree
N50 contains 50 to 50.9
E10 contains 10 to 10.9
S70 contains -69.99 to -69.0
W20 contains -19.99 to -19.0
"""
# adding small buffer for unlikely case ... | [
"def",
"aster_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"# adding small buffer for unlikely case where one lon/lat_ex == xx.0",
"lons",
"=",
"np",
".",
"arange",
"(",
"np",
".",
"floor",
"(",
"lon_ex",
"[",
"0",
"]",
"-",
"1e-9",
")",
",",
"np",
".",
"c... | [
1642,
0
] | [
1666,
35
] | python | en | ['en', 'en', 'en'] | True |
nasadem_zone | (lon_ex, lat_ex) | Returns a list of NASADEM zones covering the desired extent.
NASADEM tiles are 1 degree x 1 degree
N50 contains 50 to 50.9
E10 contains 10 to 10.9
S70 contains -69.99 to -69.0
W20 contains -19.99 to -19.0
| Returns a list of NASADEM zones covering the desired extent. | def nasadem_zone(lon_ex, lat_ex):
"""Returns a list of NASADEM zones covering the desired extent.
NASADEM tiles are 1 degree x 1 degree
N50 contains 50 to 50.9
E10 contains 10 to 10.9
S70 contains -69.99 to -69.0
W20 contains -19.99 to -19.0
"""
# adding small buffer for unlikely case ... | [
"def",
"nasadem_zone",
"(",
"lon_ex",
",",
"lat_ex",
")",
":",
"# adding small buffer for unlikely case where one lon/lat_ex == xx.0",
"lons",
"=",
"np",
".",
"arange",
"(",
"np",
".",
"floor",
"(",
"lon_ex",
"[",
"0",
"]",
"-",
"1e-9",
")",
",",
"np",
".",
... | [
1669,
0
] | [
1693,
35
] | python | en | ['en', 'en', 'en'] | True |
mapzen_zone | (lon_ex, lat_ex, dx_meter=None, zoom=None) | Returns a list of AWS mapzen zones covering the desired extent.
For mapzen one has to specify the level of detail (zoom) one wants. The
best way in OGGM is to specify dx_meter of the underlying map and OGGM
will decide which zoom level works best.
| Returns a list of AWS mapzen zones covering the desired extent. | def mapzen_zone(lon_ex, lat_ex, dx_meter=None, zoom=None):
"""Returns a list of AWS mapzen zones covering the desired extent.
For mapzen one has to specify the level of detail (zoom) one wants. The
best way in OGGM is to specify dx_meter of the underlying map and OGGM
will decide which zoom level works... | [
"def",
"mapzen_zone",
"(",
"lon_ex",
",",
"lat_ex",
",",
"dx_meter",
"=",
"None",
",",
"zoom",
"=",
"None",
")",
":",
"if",
"dx_meter",
"is",
"None",
"and",
"zoom",
"is",
"None",
":",
"raise",
"InvalidParamsError",
"(",
"'Need either zoom level or dx_meter.'",... | [
1696,
0
] | [
1744,
16
] | python | en | ['en', 'en', 'en'] | True |
get_demo_file | (fname) | Returns the path to the desired OGGM-sample-file.
If Sample data is not cached it will be downloaded from
https://github.com/OGGM/oggm-sample-data
Parameters
----------
fname : str
Filename of the desired OGGM-sample-file
Returns
-------
str
Absolute path to the desire... | Returns the path to the desired OGGM-sample-file. | def get_demo_file(fname):
"""Returns the path to the desired OGGM-sample-file.
If Sample data is not cached it will be downloaded from
https://github.com/OGGM/oggm-sample-data
Parameters
----------
fname : str
Filename of the desired OGGM-sample-file
Returns
-------
str
... | [
"def",
"get_demo_file",
"(",
"fname",
")",
":",
"d",
"=",
"download_oggm_files",
"(",
")",
"if",
"fname",
"in",
"d",
":",
"return",
"d",
"[",
"fname",
"]",
"else",
":",
"return",
"None"
] | [
1747,
0
] | [
1768,
19
] | python | en | ['en', 'en', 'en'] | True |
get_wgms_files | () | Get the path to the default WGMS-RGI link file and the data dir.
Returns
-------
(file, dir) : paths to the files
| Get the path to the default WGMS-RGI link file and the data dir. | def get_wgms_files():
"""Get the path to the default WGMS-RGI link file and the data dir.
Returns
-------
(file, dir) : paths to the files
"""
download_oggm_files()
sdir = os.path.join(cfg.CACHE_DIR,
'oggm-sample-data-%s' % SAMPLE_DATA_COMMIT,
... | [
"def",
"get_wgms_files",
"(",
")",
":",
"download_oggm_files",
"(",
")",
"sdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cfg",
".",
"CACHE_DIR",
",",
"'oggm-sample-data-%s'",
"%",
"SAMPLE_DATA_COMMIT",
",",
"'wgms'",
")",
"datadir",
"=",
"os",
".",
"pat... | [
1771,
0
] | [
1789,
24
] | python | en | ['en', 'en', 'en'] | True |
get_glathida_file | () | Get the path to the default GlaThiDa-RGI link file.
Returns
-------
file : paths to the file
| Get the path to the default GlaThiDa-RGI link file. | def get_glathida_file():
"""Get the path to the default GlaThiDa-RGI link file.
Returns
-------
file : paths to the file
"""
# Roll our own
download_oggm_files()
sdir = os.path.join(cfg.CACHE_DIR,
'oggm-sample-data-%s' % SAMPLE_DATA_COMMIT,
... | [
"def",
"get_glathida_file",
"(",
")",
":",
"# Roll our own",
"download_oggm_files",
"(",
")",
"sdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cfg",
".",
"CACHE_DIR",
",",
"'oggm-sample-data-%s'",
"%",
"SAMPLE_DATA_COMMIT",
",",
"'glathida'",
")",
"outf",
"=... | [
1792,
0
] | [
1807,
15
] | python | en | ['en', 'en', 'en'] | True |
get_rgi_dir | (version=None, reset=False) | Path to the RGI directory.
If the RGI files are not present, download them.
Parameters
----------
version : str
'5', '6', defaults to None (linking to the one specified in cfg.PARAMS)
reset : bool
If True, deletes the RGI directory first and downloads the data
Returns
----... | Path to the RGI directory. | def get_rgi_dir(version=None, reset=False):
"""Path to the RGI directory.
If the RGI files are not present, download them.
Parameters
----------
version : str
'5', '6', defaults to None (linking to the one specified in cfg.PARAMS)
reset : bool
If True, deletes the RGI directory... | [
"def",
"get_rgi_dir",
"(",
"version",
"=",
"None",
",",
"reset",
"=",
"False",
")",
":",
"with",
"get_lock",
"(",
")",
":",
"return",
"_get_rgi_dir_unlocked",
"(",
"version",
"=",
"version",
",",
"reset",
"=",
"reset",
")"
] | [
1810,
0
] | [
1829,
66
] | python | en | ['en', 'en', 'en'] | True |
get_rgi_region_file | (region, version=None, reset=False) | Path to the RGI region file.
If the RGI files are not present, download them.
Parameters
----------
region : str
from '01' to '19'
version : str
'5', '6', defaults to None (linking to the one specified in cfg.PARAMS)
reset : bool
If True, deletes the RGI directory first... | Path to the RGI region file. | def get_rgi_region_file(region, version=None, reset=False):
"""Path to the RGI region file.
If the RGI files are not present, download them.
Parameters
----------
region : str
from '01' to '19'
version : str
'5', '6', defaults to None (linking to the one specified in cfg.PARAMS... | [
"def",
"get_rgi_region_file",
"(",
"region",
",",
"version",
"=",
"None",
",",
"reset",
"=",
"False",
")",
":",
"rgi_dir",
"=",
"get_rgi_dir",
"(",
"version",
"=",
"version",
",",
"reset",
"=",
"reset",
")",
"f",
"=",
"list",
"(",
"glob",
".",
"glob",
... | [
1884,
0
] | [
1907,
15
] | python | en | ['en', 'it', 'en'] | True |
get_rgi_glacier_entities | (rgi_ids, version=None) | Get a list of glacier outlines selected from their RGI IDs.
Will download RGI data if not present.
Parameters
----------
rgi_ids : list of str
the glaciers you want the outlines for
version : str
the rgi version
Returns
-------
geopandas.GeoDataFrame
containing... | Get a list of glacier outlines selected from their RGI IDs. | def get_rgi_glacier_entities(rgi_ids, version=None):
"""Get a list of glacier outlines selected from their RGI IDs.
Will download RGI data if not present.
Parameters
----------
rgi_ids : list of str
the glaciers you want the outlines for
version : str
the rgi version
Retur... | [
"def",
"get_rgi_glacier_entities",
"(",
"rgi_ids",
",",
"version",
"=",
"None",
")",
":",
"regions",
"=",
"[",
"s",
".",
"split",
"(",
"'-'",
")",
"[",
"1",
"]",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"for",
"s",
"in",
"rgi_ids",
"]",
"if"... | [
1910,
0
] | [
1942,
20
] | python | en | ['en', 'en', 'en'] | True |
get_rgi_intersects_dir | (version=None, reset=False) | Path to the RGI directory containing the intersect files.
If the files are not present, download them.
Parameters
----------
version : str
'5', '6', defaults to None (linking to the one specified in cfg.PARAMS)
reset : bool
If True, deletes the intersects before redownloading them
... | Path to the RGI directory containing the intersect files. | def get_rgi_intersects_dir(version=None, reset=False):
"""Path to the RGI directory containing the intersect files.
If the files are not present, download them.
Parameters
----------
version : str
'5', '6', defaults to None (linking to the one specified in cfg.PARAMS)
reset : bool
... | [
"def",
"get_rgi_intersects_dir",
"(",
"version",
"=",
"None",
",",
"reset",
"=",
"False",
")",
":",
"with",
"get_lock",
"(",
")",
":",
"return",
"_get_rgi_intersects_dir_unlocked",
"(",
"version",
"=",
"version",
",",
"reset",
"=",
"reset",
")"
] | [
1945,
0
] | [
1964,
77
] | python | en | ['en', 'en', 'en'] | True |
get_rgi_intersects_region_file | (region=None, version=None, reset=False) | Path to the RGI regional intersect file.
If the RGI files are not present, download them.
Parameters
----------
region : str
from '00' to '19', with '00' being the global file (deprecated).
From RGI version '61' onwards, please use `get_rgi_intersects_entities`
with a list of g... | Path to the RGI regional intersect file. | def get_rgi_intersects_region_file(region=None, version=None, reset=False):
"""Path to the RGI regional intersect file.
If the RGI files are not present, download them.
Parameters
----------
region : str
from '00' to '19', with '00' being the global file (deprecated).
From RGI vers... | [
"def",
"get_rgi_intersects_region_file",
"(",
"region",
"=",
"None",
",",
"version",
"=",
"None",
",",
"reset",
"=",
"False",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"cfg",
".",
"PARAMS",
"[",
"'rgi_version'",
"]",
"if",
"len",
"(",... | [
2033,
0
] | [
2072,
15
] | python | en | ['en', 'en', 'en'] | True |
get_rgi_intersects_entities | (rgi_ids, version=None) | Get a list of glacier intersects selected from their RGI IDs.
Parameters
----------
rgi_ids: list of str
list of rgi_ids you want to look for intersections for
version: str
'5', '6', '61'... defaults the one specified in cfg.PARAMS
Returns
-------
geopandas.GeoDataFrame
... | Get a list of glacier intersects selected from their RGI IDs. | def get_rgi_intersects_entities(rgi_ids, version=None):
"""Get a list of glacier intersects selected from their RGI IDs.
Parameters
----------
rgi_ids: list of str
list of rgi_ids you want to look for intersections for
version: str
'5', '6', '61'... defaults the one specified in cfg... | [
"def",
"get_rgi_intersects_entities",
"(",
"rgi_ids",
",",
"version",
"=",
"None",
")",
":",
"if",
"version",
"is",
"None",
":",
"version",
"=",
"cfg",
".",
"PARAMS",
"[",
"'rgi_version'",
"]",
"if",
"len",
"(",
"version",
")",
"==",
"1",
":",
"version",... | [
2075,
0
] | [
2108,
20
] | python | en | ['en', 'en', 'en'] | True |
is_dem_source_available | (source, lon_ex, lat_ex) | Checks if a DEM source is available for your purpose.
This is only a very rough check! It doesn't mean that the data really is
available, but at least it's worth a try.
Parameters
----------
source : str, required
the source you want to check for
lon_ex : tuple or int, required
... | Checks if a DEM source is available for your purpose. | def is_dem_source_available(source, lon_ex, lat_ex):
"""Checks if a DEM source is available for your purpose.
This is only a very rough check! It doesn't mean that the data really is
available, but at least it's worth a try.
Parameters
----------
source : str, required
the source you w... | [
"def",
"is_dem_source_available",
"(",
"source",
",",
"lon_ex",
",",
"lat_ex",
")",
":",
"from",
"oggm",
".",
"utils",
"import",
"tolist",
"lon_ex",
"=",
"tolist",
"(",
"lon_ex",
",",
"length",
"=",
"2",
")",
"lat_ex",
"=",
"tolist",
"(",
"lat_ex",
",",
... | [
2111,
0
] | [
2168,
19
] | python | en | ['en', 'en', 'en'] | True |
default_dem_source | (rgi_id) | Current default DEM source at a given location.
Parameters
----------
rgi_id : str
the RGI id
Returns
-------
the chosen DEM source
| Current default DEM source at a given location. | def default_dem_source(rgi_id):
"""Current default DEM source at a given location.
Parameters
----------
rgi_id : str
the RGI id
Returns
-------
the chosen DEM source
"""
rgi_reg = 'RGI{}'.format(rgi_id[6:8])
rgi_id = rgi_id[:14]
if cfg.DEM_SOURCE_TABLE.get(rgi_reg)... | [
"def",
"default_dem_source",
"(",
"rgi_id",
")",
":",
"rgi_reg",
"=",
"'RGI{}'",
".",
"format",
"(",
"rgi_id",
"[",
"6",
":",
"8",
"]",
")",
"rgi_id",
"=",
"rgi_id",
"[",
":",
"14",
"]",
"if",
"cfg",
".",
"DEM_SOURCE_TABLE",
".",
"get",
"(",
"rgi_reg... | [
2171,
0
] | [
2194,
15
] | python | en | ['en', 'en', 'en'] | True |
get_topo_file | (lon_ex=None, lat_ex=None, rgi_id=None, *,
dx_meter=None, zoom=None, source=None) | Path(s) to the DEM file(s) covering the desired extent.
If the needed files for covering the extent are not present, download them.
The default behavior is to try a list of DEM sources in order, and
stop once the downloaded data is covering a large enough part of the
glacier. The DEM sources are teste... | Path(s) to the DEM file(s) covering the desired extent. | def get_topo_file(lon_ex=None, lat_ex=None, rgi_id=None, *,
dx_meter=None, zoom=None, source=None):
"""Path(s) to the DEM file(s) covering the desired extent.
If the needed files for covering the extent are not present, download them.
The default behavior is to try a list of DEM sources ... | [
"def",
"get_topo_file",
"(",
"lon_ex",
"=",
"None",
",",
"lat_ex",
"=",
"None",
",",
"rgi_id",
"=",
"None",
",",
"*",
",",
"dx_meter",
"=",
"None",
",",
"zoom",
"=",
"None",
",",
"source",
"=",
"None",
")",
":",
"from",
"oggm",
".",
"utils",
"impor... | [
2197,
0
] | [
2347,
61
] | python | en | ['en', 'en', 'en'] | True |
ImplicitFTPTLS.sock | (self) | Return the socket. | Return the socket. | def sock(self):
"""Return the socket."""
return self._sock | [
"def",
"sock",
"(",
"self",
")",
":",
"return",
"self",
".",
"_sock"
] | [
450,
4
] | [
452,
25
] | python | en | ['en', 'no', 'en'] | True |
ImplicitFTPTLS.sock | (self, value) | When modifying the socket, ensure that it is ssl wrapped. | When modifying the socket, ensure that it is ssl wrapped. | def sock(self, value):
"""When modifying the socket, ensure that it is ssl wrapped."""
if value is not None and not isinstance(value, ssl.SSLSocket):
value = self.context.wrap_socket(value)
self._sock = value | [
"def",
"sock",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"value",
",",
"ssl",
".",
"SSLSocket",
")",
":",
"value",
"=",
"self",
".",
"context",
".",
"wrap_socket",
"(",
"value",
")",
"... | [
455,
4
] | [
459,
26
] | python | en | ['en', 'en', 'en'] | True |
CasaImage.parse_data | (self, table, plane=0) | extract and massage data from CASA table | extract and massage data from CASA table | def parse_data(self, table, plane=0):
"""extract and massage data from CASA table"""
data = table[0]['map'].squeeze()
planes = len(data.shape)
if planes != 2:
msg = "received datacube with %s planes, assuming Stokes I and taking plane 0" % planes
logger.warn(msg)
... | [
"def",
"parse_data",
"(",
"self",
",",
"table",
",",
"plane",
"=",
"0",
")",
":",
"data",
"=",
"table",
"[",
"0",
"]",
"[",
"'map'",
"]",
".",
"squeeze",
"(",
")",
"planes",
"=",
"len",
"(",
"data",
".",
"shape",
")",
"if",
"planes",
"!=",
"2",... | [
42,
4
] | [
52,
19
] | python | en | ['en', 'en', 'en'] | True |
CasaImage.parse_coordinates | (self, table) | Returns a WCS object | Returns a WCS object | def parse_coordinates(self, table):
"""Returns a WCS object"""
wcs = WCS()
my_coordinates = table.getkeyword('coords')['direction0']
wcs.crval = my_coordinates['crval']
wcs.crpix = my_coordinates['crpix']
wcs.cdelt = my_coordinates['cdelt']
ctype = ['unknown', 'un... | [
"def",
"parse_coordinates",
"(",
"self",
",",
"table",
")",
":",
"wcs",
"=",
"WCS",
"(",
")",
"my_coordinates",
"=",
"table",
".",
"getkeyword",
"(",
"'coords'",
")",
"[",
"'direction0'",
"]",
"wcs",
".",
"crval",
"=",
"my_coordinates",
"[",
"'crval'",
"... | [
54,
4
] | [
72,
18
] | python | en | ['en', 'bg', 'en'] | True |
CasaImage.parse_frequency | (self, table) | extract frequency related information from headers | extract frequency related information from headers | def parse_frequency(self, table):
"""extract frequency related information from headers"""
freq_eff = table.getkeywords()['coords']['spectral2']['restfreq']
freq_bw = table.getkeywords()['coords']['spectral2']['wcs']['cdelt']
return freq_eff, freq_bw | [
"def",
"parse_frequency",
"(",
"self",
",",
"table",
")",
":",
"freq_eff",
"=",
"table",
".",
"getkeywords",
"(",
")",
"[",
"'coords'",
"]",
"[",
"'spectral2'",
"]",
"[",
"'restfreq'",
"]",
"freq_bw",
"=",
"table",
".",
"getkeywords",
"(",
")",
"[",
"'... | [
74,
4
] | [
78,
32
] | python | en | ['en', 'en', 'en'] | True |
CasaImage.parse_beam | (self, table) |
Returns:
- Beam parameters, (semimajor, semiminor, parallactic angle) in
(pixels,pixels, radians).
|
Returns:
- Beam parameters, (semimajor, semiminor, parallactic angle) in
(pixels,pixels, radians).
| def parse_beam(self, table):
"""
Returns:
- Beam parameters, (semimajor, semiminor, parallactic angle) in
(pixels,pixels, radians).
"""
def ensure_degrees(quantity):
if quantity['unit'] == 'deg':
return quantity['value']
elif ... | [
"def",
"parse_beam",
"(",
"self",
",",
"table",
")",
":",
"def",
"ensure_degrees",
"(",
"quantity",
")",
":",
"if",
"quantity",
"[",
"'unit'",
"]",
"==",
"'deg'",
":",
"return",
"quantity",
"[",
"'value'",
"]",
"elif",
"quantity",
"[",
"'unit'",
"]",
"... | [
80,
4
] | [
100,
30
] | python | en | ['en', 'error', 'th'] | False |
CasaImage.parse_taustartts | (self, table) |
Extract integration start-time from CASA table header.
This applies to some CASA images (typically those created from uvFITS
files) but not all, and so should be called for each sub-class.
Arguments:
table: MAIN table of CASA image.
Returns:
Time of im... |
Extract integration start-time from CASA table header. | def parse_taustartts(self, table):
"""
Extract integration start-time from CASA table header.
This applies to some CASA images (typically those created from uvFITS
files) but not all, and so should be called for each sub-class.
Arguments:
table: MAIN table of CASA i... | [
"def",
"parse_taustartts",
"(",
"self",
",",
"table",
")",
":",
"obsdate",
"=",
"table",
".",
"getkeyword",
"(",
"'coords'",
")",
"[",
"'obsdate'",
"]",
"[",
"'m0'",
"]",
"[",
"'value'",
"]",
"return",
"mjd2datetime",
"(",
"obsdate",
")"
] | [
109,
4
] | [
123,
36
] | python | en | ['en', 'error', 'th'] | False |
CasaImage.unique_column_values | (table, column_name) |
Find all the unique values in a particular column of a CASA table.
Arguments:
- table: ``casacore.tables.table``
- column_name: ``str``
Returns:
- ``numpy.ndarray`` containing unique values in column.
|
Find all the unique values in a particular column of a CASA table. | def unique_column_values(table, column_name):
"""
Find all the unique values in a particular column of a CASA table.
Arguments:
- table: ``casacore.tables.table``
- column_name: ``str``
Returns:
- ``numpy.ndarray`` containing unique values in column.... | [
"def",
"unique_column_values",
"(",
"table",
",",
"column_name",
")",
":",
"return",
"table",
".",
"query",
"(",
"columns",
"=",
"column_name",
",",
"sortlist",
"=",
"\"unique %s\"",
"%",
"(",
"column_name",
")",
")",
".",
"getcol",
"(",
"column_name",
")"
] | [
127,
4
] | [
140,
29
] | python | en | ['en', 'error', 'th'] | False |
find_log_caller_module | (record: logging.LogRecord) | Find the module name corresponding to where this record was logged.
Sadly `record.module` is just the innermost component of the full
module name, so we have to go reconstruct this ourselves.
| Find the module name corresponding to where this record was logged. | def find_log_caller_module(record: logging.LogRecord) -> Optional[str]:
"""Find the module name corresponding to where this record was logged.
Sadly `record.module` is just the innermost component of the full
module name, so we have to go reconstruct this ourselves.
"""
# Repeat a search similar to... | [
"def",
"find_log_caller_module",
"(",
"record",
":",
"logging",
".",
"LogRecord",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"# Repeat a search similar to that in logging.Logger.findCaller.",
"# The logging call should still be on the stack somewhere; search until",
"# we find so... | [
143,
0
] | [
159,
20
] | python | en | ['en', 'en', 'en'] | True |
log_to_file | (
logger: Logger,
filename: str,
log_format: str = "%(asctime)s %(levelname)-8s %(message)s",
) | Note: `filename` should be declared in zproject/computed_settings.py with zulip_path. | Note: `filename` should be declared in zproject/computed_settings.py with zulip_path. | def log_to_file(
logger: Logger,
filename: str,
log_format: str = "%(asctime)s %(levelname)-8s %(message)s",
) -> None:
"""Note: `filename` should be declared in zproject/computed_settings.py with zulip_path."""
formatter = logging.Formatter(log_format)
handler = logging.FileHandler(filename)
... | [
"def",
"log_to_file",
"(",
"logger",
":",
"Logger",
",",
"filename",
":",
"str",
",",
"log_format",
":",
"str",
"=",
"\"%(asctime)s %(levelname)-8s %(message)s\"",
",",
")",
"->",
"None",
":",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"log_format",
"... | [
288,
0
] | [
297,
30
] | python | en | ['en', 'en', 'en'] | True |
drop_single_value_columns | (df) |
Drop datafame columns with zero variance. Return a new dataframe.
|
Drop datafame columns with zero variance. Return a new dataframe.
| def drop_single_value_columns(df):
"""
Drop datafame columns with zero variance. Return a new dataframe.
"""
keep = []
for i in range(len(df.columns)):
if len(df.iloc[:,i].drop_duplicates()) > 1:
keep.append(df.columns.values[i])
return df[keep] | [
"def",
"drop_single_value_columns",
"(",
"df",
")",
":",
"keep",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"df",
".",
"columns",
")",
")",
":",
"if",
"len",
"(",
"df",
".",
"iloc",
"[",
":",
",",
"i",
"]",
".",
"drop_duplicates",... | [
95,
0
] | [
105,
19
] | python | en | ['en', 'error', 'th'] | False |
drop_string_columns | (df) |
Drop dataframe columns with non-numeric values. Return a new dataframe.
|
Drop dataframe columns with non-numeric values. Return a new dataframe.
| def drop_string_columns(df):
"""
Drop dataframe columns with non-numeric values. Return a new dataframe.
"""
keep = []
for i in range(len(df.columns)):
unique = df.iloc[:,i].drop_duplicates()
keepQ = True
for j in range(len(unique)):
if type(unique.iloc[j]) =... | [
"def",
"drop_string_columns",
"(",
"df",
")",
":",
"keep",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"df",
".",
"columns",
")",
")",
":",
"unique",
"=",
"df",
".",
"iloc",
"[",
":",
",",
"i",
"]",
".",
"drop_duplicates",
"(",
"... | [
109,
0
] | [
124,
19
] | python | en | ['en', 'error', 'th'] | False |
remove_features | (df, drop_list) |
Remove features from dataframe with columns containing substrings in
drop_list. Return a new dataframe.
|
Remove features from dataframe with columns containing substrings in
drop_list. Return a new dataframe.
| def remove_features(df, drop_list):
"""
Remove features from dataframe with columns containing substrings in
drop_list. Return a new dataframe.
"""
keep = []
for column_name in list(df.columns.values):
keepQ = True
for substring in list(drop_list):
if substring in co... | [
"def",
"remove_features",
"(",
"df",
",",
"drop_list",
")",
":",
"keep",
"=",
"[",
"]",
"for",
"column_name",
"in",
"list",
"(",
"df",
".",
"columns",
".",
"values",
")",
":",
"keepQ",
"=",
"True",
"for",
"substring",
"in",
"list",
"(",
"drop_list",
... | [
128,
0
] | [
143,
19
] | python | en | ['en', 'error', 'th'] | False |
standardize | (df, target, scaler='standard') |
Standardize descriptors but keep target.
|
Standardize descriptors but keep target.
| def standardize(df, target, scaler='standard'):
"""
Standardize descriptors but keep target.
"""
if scaler == 'minmax':
scaler = MinMaxScaler()
else:
scaler = StandardScaler()
if target != None:
data = df.drop(target,axis=1)
else:
data = df.copy()
... | [
"def",
"standardize",
"(",
"df",
",",
"target",
",",
"scaler",
"=",
"'standard'",
")",
":",
"if",
"scaler",
"==",
"'minmax'",
":",
"scaler",
"=",
"MinMaxScaler",
"(",
")",
"else",
":",
"scaler",
"=",
"StandardScaler",
"(",
")",
"if",
"target",
"!=",
"N... | [
147,
0
] | [
169,
17
] | python | en | ['en', 'error', 'th'] | False |
uncorrelated_features | (df, target, threshold=0.95) |
Returns an uncorrelated set of features.
|
Returns an uncorrelated set of features.
| def uncorrelated_features(df, target, threshold=0.95):
"""
Returns an uncorrelated set of features.
"""
if target != None:
data = df.drop(target,axis=1)
else:
data = df.copy()
corr = data.corr().abs()
keep = []
for i in range(len(corr.iloc[:,0])):
above ... | [
"def",
"uncorrelated_features",
"(",
"df",
",",
"target",
",",
"threshold",
"=",
"0.95",
")",
":",
"if",
"target",
"!=",
"None",
":",
"data",
"=",
"df",
".",
"drop",
"(",
"target",
",",
"axis",
"=",
"1",
")",
"else",
":",
"data",
"=",
"df",
".",
... | [
173,
0
] | [
196,
15
] | python | en | ['en', 'error', 'th'] | False |
timer.stop | (self) |
Returns wall clock-time.
|
Returns wall clock-time.
| def stop(self):
"""
Returns wall clock-time.
"""
self.end = time.time()
print(self.name + ': ' + str(self.end - self.start) + ' s') | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"end",
"=",
"time",
".",
"time",
"(",
")",
"print",
"(",
"self",
".",
"name",
"+",
"': '",
"+",
"str",
"(",
"self",
".",
"end",
"-",
"self",
".",
"start",
")",
"+",
"' s'",
")"
] | [
23,
4
] | [
29,
67
] | python | en | ['en', 'error', 'th'] | False |
bot.talk | (self, text) | Print out text. | Print out text. | def talk(self, text):
"""Print out text."""
print('\n' + self.name + ': ' + text) | [
"def",
"talk",
"(",
"self",
",",
"text",
")",
":",
"print",
"(",
"'\\n'",
"+",
"self",
".",
"name",
"+",
"': '",
"+",
"text",
")"
] | [
209,
4
] | [
212,
45
] | python | en | ['en', 'en', 'en'] | True |
bot.get_response | (self, question) | Ask a question and wait for a response. | Ask a question and wait for a response. | def get_response(self, question):
"""Ask a question and wait for a response."""
self.talk(question)
text = input('~ ')
return text | [
"def",
"get_response",
"(",
"self",
",",
"question",
")",
":",
"self",
".",
"talk",
"(",
"question",
")",
"text",
"=",
"input",
"(",
"'~ '",
")",
"return",
"text"
] | [
214,
4
] | [
219,
19
] | python | en | ['en', 'en', 'en'] | True |
bot.parse | (self, text, triggers, not_triggers) | Parse response text for triggers/not_triggers. | Parse response text for triggers/not_triggers. | def parse(self, text, triggers, not_triggers):
"""Parse response text for triggers/not_triggers."""
# Test for trigger substrings
bool_ = [True if t in text.lower() else False for t in triggers]
# Test for anti-trigger substrings
bool_not = [True if t in text.lo... | [
"def",
"parse",
"(",
"self",
",",
"text",
",",
"triggers",
",",
"not_triggers",
")",
":",
"# Test for trigger substrings",
"bool_",
"=",
"[",
"True",
"if",
"t",
"in",
"text",
".",
"lower",
"(",
")",
"else",
"False",
"for",
"t",
"in",
"triggers",
"]",
"... | [
221,
4
] | [
235,
24
] | python | en | ['en', 'en', 'en'] | True |
bot.multi_parse | (self, text, trigger_dict) | Parse text for a number of responses. | Parse text for a number of responses. | def multi_parse(self, text, trigger_dict):
"""Parse text for a number of responses."""
# Test for triggers in substrings
triggered = []
for key in trigger_dict:
bool_ = [True if t in text.lower() else False for t in trigger_dict[key]]
if True in bool_:
... | [
"def",
"multi_parse",
"(",
"self",
",",
"text",
",",
"trigger_dict",
")",
":",
"# Test for triggers in substrings",
"triggered",
"=",
"[",
"]",
"for",
"key",
"in",
"trigger_dict",
":",
"bool_",
"=",
"[",
"True",
"if",
"t",
"in",
"text",
".",
"lower",
"(",
... | [
237,
4
] | [
247,
24
] | python | en | ['en', 'en', 'en'] | True |
bot.parse_respond | (self, text, triggers, not_triggers, response, not_response) | Parse response text for triggers/not_triggers and then respond. | Parse response text for triggers/not_triggers and then respond. | def parse_respond(self, text, triggers, not_triggers, response, not_response):
"""Parse response text for triggers/not_triggers and then respond."""
check = self.parse(text, triggers, not_triggers)
if check == 'Resolve':
return 'Resolve'
elif check:
... | [
"def",
"parse_respond",
"(",
"self",
",",
"text",
",",
"triggers",
",",
"not_triggers",
",",
"response",
",",
"not_response",
")",
":",
"check",
"=",
"self",
".",
"parse",
"(",
"text",
",",
"triggers",
",",
"not_triggers",
")",
"if",
"check",
"==",
"'Res... | [
249,
4
] | [
259,
33
] | python | en | ['en', 'en', 'en'] | True |
bot.resolve | (self, question, question_root, triggers, not_triggers, response, not_response) | Resolve a boolean issue | Resolve a boolean issue | def resolve(self, question, question_root, triggers, not_triggers, response, not_response):
"""Resolve a boolean issue"""
# Ask initial question and get response
text = self.get_response(question)
# Parse the response text
out = self.parse_respond(text, ... | [
"def",
"resolve",
"(",
"self",
",",
"question",
",",
"question_root",
",",
"triggers",
",",
"not_triggers",
",",
"response",
",",
"not_response",
")",
":",
"# Ask initial question and get response",
"text",
"=",
"self",
".",
"get_response",
"(",
"question",
")",
... | [
261,
4
] | [
275,
18
] | python | en | ['en', 'en', 'en'] | True |
bot.resolve_direct | (self, question, trigger_dict, response_dict, print_dict, confirm_dict) | Resolve an issue with triggers and responses defined in dicts | Resolve an issue with triggers and responses defined in dicts | def resolve_direct(self, question, trigger_dict, response_dict, print_dict, confirm_dict):
"""Resolve an issue with triggers and responses defined in dicts"""
# Ask initial question and get response
text = self.get_response(question)
# Parse the response text
... | [
"def",
"resolve_direct",
"(",
"self",
",",
"question",
",",
"trigger_dict",
",",
"response_dict",
",",
"print_dict",
",",
"confirm_dict",
")",
":",
"# Ask initial question and get response",
"text",
"=",
"self",
".",
"get_response",
"(",
"question",
")",
"# Parse th... | [
277,
4
] | [
314,
48
] | python | en | ['en', 'en', 'en'] | True |
ModeScreen.on_pre_enter | (self, *args) | Detect the current keyboard mode and set the text of the main
label accordingly. | Detect the current keyboard mode and set the text of the main
label accordingly. | def on_pre_enter(self, *args):
""" Detect the current keyboard mode and set the text of the main
label accordingly. """
self.keyboard_mode = Config.get("kivy", "keyboard_mode")
self.mode_spinner.text = "'{0}'".format(self.keyboard_mode)
p1 = "Current keyboard mode: '{0}'\n\n".f... | [
"def",
"on_pre_enter",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"keyboard_mode",
"=",
"Config",
".",
"get",
"(",
"\"kivy\"",
",",
"\"keyboard_mode\"",
")",
"self",
".",
"mode_spinner",
".",
"text",
"=",
"\"'{0}'\"",
".",
"format",
"(",
"self... | [
118,
4
] | [
138,
54
] | python | en | ['en', 'en', 'en'] | True |
ModeScreen.set_mode | (self, mode) | Sets the keyboard mode to the one specified | Sets the keyboard mode to the one specified | def set_mode(self, mode):
""" Sets the keyboard mode to the one specified """
Config.set("kivy", "keyboard_mode", mode.replace("'", ""))
Config.write()
self.center_label.text = "Please restart the application for this\n" \
"setting to take effect." | [
"def",
"set_mode",
"(",
"self",
",",
"mode",
")",
":",
"Config",
".",
"set",
"(",
"\"kivy\"",
",",
"\"keyboard_mode\"",
",",
"mode",
".",
"replace",
"(",
"\"'\"",
",",
"\"\"",
")",
")",
"Config",
".",
"write",
"(",
")",
"self",
".",
"center_label",
"... | [
140,
4
] | [
145,
37
] | python | en | ['en', 'en', 'en'] | True |
ModeScreen.next | (self) | Continue to the main screen | Continue to the main screen | def next(self):
""" Continue to the main screen """
self.manager.current = "keyboard" | [
"def",
"next",
"(",
"self",
")",
":",
"self",
".",
"manager",
".",
"current",
"=",
"\"keyboard\""
] | [
147,
4
] | [
149,
41
] | python | en | ['en', 'en', 'en'] | True |
KeyboardScreen._add_keyboards | (self) | Add a buttons for each available keyboard layout. When clicked,
the buttons will change the keyboard layout to the one selected. | Add a buttons for each available keyboard layout. When clicked,
the buttons will change the keyboard layout to the one selected. | def _add_keyboards(self):
""" Add a buttons for each available keyboard layout. When clicked,
the buttons will change the keyboard layout to the one selected. """
layouts = list(VKeyboard().available_layouts.keys())
# Add the file in our app directory, the .json extension is required.
... | [
"def",
"_add_keyboards",
"(",
"self",
")",
":",
"layouts",
"=",
"list",
"(",
"VKeyboard",
"(",
")",
".",
"available_layouts",
".",
"keys",
"(",
")",
")",
"# Add the file in our app directory, the .json extension is required.",
"layouts",
".",
"append",
"(",
"\"numer... | [
165,
4
] | [
175,
62
] | python | en | ['en', 'en', 'en'] | True |
KeyboardScreen.set_layout | (self, layout, button) | Change the keyboard layout to the one specified by *layout*. | Change the keyboard layout to the one specified by *layout*. | def set_layout(self, layout, button):
""" Change the keyboard layout to the one specified by *layout*. """
kb = Window.request_keyboard(
self._keyboard_close, self)
if kb.widget:
# If the current configuration supports Virtual Keyboards, this
# widget will be ... | [
"def",
"set_layout",
"(",
"self",
",",
"layout",
",",
"button",
")",
":",
"kb",
"=",
"Window",
".",
"request_keyboard",
"(",
"self",
".",
"_keyboard_close",
",",
"self",
")",
"if",
"kb",
".",
"widget",
":",
"# If the current configuration supports Virtual Keyboa... | [
177,
4
] | [
190,
50
] | python | en | ['en', 'en', 'en'] | True |
KeyboardScreen._keyboard_close | (self, *args) | The active keyboard is being closed. | The active keyboard is being closed. | def _keyboard_close(self, *args):
""" The active keyboard is being closed. """
if self._keyboard:
self._keyboard.unbind(on_key_down=self.key_down)
self._keyboard.unbind(on_key_up=self.key_up)
self._keyboard = None | [
"def",
"_keyboard_close",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"_keyboard",
":",
"self",
".",
"_keyboard",
".",
"unbind",
"(",
"on_key_down",
"=",
"self",
".",
"key_down",
")",
"self",
".",
"_keyboard",
".",
"unbind",
"(",
"on_ke... | [
192,
4
] | [
197,
33
] | python | en | ['en', 'en', 'en'] | True |
KeyboardScreen.key_down | (self, keyboard, keycode, text, modifiers) | The callback function that catches keyboard events. | The callback function that catches keyboard events. | def key_down(self, keyboard, keycode, text, modifiers):
""" The callback function that catches keyboard events. """
self.displayLabel.text = u"Key pressed - {0}".format(text) | [
"def",
"key_down",
"(",
"self",
",",
"keyboard",
",",
"keycode",
",",
"text",
",",
"modifiers",
")",
":",
"self",
".",
"displayLabel",
".",
"text",
"=",
"u\"Key pressed - {0}\"",
".",
"format",
"(",
"text",
")"
] | [
199,
4
] | [
201,
66
] | python | en | ['en', 'en', 'en'] | True |
KeyboardScreen.key_up | (self, keyboard, keycode, *args) | The callback function that catches keyboard events. | The callback function that catches keyboard events. | def key_up(self, keyboard, keycode, *args):
""" The callback function that catches keyboard events. """
# system keyboard keycode: (122, 'z')
# dock keyboard keycode: 'z'
if isinstance(keycode, tuple):
keycode = keycode[1]
self.displayLabel.text += u" (up {0})".format... | [
"def",
"key_up",
"(",
"self",
",",
"keyboard",
",",
"keycode",
",",
"*",
"args",
")",
":",
"# system keyboard keycode: (122, 'z')",
"# dock keyboard keycode: 'z'",
"if",
"isinstance",
"(",
"keycode",
",",
"tuple",
")",
":",
"keycode",
"=",
"keycode",
"[",
"1",
... | [
204,
4
] | [
210,
62
] | python | en | ['en', 'en', 'en'] | True |
TestDocumentEditView.test_reupload_different_file_size_and_file_hash | (self) |
Checks that reuploading the document file with a different file
changes the file size and file hash (see #5704).
|
Checks that reuploading the document file with a different file
changes the file size and file hash (see #5704).
| def test_reupload_different_file_size_and_file_hash(self):
"""
Checks that reuploading the document file with a different file
changes the file size and file hash (see #5704).
"""
# Build a fake file, and create it through the admin view
# since self.document doesn't have... | [
"def",
"test_reupload_different_file_size_and_file_hash",
"(",
"self",
")",
":",
"# Build a fake file, and create it through the admin view",
"# since self.document doesn't have a file_size set.",
"fake_file",
"=",
"SimpleUploadedFile",
"(",
"'some_file.txt'",
",",
"b'this is the content... | [
413,
4
] | [
439,
62
] | python | en | ['en', 'error', 'th'] | False |
TestDocumentEditView.test_reupload_same_name | (self) |
Checks that reuploading the document file with the same file name
changes the file name, to avoid browser cache issues (see #3816).
|
Checks that reuploading the document file with the same file name
changes the file name, to avoid browser cache issues (see #3816).
| def test_reupload_same_name(self):
"""
Checks that reuploading the document file with the same file name
changes the file name, to avoid browser cache issues (see #3816).
"""
old_filename = self.document.file.name
new_name = self.document.filename
new_file = Simpl... | [
"def",
"test_reupload_same_name",
"(",
"self",
")",
":",
"old_filename",
"=",
"self",
".",
"document",
".",
"file",
".",
"name",
"new_name",
"=",
"self",
".",
"document",
".",
"filename",
"new_file",
"=",
"SimpleUploadedFile",
"(",
"new_name",
",",
"b'An updat... | [
441,
4
] | [
459,
53
] | python | en | ['en', 'error', 'th'] | False |
TestDocumentEditView.test_reupload_different_name | (self) |
Checks that reuploading the document file with a different file name
correctly uses the new file name.
|
Checks that reuploading the document file with a different file name
correctly uses the new file name.
| def test_reupload_different_name(self):
"""
Checks that reuploading the document file with a different file name
correctly uses the new file name.
"""
old_filename = self.document.file.name
new_name = 'test_reupload_different_name.txt'
new_file = SimpleUploadedFil... | [
"def",
"test_reupload_different_name",
"(",
"self",
")",
":",
"old_filename",
"=",
"self",
".",
"document",
".",
"file",
".",
"name",
"new_name",
"=",
"'test_reupload_different_name.txt'",
"new_file",
"=",
"SimpleUploadedFile",
"(",
"new_name",
",",
"b'An updated test... | [
461,
4
] | [
479,
53
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_add | (self) |
This tests that the add view responds correctly on a GET request
|
This tests that the add view responds correctly on a GET request
| def test_add(self):
"""
This tests that the add view responds correctly on a GET request
"""
# Send request
response = self.client.get(reverse('wagtaildocs:add_multiple'))
# Check response
self.assertEqual(response.status_code, 200)
self.assertTemplateUse... | [
"def",
"test_add",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtaildocs:add_multiple'",
")",
")",
"# Check response",
"self",
".",
"assertEqual",
"(",
"response",
".",
"status_code",
",... | [
605,
4
] | [
619,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_add_post | (self) |
This tests that a POST request to the add view saves the document and returns an edit form
|
This tests that a POST request to the add view saves the document and returns an edit form
| def test_add_post(self):
"""
This tests that a POST request to the add view saves the document and returns an edit form
"""
response = self.client.post(reverse('wagtaildocs:add_multiple'), {
'files[]': SimpleUploadedFile('test.png', b"Simple text document"),
}, HTTP_X... | [
"def",
"test_add_post",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:add_multiple'",
")",
",",
"{",
"'files[]'",
":",
"SimpleUploadedFile",
"(",
"'test.png'",
",",
"b\"Simple text document\"",
")"... | [
636,
4
] | [
679,
61
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_add_post_with_collections | (self) |
This tests that a POST request to the add view saves the document
and returns an edit form, when collections are active
|
This tests that a POST request to the add view saves the document
and returns an edit form, when collections are active
| def test_add_post_with_collections(self):
"""
This tests that a POST request to the add view saves the document
and returns an edit form, when collections are active
"""
root_collection = Collection.get_first_root_node()
evil_plans_collection = root_collection.add_child(... | [
"def",
"test_add_post_with_collections",
"(",
"self",
")",
":",
"root_collection",
"=",
"Collection",
".",
"get_first_root_node",
"(",
")",
"evil_plans_collection",
"=",
"root_collection",
".",
"add_child",
"(",
"name",
"=",
"\"Evil plans\"",
")",
"response",
"=",
"... | [
681,
4
] | [
728,
58
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_add_post_noajax | (self) |
This tests that only AJAX requests are allowed to POST to the add view
|
This tests that only AJAX requests are allowed to POST to the add view
| def test_add_post_noajax(self):
"""
This tests that only AJAX requests are allowed to POST to the add view
"""
response = self.client.post(reverse('wagtaildocs:add_multiple'))
# Check response
self.assertEqual(response.status_code, 400) | [
"def",
"test_add_post_noajax",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:add_multiple'",
")",
")",
"# Check response",
"self",
".",
"assertEqual",
"(",
"response",
".",
"status_code",
",",
"4... | [
730,
4
] | [
737,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_add_post_nofile | (self) |
This tests that the add view checks for a file when a user POSTs to it
|
This tests that the add view checks for a file when a user POSTs to it
| def test_add_post_nofile(self):
"""
This tests that the add view checks for a file when a user POSTs to it
"""
response = self.client.post(reverse('wagtaildocs:add_multiple'), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
# Check response
self.assertEqual(response.status_code,... | [
"def",
"test_add_post_nofile",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:add_multiple'",
")",
",",
"HTTP_X_REQUESTED_WITH",
"=",
"'XMLHttpRequest'",
")",
"# Check response",
"self",
".",
"assertE... | [
739,
4
] | [
746,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_edit_get | (self) |
This tests that a GET request to the edit view returns a 405 "METHOD NOT ALLOWED" response
|
This tests that a GET request to the edit view returns a 405 "METHOD NOT ALLOWED" response
| def test_edit_get(self):
"""
This tests that a GET request to the edit view returns a 405 "METHOD NOT ALLOWED" response
"""
# Send request
response = self.client.get(reverse('wagtaildocs:edit_multiple', args=(self.doc.id, )))
# Check response
self.assertEqual(res... | [
"def",
"test_edit_get",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtaildocs:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"doc",
".",
"id",
",",
")",
")",
")",
"# Check re... | [
748,
4
] | [
756,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_edit_post | (self) |
This tests that a POST request to the edit view edits the document
|
This tests that a POST request to the edit view edits the document
| def test_edit_post(self):
"""
This tests that a POST request to the edit view edits the document
"""
# Send request
response = self.client.post(
reverse('wagtaildocs:edit_multiple', args=(self.doc.id, )),
{'doc-%d-%s' % (self.doc.id, field): data for field... | [
"def",
"test_edit_post",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"doc",
".",
"id",
",",
")",
")",
",",
"{",
"'... | [
758,
4
] | [
781,
35
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_edit_post_noajax | (self) |
This tests that a POST request to the edit view without AJAX returns a 400 response
|
This tests that a POST request to the edit view without AJAX returns a 400 response
| def test_edit_post_noajax(self):
"""
This tests that a POST request to the edit view without AJAX returns a 400 response
"""
# Send request
response = self.client.post(reverse('wagtaildocs:edit_multiple', args=(self.doc.id, )), {
('doc-%d-title' % self.doc.id): "New t... | [
"def",
"test_edit_post_noajax",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"doc",
".",
"id",
",",
")",
")",
",",
"{... | [
783,
4
] | [
794,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_edit_post_validation_error | (self) |
This tests that a POST request to the edit page returns a json document with "success=False"
and a form with the validation error indicated
|
This tests that a POST request to the edit page returns a json document with "success=False"
and a form with the validation error indicated
| def test_edit_post_validation_error(self):
"""
This tests that a POST request to the edit page returns a json document with "success=False"
and a form with the validation error indicated
"""
# Send request
response = self.client.post(reverse('wagtaildocs:edit_multiple', a... | [
"def",
"test_edit_post_validation_error",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"doc",
".",
"id",
",",
")",
")",
... | [
796,
4
] | [
821,
50
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_delete_get | (self) |
This tests that a GET request to the delete view returns a 405 "METHOD NOT ALLOWED" response
|
This tests that a GET request to the delete view returns a 405 "METHOD NOT ALLOWED" response
| def test_delete_get(self):
"""
This tests that a GET request to the delete view returns a 405 "METHOD NOT ALLOWED" response
"""
# Send request
response = self.client.get(reverse('wagtaildocs:delete_multiple', args=(self.doc.id, )))
# Check response
self.assertEqu... | [
"def",
"test_delete_get",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtaildocs:delete_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"doc",
".",
"id",
",",
")",
")",
")",
"# Chec... | [
823,
4
] | [
831,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_delete_post | (self) |
This tests that a POST request to the delete view deletes the document
|
This tests that a POST request to the delete view deletes the document
| def test_delete_post(self):
"""
This tests that a POST request to the delete view deletes the document
"""
# Send request
response = self.client.post(reverse('wagtaildocs:delete_multiple', args=(self.doc.id, )), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
# Check response
... | [
"def",
"test_delete_post",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:delete_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"doc",
".",
"id",
",",
")",
")",
",",
"HTTP... | [
833,
4
] | [
852,
49
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleDocumentUploader.test_delete_post_noajax | (self) |
This tests that a POST request to the delete view without AJAX returns a 400 response
|
This tests that a POST request to the delete view without AJAX returns a 400 response
| def test_delete_post_noajax(self):
"""
This tests that a POST request to the delete view without AJAX returns a 400 response
"""
# Send request
response = self.client.post(reverse('wagtaildocs:delete_multiple', args=(self.doc.id, )))
# Check response
self.assertE... | [
"def",
"test_delete_post_noajax",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtaildocs:delete_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"doc",
".",
"id",
",",
")",
")",
")",
... | [
854,
4
] | [
862,
51
] | python | en | ['en', 'error', 'th'] | False |
BaseGroupCollectionMemberPermissionFormSet.clean | (self) | Checks that no two forms refer to the same collection object | Checks that no two forms refer to the same collection object | def clean(self):
"""Checks that no two forms refer to the same collection object"""
if any(self.errors):
# Don't bother validating the formset unless each form is valid on its own
return
collections = [
form.cleaned_data['collection']
for form in ... | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"any",
"(",
"self",
".",
"errors",
")",
":",
"# Don't bother validating the formset unless each form is valid on its own",
"return",
"collections",
"=",
"[",
"form",
".",
"cleaned_data",
"[",
"'collection'",
"]",
"for",
... | [
185,
4
] | [
202,
13
] | python | en | ['en', 'en', 'en'] | True |
MLP.__init__ | (self, args) |
TODO: Write Comment
|
TODO: Write Comment
| def __init__(self, args):
"""
TODO: Write Comment
"""
self.name = 'MLP'
self.learn_rate = 0.001
MnistModel.__init__(self, args) | [
"def",
"__init__",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"name",
"=",
"'MLP'",
"self",
".",
"learn_rate",
"=",
"0.001",
"MnistModel",
".",
"__init__",
"(",
"self",
",",
"args",
")"
] | [
10,
4
] | [
19,
39
] | python | en | ['en', 'error', 'th'] | False |
MLP.network | (self, img_input) |
TODO: Write Comment
|
TODO: Write Comment
| def network(self, img_input):
"""
TODO: Write Comment
"""
from tensorflow.keras import initializers, layers, regularizers
x = layers.Flatten()(img_input)
x = layers.Dense(1024)(x)
x = layers.BatchNormalization()(x)
x = layers.Activation('relu')(x)
... | [
"def",
"network",
"(",
"self",
",",
"img_input",
")",
":",
"from",
"tensorflow",
".",
"keras",
"import",
"initializers",
",",
"layers",
",",
"regularizers",
"x",
"=",
"layers",
".",
"Flatten",
"(",
")",
"(",
"img_input",
")",
"x",
"=",
"layers",
".",
"... | [
21,
4
] | [
39,
16
] | python | en | ['en', 'error', 'th'] | False |
MLP.scheduler | (self, epoch) |
TODO: Write Comment
|
TODO: Write Comment
| def scheduler(self, epoch):
"""
TODO: Write Comment
"""
return self.learn_rate | [
"def",
"scheduler",
"(",
"self",
",",
"epoch",
")",
":",
"return",
"self",
".",
"learn_rate"
] | [
42,
4
] | [
47,
30
] | python | en | ['en', 'error', 'th'] | False |
puti16 | (fp, values) | Write network order (big-endian) 16-bit sequence | Write network order (big-endian) 16-bit sequence | def puti16(fp, values):
"""Write network order (big-endian) 16-bit sequence"""
for v in values:
if v < 0:
v += 65536
fp.write(_binary.o16be(v)) | [
"def",
"puti16",
"(",
"fp",
",",
"values",
")",
":",
"for",
"v",
"in",
"values",
":",
"if",
"v",
"<",
"0",
":",
"v",
"+=",
"65536",
"fp",
".",
"write",
"(",
"_binary",
".",
"o16be",
"(",
"v",
")",
")"
] | [
24,
0
] | [
29,
34
] | python | en | ['en', 'en', 'en'] | True |
FontFile.compile | (self) | Create metrics and bitmap | Create metrics and bitmap | def compile(self):
"""Create metrics and bitmap"""
if self.bitmap:
return
# create bitmap large enough to hold all data
h = w = maxwidth = 0
lines = 1
for glyph in self:
if glyph:
d, dst, src, im = glyph
h = max(h,... | [
"def",
"compile",
"(",
"self",
")",
":",
"if",
"self",
".",
"bitmap",
":",
"return",
"# create bitmap large enough to hold all data",
"h",
"=",
"w",
"=",
"maxwidth",
"=",
"0",
"lines",
"=",
"1",
"for",
"glyph",
"in",
"self",
":",
"if",
"glyph",
":",
"d",... | [
45,
4
] | [
90,
43
] | python | en | ['en', 'mi', 'en'] | True |
send_to_push_bouncer | (
method: str,
endpoint: str,
post_data: Union[bytes, Mapping[str, Union[str, bytes]]],
extra_headers: Mapping[str, str] = {},
) | While it does actually send the notice, this function has a lot of
code and comments around error handling for the push notifications
bouncer. There are several classes of failures, each with its own
potential solution:
* Network errors with requests.request. We raise an exception to signal
it ... | While it does actually send the notice, this function has a lot of
code and comments around error handling for the push notifications
bouncer. There are several classes of failures, each with its own
potential solution: | def send_to_push_bouncer(
method: str,
endpoint: str,
post_data: Union[bytes, Mapping[str, Union[str, bytes]]],
extra_headers: Mapping[str, str] = {},
) -> Dict[str, object]:
"""While it does actually send the notice, this function has a lot of
code and comments around error handling for the pus... | [
"def",
"send_to_push_bouncer",
"(",
"method",
":",
"str",
",",
"endpoint",
":",
"str",
",",
"post_data",
":",
"Union",
"[",
"bytes",
",",
"Mapping",
"[",
"str",
",",
"Union",
"[",
"str",
",",
"bytes",
"]",
"]",
"]",
",",
"extra_headers",
":",
"Mapping"... | [
25,
0
] | [
99,
36
] | python | en | ['en', 'en', 'en'] | True |
description_of | (lines, name='stdin') |
Return a string describing the probable encoding of a file or
list of strings.
:param lines: The lines to get the encoding of.
:type lines: Iterable of bytes
:param name: Name of file or collection of lines
:type name: str
|
Return a string describing the probable encoding of a file or
list of strings. | def description_of(lines, name='stdin'):
"""
Return a string describing the probable encoding of a file or
list of strings.
:param lines: The lines to get the encoding of.
:type lines: Iterable of bytes
:param name: Name of file or collection of lines
:type name: str
"""
u = Univers... | [
"def",
"description_of",
"(",
"lines",
",",
"name",
"=",
"'stdin'",
")",
":",
"u",
"=",
"UniversalDetector",
"(",
")",
"for",
"line",
"in",
"lines",
":",
"line",
"=",
"bytearray",
"(",
"line",
")",
"u",
".",
"feed",
"(",
"line",
")",
"# shortcut out of... | [
25,
0
] | [
50,
44
] | python | en | ['en', 'error', 'th'] | False |
main | (argv=None) |
Handles command line arguments and gets things started.
:param argv: List of arguments, as if specified on the command-line.
If None, ``sys.argv[1:]`` is used instead.
:type argv: list of str
|
Handles command line arguments and gets things started. | def main(argv=None):
"""
Handles command line arguments and gets things started.
:param argv: List of arguments, as if specified on the command-line.
If None, ``sys.argv[1:]`` is used instead.
:type argv: list of str
"""
# Get command line arguments
parser = argparse.Argume... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"# Get command line arguments",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Takes one or more file paths and reports their detected \\\n encodings\"",
")",
"parser",
".",
... | [
53,
0
] | [
80,
40
] | python | en | ['en', 'error', 'th'] | False |
get_template_dir | () |
Determines where the job and project templates are.
|
Determines where the job and project templates are.
| def get_template_dir():
"""
Determines where the job and project templates are.
"""
return path.join(tkp.__path__[0], 'config') | [
"def",
"get_template_dir",
"(",
")",
":",
"return",
"path",
".",
"join",
"(",
"tkp",
".",
"__path__",
"[",
"0",
"]",
",",
"'config'",
")"
] | [
55,
0
] | [
59,
47
] | python | en | ['en', 'error', 'th'] | False |
make_writeable | (filename) |
Make sure that the file is writeable.
Useful if our source is read-only.
|
Make sure that the file is writeable.
Useful if our source is read-only.
| def make_writeable(filename):
"""
Make sure that the file is writeable.
Useful if our source is read-only.
"""
if not os.access(filename, os.W_OK):
st = os.stat(filename)
new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
os.chmod(filename, new_permissions) | [
"def",
"make_writeable",
"(",
"filename",
")",
":",
"if",
"not",
"os",
".",
"access",
"(",
"filename",
",",
"os",
".",
"W_OK",
")",
":",
"st",
"=",
"os",
".",
"stat",
"(",
"filename",
")",
"new_permissions",
"=",
"stat",
".",
"S_IMODE",
"(",
"st",
... | [
62,
0
] | [
70,
43
] | python | en | ['en', 'error', 'th'] | False |
line_replace | (substitutes, line) | substitutions - list of 2 item tuples.
every occurance of the first item in the tuple in line will be replaces
with the second. The to be replaced thingy should be in Django
template format e.g. {% user_name %}
template format e.g. {% user_name %}
| substitutions - list of 2 item tuples.
every occurance of the first item in the tuple in line will be replaces
with the second. The to be replaced thingy should be in Django
template format e.g. {% user_name %}
template format e.g. {% user_name %}
| def line_replace(substitutes, line):
"""substitutions - list of 2 item tuples.
every occurance of the first item in the tuple in line will be replaces
with the second. The to be replaced thingy should be in Django
template format e.g. {% user_name %}
template format e.g. {% user_name %}
"""
... | [
"def",
"line_replace",
"(",
"substitutes",
",",
"line",
")",
":",
"for",
"pattern",
",",
"repl",
"in",
"substitutes",
":",
"line",
"=",
"re",
".",
"sub",
"(",
"\"{%\\s*\"",
"+",
"pattern",
"+",
"\"\\s*%}\"",
",",
"repl",
",",
"line",
")",
"return",
"li... | [
73,
0
] | [
82,
15
] | python | en | ['en', 'en', 'en'] | True |
copy_template | (job_or_project, name, target=None, **options) |
this is taken from django/core/management/templates.py and modified to fit
our needs
|
this is taken from django/core/management/templates.py and modified to fit
our needs
| def copy_template(job_or_project, name, target=None, **options):
"""
this is taken from django/core/management/templates.py and modified to fit
our needs
"""
# If it's not a valid directory name.
if not re.search(r'^[_a-zA-Z][\w\-]*$', name):
# Provide a smart error message, depending on... | [
"def",
"copy_template",
"(",
"job_or_project",
",",
"name",
",",
"target",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"# If it's not a valid directory name.",
"if",
"not",
"re",
".",
"search",
"(",
"r'^[_a-zA-Z][\\w\\-]*$'",
",",
"name",
")",
":",
"# Pro... | [
85,
0
] | [
175,
18
] | python | en | ['en', 'error', 'th'] | False |
parse_monitoringlist_positions | (args, str_name="monitor_coords",
list_name="monitor_list") | Loads a list of monitoringlist (RA,Dec) tuples from cmd line args object.
Processes the flags "--monitor-coords" and "--monitor-list"
NB This is just a dumb function that does not care about units,
those should be matched against whatever uses the resulting values...
| Loads a list of monitoringlist (RA,Dec) tuples from cmd line args object. | def parse_monitoringlist_positions(args, str_name="monitor_coords",
list_name="monitor_list"):
"""Loads a list of monitoringlist (RA,Dec) tuples from cmd line args object.
Processes the flags "--monitor-coords" and "--monitor-list"
NB This is just a dumb function that doe... | [
"def",
"parse_monitoringlist_positions",
"(",
"args",
",",
"str_name",
"=",
"\"monitor_coords\"",
",",
"list_name",
"=",
"\"monitor_list\"",
")",
":",
"monitor_coords",
"=",
"[",
"]",
"if",
"hasattr",
"(",
"args",
",",
"str_name",
")",
"and",
"getattr",
"(",
"... | [
178,
0
] | [
203,
25
] | python | en | ['en', 'en', 'en'] | True |
patch_search_fields | (model, new_search_fields) |
A context manager to allow testing of different search_fields configurations
without permanently changing the models' search_fields.
|
A context manager to allow testing of different search_fields configurations
without permanently changing the models' search_fields.
| def patch_search_fields(model, new_search_fields):
"""
A context manager to allow testing of different search_fields configurations
without permanently changing the models' search_fields.
"""
old_search_fields = model.search_fields
model.search_fields = new_search_fields
yield
model.sear... | [
"def",
"patch_search_fields",
"(",
"model",
",",
"new_search_fields",
")",
":",
"old_search_fields",
"=",
"model",
".",
"search_fields",
"model",
".",
"search_fields",
"=",
"new_search_fields",
"yield",
"model",
".",
"search_fields",
"=",
"old_search_fields"
] | [
10,
0
] | [
18,
43
] | python | en | ['en', 'error', 'th'] | False |
sql_flush | (style, connection, only_django=False, reset_sequences=True, allow_cascade=False) |
Returns a list of the SQL statements used to flush the database.
If only_django is True, then only table names that have associated Django
models and are in INSTALLED_APPS will be included.
|
Returns a list of the SQL statements used to flush the database. | def sql_flush(style, connection, only_django=False, reset_sequences=True, allow_cascade=False):
"""
Returns a list of the SQL statements used to flush the database.
If only_django is True, then only table names that have associated Django
models and are in INSTALLED_APPS will be included.
"""
i... | [
"def",
"sql_flush",
"(",
"style",
",",
"connection",
",",
"only_django",
"=",
"False",
",",
"reset_sequences",
"=",
"True",
",",
"allow_cascade",
"=",
"False",
")",
":",
"if",
"only_django",
":",
"tables",
"=",
"connection",
".",
"introspection",
".",
"djang... | [
6,
0
] | [
19,
21
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_table_list | (self, cursor) |
Returns a list of table and view names in the current database.
|
Returns a list of table and view names in the current database.
| def get_table_list(self, cursor):
"""
Returns a list of table and view names in the current database.
"""
cursor.execute("""
SELECT c.relname, c.relkind
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
... | [
"def",
"get_table_list",
"(",
"self",
",",
"cursor",
")",
":",
"cursor",
".",
"execute",
"(",
"\"\"\"\n SELECT c.relname, c.relkind\n FROM pg_catalog.pg_class c\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace\n WHERE c.relkind IN ('... | [
56,
4
] | [
69,
53
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_table_description | (self, cursor, table_name) | Returns a description of the table, with the DB-API cursor.description interface. | Returns a description of the table, with the DB-API cursor.description interface. | def get_table_description(self, cursor, table_name):
"Returns a description of the table, with the DB-API cursor.description interface."
# As cursor.description does not return reliably the nullable property,
# we have to query the information_schema (#7783)
cursor.execute("""
... | [
"def",
"get_table_description",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"# As cursor.description does not return reliably the nullable property,",
"# we have to query the information_schema (#7783)",
"cursor",
".",
"execute",
"(",
"\"\"\"\n SELECT column_n... | [
71,
4
] | [
87,
9
] | python | en | ['en', 'fr', 'en'] | True |
DatabaseIntrospection.get_relations | (self, cursor, table_name) |
Returns a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
|
Returns a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
| def get_relations(self, cursor, table_name):
"""
Returns a dictionary of {field_name: (field_name_other_table, other_table)}
representing all relationships to the given table.
"""
cursor.execute("""
SELECT c2.relname, a1.attname, a2.attname
FROM pg_constra... | [
"def",
"get_relations",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"cursor",
".",
"execute",
"(",
"\"\"\"\n SELECT c2.relname, a1.attname, a2.attname\n FROM pg_constraint con\n LEFT JOIN pg_class c1 ON con.conrelid = c1.oid\n LEFT... | [
89,
4
] | [
106,
24
] | python | en | ['en', 'error', 'th'] | False |
DatabaseIntrospection.get_constraints | (self, cursor, table_name) |
Retrieve any constraints or keys (unique, pk, fk, check, index) across
one or more columns. Also retrieve the definition of expression-based
indexes.
|
Retrieve any constraints or keys (unique, pk, fk, check, index) across
one or more columns. Also retrieve the definition of expression-based
indexes.
| def get_constraints(self, cursor, table_name):
"""
Retrieve any constraints or keys (unique, pk, fk, check, index) across
one or more columns. Also retrieve the definition of expression-based
indexes.
"""
constraints = {}
# Loop over the key table, collecting thin... | [
"def",
"get_constraints",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"constraints",
"=",
"{",
"}",
"# Loop over the key table, collecting things as constraints. The column",
"# array must return column names in the same order in which they were",
"# created.",
"# The ... | [
150,
4
] | [
243,
26
] | 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.