Best Python code snippet using selene_python
centralized_categorical_lstm_policy.py
...130 masked_probs = masked_probs * torch.Tensor(avail_actions_n) # mask131 masked_probs = masked_probs /โ masked_probs.sum(axis=-1, keepdims=True) # renormalize132 masked_dists_n = Categorical(probs=masked_probs) # redefine distribution133 return masked_dists_n134 def get_actions(self, obs_n, avail_actions_n, greedy=False):135 """Independent agent actions (not using an exponential joint action space)136 137 Args:138 obs_n: list of obs of all agents in ONE time step [o1, o2, ..., on]139 E.g. 3 agents: [o1, o2, o3]140 """141 with torch.no_grad():142 dists_n = self.step_forward(obs_n, avail_actions_n)143 if not greedy:144 actions_n = dists_n.sample().numpy()145 else:146 actions_n = np.argmax(dists_n.probs.numpy(), axis=-1)147 agent_infos_n = {}148 agent_infos_n['action_probs'] = [dists_n.probs[i].numpy() ...
dec_categorical_lstm_policy.py
Source: dec_categorical_lstm_policy.py
...129 masked_probs = masked_probs * torch.Tensor(avail_actions_n) # mask130 masked_probs = masked_probs /โ masked_probs.sum(axis=-1, keepdims=True) # renormalize131 masked_dists_n = Categorical(probs=masked_probs) # redefine distribution132 return masked_dists_n133 def get_actions(self, obs_n, avail_actions_n, greedy=False):134 """Independent agent actions (not using an exponential joint action space)135 136 Args:137 obs_n: list of obs of all agents in ONE time step [o1, o2, ..., on]138 E.g. 3 agents: [o1, o2, o3]139 """140 with torch.no_grad():141 dists_n = self.step_forward(obs_n, avail_actions_n)142 if not greedy:143 actions_n = dists_n.sample().numpy()144 else:145 actions_n = np.argmax(dists_n.probs.numpy(), axis=-1)146 agent_infos_n = {}147 agent_infos_n['action_probs'] = [dists_n.probs[i].numpy() ...
dicg_ce_categorical_lstm_policy.py
...118 masked_probs = masked_probs * torch.Tensor(avail_actions_n) # mask119 masked_probs = masked_probs /โ masked_probs.sum(axis=-1, keepdims=True) # renormalize120 masked_dists_n = Categorical(probs=masked_probs) # redefine distribution121 return masked_dists_n, attention_weights122 def get_actions(self, obs_n, avail_actions_n, greedy=False):123 """Independent agent actions (not using an exponential joint action space)124 125 Args:126 obs_n: list of obs of all agents in ONE time step [o1, o2, ..., on]127 E.g. 3 agents: [o1, o2, o3]128 """129 with torch.no_grad():130 dists_n, attention_weights = self.step_forward(obs_n, avail_actions_n)131 if not greedy:132 actions_n = dists_n.sample().numpy()133 else:134 actions_n = np.argmax(dists_n.probs.numpy(), axis=-1)135 agent_infos_n = {}136 agent_infos_n['action_probs'] = [dists_n.probs[i].numpy() ...
tree-massactions.test.js
Source: tree-massactions.test.js
...22 });23 });24 describe('check initObservable', function () {25 it('by default will set visible for all action where exist actions', function () {26 expect(model.actions()[0].visible).toBeDefined();27 expect(model.actions()[0].visible()).toBeFalsy();28 });29 it('check when actions is absent', function () {30 model.actions([{31 type: 'delete'32 }]);33 model.initObservable();34 expect(model.actions()[0].visible).toBeUndefined();35 });36 it('check nested level actions', function () {37 model.actions()[0].actions[0].actions = [{38 type: 'delete'39 }];40 model.initObservable();41 expect(model.actions()[0].actions[0].visible).toBeDefined();42 expect(model.actions()[0].actions[0].visible()).toBeFalsy();43 });44 it('check reference to parent object', function () {45 expect(model.actions()[0].parent).toBe(model.actions());46 });47 });48 describe('check recursiveObserveActions', function () {49 it('set visible for all action where exist actions', function () {50 var actions = [{51 type: 'availability',52 actions: [{53 type: 'delete'54 }]55 }];56 model.recursiveObserveActions(actions);57 expect(actions[0].visible).toBeDefined();58 expect(actions[0].visible()).toBeFalsy();59 });60 it('check when actions is absent', function () {61 var actions = [{62 type: 'delete'63 }];64 model.recursiveObserveActions(actions);65 expect(actions[0].visible).toBeUndefined();66 });67 it('check nested level actions', function () {68 var actions = [{69 type: 'availability',70 actions: [{71 type: 'delete',72 actions: [{73 type: 'safely'74 }]75 }]76 }];77 model.recursiveObserveActions(actions);78 expect(actions[0].actions[0].visible).toBeDefined();79 expect(actions[0].actions[0].visible()).toBeFalsy();80 });81 it('check reference to parent object', function () {82 var actions = [{83 type: 'availability',84 actions: [{85 type: 'delete'86 }]87 }];88 model.recursiveObserveActions(actions);89 expect(actions[0].parent).toBe(actions);90 });91 });92 it('check getAction', function () {93 expect(model.getAction('availability')).toBe(model.actions()[0]);94 expect(model.getAction('availability.enable')).toBe(model.actions()[0].actions[0]);95 expect(model.getAction('absent')).toBeFalsy();96 });97 describe('check hideSubmenus', function () {98 it('with class actions', function () {99 model.actions()[0].visible(true);100 expect(model.actions()[0].visible()).toBeTruthy();101 model.hideSubmenus();102 expect(model.actions()[0].visible()).toBeFalsy();103 });104 it('with another object', function () {105 var actions = model.actions();106 actions[0].visible(true);107 expect(actions[0].visible()).toBeTruthy();108 model.hideSubmenus(actions);109 expect(actions[0].visible()).toBeFalsy();110 });111 });112 describe('check applyAction', function () {113 it('change visibility of submenu', function () {114 expect(model.actions()[0].visible()).toBeFalsy();115 expect(model.applyAction('availability')).toBe(model);116 expect(model.actions()[0].visible()).toBeTruthy();117 });118 });119 });...
Check out the latest blogs from LambdaTest on this topic:
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.
Web applications continue to evolve at an unbelievable pace, and the architecture surrounding web apps get more complicated all of the time. With the growth in complexity of the web application and the development process, web application testing also needs to keep pace with the ever-changing demands.
โTest frequently and early.โ If youโve been following my testing agenda, youโre probably sick of hearing me repeat that. However, it is making sense that if your tests detect an issue soon after it occurs, it will be easier to resolve. This is one of the guiding concepts that makes continuous integration such an effective method. Iโve encountered several teams who have a lot of automated tests but donโt use them as part of a continuous integration approach. There are frequently various reasons why the team believes these tests cannot be used with continuous integration. Perhaps the tests take too long to run, or they are not dependable enough to provide correct results on their own, necessitating human interpretation.
Hey LambdaTesters! Weโve got something special for you this week. ????
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!!