How to use _traverse_upwards method in Slash

Best Python code snippet using slash

_hdbscan_tree.py

Source:_hdbscan_tree.py Github

copy

Full Screen

...73 while to_process.shape[0] > 0:74 result.extend(to_process.tolist())75 to_process = tree['child'][np.in1d(tree['parent'], to_process)]76 return result77def _traverse_upwards(78 cluster_tree: np.ndarray,79 cluster_selection_epsilon: np.float_,80 leaf: np.int_,81 allow_single_cluster: np.int_82) -> np.int_:83 root = cluster_tree['parent'].min()84 parent = cluster_tree[cluster_tree['child'] == leaf]['parent'][0]85 if parent == root:86 if allow_single_cluster:87 return parent88 else:89 return leaf # return node closest to root90 parent_eps = 1 / cluster_tree[cluster_tree['child'] == parent]['lambda_val']91 if parent_eps > cluster_selection_epsilon:92 return parent93 else:94 return _traverse_upwards(cluster_tree, cluster_selection_epsilon, parent, allow_single_cluster)95def _epsilon_search(96 leaves: set,97 cluster_tree: np.ndarray,98 cluster_selection_epsilon: np.float_,99 allow_single_cluster: np.int_100):101 selected_clusters = list()102 processed = list()103 for leaf in leaves:104 eps = 1 / cluster_tree['lambda_val'][cluster_tree['child'] == leaf][0]105 if eps < cluster_selection_epsilon:106 if leaf not in processed:107 epsilon_child = _traverse_upwards(cluster_tree, cluster_selection_epsilon, leaf, allow_single_cluster)108 selected_clusters.append(epsilon_child)109 for sub_node in _bfs_from_cluster_tree(cluster_tree, epsilon_child):110 if sub_node != epsilon_child:111 processed.append(sub_node)112 else:113 selected_clusters.append(leaf)114 return set(selected_clusters)115def _do_labelling(116 tree: np.ndarray,117 clusters: set,118 cluster_label_map: dict,119 allow_single_cluster: np.int_,120 cluster_selection_epsilon: np.float_121) -> np.ndarray:...

Full Screen

Full Screen

local_config.py

Source:local_config.py Github

copy

Full Screen

...27 if file_name.endswith(".py"):28 yield os.path.join(root, file_name)29 def _build_config(self, path):30 confstack = []31 for dir_path in self._traverse_upwards(path):32 slashconf_vars = self._slashconf_vars_cache.get(dir_path)33 if slashconf_vars is None:34 slashconf_vars = {}35 for slashconf_path in self._iter_slashconf_paths(dir_path):36 self.duplicate_funcs |= check_duplicate_functions(slashconf_path)37 with dessert.rewrite_assertions_context():38 slashconf_vars.update(vars(import_file(slashconf_path)))39 if slashconf_vars:40 confstack.append(slashconf_vars)41 self._slashconf_vars_cache[dir_path] = slashconf_vars42 returned = {}43 # start loading from the parent so that vars are properly overriden44 for slashconf_vars in reversed(confstack):45 returned.update(slashconf_vars)46 return returned47 def _traverse_upwards(self, path):48 path = os.path.abspath(path)49 if not os.path.exists(path):50 raise RuntimeError("Path doesn't exist: {}".format(path))51 if os.path.isfile(path):52 path = os.path.dirname(path)53 upward_limit = os.path.splitdrive(os.path.normcase(os.path.abspath(os.path.sep)))[1]54 while True:55 yield path56 if os.path.splitdrive(os.path.normcase(path))[1] == upward_limit:57 break58 new_path = os.path.dirname(path)59 assert new_path != path...

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