How to use test_long_name method in avocado

Best Python code snippet using avocado_python

StatTest.py

Source:StatTest.py Github

copy

Full Screen

1from typing import Callable2from scipy import stats3from statannotations.stats.StatResult import StatResult4# Also example for how to add other functions5def wilcoxon(group_data1, group_data2, verbose=1, **stats_params):6 """7 This function provides the equivalent behavior from earlier versions of8 statannot/statannotations.9 """10 zero_method = stats_params.pop('zero_method', None)11 if zero_method is None:12 return stats.wilcoxon(group_data1, group_data2, **stats_params)13 if zero_method == "AUTO":14 zero_method = len(group_data1) <= 20 and "pratt" or "wilcox"15 if verbose >= 1:16 print("Using zero_method ", zero_method)17 return stats.wilcoxon(group_data1, group_data2,18 zero_method=zero_method, **stats_params)19class StatTest:20 @staticmethod21 def from_library(test_name: str) -> 'StatTest':22 test = STATTEST_LIBRARY.get(test_name)23 if test is None:24 raise NotImplementedError(f"Test named {test_name} is not "25 f"implemented, or wrongly spelled")26 return test27 def __init__(self, func: Callable, test_long_name: str,28 test_short_name: str, stat_name: str = "Stat",29 alpha: float = 0.05, *args, **kwargs):30 """31 Wrapper for any statistical function to use with statannotations.32 The function must be callable with two 1D collections of data points as33 first and second arguments, can have any number of additional arguments34 , and must at least return, in order,35 a) a statistical value, and36 b) a pvalue.37 :param func:38 Function to be called39 :param test_long_name:40 Description to be used in results logging41 :param test_short_name:42 Text to be used on graph annotation to describe the test43 :param stat_name:44 Name of the statistic in results logging (t, W, F, etc)45 :param args46 Positional arguments to provide `func` at each call47 :param kwargs:48 Keyword arguments to provide `func` at each call49 """50 self._func = func51 self._test_long_name = test_long_name52 self._test_short_name = test_short_name53 self._stat_name = stat_name54 self._alpha = alpha55 self. args = args56 self.kwargs = kwargs57 self.__doc__ = (58 f"Wrapper for the function "59 f"'{func.__name__}', providing the attributes\n"60 f" `test_long_name`: {test_long_name}\n"61 f" `test_short_name`: {test_short_name} \n"62 f"------ Original function documentation ------ \n"63 f"{func.__doc__}")64 def __call__(self, group_data1, group_data2, alpha=0.05,65 **stat_params):66 stat, pval = self._func(group_data1, group_data2, *self.args,67 **{**self.kwargs, **stat_params})[:2]68 return StatResult(self._test_long_name, self._test_short_name,69 self._stat_name, stat, pval, alpha=alpha)70 @property71 def short_name(self):72 return self._test_short_name73STATTEST_LIBRARY = {74 'Levene': StatTest(stats.levene,75 'Levene test of variance', 'levene'),76 'Mann-Whitney': StatTest(stats.mannwhitneyu,77 'Mann-Whitney-Wilcoxon test two-sided',78 'M.W.W.', 'U_stat', alternative='two-sided'),79 'Mann-Whitney-gt': StatTest(stats.mannwhitneyu,80 'Mann-Whitney-Wilcoxon test greater',81 'M.W.W.', 'U_stat', alternative='greater'),82 'Mann-Whitney-ls': StatTest(stats.mannwhitneyu,83 'Mann-Whitney-Wilcoxon test smaller',84 'M.W.W.', 'U_stat', alternative='less'),85 't-test_ind': StatTest(stats.ttest_ind,86 't-test independent samples',87 't-test_ind', 't'),88 't-test_welch': StatTest(stats.ttest_ind,89 'Welch\'s t-test independent samples',90 't-test_welch', 't', equal_var=False),91 't-test_paired': StatTest(stats.ttest_rel,92 't-test paired samples', 't-test_rel', 't'),93 'Wilcoxon': StatTest(stats.wilcoxon,94 'Wilcoxon test (paired samples)', 'Wilcoxon'),95 'Wilcoxon-legacy': StatTest(wilcoxon,96 'Wilcoxon test (paired samples)', 'Wilcoxon'),97 'Kruskal': StatTest(stats.kruskal,98 'Kruskal-Wallis paired samples', 'Kruskal')...

Full Screen

Full Screen

test_path_operators.py

Source:test_path_operators.py Github

copy

Full Screen

1from pathlib import Path2from poif.tests import get_temp_path3from poif.utils import files_by_extension, get_extension_from_path, get_file_name_from_path, is_more_populated4def test_get_extension():5 f1 = Path("/test/dataset/file.jpg")6 f2 = Path("/hello/home/test_long_name.png")7 assert get_extension_from_path(f1) == "jpg"8 assert get_extension_from_path(f2) == "png"9def test_get_filename():10 f1 = Path("/test/dataset/file.jpg")11 f2 = Path("/hello/home/test_long_name.png")12 assert get_file_name_from_path(f1) == "file"13 assert get_file_name_from_path(f2) == "test_long_name"14def test_extension_bins():15 temp_path = get_temp_path(prefix="test_extension_bins")16 jpg_files = [f"{i}.jpg" for i in range(10)]17 png_files = [f"{i}.png" for i in range(10)]18 exif_files = [f"{i}.exif" for i in range(10)]19 all_files = jpg_files + png_files + exif_files20 for file in all_files:21 (temp_path / file).touch()22 extension_bins = files_by_extension(temp_path)23 assert len(extension_bins["jpg"]) == 1024 assert len(extension_bins["png"]) == 1025 assert len(extension_bins["exif"]) == 1026 assert set(extension_bins["jpg"]) == {temp_path / jpg_file for jpg_file in jpg_files}27 extension_bins = files_by_extension(temp_path, limit=20)28 assert len(extension_bins["jpg"]) == 1029 assert len(extension_bins["png"]) == 1030 assert len(extension_bins["exif"]) == 1031 limit = 232 extension_bins = files_by_extension(temp_path, limit=limit)33 assert len(extension_bins["jpg"]) == limit34 assert len(extension_bins["png"]) == limit35 assert len(extension_bins["exif"]) == limit36def test_is_more_populated():37 temp_path = get_temp_path(prefix="test_is_more_populated")38 jpg_files = [f"{i}.jpg" for i in range(10)]39 for file in jpg_files:40 (temp_path / file).touch()41 assert not is_more_populated(temp_path, 11)42 assert not is_more_populated(temp_path, 10)...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful