How to use get_deps method in tox

Best Python code snippet using tox_python

dependency_helper.py

Source:dependency_helper.py Github

copy

Full Screen

...12class DependencyHelper(object):13 def __init__(self):14 self._deps = {}1516 def get_deps(self):17 return self._deps1819 def add(self, indep_obj, dep_obj):20 if indep_obj in self._deps:21 # to avoid dependent values duplicates22 if dep_obj not in self.get_deps()[indep_obj]:23 self._deps[indep_obj].append(dep_obj)24 else:25 self._deps[indep_obj] = [dep_obj]2627 def update(self, other):28 if isinstance(other, DependencyHelper):29 result = self.get_deps()30 for other_item in other.get_deps():31 if other_item in result:32 result[other_item].extend(other.get_deps()[other_item])33 result[other_item] = list(OrderedDict.fromkeys(result[other_item]))34 else:35 result[other_item] = other.get_deps()[other_item]36 self._deps = result37 else:38 raise TypeError3940 def remove(self, indep_obj, dep_obj):41 if indep_obj in self.get_deps():42 if dep_obj in self.get_deps()[indep_obj]:43 self._deps[indep_obj].remove(dep_obj)44 if not self._deps[indep_obj]:45 del self._deps[indep_obj]4647 def get_dependent(self, key):48 return self.get_deps().get(key, [])4950 def __get_values_also_keys(self, key):51 values = self.get_deps()[key]52 values_also_keys = [x for x in values if x in self.get_deps().keys()]53 return values_also_keys5455 def has_cycle_dependency(self):56 keys = self.get_deps().keys()57 for key in keys:58 deps = self.get_deps()[key]59 values_also_keys = self.__get_values_also_keys(key)60 while values_also_keys:61 for value_also_key in values_also_keys:62 values_also_keys.extend(self.__get_values_also_keys(value_also_key))63 values_also_keys.remove(value_also_key)64 deps.extend(self.get_deps()[value_also_key])65 if key in deps:66 return True67 return False6869 def copy(self):70 return copy.deepcopy(self)7172 def __eq__(self, other):73 if isinstance(other, DependencyHelper):74 return self.get_deps() == other.get_deps()75 return NotImplemented7677 def __isub__(self, tup_to_remove: tuple):78 self.remove(tup_to_remove[0], tup_to_remove[1])79 return self8081 def __iadd__(self, new_tup: tuple):82 self.add(new_tup[0], new_tup[1])83 return self8485 def __bool__(self):86 return not self.has_cycle_dependency()8788 def __str__(self):89 str_representation = "Dependency helper: \n"90 for key in self.get_deps():91 str_representation += f"{key} : {', '.join([str(elem) for elem in self.get_deps()[key]])}\n"92 return str_representation939495class PriorityHelper(DependencyHelper):96 def enumerate_priorities(self):97 if self.has_cycle_dependency():98 print('Cycle dependency found. Priorities can not be set.')99 return None100101 priors = {}102 for indep_obj in self.get_deps():103 if indep_obj not in priors:104 priors[indep_obj] = 0105 values = self.get_deps()[indep_obj]106 for value in values:107 if value in priors and priors[value] > priors[indep_obj]:108 continue109 else:110 priors[value] = priors[indep_obj] + 1111112 return priors113114115class Instruction(object):116 def __init__(self, name):117 self._name = name118 self._elements = []119 ...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...34 'astro/models': ('constants', 'utils'),35 'astro/utils': (),36 'astro/xspec_extension': ('extension',),37 }38def get_deps(deps):39 deps = set(deps)40 alldeps = set()41 while deps:42 dep = deps.pop()43 if dep not in alldeps:44 alldeps.add(dep)45 deps.update(header_deps[dep])46 return [sherpa_inc[0] + '/sherpa/' + d + '.hh' for d in alldeps]47####48# EXTENSIONS WITH EXTERNAL DEPENDENCIES49####50def build_psf_ext(library_dirs, include_dirs, libraries):51 return Extension('sherpa.utils._psf',52 ['sherpa/utils/src/tcd/tcdCastArray.c',53 'sherpa/utils/src/tcd/tcdError.c',54 'sherpa/utils/src/tcd/tcdFFTConvolve.c',55 'sherpa/utils/src/tcd/tcdInitConvolveOut.c',56 'sherpa/utils/src/tcd/tcdInitTransform.c',57 'sherpa/utils/src/tcd/tcdPadData.c',58 'sherpa/utils/src/tcd/tcdPixelArith.c',59 'sherpa/utils/src/tcd/tcdTransform.c',60 'sherpa/utils/src/_psf.cc'],61 sherpa_inc + ['sherpa/utils/src/tcd'] + include_dirs,62 library_dirs=library_dirs,63 libraries=libraries,64 depends=(get_deps(['extension', 'utils'])+65 ['sherpa/utils/src/tcd/tcd.h',]))66def build_wcs_ext(library_dirs, include_dirs, libraries):67 return Extension('sherpa.astro.utils._wcs',68 ['sherpa/astro/utils/src/_wcs.cc'],69 sherpa_inc + include_dirs,70 library_dirs=library_dirs,71 libraries=libraries,72 depends=get_deps(['extension']))73def build_region_ext(library_dirs, include_dirs, libraries, define_macros=None):74 return Extension('sherpa.astro.utils._region',75 ['sherpa/astro/utils/src/_region.cc'],76 sherpa_inc + include_dirs,77 library_dirs=library_dirs,78 libraries=(libraries),79 define_macros=define_macros,80 depends=get_deps(['extension']))81def build_xspec_ext(library_dirs, include_dirs, libraries, define_macros=None):82 return Extension('sherpa.astro.xspec._xspec',83 ['sherpa/astro/xspec/src/_xspec.cc'],84 sherpa_inc + include_dirs,85 library_dirs=library_dirs,86 runtime_library_dirs=library_dirs,87 libraries=libraries,88 define_macros=define_macros,89 depends=(get_deps(['astro/xspec_extension'])))90def build_lib_arrays(command, libname):91 library_dirs = getattr(command, libname+'_lib_dirs').split(' ')92 include_dirs = getattr(command, libname+'_include_dirs').split(' ')93 libraries = getattr(command, libname+'_libraries').split(' ')94 return [library_dirs, include_dirs, libraries]95def clean(xs):96 "Remove all '' entries from xs, returning the new list."97 return [x for x in xs if x != '']98def build_ext(command, name, *args, **kwargs):99 """Set up the requisites for building an extension.100 Parameters101 ----------102 command103 Normally going to be self104 name105 The name of the extension - there must be a matching106 build_name_ext routine in this module.107 *args108 If there are no related libraries to build then these109 are not set, otherwise the extra names should be given110 here.111 **kwargs112 Passed to the build_name_ext routine. Presently used to113 pass the define_macros argument.114 """115 if len(args) == 0:116 options = [name]117 else:118 options = args119 libdirs = []120 incdirs = []121 libs = []122 for option in options:123 args = build_lib_arrays(command, option)124 libdirs.extend(args[0])125 incdirs.extend(args[1])126 libs.extend(args[2])127 libdirs = clean(libdirs)128 incdirs = clean(incdirs)129 libs = clean(libs)130 builder = globals().get(f'build_{name}_ext')131 return builder(libdirs, incdirs, libs, **kwargs)132###133# Static Extensions134###135estmethods = Extension('sherpa.estmethods._est_funcs',136 ['sherpa/estmethods/src/estutils.cc',137 'sherpa/estmethods/src/info_matrix.cc',138 'sherpa/estmethods/src/projection.cc',139 'sherpa/estmethods/src/estwrappers.cc'],140 (sherpa_inc + ['sherpa/utils/src/gsl']),141 depends=(get_deps(['extension', 'utils']) +142 ['sherpa/estmethods/src/estutils.hh',143 'sherpa/estmethods/src/info_matrix.hh',144 'sherpa/estmethods/src/projection.hh',145 'sherpa/utils/src/gsl/fcmp.h']))146utils = Extension('sherpa.utils._utils',147 ['sherpa/utils/src/cephes/const.c',148 'sherpa/utils/src/cephes/fabs.c',149 'sherpa/utils/src/cephes/isnan.c',150 'sherpa/utils/src/cephes/mtherr.c',151 'sherpa/utils/src/cephes/polevl.c',152 'sherpa/utils/src/cephes/ndtri.c',153 'sherpa/utils/src/cephes/gamma.c',154 'sherpa/utils/src/cephes/igam.c',155 'sherpa/utils/src/cephes/igami.c',156 'sherpa/utils/src/cephes/incbet.c',157 'sherpa/utils/src/cephes/incbi.c',158 'sherpa/utils/src/sjohnson/Faddeeva.cc',159 'sherpa/utils/src/_utils.cc'],160 sherpa_inc + ['sherpa/utils/src/cephes',161 'sherpa/utils/src/gsl',162 'sherpa/utils/src/sjohnson'],163 depends=(get_deps(['extension', 'utils'])+164 ['sherpa/utils/src/gsl/fcmp.h',165 'sherpa/utils/src/cephes/cephes.h',166 'sherpa/utils/src/cephes/mconf.h',167 'sherpa/utils/src/cephes/protos.h',168 'sherpa/utils/src/sjohnson/Faddeeva.hh']))169modelfcts = Extension('sherpa.models._modelfcts',170 ['sherpa/models/src/_modelfcts.cc'],171 sherpa_inc,172 depends=get_deps(['model_extension', 'models']))173saoopt = Extension('sherpa.optmethods._saoopt',174 ['sherpa/optmethods/src/_saoopt.cc',175 'sherpa/optmethods/src/Simplex.cc'],176 sherpa_inc + ['sherpa/utils/src/gsl'],177 depends=(get_deps(['myArray', 'extension']) +178 ['sherpa/include/sherpa/fcmp.hh',179 'sherpa/include/sherpa/MersenneTwister.h',180 'sherpa/include/sherpa/functor.hh',181 'sherpa/optmethods/src/DifEvo.hh',182 'sherpa/optmethods/src/DifEvo.cc',183 'sherpa/optmethods/src/NelderMead.hh',184 'sherpa/optmethods/src/NelderMead.cc',185 'sherpa/optmethods/src/Opt.hh',186 'sherpa/optmethods/src/PyWrapper.hh',187 'sherpa/optmethods/src/RanOpt.hh',188 'sherpa/optmethods/src/Simplex.hh',189 'sherpa/optmethods/src/Simplex.cc',190 'sherpa/optmethods/src/minpack/LevMar.hh',191 'sherpa/optmethods/src/minpack/LevMar.cc',192 'sherpa/optmethods/src/minim.hh']))193tstoptfct = Extension('sherpa.optmethods._tstoptfct',194 ['sherpa/optmethods/tests/_tstoptfct.cc'],195 sherpa_inc,196 depends=(get_deps(['extension']) +197 ['sherpa/include/sherpa/fcmp.hh',198 'sherpa/include/sherpa/MersenneTwister.h',199 'sherpa/include/sherpa/functor.hh',200 'sherpa/optmethods/tests/tstopt.hh',201 'sherpa/optmethods/tests/tstoptfct.hh',202 'sherpa/optmethods/src/DifEvo.hh',203 'sherpa/optmethods/src/DifEvo.cc',204 'sherpa/optmethods/src/NelderMead.hh',205 'sherpa/optmethods/src/NelderMead.cc',206 'sherpa/optmethods/src/Opt.hh',207 'sherpa/optmethods/src/PyWrapper.hh',208 'sherpa/optmethods/src/RanOpt.hh',209 'sherpa/optmethods/src/Simplex.hh',210 'sherpa/optmethods/src/Simplex.cc',211 'sherpa/optmethods/src/minpack/LevMar.hh',212 'sherpa/optmethods/src/minpack/LevMar.cc']))213statfcts = Extension('sherpa.stats._statfcts',214 ['sherpa/stats/src/_statfcts.cc'],215 sherpa_inc,216 depends=get_deps(['stat_extension', 'stats']))217integration = Extension('sherpa.utils.integration',218 ['sherpa/utils/src/gsl/err.c',219 'sherpa/utils/src/gsl/error.c',220 'sherpa/utils/src/gsl/stream.c',221 'sherpa/utils/src/gsl/strerror.c',222 'sherpa/utils/src/gsl/message.c',223 'sherpa/utils/src/gsl/qng.c',224 'sherpa/utils/src/sjohnson/adapt_integrate.c',225 'sherpa/utils/src/integration.cc'],226 sherpa_inc +[ 'sherpa/utils/src',227 'sherpa/utils/src/sjohnson',228 'sherpa/utils/src/gsl'],229 depends=(get_deps(['integration'])+230 ['sherpa/utils/src/sjohnson/adapt_integrate.h',231 'sherpa/utils/src/gsl/gsl_integration.h']))232astro_modelfcts = Extension('sherpa.astro.models._modelfcts',233 ['sherpa/astro/models/src/_modelfcts.cc',234 'sherpa/utils/src/sjohnson/Faddeeva.cc'],235 sherpa_inc + ['sherpa/utils/src/sjohnson'],236 depends=get_deps(['model_extension', 'astro/models']) + \237 ['sherpa/utils/src/sjohnson/Faddeeva.hh'])238pileup = Extension('sherpa.astro.utils._pileup',239 ['sherpa/astro/utils/src/fftn.c',240 'sherpa/astro/utils/src/_pileup.cc',241 'sherpa/astro/utils/src/pileup.cc'],242 sherpa_inc + ['sherpa/astro/utils/src'],243 depends=(get_deps(['extension']) +244 ['sherpa/astro/utils/src/pileup.hh',245 'sherpa/astro/utils/src/PyWrapper.hh',246 'sherpa/astro/utils/src/fftn.inc']))247astro_utils = Extension('sherpa.astro.utils._utils',248 ['sherpa/astro/utils/src/_utils.cc'],249 (sherpa_inc + ['sherpa/utils/src/gsl']),250 depends=(get_deps(['extension', 'utils', 'astro/utils'])+251 ['sherpa/utils/src/gsl/fcmp.h']))252static_ext_modules = [253 estmethods,254 utils,255 modelfcts,256 saoopt,257 tstoptfct,258 statfcts,259 integration,260 astro_modelfcts,261 pileup,262 astro_utils,...

Full Screen

Full Screen

parallel_test.py

Source:parallel_test.py Github

copy

Full Screen

...15 db: [data_volume],16 data_volume: [],17 cache: [],18}19def get_deps(obj):20 return [(dep, None) for dep in deps[obj]]21def test_parallel_execute():22 results, errors = parallel_execute(23 objects=[1, 2, 3, 4, 5],24 func=lambda x: x * 2,25 get_name=six.text_type,26 msg="Doubling",27 )28 assert sorted(results) == [2, 4, 6, 8, 10]29 assert errors == {}30def test_parallel_execute_with_deps():31 log = []32 def process(x):33 log.append(x)...

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 tox 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