How to use error_added method in Slash

Best Python code snippet using slash

test_plugin_dependency.py

Source:test_plugin_dependency.py Github

copy

Full Screen

...41 def get_name(self):42 return 'plugin b'43 def session_start(self):44 checkpoint2()45 def error_added(self, result, error): # pylint: disable=unused-argument46 pass47 for plugin_cls in [PluginA, PluginB]:48 slash.plugins.manager.install(plugin_cls(), activate_later=True)49 slash.plugins.manager.activate_pending_plugins()50 slash.hooks.session_start() # pylint: disable=no-member51 assert checkpoint1.timestamp < checkpoint2.timestamp52 slash.plugins.manager.deactivate('plugin a')53 with pytest.raises(CannotResolveDependencies) as caught:54 slash.hooks.session_start() # pylint: disable=no-member55 assert caught.value.unmet_dependencies == set(['x'])56def test_provides_globally_needs_specific_hook(checkpoint1, checkpoint2):57 '''58 Plugin A: Provides x at class level59 Plugin B: Needs x for specific hook60 '''61 @slash.plugins.provides('x')62 class PluginA(slash.plugins.interface.PluginInterface):63 def get_name(self):64 return 'plugin a'65 def session_start(self):66 checkpoint1()67 def test_start(self):68 pass69 class PluginB(slash.plugins.interface.PluginInterface):70 def get_name(self):71 return 'plugin b'72 @slash.plugins.needs('x')73 def session_start(self):74 checkpoint2()75 def error_added(self, result, error): # pylint: disable=unused-argument76 pass77 for plugin_cls in [PluginA, PluginB]:78 slash.plugins.manager.install(plugin_cls(), activate_later=True)79 slash.plugins.manager.activate_pending_plugins()80 slash.hooks.session_start() # pylint: disable=no-member81 assert checkpoint1.timestamp < checkpoint2.timestamp82 slash.plugins.manager.deactivate('plugin a')83 with pytest.raises(CannotResolveDependencies) as caught:84 slash.hooks.session_start() # pylint: disable=no-member85 assert caught.value.unmet_dependencies == set(['x'])86def test_provides_globally_needs_specific_hook_which_does_not_exist_at_a(checkpoint2):87 '''88 Plugin A: Provides x at class level89 Plugin B: Needs x for specific hook, this hook does not definied in A90 Expectations:91 Should work in the empty sense92 all non-needing hooks should work, even when missing from A, the specific hook needs to happen in A before B.93 '''94 @slash.plugins.provides('x')95 class PluginA(slash.plugins.interface.PluginInterface):96 def get_name(self):97 return 'plugin a'98 def test_start(self):99 pass100 class PluginB(slash.plugins.interface.PluginInterface):101 def get_name(self):102 return 'plugin b'103 @slash.plugins.needs('x')104 def session_start(self):105 checkpoint2()106 def error_added(self, result, error): # pylint: disable=unused-argument107 pass108 for plugin_cls in [PluginA, PluginB]:109 slash.plugins.manager.install(plugin_cls(), activate_later=True)110 slash.plugins.manager.activate_pending_plugins()111 slash.hooks.session_start() # pylint: disable=no-member112 assert checkpoint2.called113 slash.plugins.manager.deactivate('plugin a')114 with pytest.raises(CannotResolveDependencies) as caught:115 slash.hooks.session_start() # pylint: disable=no-member116 assert caught.value.unmet_dependencies == set(['x'])117def test_provides_specific_hook_needs_globally(checkpoint1, checkpoint2):118 '''119 Plugin A: Provides x on a specific hook120 Plugin B: Needs x at class level121 Expectations:122 This case should fail, because logically the other hooks don't have anyone to provide X for them123 '''124 class PluginA(slash.plugins.interface.PluginInterface):125 def get_name(self):126 return 'plugin a'127 @slash.plugins.provides('x')128 def session_start(self):129 checkpoint1()130 def test_start(self):131 pass132 @slash.plugins.needs('x')133 class PluginB(slash.plugins.interface.PluginInterface):134 def get_name(self):135 return 'plugin b'136 def session_start(self):137 checkpoint2()138 def error_added(self, result, error): # pylint: disable=unused-argument139 pass140 for plugin_cls in [PluginA, PluginB]:141 slash.plugins.manager.install(plugin_cls(), activate_later=True)142 slash.plugins.manager.activate_pending_plugins()143 slash.hooks.session_start() # pylint: disable=no-member144 with pytest.raises(CannotResolveDependencies) as caught:145 slash.hooks.error_added(result=None, error=None) # pylint: disable=no-member146 assert caught.value.unmet_dependencies == set(['x'])147def test_provides_specific_hook_needs_globally_with_this_hook_only(checkpoint1, checkpoint2):148 '''149 Plugin A: Provides x on a specific hook150 Plugin B: Needs x at class level, but only has one hook (the one provided by A)151 '''152 class PluginA(slash.plugins.interface.PluginInterface):153 def get_name(self):154 return 'plugin a'155 @slash.plugins.provides('x')156 def session_start(self):157 checkpoint1()158 def test_start(self):159 pass160 @slash.plugins.needs('x')161 class PluginB(slash.plugins.interface.PluginInterface):162 def get_name(self):163 return 'plugin b'164 def session_start(self):165 checkpoint2()166 for plugin_cls in [PluginA, PluginB]:167 slash.plugins.manager.install(plugin_cls(), activate_later=True)168 slash.plugins.manager.activate_pending_plugins()169 slash.hooks.session_start() # pylint: disable=no-member170 assert checkpoint1.timestamp < checkpoint2.timestamp171 slash.plugins.manager.deactivate('plugin a')172 with pytest.raises(CannotResolveDependencies) as caught:173 slash.hooks.session_start() # pylint: disable=no-member174 assert caught.value.unmet_dependencies == set(['x'])175@pytest.mark.parametrize('needs_parent_level', [True, False])176@pytest.mark.parametrize('provides_parent_level', [True, False])177def test_provides_needs_with_inheritence_on_class_level(checkpoint, checkpoint1, checkpoint2, needs_parent_level, provides_parent_level):178 '''179 Plugin A: Provides x in class level (by it self or by inheritence)180 Plugin b: Needs x in class level (by it self or by inheritence)181 '''182 # pylint: disable=abstract-method183 @maybe_decorate(slash.plugins.provides('x'), provides_parent_level)184 class PluginAParent(slash.plugins.interface.PluginInterface):185 def test_start(self):186 pass187 @maybe_decorate(slash.plugins.provides('x'), not provides_parent_level)188 class PluginA(PluginAParent):189 def get_name(self):190 return 'plugin a'191 def session_start(self):192 checkpoint1()193 @maybe_decorate(slash.plugins.needs('x'), needs_parent_level)194 class PluginBParent(slash.plugins.interface.PluginInterface):195 def error_added(self, result, error): # pylint: disable=unused-argument196 checkpoint()197 @maybe_decorate(slash.plugins.needs('x'), not needs_parent_level)198 class PluginB(PluginBParent):199 def get_name(self):200 return 'plugin b'201 def session_start(self):202 checkpoint2()203 for plugin_cls in [PluginA, PluginB]:204 slash.plugins.manager.install(plugin_cls(), activate_later=True)205 slash.plugins.manager.activate_pending_plugins()206 # session_start hook should be provided the PluginA.session_start method207 slash.hooks.session_start() # pylint: disable=no-member208 assert checkpoint1.timestamp < checkpoint2.timestamp209 # error_added hook should be provided by empty registration of pluginA210 slash.hooks.error_added(result=None, error=None) # pylint: disable=no-member211 assert checkpoint.called212 slash.plugins.manager.deactivate('plugin a')213 with pytest.raises(CannotResolveDependencies) as caught:214 slash.hooks.session_start() # pylint: disable=no-member215 assert caught.value.unmet_dependencies == set(['x'])216 with pytest.raises(CannotResolveDependencies) as caught:217 slash.hooks.error_added() # pylint: disable=no-member218 assert caught.value.unmet_dependencies == set(['x'])219 # Ensure only hooks required by PluginB fails220 slash.hooks.test_end() # pylint: disable=no-member221def test_provides_needs_in_both_inheritence_levels(checkpoint, checkpoint1, checkpoint2):222 # pylint: disable=abstract-method223 @slash.plugins.provides('x')224 class PluginAParent(slash.plugins.interface.PluginInterface):225 def test_start(self):226 pass227 @slash.plugins.provides('y')228 class PluginA(PluginAParent):229 def get_name(self):230 return 'plugin a'231 def session_start(self):232 checkpoint1()233 @slash.plugins.needs('x')234 class PluginBParent(slash.plugins.interface.PluginInterface):235 def error_added(self, result, error): # pylint: disable=unused-argument236 checkpoint()237 @slash.plugins.needs('y')238 class PluginB(PluginBParent):239 def get_name(self):240 return 'plugin b'241 def session_start(self):242 checkpoint2()243 for plugin_cls in [PluginA, PluginB]:244 slash.plugins.manager.install(plugin_cls(), activate_later=True)245 slash.plugins.manager.activate_pending_plugins()246 # session_start hook should be provided the PluginA.session_start method247 slash.hooks.session_start() # pylint: disable=no-member248 assert checkpoint1.timestamp < checkpoint2.timestamp249 # error_added hook should be provided by empty registration of pluginA250 slash.hooks.error_added(result=None, error=None) # pylint: disable=no-member251 assert checkpoint.called252 slash.plugins.manager.deactivate('plugin a')253 with pytest.raises(CannotResolveDependencies) as caught:254 slash.hooks.session_start() # pylint: disable=no-member255 assert caught.value.unmet_dependencies == set(['x', 'y'])256 with pytest.raises(CannotResolveDependencies) as caught:257 slash.hooks.error_added() # pylint: disable=no-member258 assert caught.value.unmet_dependencies == set(['x', 'y'])259 # Ensure only hooks required by PluginB fails260 slash.hooks.test_end() # pylint: disable=no-member261def test_provides_needs_with_inheritence_on_method_level(checkpoint):262 '''263 Plugin A: Provides x in method level (by it self or by inheritence) to test_start & session_start264 Plugin b: Needs x in method level (by it self or by inheritence) on test_start & session_start265 '''266 # pylint: disable=abstract-method267 session_start_a = Checkpoint()268 session_start_b = Checkpoint()269 test_start_a = Checkpoint()270 test_start_b = Checkpoint()271 class PluginAParent(slash.plugins.interface.PluginInterface):272 @slash.plugins.provides('x')273 def test_start(self):274 test_start_a()275 class PluginA(PluginAParent):276 def get_name(self):277 return 'plugin a'278 @slash.plugins.provides('x')279 def session_start(self):280 session_start_a()281 class PluginBParent(slash.plugins.interface.PluginInterface):282 @slash.plugins.needs('x')283 def session_start(self):284 session_start_b()285 def error_added(self, result, error): # pylint: disable=unused-argument286 checkpoint()287 class PluginB(PluginBParent):288 def get_name(self):289 return 'plugin b'290 @slash.plugins.needs('x')291 def test_start(self):292 test_start_b()293 for plugin_cls in [PluginA, PluginB]:294 slash.plugins.manager.install(plugin_cls(), activate_later=True)295 slash.plugins.manager.activate_pending_plugins()296 slash.hooks.session_start() # pylint: disable=no-member297 assert session_start_a.timestamp < session_start_b.timestamp298 slash.hooks.test_start() # pylint: disable=no-member299 assert test_start_a.timestamp < test_start_b.timestamp300 # error_added hook should not need anything301 slash.hooks.error_added(result=None, error=None) # pylint: disable=no-member302 assert checkpoint.called303 slash.plugins.manager.deactivate('plugin a')304 with pytest.raises(CannotResolveDependencies) as caught:305 slash.hooks.session_start() # pylint: disable=no-member306 assert caught.value.unmet_dependencies == set(['x'])307 with pytest.raises(CannotResolveDependencies) as caught:308 slash.hooks.test_start() # pylint: disable=no-member309 slash.hooks.error_added(result=None, error=None) # pylint: disable=no-member310 assert caught.value.unmet_dependencies == set(['x'])311def test_provides_needs_with_child_overrides():312 # pylint: disable=line-too-long313 '''314 | Hook Name | Plugin A | Plugin B |315 |---------------+-------------------------------------------------------------------------+------------------------------------------------------------------------|316 | session_start | Child Provides x in method level, overrides parent's empty registration | Needs x (Parent) & y (Child) in class level |317 | test_start | Child Provides x in method level, overrides parent's real registration | Needs x (Parent) & y (Child) in class level |318 | error_added | x is not provided, overrides parent's real registration | Needs x (Parent) & y (Child) in class level |319 | test_end | x is not provided, overrides parent's empty registration | Needs x (Parent) & y (Child) in class level |320 | session_end | Parent provides x, child provides y - both in class level | Needs x (Parent) & y (Child) in class level, z in (child) method level |321 '''322 # pylint: disable=abstract-method323 session_start_a = Checkpoint()324 session_start_b = Checkpoint()325 test_start_a = Checkpoint()326 test_start_b = Checkpoint()327 @slash.plugins.provides('x')328 class PluginAParent(slash.plugins.interface.PluginInterface):329 def test_start(self):330 test_start_a()331 def error_added(self, result, error): # pylint: disable=unused-argument332 pass333 def session_end(self):334 pass335 @slash.plugins.provides('y')336 class PluginA(PluginAParent):337 def get_name(self):338 return 'plugin a'339 @slash.plugins.provides('x')340 def session_start(self):341 # Overrides empty registration of PluginAParent342 session_start_a()343 @slash.plugins.provides('x')344 def test_start(self):345 # Overrides "real" registration of PluginAParent346 test_start_a()347 def error_added(self, result, error): # pylint: disable=unused-argument348 # Overrides "real" registration of PluginAParent349 pass350 def test_end(self):351 # Overrides empty registration of PluginAParent352 pass353 @slash.plugins.needs('x')354 class PluginBParent(slash.plugins.interface.PluginInterface):355 def session_start(self):356 session_start_b()357 def error_added(self, result, error): # pylint: disable=unused-argument358 pass359 def test_start(self):360 test_start_b()361 def test_end(self):362 pass363 @slash.plugins.needs('y')364 class PluginB(PluginBParent):365 def get_name(self):366 return 'plugin b'367 @slash.plugins.needs('z')368 def session_end(self):369 pass370 for plugin_cls in [PluginA, PluginB]:371 slash.plugins.manager.install(plugin_cls(), activate_later=True)372 slash.plugins.manager.activate_pending_plugins()373 slash.hooks.session_start() # pylint: disable=no-member374 assert session_start_a.timestamp < session_start_b.timestamp375 slash.hooks.test_start() # pylint: disable=no-member376 assert test_start_a.timestamp < test_start_b.timestamp377 slash.hooks.error_added(result=None, error=None) # pylint: disable=no-member378 slash.hooks.test_end() # pylint: disable=no-member379 with pytest.raises(CannotResolveDependencies) as caught:380 slash.hooks.session_end() # pylint: disable=no-member381 assert caught.value.unmet_dependencies == set(['z'])382 slash.plugins.manager.deactivate('plugin a')383 with pytest.raises(CannotResolveDependencies) as caught:384 slash.hooks.session_start() # pylint: disable=no-member385 assert caught.value.unmet_dependencies == set(['x', 'y'])386 with pytest.raises(CannotResolveDependencies) as caught:387 slash.hooks.test_start() # pylint: disable=no-member388 assert caught.value.unmet_dependencies == set(['x', 'y'])389 with pytest.raises(CannotResolveDependencies) as caught:390 slash.hooks.error_added(result=None, error=None) # pylint: disable=no-member391 assert caught.value.unmet_dependencies == set(['x', 'y'])392 with pytest.raises(CannotResolveDependencies) as caught:393 slash.hooks.test_end() # pylint: disable=no-member394 assert caught.value.unmet_dependencies == set(['x', 'y'])395 with pytest.raises(CannotResolveDependencies) as caught:396 slash.hooks.session_end() # pylint: disable=no-member397 assert caught.value.unmet_dependencies == set(['x', 'y', 'z'])398def autoname(plugin):399 def get_name(self):400 return type(self).__name__.lower()401 plugin.get_name = get_name...

