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
dist_table_on_dist_table
(self, node=None)
Check that if a user has a row policy on a table and a distributed table is created on that table, and another distributed table is created on top of that, the user is only able to access rows on any of the tables specified by the assigned policies.
Check that if a user has a row policy on a table and a distributed table is created on that table, and another distributed table is created on top of that, the user is only able to access rows on any of the tables specified by the assigned policies.
def dist_table_on_dist_table(self, node=None): """Check that if a user has a row policy on a table and a distributed table is created on that table, and another distributed table is created on top of that, the user is only able to access rows on any of the tables specified by the assigned policies. """ ...
[ "def", "dist_table_on_dist_table", "(", "self", ",", "node", "=", "None", ")", ":", "table_name", "=", "f\"table_{getuid()}\"", "dist_table_name", "=", "f\"dist_table_{getuid()}\"", "dist_table_2_name", "=", "f\"dist_table_2_{getuid()}\"", "pol_name", "=", "f\"pol_{getuid()...
[ 962, 0 ]
[ 1010, 67 ]
python
en
['en', 'en', 'en']
True
policy_before_table
(self, node=None)
Check that if the policy is created and altered before the table, then it is still applied correctly.
Check that if the policy is created and altered before the table, then it is still applied correctly.
def policy_before_table(self, node=None): """Check that if the policy is created and altered before the table, then it is still applied correctly. """ table_name = f"table_{getuid()}" pol_name = f"pol_{getuid()}" if node is None: node = self.context.node with Given("I have a row po...
[ "def", "policy_before_table", "(", "self", ",", "node", "=", "None", ")", ":", "table_name", "=", "f\"table_{getuid()}\"", "pol_name", "=", "f\"pol_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "Giv...
[ 1013, 0 ]
[ 1035, 63 ]
python
en
['en', 'en', 'en']
True
dict
(self, node=None)
Check that if a user has a row policy on a table and a dictionary is created on that table, the user is only able to access the rows specified by the assigned policies.
Check that if a user has a row policy on a table and a dictionary is created on that table, the user is only able to access the rows specified by the assigned policies.
def dict(self, node=None): """Check that if a user has a row policy on a table and a dictionary is created on that table, the user is only able to access the rows specified by the assigned policies. """ table_name = f"table_{getuid()}" dict_name = f"view_{getuid()}" pol_name = f"pol_{getuid()}"...
[ "def", "dict", "(", "self", ",", "node", "=", "None", ")", ":", "table_name", "=", "f\"table_{getuid()}\"", "dict_name", "=", "f\"view_{getuid()}\"", "pol_name", "=", "f\"pol_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ...
[ 1041, 0 ]
[ 1078, 60 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of ALTER ROW POLICY.
Check the RBAC functionality of ALTER ROW POLICY.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of ALTER ROW POLICY. """ self.context.node = self.context.cluster.node(node) self.context.node2 = self.context.cluster.node("clickhouse2") Suite(run=privileges_granted_directly, setup=instrument_clickhouse_server_log) Suite(...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "self", ".", "context", ".", "node2", "=", "self", ".", "...
[ 1088, 0 ]
[ 1121, 62 ]
python
en
['en', 'en', 'en']
True
CPythonConan._upgrade_single_project_file
(self, project_file)
`devenv /upgrade <project.vcxproj>` will upgrade *ALL* projects referenced by the project. By temporarily moving the solution project, only one project is upgraded This is needed for static cpython or for disabled optional dependencies (e.g. tkinter=False) Restore it afterwards because ...
`devenv /upgrade <project.vcxproj>` will upgrade *ALL* projects referenced by the project. By temporarily moving the solution project, only one project is upgraded This is needed for static cpython or for disabled optional dependencies (e.g. tkinter=False) Restore it afterwards because ...
def _upgrade_single_project_file(self, project_file): """ `devenv /upgrade <project.vcxproj>` will upgrade *ALL* projects referenced by the project. By temporarily moving the solution project, only one project is upgraded This is needed for static cpython or for disabled optional depende...
[ "def", "_upgrade_single_project_file", "(", "self", ",", "project_file", ")", ":", "tools", ".", "rename", "(", "os", ".", "path", ".", "join", "(", "self", ".", "_source_subfolder", ",", "\"PCbuild\"", ",", "\"pcbuild.sln\"", ")", ",", "os", ".", "path", ...
[ 312, 4 ]
[ 328, 85 ]
python
en
['en', 'error', 'th']
False
platform_detect
()
Detect if running on the Raspberry Pi or Beaglebone Black and return the platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN.
Detect if running on the Raspberry Pi or Beaglebone Black and return the platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN.
def platform_detect(): """Detect if running on the Raspberry Pi or Beaglebone Black and return the platform type. Will return RASPBERRY_PI, BEAGLEBONE_BLACK, or UNKNOWN.""" # Handle Raspberry Pi pi = pi_version() if pi is not None: return RASPBERRY_PI # Handle Beaglebone Black # TO...
[ "def", "platform_detect", "(", ")", ":", "# Handle Raspberry Pi", "pi", "=", "pi_version", "(", ")", "if", "pi", "is", "not", "None", ":", "return", "RASPBERRY_PI", "# Handle Beaglebone Black", "# TODO: Check the Beaglebone Black /proc/cpuinfo value instead of reading", "# ...
[ 29, 0 ]
[ 58, 18 ]
python
en
['en', 'ig', 'en']
True
pi_revision
()
Detect the revision number of a Raspberry Pi, useful for changing functionality like default I2C bus based on revision.
Detect the revision number of a Raspberry Pi, useful for changing functionality like default I2C bus based on revision.
def pi_revision(): """Detect the revision number of a Raspberry Pi, useful for changing functionality like default I2C bus based on revision.""" # Revision list available at: http://elinux.org/RPi_HardwareHistory#Board_Revision_History with open('/proc/cpuinfo', 'r') as infile: for line in infil...
[ "def", "pi_revision", "(", ")", ":", "# Revision list available at: http://elinux.org/RPi_HardwareHistory#Board_Revision_History", "with", "open", "(", "'/proc/cpuinfo'", ",", "'r'", ")", "as", "infile", ":", "for", "line", "in", "infile", ":", "# Match a line of the form \...
[ 61, 0 ]
[ 77, 72 ]
python
en
['en', 'en', 'en']
True
pi_version
()
Detect the version of the Raspberry Pi. Returns either 1, 2 or None depending on if it's a Raspberry Pi 1 (model A, B, A+, B+), Raspberry Pi 2 (model B+), or not a Raspberry Pi.
Detect the version of the Raspberry Pi. Returns either 1, 2 or None depending on if it's a Raspberry Pi 1 (model A, B, A+, B+), Raspberry Pi 2 (model B+), or not a Raspberry Pi.
def pi_version(): """Detect the version of the Raspberry Pi. Returns either 1, 2 or None depending on if it's a Raspberry Pi 1 (model A, B, A+, B+), Raspberry Pi 2 (model B+), or not a Raspberry Pi. """ # Check /proc/cpuinfo for the Hardware field value. # 2708 is pi 1 # 2709 is pi 2 # ...
[ "def", "pi_version", "(", ")", ":", "# Check /proc/cpuinfo for the Hardware field value.", "# 2708 is pi 1", "# 2709 is pi 2", "# Anything else is not a pi.", "with", "open", "(", "'/proc/cpuinfo'", ",", "'r'", ")", "as", "infile", ":", "cpuinfo", "=", "infile", ".", "r...
[ 80, 0 ]
[ 108, 19 ]
python
en
['en', 'en', 'en']
True
connect
(path)
Create a CSVClient for use with Ibis Parameters ---------- path: str or pathlib.Path Returns ------- CSVClient
Create a CSVClient for use with Ibis
def connect(path): """Create a CSVClient for use with Ibis Parameters ---------- path: str or pathlib.Path Returns ------- CSVClient """ return CSVClient(path)
[ "def", "connect", "(", "path", ")", ":", "return", "CSVClient", "(", "path", ")" ]
[ 26, 0 ]
[ 37, 26 ]
python
en
['en', 'en', 'en']
True
adjusted_R2Score
(r2_score, n, k)
Calculates adjusted_R2Score based on r2_score, number of observations (n) and number of predictor variables(k)
Calculates adjusted_R2Score based on r2_score, number of observations (n) and number of predictor variables(k)
def adjusted_R2Score(r2_score, n, k): "Calculates adjusted_R2Score based on r2_score, number of observations (n) and number of predictor variables(k)" return 1 - (((n-1)/(n-k-1)) * (1 - r2_score))
[ "def", "adjusted_R2Score", "(", "r2_score", ",", "n", ",", "k", ")", ":", "return", "1", "-", "(", "(", "(", "n", "-", "1", ")", "/", "(", "n", "-", "k", "-", "1", ")", ")", "*", "(", "1", "-", "r2_score", ")", ")" ]
[ 22, 0 ]
[ 24, 49 ]
python
en
['en', 'en', 'en']
True
_rrmse
(inp, targ)
RMSE normalized with mean of the target
RMSE normalized with mean of the target
def _rrmse(inp, targ): "RMSE normalized with mean of the target" return torch.sqrt(F.mse_loss(inp, targ)) / targ.mean() * 100
[ "def", "_rrmse", "(", "inp", ",", "targ", ")", ":", "return", "torch", ".", "sqrt", "(", "F", ".", "mse_loss", "(", "inp", ",", "targ", ")", ")", "/", "targ", ".", "mean", "(", ")", "*", "100" ]
[ 29, 0 ]
[ 31, 64 ]
python
en
['en', 'en', 'en']
True
_bias
(inp, targ)
Average bias of predictions
Average bias of predictions
def _bias(inp, targ): "Average bias of predictions" inp, targ = flatten_check(inp, targ) return (inp - targ).sum() / len(targ)
[ "def", "_bias", "(", "inp", ",", "targ", ")", ":", "inp", ",", "targ", "=", "flatten_check", "(", "inp", ",", "targ", ")", "return", "(", "inp", "-", "targ", ")", ".", "sum", "(", ")", "/", "len", "(", "targ", ")" ]
[ 37, 0 ]
[ 40, 41 ]
python
en
['en', 'id', 'en']
True
_bias_pct
(inp, targ)
Mean weighted bias
Mean weighted bias
def _bias_pct(inp, targ): "Mean weighted bias" inp, targ = flatten_check(inp, targ) return 100 * ((inp-targ).sum()/len(targ)) / targ.mean()
[ "def", "_bias_pct", "(", "inp", ",", "targ", ")", ":", "inp", ",", "targ", "=", "flatten_check", "(", "inp", ",", "targ", ")", "return", "100", "*", "(", "(", "inp", "-", "targ", ")", ".", "sum", "(", ")", "/", "len", "(", "targ", ")", ")", "...
[ 46, 0 ]
[ 49, 59 ]
python
en
['en', 'en', 'en']
True
label_ranking_average_precision_score
(sigmoid=True, sample_weight=None)
Label ranking average precision (LRAP) is the average over each ground truth label assigned to each sample, of the ratio of true vs. total labels with lower score.
Label ranking average precision (LRAP) is the average over each ground truth label assigned to each sample, of the ratio of true vs. total labels with lower score.
def label_ranking_average_precision_score(sigmoid=True, sample_weight=None): """Label ranking average precision (LRAP) is the average over each ground truth label assigned to each sample, of the ratio of true vs. total labels with lower score.""" activation = ActivationType.Sigmoid if sigmoid else Activatio...
[ "def", "label_ranking_average_precision_score", "(", "sigmoid", "=", "True", ",", "sample_weight", "=", "None", ")", ":", "activation", "=", "ActivationType", ".", "Sigmoid", "if", "sigmoid", "else", "ActivationType", ".", "No", "return", "skm_to_fastai", "(", "sk...
[ 56, 0 ]
[ 61, 47 ]
python
en
['en', 'en', 'en']
True
label_ranking_loss
(sigmoid=True, sample_weight=None)
Compute the average number of label pairs that are incorrectly ordered given y_score weighted by the size of the label set and the number of labels not in the label set.
Compute the average number of label pairs that are incorrectly ordered given y_score weighted by the size of the label set and the number of labels not in the label set.
def label_ranking_loss(sigmoid=True, sample_weight=None): """Compute the average number of label pairs that are incorrectly ordered given y_score weighted by the size of the label set and the number of labels not in the label set.""" activation = ActivationType.Sigmoid if sigmoid else ActivationType.No ...
[ "def", "label_ranking_loss", "(", "sigmoid", "=", "True", ",", "sample_weight", "=", "None", ")", ":", "activation", "=", "ActivationType", ".", "Sigmoid", "if", "sigmoid", "else", "ActivationType", ".", "No", "return", "skm_to_fastai", "(", "skm", ".", "label...
[ 65, 0 ]
[ 70, 47 ]
python
en
['en', 'en', 'en']
True
coverage_error
(sigmoid=True, sample_weight=None)
Compute how far we need to go through the ranked scores to cover all true labels. The best value is equal to the average number of labels in y_true per sample.
Compute how far we need to go through the ranked scores to cover all true labels. The best value is equal to the average number of labels in y_true per sample.
def coverage_error(sigmoid=True, sample_weight=None): """Compute how far we need to go through the ranked scores to cover all true labels. The best value is equal to the average number of labels in y_true per sample.""" activation = ActivationType.Sigmoid if sigmoid else ActivationType.No return skm_to...
[ "def", "coverage_error", "(", "sigmoid", "=", "True", ",", "sample_weight", "=", "None", ")", ":", "activation", "=", "ActivationType", ".", "Sigmoid", "if", "sigmoid", "else", "ActivationType", ".", "No", "return", "skm_to_fastai", "(", "skm", ".", "coverage_...
[ 86, 0 ]
[ 91, 115 ]
python
en
['en', 'en', 'en']
True
poly_IoU
(poly_1:Polygon, poly_2:Polygon)
IoU for polygons
IoU for polygons
def poly_IoU(poly_1:Polygon, poly_2:Polygon) -> float: "IoU for polygons" area_intersection = poly_1.intersection(poly_2).area area_union = poly_1.union(poly_2).area iou = area_intersection / area_union return iou
[ "def", "poly_IoU", "(", "poly_1", ":", "Polygon", ",", "poly_2", ":", "Polygon", ")", "->", "float", ":", "area_intersection", "=", "poly_1", ".", "intersection", "(", "poly_2", ")", ".", "area", "area_union", "=", "poly_1", ".", "union", "(", "poly_2", ...
[ 107, 0 ]
[ 112, 14 ]
python
en
['en', 'en', 'en']
True
is_true_positive
(row, results:gpd.GeoDataFrame, res_sindex:gpd.sindex)
Check if a single ground truth mask is TP or FN with 11 different IoU thresholds
Check if a single ground truth mask is TP or FN with 11 different IoU thresholds
def is_true_positive(row, results:gpd.GeoDataFrame, res_sindex:gpd.sindex): "Check if a single ground truth mask is TP or FN with 11 different IoU thresholds" iou_threshs = np.arange(0.5, 1.04, 0.05) # Matching predictions using spatial index c = list(res_sindex.intersection(row.geometry.bounds)) p...
[ "def", "is_true_positive", "(", "row", ",", "results", ":", "gpd", ".", "GeoDataFrame", ",", "res_sindex", ":", "gpd", ".", "sindex", ")", ":", "iou_threshs", "=", "np", ".", "arange", "(", "0.5", ",", "1.04", ",", "0.05", ")", "# Matching predictions usin...
[ 115, 0 ]
[ 144, 18 ]
python
en
['en', 'en', 'en']
True
is_false_positive
(row, ground_truth:gpd.GeoDataFrame, gt_sindex:gpd.sindex, results:gpd.GeoDataFrame, res_sindex:gpd.sindex)
Check if prediction is FP or TP for 11 different IoU thresholds
Check if prediction is FP or TP for 11 different IoU thresholds
def is_false_positive(row, ground_truth:gpd.GeoDataFrame, gt_sindex:gpd.sindex, results:gpd.GeoDataFrame, res_sindex:gpd.sindex): "Check if prediction is FP or TP for 11 different IoU thresholds" iou_threshs = np.arange(0.5, 1.04, 0.05) # First find out the matching ground truth mask...
[ "def", "is_false_positive", "(", "row", ",", "ground_truth", ":", "gpd", ".", "GeoDataFrame", ",", "gt_sindex", ":", "gpd", ".", "sindex", ",", "results", ":", "gpd", ".", "GeoDataFrame", ",", "res_sindex", ":", "gpd", ".", "sindex", ")", ":", "iou_threshs...
[ 148, 0 ]
[ 215, 18 ]
python
en
['en', 'en', 'en']
True
average_precision
(ground_truth:gpd.GeoDataFrame, preds:gpd.GeoDataFrame)
Get 11-point AP score for each label separately and with all iou_thresholds
Get 11-point AP score for each label separately and with all iou_thresholds
def average_precision(ground_truth:gpd.GeoDataFrame, preds:gpd.GeoDataFrame) -> dict: "Get 11-point AP score for each label separately and with all iou_thresholds" # Clip geodataframes so that they cover the same area preds = gpd.clip(preds, box(*ground_truth.total_bounds), keep_geom_type=True) ground_...
[ "def", "average_precision", "(", "ground_truth", ":", "gpd", ".", "GeoDataFrame", ",", "preds", ":", "gpd", ".", "GeoDataFrame", ")", "->", "dict", ":", "# Clip geodataframes so that they cover the same area", "preds", "=", "gpd", ".", "clip", "(", "preds", ",", ...
[ 219, 0 ]
[ 257, 19 ]
python
en
['en', 'en', 'en']
True
average_recall
(ground_truth:gpd.GeoDataFrame, preds:gpd.GeoDataFrame, max_detections:int=None)
Get 11-point AR score for each label separately and with all iou_thresholds. If `max_detections` is not `None` evaluate with only that most confident predictions Seems to be still bugged, needs fixing
Get 11-point AR score for each label separately and with all iou_thresholds. If `max_detections` is not `None` evaluate with only that most confident predictions Seems to be still bugged, needs fixing
def average_recall(ground_truth:gpd.GeoDataFrame, preds:gpd.GeoDataFrame, max_detections:int=None) -> dict: """Get 11-point AR score for each label separately and with all iou_thresholds. If `max_detections` is not `None` evaluate with only that most confident predictions Seems to be still bugged, needs fix...
[ "def", "average_recall", "(", "ground_truth", ":", "gpd", ".", "GeoDataFrame", ",", "preds", ":", "gpd", ".", "GeoDataFrame", ",", "max_detections", ":", "int", "=", "None", ")", "->", "dict", ":", "# Clip geodataframes so that they cover the same area", "preds", ...
[ 261, 0 ]
[ 287, 19 ]
python
en
['en', 'en', 'en']
True
_summarize_coco
(cocoeval:COCOeval)
Compute and display summary metrics for evaluation results. Note this functin can *only* be applied on the default parameter setting
Compute and display summary metrics for evaluation results. Note this functin can *only* be applied on the default parameter setting
def _summarize_coco(cocoeval:COCOeval): """ Compute and display summary metrics for evaluation results. Note this functin can *only* be applied on the default parameter setting """ def _summarize(ap=1, iouThr=None, areaRng='all', maxDets=100): p = cocoeval.params iStr = ' {:<18} {} @...
[ "def", "_summarize_coco", "(", "cocoeval", ":", "COCOeval", ")", ":", "def", "_summarize", "(", "ap", "=", "1", ",", "iouThr", "=", "None", ",", "areaRng", "=", "'all'", ",", "maxDets", "=", "100", ")", ":", "p", "=", "cocoeval", ".", "params", "iStr...
[ 432, 0 ]
[ 506, 32 ]
python
en
['en', 'error', 'th']
False
GisCOCOeval.prepare_data
(self, gt_label_col:str='label', res_label_col:str='label')
Convert GIS-data predictions to COCO-format for evaluation, and save resulting files to self.outpath
Convert GIS-data predictions to COCO-format for evaluation, and save resulting files to self.outpath
def prepare_data(self, gt_label_col:str='label', res_label_col:str='label'): "Convert GIS-data predictions to COCO-format for evaluation, and save resulting files to self.outpath" self.coco_proc.shp_to_coco(label_col=gt_label_col) self.coco_proc.results_to_coco_res(label_col=res_label_col)
[ "def", "prepare_data", "(", "self", ",", "gt_label_col", ":", "str", "=", "'label'", ",", "res_label_col", ":", "str", "=", "'label'", ")", ":", "self", ".", "coco_proc", ".", "shp_to_coco", "(", "label_col", "=", "gt_label_col", ")", "self", ".", "coco_pr...
[ 306, 4 ]
[ 309, 67 ]
python
en
['en', 'en', 'en']
True
GisCOCOeval.prepare_eval
(self, eval_type:str='segm')
Prepare COCOeval to evaluate predictions with 100 and 1000 detections. AP metrics are evaluated with 1000 detections and AR with 100
Prepare COCOeval to evaluate predictions with 100 and 1000 detections. AP metrics are evaluated with 1000 detections and AR with 100
def prepare_eval(self, eval_type:str='segm'): """ Prepare COCOeval to evaluate predictions with 100 and 1000 detections. AP metrics are evaluated with 1000 detections and AR with 100 """ self.coco = COCO(f'{self.outpath}/coco.json') self.coco_res = self.coco.loadRes(f'{se...
[ "def", "prepare_eval", "(", "self", ",", "eval_type", ":", "str", "=", "'segm'", ")", ":", "self", ".", "coco", "=", "COCO", "(", "f'{self.outpath}/coco.json'", ")", "self", ".", "coco_res", "=", "self", ".", "coco", ".", "loadRes", "(", "f'{self.outpath}/...
[ 311, 4 ]
[ 319, 51 ]
python
en
['en', 'error', 'th']
False
GisCOCOeval.evaluate
(self)
Run evaluation and print metrics
Run evaluation and print metrics
def evaluate(self): "Run evaluation and print metrics" for cat in self.coco_categories: print(f'\nEvaluating for category {cat["name"]}') self.coco_eval.params.catIds = [cat['id']] self.coco_eval.evaluate() self.coco_eval.accumulate() _summari...
[ "def", "evaluate", "(", "self", ")", ":", "for", "cat", "in", "self", ".", "coco_categories", ":", "print", "(", "f'\\nEvaluating for category {cat[\"name\"]}'", ")", "self", ".", "coco_eval", ".", "params", ".", "catIds", "=", "[", "cat", "[", "'id'", "]", ...
[ 321, 4 ]
[ 336, 39 ]
python
en
['en', 'su', 'en']
True
GisCOCOeval.save_results
(self, outpath, iou_thresh:float=0.5)
Saves correctly detected ground truths, correct detections missed ground truths and misclassifications with specified iou_threshold in separate files for each scene
Saves correctly detected ground truths, correct detections missed ground truths and misclassifications with specified iou_threshold in separate files for each scene
def save_results(self, outpath, iou_thresh:float=0.5): """Saves correctly detected ground truths, correct detections missed ground truths and misclassifications with specified iou_threshold in separate files for each scene""" if not os.path.exists(f'{self.coco_proc.outpath}/{outpath}'): ...
[ "def", "save_results", "(", "self", ",", "outpath", ",", "iou_thresh", ":", "float", "=", "0.5", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "f'{self.coco_proc.outpath}/{outpath}'", ")", ":", "os", ".", "makedirs", "(", "f'{self.coco_proc.o...
[ 338, 4 ]
[ 430, 71 ]
python
en
['en', 'en', 'en']
True
rangeof
(iterable)
Equivalent for range(len(iterable))
Equivalent for range(len(iterable))
def rangeof(iterable): "Equivalent for range(len(iterable))" return range(len(iterable))
[ "def", "rangeof", "(", "iterable", ")", ":", "return", "range", "(", "len", "(", "iterable", ")", ")" ]
[ 10, 0 ]
[ 12, 31 ]
python
en
['en', 'no', 'en']
True
fix_multipolys
(multipoly:shapely.geometry.MultiPolygon)
Convert MultiPolygon to a single Polygon. The resulting Polygon has the exterior boundaries of the largest geometry of the MultiPolygon
Convert MultiPolygon to a single Polygon. The resulting Polygon has the exterior boundaries of the largest geometry of the MultiPolygon
def fix_multipolys(multipoly:shapely.geometry.MultiPolygon): """Convert MultiPolygon to a single Polygon. The resulting Polygon has the exterior boundaries of the largest geometry of the MultiPolygon""" temp_poly = None max_area = 0 for geom in multipoly.geoms: area = geom.area if ar...
[ "def", "fix_multipolys", "(", "multipoly", ":", "shapely", ".", "geometry", ".", "MultiPolygon", ")", ":", "temp_poly", "=", "None", "max_area", "=", "0", "for", "geom", "in", "multipoly", ".", "geoms", ":", "area", "=", "geom", ".", "area", "if", "area"...
[ 17, 0 ]
[ 27, 55 ]
python
en
['en', 'en', 'en']
True
cut_cone_v
(r_1:float, r_2:float, h:float)
V = (h(A + sqrt(A*A') + A))/3
V = (h(A + sqrt(A*A') + A))/3
def cut_cone_v(r_1:float, r_2:float, h:float): "V = (h(A + sqrt(A*A') + A))/3" A_1 = np.pi * r_1**2 A_2 = np.pi * r_2**2 V = (h*(A_1 + np.sqrt(A_1 * A_2) + A_2))/3 return V
[ "def", "cut_cone_v", "(", "r_1", ":", "float", ",", "r_2", ":", "float", ",", "h", ":", "float", ")", ":", "A_1", "=", "np", ".", "pi", "*", "r_1", "**", "2", "A_2", "=", "np", ".", "pi", "*", "r_2", "**", "2", "V", "=", "(", "h", "*", "(...
[ 37, 0 ]
[ 42, 12 ]
python
en
['en', 'lb', 'sw']
False
simple_get
(url)
Attempts to get the content at `url` by making an HTTP GET request. If the content-type of response is some kind of HTML/XML, return the text content, otherwise return None.
Attempts to get the content at `url` by making an HTTP GET request. If the content-type of response is some kind of HTML/XML, return the text content, otherwise return None.
def simple_get(url): """ Attempts to get the content at `url` by making an HTTP GET request. If the content-type of response is some kind of HTML/XML, return the text content, otherwise return None. """ try: with closing(get(url, stream=True)) as resp: if is_good_response(res...
[ "def", "simple_get", "(", "url", ")", ":", "try", ":", "with", "closing", "(", "get", "(", "url", ",", "stream", "=", "True", ")", ")", "as", "resp", ":", "if", "is_good_response", "(", "resp", ")", ":", "return", "resp", ".", "content", "else", ":...
[ 25, 0 ]
[ 40, 19 ]
python
en
['en', 'error', 'th']
False
is_good_response
(resp)
Returns True if the response seems to be HTML, False otherwise.
Returns True if the response seems to be HTML, False otherwise.
def is_good_response(resp): """ Returns True if the response seems to be HTML, False otherwise. """ content_type = resp.headers['Content-Type'].lower() return (resp.status_code == 200 and content_type is not None and content_type.find('html') > -1)
[ "def", "is_good_response", "(", "resp", ")", ":", "content_type", "=", "resp", ".", "headers", "[", "'Content-Type'", "]", ".", "lower", "(", ")", "return", "(", "resp", ".", "status_code", "==", "200", "and", "content_type", "is", "not", "None", "and", ...
[ 43, 0 ]
[ 50, 47 ]
python
en
['en', 'error', 'th']
False
adjoin
(space, *lists)
Glues together two sets of strings using the amount of space requested. The idea is to prettify. Brought over from from pandas
Glues together two sets of strings using the amount of space requested. The idea is to prettify.
def adjoin(space, *lists): """ Glues together two sets of strings using the amount of space requested. The idea is to prettify. Brought over from from pandas """ out_lines = [] newLists = [] lengths = [max(map(len, x)) + space for x in lists[:-1]] # not the last one lengths.app...
[ "def", "adjoin", "(", "space", ",", "*", "lists", ")", ":", "out_lines", "=", "[", "]", "newLists", "=", "[", "]", "lengths", "=", "[", "max", "(", "map", "(", "len", ",", "x", ")", ")", "+", "space", "for", "x", "in", "lists", "[", ":", "-",...
[ 92, 0 ]
[ 114, 45 ]
python
en
['en', 'error', 'th']
False
approx_equal
(a, b, eps)
Return whether the difference between `a` and `b` is less than `eps`. Parameters ---------- a : numbers.Real b : numbers.Real eps : numbers.Real Returns ------- are_diff : bool
Return whether the difference between `a` and `b` is less than `eps`.
def approx_equal(a, b, eps): """Return whether the difference between `a` and `b` is less than `eps`. Parameters ---------- a : numbers.Real b : numbers.Real eps : numbers.Real Returns ------- are_diff : bool """ assert abs(a - b) < eps
[ "def", "approx_equal", "(", "a", ",", "b", ",", "eps", ")", ":", "assert", "abs", "(", "a", "-", "b", ")", "<", "eps" ]
[ 131, 0 ]
[ 144, 27 ]
python
en
['en', 'en', 'en']
True
safe_index
(elements, value)
Find the location of `value` in `elements`, return -1 if `value` is not found instead of raising ``ValueError``. Parameters ---------- elements : Sequence value : object Returns ------- location : object Examples -------- >>> sequence = [1, 2, 3] >>> safe_index(sequenc...
Find the location of `value` in `elements`, return -1 if `value` is not found instead of raising ``ValueError``.
def safe_index(elements, value): """Find the location of `value` in `elements`, return -1 if `value` is not found instead of raising ``ValueError``. Parameters ---------- elements : Sequence value : object Returns ------- location : object Examples -------- >>> sequenc...
[ "def", "safe_index", "(", "elements", ",", "value", ")", ":", "try", ":", "return", "elements", ".", "index", "(", "value", ")", "except", "ValueError", ":", "return", "-", "1" ]
[ 155, 0 ]
[ 179, 17 ]
python
en
['en', 'en', 'en']
True
is_iterable
(o)
Return whether `o` is a non-string iterable. Parameters ---------- o : object Any python object Returns ------- is_seq : bool Examples -------- >>> x = '1' >>> is_iterable(x) False >>> is_iterable(iter(x)) True >>> is_iterable(i for i in range(1)) T...
Return whether `o` is a non-string iterable.
def is_iterable(o): """Return whether `o` is a non-string iterable. Parameters ---------- o : object Any python object Returns ------- is_seq : bool Examples -------- >>> x = '1' >>> is_iterable(x) False >>> is_iterable(iter(x)) True >>> is_iterable...
[ "def", "is_iterable", "(", "o", ")", ":", "return", "(", "not", "isinstance", "(", "o", ",", "six", ".", "string_types", ")", "and", "isinstance", "(", "o", ",", "collections", ".", "Iterable", ")", ")" ]
[ 182, 0 ]
[ 209, 48 ]
python
en
['en', 'en', 'en']
True
convert_unit
(value, unit, to)
Convert `value`--which is assumed to be in units of `unit`--to units of `to`. Parameters ---------- value : Union[numbers.Real, ibis.expr.types.NumericValue] Returns ------- result : Union[numbers.Integral, ibis.expr.types.NumericValue] Examples -------- >>> one_second = 1000 ...
Convert `value`--which is assumed to be in units of `unit`--to units of `to`.
def convert_unit(value, unit, to): """Convert `value`--which is assumed to be in units of `unit`--to units of `to`. Parameters ---------- value : Union[numbers.Real, ibis.expr.types.NumericValue] Returns ------- result : Union[numbers.Integral, ibis.expr.types.NumericValue] Exampl...
[ "def", "convert_unit", "(", "value", ",", "unit", ",", "to", ")", ":", "# Don't do anything if from and to units are equivalent", "if", "unit", "==", "to", ":", "return", "value", "units", "=", "(", "'W'", ",", "'D'", ",", "'h'", ",", "'m'", ",", "'s'", ",...
[ 212, 0 ]
[ 270, 26 ]
python
en
['en', 'en', 'en']
True
allow_experimental_map_type
(self)
Set allow_experimental_map_type = 1
Set allow_experimental_map_type = 1
def allow_experimental_map_type(self): """Set allow_experimental_map_type = 1 """ setting = ("allow_experimental_map_type", 1) default_query_settings = None try: with By("adding allow_experimental_map_type to the default query settings"): default_query_settings = getsattr(curren...
[ "def", "allow_experimental_map_type", "(", "self", ")", ":", "setting", "=", "(", "\"allow_experimental_map_type\"", ",", "1", ")", "default_query_settings", "=", "None", "try", ":", "with", "By", "(", "\"adding allow_experimental_map_type to the default query settings\"", ...
[ 15, 0 ]
[ 32, 24 ]
python
en
['it', 'en', 'en']
True
create_table
(self, name, statement, on_cluster=False)
Create table.
Create table.
def create_table(self, name, statement, on_cluster=False): """Create table. """ node = current().context.node try: with Given(f"I have a {name} table"): node.query(statement.format(name=name)) yield name finally: with Finally("I drop the table"): if on...
[ "def", "create_table", "(", "self", ",", "name", ",", "statement", ",", "on_cluster", "=", "False", ")", ":", "node", "=", "current", "(", ")", ".", "context", ".", "node", "try", ":", "with", "Given", "(", "f\"I have a {name} table\"", ")", ":", "node",...
[ 35, 0 ]
[ 48, 58 ]
python
en
['en', 'ga', 'en']
False
getArticlesOn_n_pages
(num_pages_to_check)
clanki se pojavijo na strani sele, ko se zloada javascript, zato se uporabi selenium knjiznjica
clanki se pojavijo na strani sele, ko se zloada javascript, zato se uporabi selenium knjiznjica
def getArticlesOn_n_pages(num_pages_to_check): ''' clanki se pojavijo na strani sele, ko se zloada javascript, zato se uporabi selenium knjiznjica ''' options = Options() options.set_headless(headless=True) options.add_argument("--window-size=1920x1080") driver = webdriver.Chrome...
[ "def", "getArticlesOn_n_pages", "(", "num_pages_to_check", ")", ":", "options", "=", "Options", "(", ")", "options", ".", "set_headless", "(", "headless", "=", "True", ")", "options", ".", "add_argument", "(", "\"--window-size=1920x1080\"", ")", "driver", "=", "...
[ 47, 0 ]
[ 82, 19 ]
python
en
['en', 'error', 'th']
False
privileges_granted_directly
(self, node=None)
Check that a user is able to execute `SYSTEM TTL MERGES` commands if and only if the privilege has been granted directly.
Check that a user is able to execute `SYSTEM TTL MERGES` commands if and only if the privilege has been granted directly.
def privileges_granted_directly(self, node=None): """Check that a user is able to execute `SYSTEM TTL MERGES` commands if and only if the privilege has been granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"): ...
[ "def", "privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ",", "f\"{user_...
[ 8, 0 ]
[ 23, 80 ]
python
en
['en', 'en', 'en']
True
privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `SYSTEM TTL MERGES` commands if and only if the privilege has been granted via role.
Check that a user is able to execute `SYSTEM TTL MERGES` commands if and only if the privilege has been granted via role.
def privileges_granted_via_role(self, node=None): """Check that a user is able to execute `SYSTEM TTL MERGES` commands if and only if the privilege has been granted via role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.node ...
[ "def", "privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with"...
[ 26, 0 ]
[ 45, 80 ]
python
en
['en', 'en', 'en']
True
check_privilege
(self, privilege, on, grant_target_name, user_name, table_name, node=None)
Run checks for commands that require SYSTEM TTL MERGES privilege.
Run checks for commands that require SYSTEM TTL MERGES privilege.
def check_privilege(self, privilege, on, grant_target_name, user_name, table_name, node=None): """Run checks for commands that require SYSTEM TTL MERGES privilege. """ if node is None: node = self.context.node Suite(test=start_ttl_merges)(privilege=privilege, on=on, grant_target_name=grant_tar...
[ "def", "check_privilege", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "table_name", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "S...
[ 57, 0 ]
[ 65, 140 ]
python
en
['en', 'en', 'en']
True
start_ttl_merges
(self, privilege, on, grant_target_name, user_name, table_name, node=None)
Check that user is only able to execute `SYSTEM START TTL MERGES` when they have privilege.
Check that user is only able to execute `SYSTEM START TTL MERGES` when they have privilege.
def start_ttl_merges(self, privilege, on, grant_target_name, user_name, table_name, node=None): """Check that user is only able to execute `SYSTEM START TTL MERGES` when they have privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.contex...
[ "def", "start_ttl_merges", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "table_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=",...
[ 68, 0 ]
[ 110, 55 ]
python
en
['en', 'en', 'en']
True
stop_ttl_merges
(self, privilege, on, grant_target_name, user_name, table_name, node=None)
Check that user is only able to execute `SYSTEM STOP TTL MERGES` when they have privilege.
Check that user is only able to execute `SYSTEM STOP TTL MERGES` when they have privilege.
def stop_ttl_merges(self, privilege, on, grant_target_name, user_name, table_name, node=None): """Check that user is only able to execute `SYSTEM STOP TTL MERGES` when they have privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.context....
[ "def", "stop_ttl_merges", "(", "self", ",", "privilege", ",", "on", ",", "grant_target_name", ",", "user_name", ",", "table_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", ...
[ 113, 0 ]
[ 155, 55 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of SYSTEM TTL MERGES.
Check the RBAC functionality of SYSTEM TTL MERGES.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of SYSTEM TTL MERGES. """ self.context.node = self.context.cluster.node(node) Suite(run=privileges_granted_directly, setup=instrument_clickhouse_server_log) Suite(run=privileges_granted_via_role, setup=instrument_clickhouse_serv...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "Suite", "(", "run", "=", "privileges_granted_directly", ",", ...
[ 164, 0 ]
[ 170, 82 ]
python
en
['en', 'en', 'en']
True
_find_seed
(x)
Grabs seed from image name. if can't find seed, returns 'reference'
Grabs seed from image name.
def _find_seed(x): """Grabs seed from image name. if can't find seed, returns 'reference' """ try: return re.findall('seed-(\d+)_', x)[0] except IndexError: return 'reference'
[ "def", "_find_seed", "(", "x", ")", ":", "try", ":", "return", "re", ".", "findall", "(", "'seed-(\\d+)_'", ",", "x", ")", "[", "0", "]", "except", "IndexError", ":", "return", "'reference'" ]
[ 18, 0 ]
[ 27, 26 ]
python
en
['en', 'en', 'en']
True
_find_init_type
(x)
Grab init string from image name. If can't find it, returns 'reference'
Grab init string from image name.
def _find_init_type(x): """Grab init string from image name. If can't find it, returns 'reference' """ try: return re.findall('init-(.+)_lr', x)[0] except IndexError: return 'reference'
[ "def", "_find_init_type", "(", "x", ")", ":", "try", ":", "return", "re", ".", "findall", "(", "'init-(.+)_lr'", ",", "x", ")", "[", "0", "]", "except", "IndexError", ":", "return", "'reference'" ]
[ 30, 0 ]
[ 38, 26 ]
python
en
['en', 'en', 'en']
True
_grab_seed_n
(x)
Grab seed n from full seed If it's not an int, return 'reference'.
Grab seed n from full seed
def _grab_seed_n(x): """Grab seed n from full seed If it's not an int, return 'reference'. """ try: return int(str(x)[-1]) except ValueError: return x
[ "def", "_grab_seed_n", "(", "x", ")", ":", "try", ":", "return", "int", "(", "str", "(", "x", ")", "[", "-", "1", "]", ")", "except", "ValueError", ":", "return", "x" ]
[ 41, 0 ]
[ 49, 16 ]
python
en
['en', 'af', 'en']
True
model_distance
(model, synth_model_name, ref_image_name, scaling, distance_func=pop.optim.l2_norm)
Calculate distances between images for a model. We want to reason about the model distance of our best model (by default, the L2-norm of the difference in model space) between images synthesized by other models / scaling values. This is a step on the way towards getting a human perceptual metric, and s...
Calculate distances between images for a model.
def model_distance(model, synth_model_name, ref_image_name, scaling, distance_func=pop.optim.l2_norm): """Calculate distances between images for a model. We want to reason about the model distance of our best model (by default, the L2-norm of the difference in model space) between images...
[ "def", "model_distance", "(", "model", ",", "synth_model_name", ",", "ref_image_name", ",", "scaling", ",", "distance_func", "=", "pop", ".", "optim", ".", "l2_norm", ")", ":", "paths", "=", "utils", ".", "generate_metamer_paths", "(", "synth_model_name", ",", ...
[ 52, 0 ]
[ 176, 13 ]
python
en
['en', 'en', 'en']
True
find_roi
(img_size, mean, cov)
Function for finding the region of interest for a probability heatmap generated by a Gaussian corner. This region of interest is the area with most change therein, with probabilities above 0.0027 and below 0.9973 :param img_size: tuple: formatted (n_rows, n_cols) depicting the size of the image :param ...
Function for finding the region of interest for a probability heatmap generated by a Gaussian corner. This region of interest is the area with most change therein, with probabilities above 0.0027 and below 0.9973 :param img_size: tuple: formatted (n_rows, n_cols) depicting the size of the image :param ...
def find_roi(img_size, mean, cov): """ Function for finding the region of interest for a probability heatmap generated by a Gaussian corner. This region of interest is the area with most change therein, with probabilities above 0.0027 and below 0.9973 :param img_size: tuple: formatted (n_rows, n_cols) d...
[ "def", "find_roi", "(", "img_size", ",", "mean", ",", "cov", ")", ":", "# Calculate approximate ROI", "stdy", "=", "cov", "[", "0", ",", "0", "]", "**", "0.5", "stdx", "=", "cov", "[", "1", ",", "1", "]", "**", "0.5", "minx", "=", "int", "(", "ma...
[ 116, 0 ]
[ 162, 85 ]
python
en
['en', 'error', 'th']
False
gen_single_heatmap
(img_size, mean, cov)
Function for generating the heatmap for a given Gaussian corner. :param img_size: tuple: formatted (n_rows, n_cols) depicting the size of the image :param mean: list: formatted [mu_y, mu_x] describes the location of the mean of the Gaussian corner. :param cov: 2D array: formatted [[var_y, corr], [corr,...
Function for generating the heatmap for a given Gaussian corner. :param img_size: tuple: formatted (n_rows, n_cols) depicting the size of the image :param mean: list: formatted [mu_y, mu_x] describes the location of the mean of the Gaussian corner. :param cov: 2D array: formatted [[var_y, corr], [corr,...
def gen_single_heatmap(img_size, mean, cov): """ Function for generating the heatmap for a given Gaussian corner. :param img_size: tuple: formatted (n_rows, n_cols) depicting the size of the image :param mean: list: formatted [mu_y, mu_x] describes the location of the mean of the Gaussian corner. :p...
[ "def", "gen_single_heatmap", "(", "img_size", ",", "mean", ",", "cov", ")", ":", "heatmap", "=", "np", ".", "zeros", "(", "img_size", ",", "dtype", "=", "np", ".", "float32", ")", "g", "=", "multivariate_normal", "(", "mean", "=", "mean", ",", "cov", ...
[ 165, 0 ]
[ 215, 18 ]
python
en
['en', 'error', 'th']
False
BBoxDetInst.__init__
(self, class_list, box, pos_prob=1.0)
Initialisation function for a BBox detection instance :param class_list: list of class probabilities for the detection :param box: list of box corners that contain the object detected (inclusively). Formatted [x1, y1, x2, y2] :param pos_prob: float depicting the positional confi...
Initialisation function for a BBox detection instance :param class_list: list of class probabilities for the detection :param box: list of box corners that contain the object detected (inclusively). Formatted [x1, y1, x2, y2] :param pos_prob: float depicting the positional confi...
def __init__(self, class_list, box, pos_prob=1.0): """ Initialisation function for a BBox detection instance :param class_list: list of class probabilities for the detection :param box: list of box corners that contain the object detected (inclusively). Formatted [x1, y1, x2, y2]...
[ "def", "__init__", "(", "self", ",", "class_list", ",", "box", ",", "pos_prob", "=", "1.0", ")", ":", "super", "(", "BBoxDetInst", ",", "self", ")", ".", "__init__", "(", "class_list", ")", "self", ".", "box", "=", "box", "self", ".", "pos_prob", "="...
[ 44, 4 ]
[ 54, 32 ]
python
en
['en', 'error', 'th']
False
PBoxDetInst.__init__
(self, class_list, box, covs)
Initialisation function for a PBox detection instance :param class_list: list of class probabilities for the detection :param box: list of BBox corners, used to define the Gaussian corner mean locations for the box. Formatted [x1, y1, x2, y2] :param covs: list of two 2D covarian...
Initialisation function for a PBox detection instance :param class_list: list of class probabilities for the detection :param box: list of BBox corners, used to define the Gaussian corner mean locations for the box. Formatted [x1, y1, x2, y2] :param covs: list of two 2D covarian...
def __init__(self, class_list, box, covs): """ Initialisation function for a PBox detection instance :param class_list: list of class probabilities for the detection :param box: list of BBox corners, used to define the Gaussian corner mean locations for the box. Formatted [x1, y1...
[ "def", "__init__", "(", "self", ",", "class_list", ",", "box", ",", "covs", ")", ":", "super", "(", "PBoxDetInst", ",", "self", ")", ".", "__init__", "(", "class_list", ")", "self", ".", "box", "=", "box", "self", ".", "covs", "=", "covs" ]
[ 81, 4 ]
[ 92, 24 ]
python
en
['en', 'error', 'th']
False
Generator.write_gcp_kpt
(kpt="kpt")
Create test data based on running the kpt commands. This will allow us to see any diffs if we refactor the commands
Create test data based on running the kpt commands.
def write_gcp_kpt(kpt="kpt"): """Create test data based on running the kpt commands. This will allow us to see any diffs if we refactor the commands """ repo_root = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]) repo_root = repo_root.decode() repo_root = repo_root.strip() ...
[ "def", "write_gcp_kpt", "(", "kpt", "=", "\"kpt\"", ")", ":", "repo_root", "=", "subprocess", ".", "check_output", "(", "[", "\"git\"", ",", "\"rev-parse\"", ",", "\"--show-toplevel\"", "]", ")", "repo_root", "=", "repo_root", ".", "decode", "(", ")", "repo_...
[ 10, 2 ]
[ 52, 71 ]
python
en
['en', 'no', 'en']
True
XercesCConan._validate
(self, option, value, os)
Validate that the given `option` has the required `value` for the given `os` If not raises a ConanInvalidConfiguration error :param option: the name of the option to validate :param value: the value that the `option` should have :param os: either a single string or a tuple of s...
Validate that the given `option` has the required `value` for the given `os` If not raises a ConanInvalidConfiguration error
def _validate(self, option, value, os): """ Validate that the given `option` has the required `value` for the given `os` If not raises a ConanInvalidConfiguration error :param option: the name of the option to validate :param value: the value that the `option` should have ...
[ "def", "_validate", "(", "self", ",", "option", ",", "value", ",", "os", ")", ":", "if", "self", ".", "settings", ".", "os", "not", "in", "os", "and", "getattr", "(", "self", ".", "options", ",", "option", ")", "==", "value", ":", "raise", "ConanIn...
[ 73, 4 ]
[ 88, 13 ]
python
en
['en', 'error', 'th']
False
compile
(expr, params=None)
Compile an ibis expression to the PostgreSQL target. Parameters ---------- expr : ibis.expr.types.Expr The ibis expression to compile params : dict or None ``dict`` mapping :class:`ibis.expr.types.ScalarParameter` objects to values Returns ------- sqlalchemy_express...
Compile an ibis expression to the PostgreSQL target.
def compile(expr, params=None): """Compile an ibis expression to the PostgreSQL target. Parameters ---------- expr : ibis.expr.types.Expr The ibis expression to compile params : dict or None ``dict`` mapping :class:`ibis.expr.types.ScalarParameter` objects to values Ret...
[ "def", "compile", "(", "expr", ",", "params", "=", "None", ")", ":", "return", "to_sqlalchemy", "(", "expr", ",", "dialect", ".", "make_context", "(", "params", "=", "params", ")", ")" ]
[ 10, 0 ]
[ 47, 67 ]
python
en
['en', 'en', 'en']
True
connect
( host='localhost', user=None, password=None, port=5432, database=None, url=None, driver='psycopg2' )
Create an Ibis client located at `user`:`password`@`host`:`port` connected to a PostgreSQL database named `database`. Parameters ---------- host : string, default 'localhost' user : string, default None password : string, default None port : string or integer, default 5432 database : st...
Create an Ibis client located at `user`:`password`@`host`:`port` connected to a PostgreSQL database named `database`.
def connect( host='localhost', user=None, password=None, port=5432, database=None, url=None, driver='psycopg2' ): """Create an Ibis client located at `user`:`password`@`host`:`port` connected to a PostgreSQL database named `database`. Parameters ---------- host : string,...
[ "def", "connect", "(", "host", "=", "'localhost'", ",", "user", "=", "None", ",", "password", "=", "None", ",", "port", "=", "5432", ",", "database", "=", "None", ",", "url", "=", "None", ",", "driver", "=", "'psycopg2'", ")", ":", "return", "Postgre...
[ 50, 0 ]
[ 124, 5 ]
python
en
['en', 'en', 'en']
True
privilege_granted_directly_or_via_role
(self, table_type, privilege, node=None)
Check that user is only able to execute ALTER MOVE PARTITION when they have required privilege, either directly or via role.
Check that user is only able to execute ALTER MOVE PARTITION when they have required privilege, either directly or via role.
def privilege_granted_directly_or_via_role(self, table_type, privilege, node=None): """Check that user is only able to execute ALTER MOVE PARTITION when they have required privilege, either directly or via role. """ role_name = f"role_{getuid()}" user_name = f"user_{getuid()}" if node is None: ...
[ "def", "privilege_granted_directly_or_via_role", "(", "self", ",", "table_type", ",", "privilege", ",", "node", "=", "None", ")", ":", "role_name", "=", "f\"role_{getuid()}\"", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=",...
[ 10, 0 ]
[ 32, 136 ]
python
en
['en', 'en', 'en']
True
privilege_check
(grant_target_name, user_name, table_type, privilege, node=None)
Run scenarios to check the user's access with different privileges.
Run scenarios to check the user's access with different privileges.
def privilege_check(grant_target_name, user_name, table_type, privilege, node=None): """Run scenarios to check the user's access with different privileges. """ exitcode, message = errors.not_enough_privileges(name=f"{user_name}") with Scenario("user without privilege", setup=instrument_clickhouse_serve...
[ "def", "privilege_check", "(", "grant_target_name", ",", "user_name", ",", "table_type", ",", "privilege", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "f\"{user_name}\"", ")", "...
[ 34, 0 ]
[ 152, 70 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1", stress=None, parallel=None)
Check the RBAC functionality of ALTER MOVE.
Check the RBAC functionality of ALTER MOVE.
def feature(self, node="clickhouse1", stress=None, parallel=None): """Check the RBAC functionality of ALTER MOVE. """ self.context.node = self.context.cluster.node(node) if parallel is not None: self.context.parallel = parallel if stress is not None: self.context.stress = stress ...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ",", "stress", "=", "None", ",", "parallel", "=", "None", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", ...
[ 164, 0 ]
[ 183, 98 ]
python
en
['en', 'en', 'en']
True
addressToLine_privileges_granted_directly
(self, node=None)
Check that a user is able to execute `addressToLine` with privileges are granted directly.
Check that a user is able to execute `addressToLine` with privileges are granted directly.
def addressToLine_privileges_granted_directly(self, node=None): """Check that a user is able to execute `addressToLine` with privileges are granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"): Suite(run=ad...
[ "def", "addressToLine_privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ","...
[ 26, 0 ]
[ 40, 74 ]
python
en
['en', 'en', 'en']
True
addressToLine_privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `addressToLine` with privileges are granted through a role.
Check that a user is able to execute `addressToLine` with privileges are granted through a role.
def addressToLine_privileges_granted_via_role(self, node=None): """Check that a user is able to execute `addressToLine` with privileges are granted through a role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.node with user(nod...
[ "def", "addressToLine_privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "n...
[ 43, 0 ]
[ 61, 74 ]
python
en
['en', 'en', 'en']
True
addressToLine
(self, privilege, grant_target_name, user_name, node=None)
Check that user is only able to execute `addressToLine` when they have the necessary privilege.
Check that user is only able to execute `addressToLine` when they have the necessary privilege.
def addressToLine(self, privilege, grant_target_name, user_name, node=None): """Check that user is only able to execute `addressToLine` when they have the necessary privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.context.node wit...
[ "def", "addressToLine", "(", "self", ",", "privilege", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ")", "if", "node", ...
[ 73, 0 ]
[ 111, 51 ]
python
en
['en', 'en', 'en']
True
addressToSymbol_privileges_granted_directly
(self, node=None)
Check that a user is able to execute `addressToSymbol` with privileges are granted directly.
Check that a user is able to execute `addressToSymbol` with privileges are granted directly.
def addressToSymbol_privileges_granted_directly(self, node=None): """Check that a user is able to execute `addressToSymbol` with privileges are granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"): Suite(ru...
[ "def", "addressToSymbol_privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", "...
[ 114, 0 ]
[ 128, 74 ]
python
en
['en', 'en', 'en']
True
addressToSymbol_privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `addressToSymbol` with privileges are granted through a role.
Check that a user is able to execute `addressToSymbol` with privileges are granted through a role.
def addressToSymbol_privileges_granted_via_role(self, node=None): """Check that a user is able to execute `addressToSymbol` with privileges are granted through a role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.node with user...
[ "def", "addressToSymbol_privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", ...
[ 131, 0 ]
[ 149, 74 ]
python
en
['en', 'en', 'en']
True
addressToSymbol
(self, privilege, grant_target_name, user_name, node=None)
Check that user is only able to execute `addressToSymbol` when they have the necessary privilege.
Check that user is only able to execute `addressToSymbol` when they have the necessary privilege.
def addressToSymbol(self, privilege, grant_target_name, user_name, node=None): """Check that user is only able to execute `addressToSymbol` when they have the necessary privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.context.node ...
[ "def", "addressToSymbol", "(", "self", ",", "privilege", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ")", "if", "node"...
[ 161, 0 ]
[ 199, 51 ]
python
en
['en', 'en', 'en']
True
demangle_privileges_granted_directly
(self, node=None)
Check that a user is able to execute `demangle` with privileges are granted directly.
Check that a user is able to execute `demangle` with privileges are granted directly.
def demangle_privileges_granted_directly(self, node=None): """Check that a user is able to execute `demangle` with privileges are granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"): Suite(run=demangle, ...
[ "def", "demangle_privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ",", "...
[ 202, 0 ]
[ 216, 74 ]
python
en
['en', 'en', 'en']
True
demangle_privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `demangle` with privileges are granted through a role.
Check that a user is able to execute `demangle` with privileges are granted through a role.
def demangle_privileges_granted_via_role(self, node=None): """Check that a user is able to execute `demangle` with privileges are granted through a role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.node with user(node, f"{user...
[ "def", "demangle_privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node",...
[ 219, 0 ]
[ 237, 74 ]
python
en
['en', 'en', 'en']
True
demangle
(self, privilege, grant_target_name, user_name, node=None)
Check that user is only able to execute `demangle` when they have the necessary privilege.
Check that user is only able to execute `demangle` when they have the necessary privilege.
def demangle(self, privilege, grant_target_name, user_name, node=None): """Check that user is only able to execute `demangle` when they have the necessary privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.context.node with Scenario...
[ "def", "demangle", "(", "self", ",", "privilege", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ")", "if", "node", "is...
[ 249, 0 ]
[ 287, 51 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of INTROSPECTION.
Check the RBAC functionality of INTROSPECTION.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of INTROSPECTION. """ self.context.node = self.context.cluster.node(node) with allow_introspection_functions(self.context.node): Suite(run=addressToLine_privileges_granted_directly, setup=instrument_clickhouse_server_log) ...
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "with", "allow_introspection_functions", "(", "self", ".", "con...
[ 296, 0 ]
[ 307, 95 ]
python
en
['en', 'en', 'en']
True
create_fourier_heatmap_from_error_matrix
( error_matrix: torch.Tensor, )
Create Fourier Heat Map from error matrix (about quadrant 1 and 4). Note: Fourier Heat Map is symmetric about the origin. So by performing an inversion operation about the origin, Fourier Heat Map is created from error matrix. Args: error_matrix (torch.Tensor): The size of error matrix...
Create Fourier Heat Map from error matrix (about quadrant 1 and 4).
def create_fourier_heatmap_from_error_matrix( error_matrix: torch.Tensor, ) -> torch.Tensor: """Create Fourier Heat Map from error matrix (about quadrant 1 and 4). Note: Fourier Heat Map is symmetric about the origin. So by performing an inversion operation about the origin, Fourier Heat Ma...
[ "def", "create_fourier_heatmap_from_error_matrix", "(", "error_matrix", ":", "torch", ".", "Tensor", ",", ")", "->", "torch", ".", "Tensor", ":", "assert", "len", "(", "error_matrix", ".", "size", "(", ")", ")", "==", "2", "assert", "error_matrix", ".", "siz...
[ 18, 0 ]
[ 40, 70 ]
python
en
['en', 'en', 'en']
True
save_fourier_heatmap
( fhmap: torch.Tensor, savedir: pathlib.Path, suffix: str = "" )
Save Fourier Heat Map as a png image. Args: fhmap (torch.Tensor): Fourier Heat Map. savedir (pathlib.Path): Path to the directory where the results will be saved. suffix (str, optional): Suffix which is attached to result file of Fourier Heat Map.
Save Fourier Heat Map as a png image.
def save_fourier_heatmap( fhmap: torch.Tensor, savedir: pathlib.Path, suffix: str = "" ) -> None: """Save Fourier Heat Map as a png image. Args: fhmap (torch.Tensor): Fourier Heat Map. savedir (pathlib.Path): Path to the directory where the results will be saved. suffix (str, option...
[ "def", "save_fourier_heatmap", "(", "fhmap", ":", "torch", ".", "Tensor", ",", "savedir", ":", "pathlib", ".", "Path", ",", "suffix", ":", "str", "=", "\"\"", ")", "->", "None", ":", "torch", ".", "save", "(", "fhmap", ",", "savedir", "/", "(", "\"fh...
[ 43, 0 ]
[ 65, 20 ]
python
en
['en', 'en', 'en']
True
insert_fourier_noise
(transforms: List, basis: torch.Tensor)
Insert Fourier noise transform to given a list of transform by inplace operation. Note: If Normalize transform is included in the given list, Fourier noise transform is added to just before Normalize transform. If not, Fourier noise transform is added at the end of the list. Args: tran...
Insert Fourier noise transform to given a list of transform by inplace operation.
def insert_fourier_noise(transforms: List, basis: torch.Tensor) -> None: """Insert Fourier noise transform to given a list of transform by inplace operation. Note: If Normalize transform is included in the given list, Fourier noise transform is added to just before Normalize transform. If not, ...
[ "def", "insert_fourier_noise", "(", "transforms", ":", "List", ",", "basis", ":", "torch", ".", "Tensor", ")", "->", "None", ":", "def", "_get_index_of_normalize", "(", "transforms", ":", "List", ")", "->", "Optional", "[", "int", "]", ":", "for", "index",...
[ 68, 0 ]
[ 91, 59 ]
python
en
['en', 'en', 'en']
True
eval_fourier_heatmap
( input_size: int, ignore_edge_size: int, eps: float, arch: nn.Module, dataset: torchvision.datasets.VisionDataset, batch_size: int, device: torch.device, topk: Tuple[int, ...] = (1,), savedir: Optional[pathlib.Path] = None, )
Evaluate Fourier Heat Map about given architecture and dataset. Args: input_size (int): A size of input image. ignore_edge_size (int): A size of the edge to ignore. eps (float): L2 norm size of Fourier basis. arch (nn.Module): An architecture to be evaluated. dataset (torchv...
Evaluate Fourier Heat Map about given architecture and dataset.
def eval_fourier_heatmap( input_size: int, ignore_edge_size: int, eps: float, arch: nn.Module, dataset: torchvision.datasets.VisionDataset, batch_size: int, device: torch.device, topk: Tuple[int, ...] = (1,), savedir: Optional[pathlib.Path] = None, ) -> List[torch.Tensor]: """Eva...
[ "def", "eval_fourier_heatmap", "(", "input_size", ":", "int", ",", "ignore_edge_size", ":", "int", ",", "eps", ":", "float", ",", "arch", ":", "nn", ".", "Module", ",", "dataset", ":", "torchvision", ".", "datasets", ".", "VisionDataset", ",", "batch_size", ...
[ 94, 0 ]
[ 185, 27 ]
python
en
['en', 'en', 'en']
True
HashRing.__init__
(self, nodes=None, weights=None)
`nodes` is a list of objects that have a proper __str__ representation. `weights` is dictionary that sets weights to the nodes. The default weight is that all nodes are equal.
`nodes` is a list of objects that have a proper __str__ representation. `weights` is dictionary that sets weights to the nodes. The default weight is that all nodes are equal.
def __init__(self, nodes=None, weights=None): """`nodes` is a list of objects that have a proper __str__ representation. `weights` is dictionary that sets weights to the nodes. The default weight is that all nodes are equal. """ self.ring = dict() self._sorted_keys = [] ...
[ "def", "__init__", "(", "self", ",", "nodes", "=", "None", ",", "weights", "=", "None", ")", ":", "self", ".", "ring", "=", "dict", "(", ")", "self", ".", "_sorted_keys", "=", "[", "]", "self", ".", "nodes", "=", "nodes", "if", "not", "weights", ...
[ 13, 4 ]
[ 27, 31 ]
python
en
['en', 'en', 'en']
True
HashRing._generate_circle
(self)
Generates the circle.
Generates the circle.
def _generate_circle(self): """Generates the circle. """ total_weight = 0 for node in self.nodes: total_weight += self.weights.get(node, 1) for node in self.nodes: weight = 1 if node in self.weights: weight = self.weights.get(...
[ "def", "_generate_circle", "(", "self", ")", ":", "total_weight", "=", "0", "for", "node", "in", "self", ".", "nodes", ":", "total_weight", "+=", "self", ".", "weights", ".", "get", "(", "node", ",", "1", ")", "for", "node", "in", "self", ".", "nodes...
[ 29, 4 ]
[ 52, 32 ]
python
en
['en', 'ms', 'en']
True
HashRing.get_node
(self, string_key)
Given a string key a corresponding node in the hash ring is returned. If the hash ring is empty, `None` is returned.
Given a string key a corresponding node in the hash ring is returned.
def get_node(self, string_key): """Given a string key a corresponding node in the hash ring is returned. If the hash ring is empty, `None` is returned. """ pos = self.get_node_pos(string_key) if pos is None: return None return self.ring[self._sorted_keys[pos]...
[ "def", "get_node", "(", "self", ",", "string_key", ")", ":", "pos", "=", "self", ".", "get_node_pos", "(", "string_key", ")", "if", "pos", "is", "None", ":", "return", "None", "return", "self", ".", "ring", "[", "self", ".", "_sorted_keys", "[", "pos",...
[ 54, 4 ]
[ 62, 48 ]
python
en
['en', 'en', 'en']
True
HashRing.get_node_pos
(self, string_key)
Given a string key a corresponding node in the hash ring is returned along with it's position in the ring. If the hash ring is empty, (`None`, `None`) is returned.
Given a string key a corresponding node in the hash ring is returned along with it's position in the ring.
def get_node_pos(self, string_key): """Given a string key a corresponding node in the hash ring is returned along with it's position in the ring. If the hash ring is empty, (`None`, `None`) is returned. """ if not self.ring: return None key = self.gen_key(st...
[ "def", "get_node_pos", "(", "self", ",", "string_key", ")", ":", "if", "not", "self", ".", "ring", ":", "return", "None", "key", "=", "self", ".", "gen_key", "(", "string_key", ")", "nodes", "=", "self", ".", "_sorted_keys", "pos", "=", "bisect", "(", ...
[ 64, 4 ]
[ 81, 22 ]
python
en
['en', 'en', 'en']
True
HashRing.iterate_nodes
(self, string_key, distinct=True)
Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, then the nodes returned will be unique, i.e. no virtual copies will be returned.
Given a string key it returns the nodes as a generator that can hold the key.
def iterate_nodes(self, string_key, distinct=True): """Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, then the nodes returned will be unique, ...
[ "def", "iterate_nodes", "(", "self", ",", "string_key", ",", "distinct", "=", "True", ")", ":", "if", "not", "self", ".", "ring", ":", "yield", "None", ",", "None", "returned_values", "=", "set", "(", ")", "def", "distinct_filter", "(", "value", ")", "...
[ 83, 4 ]
[ 112, 29 ]
python
en
['en', 'en', 'en']
True
HashRing.gen_key
(self, key)
Given a string key it returns a long value, this long value represents a place on the hash ring. md5 is currently used because it mixes well.
Given a string key it returns a long value, this long value represents a place on the hash ring.
def gen_key(self, key): """Given a string key it returns a long value, this long value represents a place on the hash ring. md5 is currently used because it mixes well. """ b_key = self._hash_digest(key) return self._hash_val(b_key, lambda x: x)
[ "def", "gen_key", "(", "self", ",", "key", ")", ":", "b_key", "=", "self", ".", "_hash_digest", "(", "key", ")", "return", "self", ".", "_hash_val", "(", "b_key", ",", "lambda", "x", ":", "x", ")" ]
[ 114, 4 ]
[ 121, 49 ]
python
en
['en', 'en', 'en']
True
flatten_union
(table)
Extract all union queries from `table`. Parameters ---------- table : TableExpr Returns ------- Iterable[Union[TableExpr, bool]]
Extract all union queries from `table`.
def flatten_union(table): """Extract all union queries from `table`. Parameters ---------- table : TableExpr Returns ------- Iterable[Union[TableExpr, bool]] """ op = table.op() if isinstance(op, ops.Union): return toolz.concatv( flatten_union(op.left), [op....
[ "def", "flatten_union", "(", "table", ")", ":", "op", "=", "table", ".", "op", "(", ")", "if", "isinstance", "(", "op", ",", "ops", ".", "Union", ")", ":", "return", "toolz", ".", "concatv", "(", "flatten_union", "(", "op", ".", "left", ")", ",", ...
[ 981, 0 ]
[ 997, 18 ]
python
en
['en', 'en', 'en']
True
QueryContext.collapse
(self, queries)
Turn a sequence of queries into something executable. Parameters ---------- queries : List[str] Returns ------- query : str
Turn a sequence of queries into something executable.
def collapse(self, queries): """Turn a sequence of queries into something executable. Parameters ---------- queries : List[str] Returns ------- query : str """ return '\n\n'.join(queries)
[ "def", "collapse", "(", "self", ",", "queries", ")", ":", "return", "'\\n\\n'", ".", "join", "(", "queries", ")" ]
[ 1094, 4 ]
[ 1105, 35 ]
python
en
['en', 'en', 'en']
True
QueryContext.get_ref
(self, expr)
Get the alias being used throughout a query to refer to a particular table or inline view
Get the alias being used throughout a query to refer to a particular table or inline view
def get_ref(self, expr): """ Get the alias being used throughout a query to refer to a particular table or inline view """ return self._get_table_item('_table_refs', expr)
[ "def", "get_ref", "(", "self", ",", "expr", ")", ":", "return", "self", ".", "_get_table_item", "(", "'_table_refs'", ",", "expr", ")" ]
[ 1167, 4 ]
[ 1172, 56 ]
python
en
['en', 'error', 'th']
False
ExprTranslator.get_result
(self)
Build compiled SQL expression from the bottom up and return as a string
Build compiled SQL expression from the bottom up and return as a string
def get_result(self): """ Build compiled SQL expression from the bottom up and return as a string """ translated = self.translate(self.expr) if self._needs_name(self.expr): # TODO: this could fail in various ways name = self.expr.get_name() tra...
[ "def", "get_result", "(", "self", ")", ":", "translated", "=", "self", ".", "translate", "(", "self", ".", "expr", ")", "if", "self", ".", "_needs_name", "(", "self", ".", "expr", ")", ":", "# TODO: this could fail in various ways", "name", "=", "self", "....
[ 1258, 4 ]
[ 1267, 25 ]
python
en
['en', 'error', 'th']
False
Select.compile
(self)
This method isn't yet idempotent; calling multiple times may yield unexpected results
This method isn't yet idempotent; calling multiple times may yield unexpected results
def compile(self): """ This method isn't yet idempotent; calling multiple times may yield unexpected results """ # Can't tell if this is a hack or not. Revisit later self.context.set_query(self) # If any subqueries, translate them and add to beginning of query as...
[ "def", "compile", "(", "self", ")", ":", "# Can't tell if this is a hack or not. Revisit later", "self", ".", "context", ".", "set_query", "(", "self", ")", "# If any subqueries, translate them and add to beginning of query as", "# part of the WITH section", "with_frag", "=", "...
[ 1534, 4 ]
[ 1577, 20 ]
python
en
['en', 'error', 'th']
False
test_insert_distributed_async_send_different_header
(batch)
Check INSERT Into Distributed() with different headers in *.bin If batching will not distinguish headers underlying table will never receive the data.
Check INSERT Into Distributed() with different headers in *.bin If batching will not distinguish headers underlying table will never receive the data.
def test_insert_distributed_async_send_different_header(batch): """ Check INSERT Into Distributed() with different headers in *.bin If batching will not distinguish headers underlying table will never receive the data. """ drop_tables() create_tables('insert_distributed_async_send_cluster_two_s...
[ "def", "test_insert_distributed_async_send_different_header", "(", "batch", ")", ":", "drop_tables", "(", ")", "create_tables", "(", "'insert_distributed_async_send_cluster_two_shards'", ")", "node", "=", "get_node", "(", "batch", ")", "node", ".", "query", "(", "\"INSE...
[ 193, 0 ]
[ 243, 57 ]
python
en
['en', 'error', 'th']
False
DeploymentManager.get_stack_name
(self, template_name)
Ensures our stack names are deterministic
Ensures our stack names are deterministic
def get_stack_name(self, template_name): """Ensures our stack names are deterministic""" return '{}-{}'.format(self.deployment_name, template_name)
[ "def", "get_stack_name", "(", "self", ",", "template_name", ")", ":", "return", "'{}-{}'", ".", "format", "(", "self", ".", "deployment_name", ",", "template_name", ")" ]
[ 32, 4 ]
[ 34, 66 ]
python
en
['en', 'en', 'en']
True
DeploymentManager.get_stack_status
(self, stack_name)
Queries boto3 api for the stack status
Queries boto3 api for the stack status
def get_stack_status(self, stack_name): """Queries boto3 api for the stack status """ stacks = self.client.list_stacks()['StackSummaries'] for stack in stacks: if stack['StackName'].lower() == stack_name.lower(): return stack return None
[ "def", "get_stack_status", "(", "self", ",", "stack_name", ")", ":", "stacks", "=", "self", ".", "client", ".", "list_stacks", "(", ")", "[", "'StackSummaries'", "]", "for", "stack", "in", "stacks", ":", "if", "stack", "[", "'StackName'", "]", ".", "lowe...
[ 36, 4 ]
[ 42, 19 ]
python
en
['en', 'en', 'en']
True
DeploymentManager.wait_for_stack_status
(self, stack_name, timeout=STACK_WAIT_TIMEOUT, poll_interval=10, allowed_final_statuses=['CREATE_COMPLETE'], allowed_wait_statuses=['CREATE_IN_PROGRESS'])
Waits for a stack to reach one of states in @allowed_final_status
Waits for a stack to reach one of states in
def wait_for_stack_status(self, stack_name, timeout=STACK_WAIT_TIMEOUT, poll_interval=10, allowed_final_statuses=['CREATE_COMPLETE'], allowed_wait_statuses=['CREATE_IN_PROGRESS']): """Waits for a stack to reach one of stat...
[ "def", "wait_for_stack_status", "(", "self", ",", "stack_name", ",", "timeout", "=", "STACK_WAIT_TIMEOUT", ",", "poll_interval", "=", "10", ",", "allowed_final_statuses", "=", "[", "'CREATE_COMPLETE'", "]", ",", "allowed_wait_statuses", "=", "[", "'CREATE_IN_PROGRESS'...
[ 44, 4 ]
[ 67, 82 ]
python
en
['en', 'en', 'en']
True
DeploymentManager.get_stack_parameters
(self, template_name)
Builds the inputs we need to deploy a stack in this deployment
Builds the inputs we need to deploy a stack in this deployment
def get_stack_parameters(self, template_name): """Builds the inputs we need to deploy a stack in this deployment""" template_parameters = json.loads(self.read_template(template_name))['Parameters'] stack_parameters = [] for k in template_parameters.keys(): # assign variables...
[ "def", "get_stack_parameters", "(", "self", ",", "template_name", ")", ":", "template_parameters", "=", "json", ".", "loads", "(", "self", ".", "read_template", "(", "template_name", ")", ")", "[", "'Parameters'", "]", "stack_parameters", "=", "[", "]", "for",...
[ 69, 4 ]
[ 79, 31 ]
python
en
['en', 'en', 'en']
True
DeploymentManager.read_template
(self, template_name)
Reads a CFT template from a file. Return whole template as string
Reads a CFT template from a file. Return whole template as string
def read_template(self, template_name): """ Reads a CFT template from a file. Return whole template as string """ with open(TEMPLATES_DIR + '/' + template_name + ".template") as template_fp: return template_fp.read()
[ "def", "read_template", "(", "self", ",", "template_name", ")", ":", "with", "open", "(", "TEMPLATES_DIR", "+", "'/'", "+", "template_name", "+", "\".template\"", ")", "as", "template_fp", ":", "return", "template_fp", ".", "read", "(", ")" ]
[ 81, 4 ]
[ 87, 37 ]
python
en
['en', 'error', 'th']
False
DeploymentManager.create_or_update_stack
(self, template_name)
Deploys a stack from a given template. Does not update CF stacks if the template has changed.
Deploys a stack from a given template. Does not update CF stacks if the template has changed.
def create_or_update_stack(self, template_name): """ Deploys a stack from a given template. Does not update CF stacks if the template has changed. """ stack_name = self.get_stack_name(template_name) stack_parameters = self.get_stack_parameters(template_name) ...
[ "def", "create_or_update_stack", "(", "self", ",", "template_name", ")", ":", "stack_name", "=", "self", ".", "get_stack_name", "(", "template_name", ")", "stack_parameters", "=", "self", ".", "get_stack_parameters", "(", "template_name", ")", "template_body", "=", ...
[ 89, 4 ]
[ 121, 20 ]
python
en
['en', 'error', 'th']
False
DeploymentManager.add_vars_to_namespace
(self, to_add)
Adds variables provided within the function arguments to the namespace for this deployment. Use to keep track of all variables for a deployment.
Adds variables provided within the function arguments to the namespace for this deployment. Use to keep track of all variables for a deployment.
def add_vars_to_namespace(self, to_add): """ Adds variables provided within the function arguments to the namespace for this deployment. Use to keep track of all variables for a deployment. """ for k, v in to_add.iteritems(): if v: ...
[ "def", "add_vars_to_namespace", "(", "self", ",", "to_add", ")", ":", "for", "k", ",", "v", "in", "to_add", ".", "iteritems", "(", ")", ":", "if", "v", ":", "self", ".", "namespace", "[", "k", "]", "=", "v" ]
[ 127, 4 ]
[ 135, 37 ]
python
en
['en', 'error', 'th']
False
DeploymentManager.add_outputs_to_namespace
(self, stack)
Adds outputs of a stack to the namespace for this deployment. Use to keep track of all variables for a deployment.
Adds outputs of a stack to the namespace for this deployment. Use to keep track of all variables for a deployment.
def add_outputs_to_namespace(self, stack): """ Adds outputs of a stack to the namespace for this deployment. Use to keep track of all variables for a deployment. """ if 'Outputs' in stack: for item in stack['Outputs']: self.namespac...
[ "def", "add_outputs_to_namespace", "(", "self", ",", "stack", ")", ":", "if", "'Outputs'", "in", "stack", ":", "for", "item", "in", "stack", "[", "'Outputs'", "]", ":", "self", ".", "namespace", "[", "item", "[", "'OutputKey'", "]", "]", "=", "item", "...
[ 137, 4 ]
[ 145, 71 ]
python
en
['en', 'error', 'th']
False
privileges_granted_directly
(self, node=None)
Check that a user is able to execute `SHOW USERS` with privileges are granted directly.
Check that a user is able to execute `SHOW USERS` with privileges are granted directly.
def privileges_granted_directly(self, node=None): """Check that a user is able to execute `SHOW USERS` with privileges are granted directly. """ user_name = f"user_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"): Suite(run=check_privilege, ...
[ "def", "privileges_granted_directly", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with", "user", "(", "node", ",", "f\"{user_...
[ 8, 0 ]
[ 22, 74 ]
python
en
['en', 'en', 'en']
True
privileges_granted_via_role
(self, node=None)
Check that a user is able to execute `SHOW USERS` with privileges are granted through a role.
Check that a user is able to execute `SHOW USERS` with privileges are granted through a role.
def privileges_granted_via_role(self, node=None): """Check that a user is able to execute `SHOW USERS` with privileges are granted through a role. """ user_name = f"user_{getuid()}" role_name = f"role_{getuid()}" if node is None: node = self.context.node with user(node, f"{user_name}"...
[ "def", "privileges_granted_via_role", "(", "self", ",", "node", "=", "None", ")", ":", "user_name", "=", "f\"user_{getuid()}\"", "role_name", "=", "f\"role_{getuid()}\"", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "with"...
[ 25, 0 ]
[ 43, 74 ]
python
en
['en', 'en', 'en']
True
check_privilege
(self, privilege, grant_target_name, user_name, node=None)
Run checks for commands that require SHOW USERS privilege.
Run checks for commands that require SHOW USERS privilege.
def check_privilege(self, privilege, grant_target_name, user_name, node=None): """Run checks for commands that require SHOW USERS privilege. """ if node is None: node = self.context.node Suite(test=show_users)(privilege=privilege, grant_target_name=grant_target_name, user_name=user_name) S...
[ "def", "check_privilege", "(", "self", ",", "privilege", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "if", "node", "is", "None", ":", "node", "=", "self", ".", "context", ".", "node", "Suite", "(", "test", "=", "show...
[ 53, 0 ]
[ 61, 106 ]
python
en
['en', 'en', 'en']
True
show_users
(self, privilege, grant_target_name, user_name, node=None)
Check that user is only able to execute `SHOW USERS` when they have the necessary privilege.
Check that user is only able to execute `SHOW USERS` when they have the necessary privilege.
def show_users(self, privilege, grant_target_name, user_name, node=None): """Check that user is only able to execute `SHOW USERS` when they have the necessary privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.context.node with Scen...
[ "def", "show_users", "(", "self", ",", "privilege", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ")", "if", "node", "...
[ 67, 0 ]
[ 105, 51 ]
python
en
['en', 'en', 'en']
True
show_create
(self, privilege, grant_target_name, user_name, node=None)
Check that user is only able to execute `SHOW CREATE USER` when they have the necessary privilege.
Check that user is only able to execute `SHOW CREATE USER` when they have the necessary privilege.
def show_create(self, privilege, grant_target_name, user_name, node=None): """Check that user is only able to execute `SHOW CREATE USER` when they have the necessary privilege. """ exitcode, message = errors.not_enough_privileges(name=user_name) if node is None: node = self.context.node wi...
[ "def", "show_create", "(", "self", ",", "privilege", ",", "grant_target_name", ",", "user_name", ",", "node", "=", "None", ")", ":", "exitcode", ",", "message", "=", "errors", ".", "not_enough_privileges", "(", "name", "=", "user_name", ")", "if", "node", ...
[ 111, 0 ]
[ 158, 55 ]
python
en
['en', 'en', 'en']
True
feature
(self, node="clickhouse1")
Check the RBAC functionality of SHOW USERS.
Check the RBAC functionality of SHOW USERS.
def feature(self, node="clickhouse1"): """Check the RBAC functionality of SHOW USERS. """ self.context.node = self.context.cluster.node(node) Suite(run=privileges_granted_directly, setup=instrument_clickhouse_server_log) Suite(run=privileges_granted_via_role, setup=instrument_clickhouse_server_log)
[ "def", "feature", "(", "self", ",", "node", "=", "\"clickhouse1\"", ")", ":", "self", ".", "context", ".", "node", "=", "self", ".", "context", ".", "cluster", ".", "node", "(", "node", ")", "Suite", "(", "run", "=", "privileges_granted_directly", ",", ...
[ 167, 0 ]
[ 173, 82 ]
python
en
['en', 'en', 'en']
True