How to use iter_variations method in Slash

Best Python code snippet using slash

config.py

Source:config.py Github

copy

Full Screen

...155 raise ValueError("Path: {} doesn't exist".format(str(path)))156 with open(str(path), 'rb') as f:157 cfg = yaml.safe_load(f)158 return Config(cfg)159def iter_variations(cfg, strategy):160 # Make list of ConfigVariation objects in cfg161 variations = []162 for node in cfg.traverse(bredth=True, objects=True):163 if type(node) == ConfigVariation:164 variations.append(node)165 166 stop = False167 while not stop:168 yield cfg169 if len(variations) == 0:170 break171 172 for i, node in enumerate(variations):173 if strategy == 'seq':174 _, rollover = node.next()175 176 elif strategy == 'foreach':177 _, rollover = node.next()178 if not rollover:179 break180 # When the final ConfigVariation rolls over we are done181 if rollover and i == (len(variations) - 1):182 stop = True183 break184def iter_configs(cfg, exp_cfg):185 overlay = exp_cfg['overlay']186 cfg = copy.deepcopy(cfg)187 for v in iter_variations(overlay, exp_cfg['variation_strategy']):188 cfg.apply(v)...

Full Screen

Full Screen

variation_factory.py

Source:variation_factory.py Github

copy

Full Screen

...72 elif isinstance(fixture, Parametrization):73 self._param_name_bindings[name] = fixture74 else:75 raise NotImplementedError() # pragma: no cover76 def iter_variations(self):77 needed_ids = OrderedSet()78 self._needed_fixtures.sort(key=lambda x: x.info.scope, reverse=True)79 for fixture in self._needed_fixtures:80 needed_ids.update(self._store.get_all_needed_fixture_ids(fixture))81 parametrizations = [self._store.get_fixture_by_id(param_id) for param_id in needed_ids]82 if not needed_ids:83 yield Variation(self._store, {}, {})84 return85 for value_indices in itertools.product(*(range(len(p.values)) for p in parametrizations)):86 yield self._build_variation(parametrizations, value_indices)87 def _build_variation(self, parametrizations, value_indices):88 value_index_by_id = {}89 for param, param_index in zip(parametrizations, value_indices):90 value_index_by_id[param.info.id] = param_index...

Full Screen

Full Screen

day21.py

Source:day21.py Github

copy

Full Screen

...3def x_mirror(data):4 return "\n".join("".join(reversed(row)) for row in data.split("\n"))5def rotate_clockwise(data):6 return x_mirror(transpose(data))7def iter_variations(data):8 funcs = [transpose, x_mirror] * 49 for f in funcs:10 yield data11 data = f(data)12def y_combine(groups):13 return "\n".join(groups)14def x_combine(groups):15 return transpose(y_combine(map(transpose, groups)))16def separate(data, chunk_size):17 rows = data.split("\n")18 size = len(rows)19 return [["\n".join("".join(rows[y+j][x+i] for i in range(chunk_size)) for j in range(chunk_size)) for x in range(0, size, chunk_size)] for y in range(0, size, chunk_size)]20def combine(separated_data):21 rows = [x_combine(row) for row in separated_data]22 return y_combine(rows)23d = {}24with open("21_input.txt") as file:25 for line in file:26 l,r = line.strip().replace("/", "\n").split(" => ")27 for x in iter_variations(l):28 d[x] = r29data = """.#.30..#31###"""32size = 333for i in range(18):34 if i == 5: print(data.count("#"))35 if size % 2 == 0:36 blocks = separate(data, 2)37 size = size * 3 // 2 38 else:39 blocks = separate(data, 3)40 size = size * 4 // 341 blocks = [[d[block] for block in row] for row in blocks]...

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