Full Screen

Full Screen

change_condition_number.py

Source:change_condition_number.py Github

copy

Full Screen

1import matplotlib2matplotlib.use("Agg")3import matplotlib.pyplot as plt4plt.rcParams.update({'font.size': 12})5import multiprocessing as mp6import numpy as np7import os8from algorithms.gradient_descent import GradientDescent9from algorithms.iterative_threshold_methods import IterativeThresholdMethods10import utils.constants as constants11from utils.draw import Draw12from utils.error import Error13from utils.generate_data import GenerateData14class ChangeConditionNumber:15 """Simulations on the change of condition number of design matrix.16 """17 def __init__(self, x=constants.X):18 """Set the type of design matrix, anisotropic and some constants.19 """20 self.design = constants.ANISOTROPIC_NAME21 self.steps = constants.GD_STEPS # number of experiments22 self.num_iter = constants.GD_NUM_ITERATION # number of iterations23 self.x_original = x24 self.gd_types = (constants.GD_NAME, constants.FAST_NEWTON_NAME)25 self.iter_types = (constants.IHT_NAME, constants.HTP_NAME)26 self.iterative_threshold_methods = (constants.ISTA_NAME, )27 def _update_algos_map(self, algos_map, algo_name, kappa, error_added):28 """A private function to update @param algos_map.29 30 @param algos_map: key is algo name, value is a dict with kappa-error as key-value pair.31 @param algo_name: the key of algos_map which needs an update.32 e.g. constants.ISTA_NAME, constants.GD_NAME+constants.IHT_NAME, see utils.constants.33 @param kappa: (condition number) It is a key of the map, algos_map[algo_name].34 @param error_added: the error of an experiment with kappa as condition numebr35 and algo_name as the algorithm.36 @return the updated map.37 """38 if algos_map.get(algo_name):39 curr_kappa_error_map = algos_map[algo_name]40 else:41 curr_kappa_error_map = dict()42 if curr_kappa_error_map.get(kappa):43 # if curr_kappa_error_map has a key, kappa.44 curr_kappa_error_map[kappa] += error_added45 else: # if curr_kappa_error_map never see this key.46 curr_kappa_error_map[kappa] = error_added47 algos_map[algo_name] = curr_kappa_error_map48 return algos_map49 def run_one_experiment(self, kappa):50 """Run one experient working for multiprocessing.51 52 @param kappa - condition number.53 @return algo_name gener_error hashmap.54 """55 y, H, self.SIGMA_half = GenerateData(self.design, kappa,56 self.x_original).generate_data()57 algos_map = dict()58 for algo_name in self.iterative_threshold_methods:59 _, best_lambda, gener_error = IterativeThresholdMethods(60 ).get_errors_by_cv(self.x_original, y, H, self.num_iter,61 self.SIGMA_half, algo_name, False)62 # To add {algo_name: {kappa, final_error}} key-value-pair to algos_map.63 algos_map = self._update_algos_map(algos_map, algo_name, kappa,64 gener_error[-1])65 print(algo_name, best_lambda)66 for gd_type in self.gd_types:67 for iter_type in self.iter_types:68 _, best_lambda, gener_error = GradientDescent().get_errors_by_cv(69 self.x_original, y, H, self.num_iter, self.SIGMA_half,70 gd_type, iter_type, False)71 algo_name = gd_type + "+" + iter_type72 algos_map = self._update_algos_map(algos_map, algo_name, kappa,73 gener_error[-1])74 print(algo_name, best_lambda)75 return algos_map76 def compare_condition_numbers(self):77 """Get the change of generalization error w.r.t. condition number.78 """79 algos_map = {}80 for _ in range(self.steps): # Run several experiments81 """Multiprocess.82 If you want to cancel multiprocess, rewrite the line to be 83 "pool = mp.Pool(1)".84 """85 pool = mp.Pool(mp.cpu_count())86 pool_results = pool.map(self.run_one_experiment,87 np.arange(1, 101, 10), 1)88 # To add pool_results into algos_map89 for map_result in pool_results:90 for algo_name in map_result:91 for kappa in map_result[algo_name]:92 error = map_result[algo_name][kappa] / self.steps93 algos_map = self._update_algos_map(94 algos_map, algo_name, kappa, error)95 for algo_name in algos_map:96 Draw().plot_using_a_map(algos_map[algo_name], algo_name)97 # Store @param algos_map in a npy (binary) format.98 with open(99 os.path.dirname(os.path.abspath(__file__)) +100 '/figures/condition number/result_dict.npy', 'wb') as f:101 np.save(f, algos_map)102 plt.xlabel("condition number")103 plt.ylabel("generalization error")104 plt.title("Change condition number of design matrix x " +105 str(np.max(self.x_original)))106 plt.legend()107 plt.savefig(108 os.path.dirname(os.path.abspath(__file__)) +109 "/figures/condition number/comparison by change of condition number x20.pdf"110 )111 plt.clf()112if __name__ == "__main__":113 """To change the true signal, modify x_value.114 """115 x_value = 20.116 x = x_value * np.ones((constants.P))117 x[constants.S:] = 0118 x = np.random.permutation(x)...

