Best Python code snippet using pandera_python
base.py
Source:base.py
1from pyrl.utils import collate, create_random_space, torchify2import torch3NUM_SAMPLES = 1004def custom_equals(a, b):5 if isinstance(a, dict):6 assert isinstance(b, dict) and b.keys() == a.keys()7 for k, v in a.items():8 custom_equals(v, b[k])9 else:10 print("ISCLOSE:", torch.isclose(a.float(), b.float()))11 assert (12 isinstance(b, torch.Tensor)13 and b.dim() == 214 and torch.all(torch.isclose(a.float(), b.float()))15 )16def make_test_multi_space(model, size=20):17 def test_multi_space():18 for _ in range(NUM_SAMPLES):19 space = create_random_space()20 m = model(space)21 samples = []22 for _ in range(size):23 samples.append({"obs": space.sample()})24 sample = collate([torchify(s) for s in samples])["obs"]25 print("=" * 50)26 print("SPACE:", space)27 print("SAMPLE:", sample)28 forward = m.forward(sample)29 print("FORWARD:", forward)30 custom_equals(forward, sample)31 return test_multi_space32def make_test_single_space(model):...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!