Best Python code snippet using pandera_python
functions.py
Source: functions.py
...169 largest=True,170 short=True,171 )172 )173def pretty_param(param, value=None):174 if isinstance(param, str):175 return unit_of.get(param.split(".")[0], "{}").format(value)176 elif isinstance(param, dict):177 return [178 f"{param_}: {pretty_param(param_, value_)}"179 for param_, value_ in param.items()180 ]181 else:182 print(f"{NAME}.pretty_param({param.__class__.__name__}), class not found.")183def pretty_shape(shape):184 """describe shape as a string.185 Args:186 shape (List[int]): shape.187 Returns:188 str: shape as string.189 """190 return "x".join([str(value) for value in list(shape)])191def pretty_shape_of_matrix(matrix):192 """describe size of matrix as a string.193 Args:194 matrix (Any): matrix.195 Returns:196 str: size of matrix....
elasticsearch.py
Source: elasticsearch.py
...19 not create new cluster!")20@require_basic_auth21class ElasticsearchClusterInitHandler(ElasticSearchBaseHandler):22 def post(self):23 param = self.pretty_param()24 cluster_name = param['clusterName']25 self.check_cluster(cluster_name)26 self.elastic_op.init_cluster(param)27 self.finish({"message": "creating cluster successful!"})28@require_basic_auth29class ElasticsearchNodeInitHandler(ElasticSearchBaseHandler):30 def post(self):31 param = self.pretty_param()32 self.elastic_op.init_node(param)33 self.finish({"message": "creating cluster successful!"})34@require_basic_auth35class ElasticsearchNodeSyncHandler(ElasticSearchBaseHandler):36 def post(self):37 param = self.pretty_param()38 zk_op = self.get_zkoper()39 if zk_op.cluster_exists(param['clusterName']):40 self.elastic_op.sync_node(param['clusterName'])41 self.finish({"message": "sync cluster info successful!"})42@require_basic_auth43class ElasticsearchConfigHandler(ElasticSearchBaseHandler):44 """45 function: start node46 url example: curl --user root:root -d "" "http://localhost:9999/elasticsearch/config"47 """48 def post(self):49 param = self.pretty_param()50 es_heap_size = int(param.get('es_heap_size', ES_HEAP_SIZE))51 if es_heap_size < ES_HEAP_SIZE:52 self.set_status(500)53 self.finish({"message": "para not valid!"})54 return55 self.elastic_op.config()56 self.elastic_op.sys_config(57 es_heap_size='%dg' % (es_heap_size / ES_HEAP_SIZE))58 self.finish({"message": "config cluster successful!"})59@require_basic_auth60class Elasticsearch_Start_Handler(ElasticSearchBaseHandler):61 def post(self):62 """63 function: start node...
visualizations.py
Source: visualizations.py
1from typing import List, Tuple2import matplotlib.pyplot as plt3import numpy as np4import pandas as pd5import seaborn as sns6def plot_metric_score_variation(7 data: pd.DataFrame, param: str, colors: list,8 xytext_locs: List[Tuple[int, int]], scale_y_axis: bool = True9) -> None:10 pretty_param = param.split('__')[1]11 titles = [12 'F-Score', 'G-Mean', 'Precision',13 'Recall', 'ROC AUC', 'Specificity']14 # get list of metrics to plot15 metrics_to_plot = [16 col.replace('mean_test_', '')17 for col in data.columns18 if col.startswith('mean_test_')]19 # plot metric score variation in relation with a param change by experiment20 fig = plt.figure(figsize=[10, 13])21 plt.suptitle(f'Variación de "{pretty_param}"', fontsize=14)22 plot_params = {'data': data, 'x': param}23 for index, metric in enumerate(metrics_to_plot):24 test_metric = f'mean_test_{metric}'25 train_metric = f'mean_train_{metric}'26 plt.subplot(3, 2, index+1)27 sns.lineplot(28 **plot_params,29 y=test_metric,30 label=f'test',31 color=colors[0])32 ax = sns.lineplot(33 **plot_params,34 y=train_metric,35 label=f'train',36 color=colors[1])37 set_lineplot_annotation(ax, colors, xytext_locs)38 plt.legend().remove()39 plt.title(titles[index], fontsize=14)40 plt.xlabel(pretty_param)41 plt.ylabel('puntuación')42 plt.ylim([0, 1]) if scale_y_axis else None43 handles, labels = ax.get_legend_handles_labels()44 fig.legend( # title='Legenda'45 handles, labels, loc='upper center',46 bbox_to_anchor=(0.5, 0.965),47 ncol=2, fancybox=True, shadow=False,48 facecolor='white', edgecolor='grey')49 plt.tight_layout()50def set_lineplot_annotation(ax, colors: list, xytext_locs: List[Tuple[int, int]] = None) -> None:51 tex_locs = ['top', 'bottom']52 xytext_locs = xytext_locs or [(0, 0), (0, 0)]53 annotate_params = {54 'xytext': (0, 0),55 'textcoords': "offset points",56 'ha': 'center',57 'weight': 'bold',58 'bbox': {59 'boxstyle': 'round,pad=0.3',60 'fc': 'white',61 'alpha': 0.5}}62 for i, line in enumerate(ax.lines):63 annotate_params.update(64 {'xytext': xytext_locs[i], 'va': tex_locs[i], 'color': colors[i]})65 y_max = np.max(line.get_ydata())66 max_index = np.where(line.get_ydata() == y_max)[0][0]67 x_max = line.get_xdata()[max_index]68 ax.annotate(69 '{:.2f}%'.format(y_max*100),70 (x_max, y_max),71 **annotate_params)72 y_min = np.min(line.get_ydata())73 min_index = np.where(line.get_ydata() == y_min)[0][0]74 x_min = line.get_xdata()[min_index]75 ax.annotate(76 '{:.2f}%'.format(y_min*100),77 (x_min, y_min),...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!