Full Screen

Full Screen

support_recovery.py

Source:support_recovery.py Github

copy

Full Screen

1import matplotlib2matplotlib.use("Agg")3import matplotlib.pyplot as plt4plt.rcParams.update({'font.size': 12})5import multiprocessing as mp6import numpy as np7import os8from algorithms.gradient_descent import GradientDescent9from algorithms.iterative_threshold_methods import IterativeThresholdMethods10import utils.constants as constants11from utils.draw import Draw12from utils.error import Error13from utils.generate_data import GenerateData14class ChangeSignal:15 """Simulations on the change of exact recovery w.r.t. the signal.16 """17 def __init__(self, kappa, error_name=constants.EXACT_RECOVERY_NAME):18 """Initialize.19 """20 self.kappa = kappa21 self.error_name = error_name22 self.design = constants.ANISOTROPIC_NAME23 self.steps = constants.GD_STEPS # number of experiments24 self.num_iter = constants.GD_NUM_ITERATION # number of iterations25 self.gd_types = (constants.GD_NAME, constants.FAST_NEWTON_NAME)26 self.iter_types = (constants.IHT_NAME, constants.HTP_NAME)27 self.iterative_threshold_methods = (constants.ISTA_NAME, )28 def _update_algos_map(self, algos_map, algo_name, a, error_added):29 """A private function to update @param algos_map.30 31 @param algos_map: key is algo name, value is a dict with signal-error as key-value pair.32 @param algo_name: the key of algos_map which needs an update.33 e.g. constants.ISTA_NAME, constants.GD_NAME+constants.IHT_NAME, see utils.constants.34 @param a - the signal value.35 @param error_added: the error to be added to the map.36 @return the updated map.37 """38 if algos_map.get(algo_name):39 curr_map = algos_map[algo_name]40 else:41 curr_map = dict()42 if curr_map.get(a):43 curr_map[a] += error_added44 else:45 curr_map[a] = error_added46 algos_map[algo_name] = curr_map47 return algos_map48 def run_one_experiment(self, a):49 """Run one experiment on the change of exact recovery w.r.t. the signal.50 51 @param a - the value of the true signal52 @return algo_name gener_error hashmap.53 """54 signal = a * np.ones((constants.P))55 signal[constants.S:] = 056 signal = np.random.permutation(signal)57 y, H, self.SIGMA_half = GenerateData(self.design, self.kappa,58 signal).generate_data()59 algos_map = dict()60 for algo_name in self.iterative_threshold_methods:61 _, best_lambda, gener_error = IterativeThresholdMethods(62 self.error_name).get_errors_by_cv(signal, y, H, self.num_iter,63 self.SIGMA_half, algo_name,64 False)65 # To add {algo_name: {a, final_error}} key-value-pair to algos_map.66 algos_map = self._update_algos_map(algos_map, algo_name, a,67 gener_error[-1])68 print(algo_name, best_lambda)69 for gd_type in self.gd_types:70 for iter_type in self.iter_types:71 _, best_lambda, gener_error = GradientDescent(72 constants.FAST_NEWTON_NUM_GD,73 self.error_name).get_errors_by_cv(signal, y, H,74 self.num_iter,75 self.SIGMA_half, gd_type,76 iter_type, False)77 algo_name = gd_type + "+" + iter_type78 algos_map = self._update_algos_map(algos_map, algo_name, a,79 gener_error[-1])80 print(algo_name, best_lambda)81 return algos_map82 def change_signal(self, signal_range):83 """Run several experiments and get the change of exact recovery w.r.t. signal.84 """85 algos_map = {}86 for _ in range(self.steps): # Run several experiments87 for a in signal_range:88 map_result = self.run_one_experiment(a)89 for algo_name in map_result:90 for signal in map_result[algo_name]:91 error = map_result[algo_name][signal] / self.steps92 algos_map = self._update_algos_map(93 algos_map, algo_name, signal, error)94 for algo_name in algos_map:95 Draw().plot_using_a_map(algos_map[algo_name], algo_name)96 # Store @param algos_map in a npy (binary) format.97 with open(98 os.path.dirname(os.path.abspath(__file__)) +99 "/figures/change signal/result_dict_kappa" +100 str(int(self.kappa)) + ".npy", 'wb') as f:101 np.save(f, algos_map)102 plt.xlabel("signal a")103 plt.ylabel("exact recovery")104 plt.title("Change signal with kappa " + str(int(self.kappa)))105 plt.legend()106 plt.savefig(107 os.path.dirname(os.path.abspath(__file__)) +108 "/figures/change signal/comparison by change of signal kappa" +109 str(int(self.kappa)) + ".pdf")110 plt.clf()111if __name__ == "__main__":112 """To change the condition number, modify kappa.113 """114 kappa = 1.115 signal_range = [0.001, 0.005, 0.01, 0.03, 0.05, 0.07, 0.1, 0.15]...

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