How to use lazy_calculate method in hypothesis

Best Python code snippet using hypothesis

data.py

Source:data.py Github

copy

Full Screen

...208 This has the slightly weird result that we are defining nested209 classes which get turned into properties."""210 name = cls.__name__211 cache_name = "__" + name212 def lazy_calculate(self):213 result = getattr(self, cache_name, None)214 if result is None:215 result = cls(self).run()216 setattr(self, cache_name, result)217 return result218 lazy_calculate.__name__ = cls.__name__219 lazy_calculate.__qualname__ = getattr(cls, "__qualname__", cls.__name__)220 return property(lazy_calculate)221DRAW_BITS_RECORD = 0222STOP_EXAMPLE_DISCARD_RECORD = 1223STOP_EXAMPLE_NO_DISCARD_RECORD = 2224START_EXAMPLE_RECORD = 3225class ExampleRecord:226 """Records the series of ``start_example``, ``stop_example``, and...

Full Screen

Full Screen

data_handler.py

Source:data_handler.py Github

copy

Full Screen

...23 self.num_seqs = len(self.seqs)24 # GET WEIGHTS FOR SEQUENCES25 seq_log_path = make_path('seq_weights.pkl')26 logging.info("CALCULATING SEQ WEIGHTS")27 self.seq_weights = tools.lazy_calculate(self.calc_seq_weights, seq_log_path)28 # GET CLUSTERS FOR SEQUENCES29 cluster_path = make_path('clusters_{}.pkl'.format(tools.n_clusters))30 self.seq_clusters = tools.lazy_calculate(self.cluster_seqs, cluster_path)31 # SELECT TEST AND TRAIN SET32 test_id_path = make_path(os.path.join(run_time, 'test_ids.pkl'))33 self.test_idx = tools.lazy_calculate(self.choose_test_set, test_id_path)34 self.train_idx = list(set(np.arange(self.num_seqs)) - set(self.test_idx))35 self.test_size = len(self.test_idx)36 self.train_size = len(self.train_idx)37 # DICTIONARIES TO KEEP TRACK OF WHICH INDICES HAVE BEEN USED IN A GIVEN EPOCH38 self.unused_test_idx = dict(zip(self.test_idx, self.seq_weights[self.test_idx]))39 self.unused_train_idx = dict(zip(self.train_idx, self.seq_weights[self.train_idx]))40 # Remove gaps41 if not use_full_seqs:42 self.seqs = tools.remove_gaps(self.seqs)43 # Re-adjust the max sequence length44 self.max_seq_len = max(len(seq) for seq in self.seqs.values())45 # GET DIST OF FIRST ELEMENT OF SEQS (for generation purposes)46 seed_weight_path = make_path('seed_weights.pkl')47 self.seed_weights = self.calc_seed_weights()...

Full Screen

Full Screen

tools.py

Source:tools.py Github

copy

Full Screen

...20# HYPER PARAMETERS21similarity_cutoff = 0.222n_clusters = 5023# HELPER FUNCTIONS24def lazy_calculate(function, path):25 if os.path.exists(path):26 with open(path) as f:27 return pickle.load(f)28 else:29 data = function()30 with open(path, 'w') as f:31 pickle.dump(data, f)32 return data33 return wrapper34def get_alignment_filename(gene):35 for filename in os.listdir('alignments'):36 if filename.startswith(gene):37 return filename38def get_results_filename(gene):...

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