How to use new_action method in tox

Best Python code snippet using tox_python

test_bill_actions.py

Source:test_bill_actions.py Github

copy

Full Screen

1import unittest2import bill_info3# parsing various kinds of action text to extract metadata and establish state4def parse_bill_action(line, state, bill_id, title):5 return bill_info.parse_bill_action({"text": line}, state, bill_id, title)6class BillActions(unittest.TestCase):7 def test_veto(self):8 bill_id = "hjres64-111"9 title = "Making further continuing appropriations for fiscal year 2010, and for other purposes."10 state = "PASSED:BILL"11 line = "Vetoed by President."12 new_action, new_state = parse_bill_action(line, state, bill_id, title)13 self.assertEqual(new_action['type'], "vetoed")14 self.assertEqual(new_state, "PROV_KILL:VETO")15 def test_pocket_veto(self):16 bill_id = "hr2415-106"17 title = "United Nations Reform Act of 1999"18 state = "PASSED:BILL"19 line = "Pocket Vetoed by President."20 new_action, new_state = parse_bill_action(line, state, bill_id, title)21 self.assertEqual(new_action['type'], "vetoed")22 self.assertEqual(new_action['pocket'], "1")23 self.assertEqual(new_state, "VETOED:POCKET")24 def test_reported_from_committee(self):25 bill_id = "s968-112"26 title = "A bill to prevent online threats to economic creativity and theft of intellectual property, and for other purposes."27 state = "REFERRED"28 line = "Committee on the Judiciary. Ordered to be reported with an amendment in the nature of a substitute favorably."29 new_action, new_state = parse_bill_action(line, state, bill_id, title)30 self.assertEqual(new_action['type'], 'calendar')31 # self.assertEqual(new_action['committee'], "Committee on the Judiciary")32 self.assertEqual(new_state, "REPORTED")33 def test_added_to_calendar(self):34 bill_id = "s968-112"35 title = "A bill to prevent online threats to economic creativity and theft of intellectual property, and for other purposes."36 state = "REPORTED"37 line = "Placed on Senate Legislative Calendar under General Orders. Calendar No. 70."38 new_action, new_state = parse_bill_action(line, state, bill_id, title)39 self.assertEqual(new_action['type'], 'calendar')40 self.assertEqual(new_action['calendar'], "Senate Legislative")41 self.assertEqual(new_action['under'], "General Orders")42 self.assertEqual(new_action['number'], "70")43 self.assertEqual(new_state, None)44 def test_enacted_as_public_law(self):45 bill_id = "hr3590-111"46 title = "An act entitled The Patient Protection and Affordable Care Act."47 state = "ENACTED:SIGNED"48 line = "Became Public Law No: 111-148."49 new_action, new_state = parse_bill_action(line, state, bill_id, title)50 self.assertEqual(new_action['type'], "enacted")51 self.assertEqual(new_action['congress'], "111")52 self.assertEqual(new_action['number'], "148")53 self.assertEqual(new_action['law'], "public")54 def test_cleared_for_whitehouse(self):55 bill_id = "hr3590-111"56 title = "An act entitled The Patient Protection and Affordable Care Act."57 state = "PASSED:BILL"58 line = "Cleared for White House."59 new_action, new_state = parse_bill_action(line, state, bill_id, title)60 # should not be marked as presented to president, since it hasn't been yet61 # self.assertEqual(new_action['type'], 'action')62 def test_presented_to_president(self):63 bill_id = "hr3590-111"64 title = "An act entitled The Patient Protection and Affordable Care Act."65 state = "PASSED:BILL"66 line = "Presented to President."67 new_action, new_state = parse_bill_action(line, state, bill_id, title)68 self.assertEqual(new_action['type'], 'topresident')69 def test_signed_by_president(self):70 bill_id = "hr3590-111"71 title = "An act entitled The Patient Protection and Affordable Care Act."72 state = "PASSED:BILL"73 line = "Signed by President."74 new_action, new_state = parse_bill_action(line, state, bill_id, title)75 self.assertEqual(new_action['type'], 'signed')76 # voting tests77 def test_vote_normal_roll(self):78 bill_id = "hr3590-111"79 title = "An act entitled The Patient Protection and Affordable Care Act."80 state = "INTRODUCED"81 line = "On motion to suspend the rules and pass the bill Agreed to by the Yeas and Nays: (2/3 required): 416 - 0 (Roll no. 768)."82 new_action, new_state = parse_bill_action(line, state, bill_id, title)83 self.assertEqual(new_action['type'], "vote")84 self.assertEqual(new_action['vote_type'], "vote")85 self.assertEqual(new_action['where'], "h")86 self.assertEqual(new_action['how'], "roll")87 self.assertEqual(new_action['result'], "pass")88 self.assertEqual(new_action['roll'], "768")89 self.assertEqual(new_state, "PASS_OVER:HOUSE")90 def test_vote_normal_roll_second(self):91 bill_id = "hr3590-111"92 title = "An act entitled The Patient Protection and Affordable Care Act."93 state = "PASS_OVER:HOUSE"94 line = "Passed Senate with an amendment and an amendment to the Title by Yea-Nay Vote. 60 - 39. Record Vote Number: 396."95 new_action, new_state = parse_bill_action(line, state, bill_id, title)96 self.assertEqual(new_action['type'], "vote")97 self.assertEqual(new_action['vote_type'], "vote2")98 self.assertEqual(new_action['where'], "s")99 self.assertEqual(new_action['how'], "roll")100 self.assertEqual(new_action['result'], "pass")101 self.assertEqual(new_action['roll'], "396")102 self.assertEqual(new_state, "PASS_BACK:SENATE")103 def test_cloture_vote_verbose(self):104 bill_id = "s1982-113"105 title = "Comprehensive Veterans Health and Benefits and Military Retirement Pay Restoration Act of 2014"106 line = "Cloture motion on the motion to proceed to the measure invoked in Senate by Yea-Nay Vote. 99 - 0. Record Vote Number: 44."107 state = "REPORTED"108 new_action, new_state = parse_bill_action(line, state, bill_id, title)109 self.assertEqual(new_action['type'], "vote-aux")110 self.assertEqual(new_action['vote_type'], "cloture")111 self.assertEqual(new_action['where'], "s")112 self.assertEqual(new_action['how'], "roll")113 self.assertEqual(new_action['result'], "pass")114 self.assertEqual(new_action['roll'], "44")115 self.assertEqual(new_state, None)116 def test_vote_roll_pingpong(self):117 bill_id = "hr3590-111"118 title = "An act entitled The Patient Protection and Affordable Care Act."119 state = "PASS_BACK:SENATE"120 line = "On motion that the House agree to the Senate amendments Agreed to by recorded vote: 219 - 212 (Roll no. 165)."121 new_action, new_state = parse_bill_action(line, state, bill_id, title)122 self.assertEqual(new_action['roll'], "165")123 self.assertEqual(new_action['type'], "vote")124 self.assertEqual(new_action['vote_type'], "pingpong")125 self.assertEqual(new_action['where'], "h")126 self.assertEqual(new_action['how'], "roll")127 self.assertEqual(new_action['result'], "pass")128 def test_vote_cloture(self):129 bill_id = "hr3590-111"130 title = "An act entitled The Patient Protection and Affordable Care Act."131 state = "PASS_OVER:HOUSE" # should not change132 line = "Cloture on the motion to proceed to the bill invoked in Senate by Yea-Nay Vote. 60 - 39. Record Vote Number: 353."133 new_action, new_state = parse_bill_action(line, state, bill_id, title)134 self.assertEqual(new_action['roll'], "353")135 self.assertEqual(new_action['type'], "vote-aux")136 self.assertEqual(new_action['vote_type'], "cloture")137 self.assertEqual(new_action['where'], "s")138 self.assertEqual(new_action['how'], "roll")139 self.assertEqual(new_action['result'], "pass")140 self.assertEqual(new_state, None) # unchanged141 def test_vote_cloture_2(self):142 bill_id = "hr3590-111"143 title = "An act entitled The Patient Protection and Affordable Care Act."144 state = "PASS_OVER:HOUSE" # should not change145 line = "Cloture invoked in Senate by Yea-Nay Vote. 60 - 39. Record Vote Number: 395."146 new_action, new_state = parse_bill_action(line, state, bill_id, title)147 self.assertEqual(new_action['roll'], "395")148 self.assertEqual(new_action['type'], "vote-aux")149 self.assertEqual(new_action['vote_type'], "cloture")150 self.assertEqual(new_action['where'], "s")151 self.assertEqual(new_action['how'], "roll")152 self.assertEqual(new_action['result'], "pass")153 self.assertEqual(new_state, None) # unchanged154 # not sure whether to include votes that are on process, not passage or cloture155 # def test_vote_process_voice_senate(self):156 # bill_id = "hr3590-111"157 # title = "An act entitled The Patient Protection and Affordable Care Act."158 # state = "PASS_OVER:HOUSE" # should not change159 # line = "Motion to proceed to consideration of measure agreed to in Senate by Unanimous Consent."160 # new_action, new_state = parse_bill_action(line, state, bill_id, title)161 # self.assertEqual(new_action['type'], 'vote')162 # self.assertEqual(new_action['vote_type'], 'other')163 # self.assertEqual(new_action['how'], 'Unanimous Consent')164 # self.assertEqual(new_action['where'], 's')165 # self.assertEqual(new_action['result'], 'pass')166 # self.assertEqual(new_state, None)167 # def test_vote_commit_roll_failure(self):168 # bill_id = "hr3590-111"169 # title = "An act entitled The Patient Protection and Affordable Care Act."170 # state = "PASS_OVER:HOUSE" # should not change171 # line = "Motion by Senator McCain to commit to Senate Committee on Finance under the order of 12/2/2009, not having achieved 60 votes in the affirmative, the motion was rejected in Senate by Yea-Nay Vote. 42 - 58. Record Vote Number: 358."172 # new_action, new_state = parse_bill_action(line, state, bill_id, title)173 # self.assertEqual(new_action['type'], 'vote')174 # self.assertEqual(new_action['vote_type'], 'other')175 # self.assertEqual(new_action['how'], 'roll')176 # self.assertEqual(new_action['where'], 's')177 # self.assertEqual(new_action['result'], 'fail')178 # self.assertEqual(new_action['roll'], "358")179 # self.assertEqual(new_state, None)180 # def test_vote_motion_conference(self):181 # bill_id = "hr3630-112"182 # title = "A bill to extend the payroll tax holiday, unemployment compensation, Medicare physician payment, provide for the consideration of the Keystone XL pipeline, and for other purposes."183 # state = "PASS_BACK:SENATE"184 # line = "On motion that the House disagree to the Senate amendments, and request a conference Agreed to by the Yeas and Nays: 229 - 193 (Roll no. 946)."185 # new_action, new_state = parse_bill_action(line, state, bill_id, title)186 # self.assertEqual(new_action['type'], 'vote')187 # self.assertEqual(new_action['vote_type'], 'other')188 # self.assertEqual(new_action['how'], 'roll')189 # self.assertEqual(new_action['where'], 'h')190 # self.assertEqual(new_action['result'], 'pass')191 # self.assertEqual(new_action['roll'], "946")192 # self.assertEqual(new_state, None)193 # def test_vote_motion_instruct_conferees(self):194 # bill_id = "hr3630-112"195 # title = "A bill to extend the payroll tax holiday, unemployment compensation, Medicare physician payment, provide for the consideration of the Keystone XL pipeline, and for other purposes."196 # state = "PASS_BACK:SENATE"197 # line = "On motion that the House instruct conferees Agreed to by the Yeas and Nays: 397 - 16 (Roll no. 9)."198 # new_action, new_state = parse_bill_action(line, state, bill_id, title)199 # self.assertEqual(new_action['type'], 'vote')200 # self.assertEqual(new_action['vote_type'], 'other')201 # self.assertEqual(new_action['how'], 'roll')202 # self.assertEqual(new_action['where'], 'h')203 # self.assertEqual(new_action['result'], 'pass')204 # self.assertEqual(new_action['roll'], "9")205 # self.assertEqual(new_state, None)206 def test_vote_conference_report_house_pass(self):207 bill_id = "hr3630-112"208 title = "A bill to extend the payroll tax holiday, unemployment compensation, Medicare physician payment, provide for the consideration of the Keystone XL pipeline, and for other purposes."209 state = "PASS_BACK:SENATE"210 line = "On agreeing to the conference report Agreed to by the Yeas and Nays: 293 - 132 (Roll no. 72)."211 new_action, new_state = parse_bill_action(line, state, bill_id, title)212 self.assertEqual(new_action['type'], 'vote')213 self.assertEqual(new_action['vote_type'], 'conference')214 self.assertEqual(new_action['how'], 'roll')215 self.assertEqual(new_action['where'], 'h')216 self.assertEqual(new_action['result'], 'pass')217 self.assertEqual(new_action['roll'], "72")218 self.assertEqual(new_state, 'CONFERENCE:PASSED:HOUSE')219 def test_vote_conference_report_senate_pass(self):220 bill_id = "hr3630-112"221 title = "A bill to extend the payroll tax holiday, unemployment compensation, Medicare physician payment, provide for the consideration of the Keystone XL pipeline, and for other purposes."222 state = "CONFERENCE:PASSED:HOUSE"223 line = "Senate agreed to conference report by Yea-Nay Vote. 60 - 36. Record Vote Number: 22."224 new_action, new_state = parse_bill_action(line, state, bill_id, title)225 self.assertEqual(new_action['type'], 'vote')226 self.assertEqual(new_action['vote_type'], 'conference')227 self.assertEqual(new_action['how'], 'roll')228 self.assertEqual(new_action['where'], 's')229 self.assertEqual(new_action['result'], 'pass')230 self.assertEqual(new_action['roll'], "22")231 self.assertEqual(new_state, 'PASSED:BILL')232 def test_vote_veto_override_fail(self):233 bill_id = "hjres64-111"234 title = "Making further continuing appropriations for fiscal year 2010, and for other purposes."235 state = "PROV_KILL:VETO"236 line = "On passage, the objections of the President to the contrary notwithstanding Failed by the Yeas and Nays: (2/3 required): 143 - 245, 1 Present (Roll no. 2).On passage, the objections of the President to the contrary notwithstanding Failed by the Yeas and Nays: (2/3 required): 143 - 245, 1 Present (Roll no. 2)."237 new_action, new_state = parse_bill_action(line, state, bill_id, title)238 self.assertEqual(new_action['type'], "vote")239 self.assertEqual(new_action['vote_type'], "override")240 self.assertEqual(new_action['where'], "h")241 self.assertEqual(new_action["result"], "fail")242 self.assertEqual(new_action["how"], "roll")243 self.assertEqual(new_action["roll"], "2")244 self.assertEqual(new_state, "VETOED:OVERRIDE_FAIL_ORIGINATING:HOUSE")245 def test_veto_override_success_once(self):246 bill_id = "hr6331-110"247 title = "Medicare Improvements for Patients and Providers Act of 2008"248 state = "PROV_KILL:VETO"249 line = "Two-thirds of the Members present having voted in the affirmative the bill is passed, Passed by the Yeas and Nays: (2/3 required): 383 - 41 (Roll no. 491)."250 new_action, new_state = parse_bill_action(line, state, bill_id, title)251 self.assertEqual(new_action['type'], "vote")252 self.assertEqual(new_action['vote_type'], "override")253 self.assertEqual(new_action['where'], "h")254 self.assertEqual(new_action["result"], "pass")255 self.assertEqual(new_action["how"], "roll")256 self.assertEqual(new_action["roll"], "491")257 self.assertEqual(new_state, "VETOED:OVERRIDE_PASS_OVER:HOUSE")258 def test_veto_override_success_twice(self):259 bill_id = "hr6331-110"260 title = "Medicare Improvements for Patients and Providers Act of 2008"261 state = "VETOED:OVERRIDE_PASS_OVER:HOUSE"262 line = "Passed Senate over veto by Yea-Nay Vote. 70 - 26. Record Vote Number: 177."263 new_action, new_state = parse_bill_action(line, state, bill_id, title)264 self.assertEqual(new_action['type'], "vote")265 self.assertEqual(new_action['vote_type'], "override")266 self.assertEqual(new_action['where'], "s")267 self.assertEqual(new_action["result"], "pass")268 self.assertEqual(new_action["how"], "roll")269 self.assertEqual(new_action["roll"], "177")270 # self.assertEqual(new_state, "VETOED:OVERRIDE_COMPLETE:SENATE")271 # Fictional bill, no constitutional amendment passed by both Houses272 # in the THOMAS era (1973-present).273 # The 26th was passed by Congress in 1971, 27th passed by Congress in 1789.274 # The line here is taken from hjres10-109, when the House passed a275 # flag burning amendment. (A separate version later failed the Senate by one vote.)276 def test_passed_constitutional_amendment(self):277 bill_id = "sjres64-1000"278 title = "Proposing an amendment to the Constitution of the United States authorizing the Congress to prohibit the physical desecration of the flag of the United States."279 state = "PASS_OVER:SENATE"280 line = "On passage Passed by the Yeas and Nays: (2/3 required): 286 - 130 (Roll no. 296)."281 new_action, new_state = parse_bill_action(line, state, bill_id, title)282 self.assertEqual(new_action['type'], "vote")283 self.assertEqual(new_action['vote_type'], "vote2")284 self.assertEqual(new_action['where'], "h")285 self.assertEqual(new_action["result"], "pass")286 self.assertEqual(new_action["how"], "roll")287 self.assertEqual(new_action["roll"], "296")288 self.assertEqual(new_state, "PASSED:CONSTAMEND")289 def test_passed_concurrent_resolution(self):290 bill_id = "hconres74-112"291 title = "Providing for a joint session of Congress to receive a message from the President."292 state = "PASS_OVER:HOUSE"293 line = "Received in the Senate, considered, and agreed to without amendment by Unanimous Consent."294 new_action, new_state = parse_bill_action(line, state, bill_id, title)295 self.assertEqual(new_action['type'], "vote")296 self.assertEqual(new_action['vote_type'], "vote2")297 self.assertEqual(new_action['where'], "s")298 self.assertEqual(new_action["result"], "pass")299 self.assertEqual(new_action["how"], "by Unanimous Consent")300 self.assertEqual(new_state, "PASSED:CONCURRENTRES")301 def test_passed_simple_resolution_house(self):302 bill_id = "hres9-112"303 title = "Instructing certain committees to report legislation replacing the job-killing health care law."304 state = "REPORTED"305 line = "On agreeing to the resolution, as amended Agreed to by the Yeas and Nays: 253 - 175 (Roll no. 16)."306 new_action, new_state = parse_bill_action(line, state, bill_id, title)307 self.assertEqual(new_action['type'], "vote")308 self.assertEqual(new_action['vote_type'], "vote")309 self.assertEqual(new_action['where'], "h")310 self.assertEqual(new_action["result"], "pass")311 self.assertEqual(new_action["how"], "roll")312 self.assertEqual(new_action['roll'], "16")313 self.assertEqual(new_state, "PASSED:SIMPLERES")314 def test_passed_simple_resolution_senate(self):315 bill_id = "sres484-112"316 title = "A resolution designating June 7, 2012, as \"National Hunger Awareness Day\"."317 state = "REPORTED"318 line = "Submitted in the Senate, considered, and agreed to without amendment and with a preamble by Unanimous Consent."319 new_action, new_state = parse_bill_action(line, state, bill_id, title)320 self.assertEqual(new_action['type'], "vote")321 self.assertEqual(new_action['vote_type'], "vote")322 self.assertEqual(new_action['where'], "s")323 self.assertEqual(new_action["result"], "pass")324 self.assertEqual(new_action["how"], "by Unanimous Consent")325 self.assertEqual(new_state, "PASSED:SIMPLERES")326 def test_failed_simple_resolution_senate(self):327 bill_id = "sres5-113"328 title = "A resolution amending the Standing Rules of the Senate to provide for cloture to be invoked with less than a three-fifths majority after additional debate."329 state = "INTRODUCED"330 line = "Disagreed to in Senate by Voice Vote."331 new_action, new_state = parse_bill_action(line, state, bill_id, title)332 self.assertEqual(new_action['type'], "vote")333 self.assertEqual(new_action['vote_type'], "vote")334 self.assertEqual(new_action['where'], "s")335 self.assertEqual(new_action["result"], "fail")336 self.assertEqual(new_action["how"], "by Voice Vote")337 self.assertEqual(new_state, "FAIL:ORIGINATING:SENATE")338 def test_failed_suspension_vote(self):339 bill_id = "hr1954-112"340 title = "To implement the President's request to increase the statutory limit on the public debt."341 state = "REFERRED"342 line = "On motion to suspend the rules and pass the bill Failed by the Yeas and Nays: (2/3 required): 97 - 318, 7 Present (Roll no. 379)."343 new_action, new_state = parse_bill_action(line, state, bill_id, title)344 self.assertEqual(new_action['type'], "vote")345 self.assertEqual(new_action['vote_type'], "vote")346 self.assertEqual(new_action['where'], "h")347 self.assertEqual(new_action["result"], "fail")348 self.assertEqual(new_action["how"], "roll")349 self.assertEqual(new_action['roll'], "379")350 self.assertEqual(new_state, "PROV_KILL:SUSPENSIONFAILED")351 def test_passed_by_special_rule(self):352 bill_id = "hres240-109"353 title = "Amending the Rules of the House of Representatives to reinstate certain provisions of the rules relating to procedures of the Committee on Standards of Official Conduct to the form in which those provisions existed at the close of the 108th Congress."354 state = "INTRODUCED"355 line = "Passed House pursuant to H. Res. 241."356 new_action, new_state = parse_bill_action(line, state, bill_id, title)357 self.assertEqual(new_action['type'], "vote")358 self.assertEqual(new_action['vote_type'], "vote")359 self.assertEqual(new_action['where'], "h")360 self.assertEqual(new_action["result"], "pass")361 self.assertEqual(new_action["how"], "by special rule")362 self.assertEqual(new_state, "PASSED:SIMPLERES")363 self.assertEqual(new_action['bill_ids'], ["hres241-109"])364 def test_referral_committee(self):365 bill_id = "hr547-113"366 title = "To provide for the establishment of a border protection strategy for the international land borders of the United States, to address the ecological and environmental impacts of border security infrastructure, measures, and activities along the international land borders of the United States, and for other purposes."367 state = "INTRODUCED"368 line = "Referred to the Committee on Homeland Security, and in addition to the Committees on Armed Services, Agriculture, and Natural Resources, for a period to be subsequently determined by the Speaker, in each case for consideration of such provisions as fall within the jurisdiction of the committee concerned."369 new_action, new_state = parse_bill_action(line, state, bill_id, title)370 self.assertEqual(new_action['type'], "referral")371 self.assertEqual(new_state, "REFERRED")372 def test_referral_subcommittee(self):373 bill_id = "hr547-113"374 title = "To provide for the establishment of a border protection strategy for the international land borders of the United States, to address the ecological and environmental impacts of border security infrastructure, measures, and activities along the international land borders of the United States, and for other purposes."375 state = "INTRODUCED"376 line = "Referred to the Subcommittee Indian and Alaska Native Affairs."377 new_action, new_state = parse_bill_action(line, state, bill_id, title)378 self.assertEqual(new_action['type'], "referral")379 self.assertEqual(new_state, "REFERRED")380 def test_hearings_held(self):381 bill_id = "s54-113"382 title = "A bill to increase public safety by punishing and deterring firearms trafficking."383 state = "REFERRED"384 line = "Committee on the Judiciary Subcommittee on the Constitution, Civil Rights and Human Rights. Hearings held."385 new_action, new_state = parse_bill_action(line, state, bill_id, title)386 self.assertEqual(new_action['type'], "hearings")387 # self.assertEqual(new_action['committees'], "Committee on the Judiciary Subcommittee on the Constitution, Civil Rights and Human Rights")...

Full Screen

Full Screen

test_dreamer_agent.py

Source:test_dreamer_agent.py Github

copy

Full Screen

1# import torch2#3# from dreamer.agents.atari_dreamer_agent import AtariDreamerAgent4# from rlpyt.envs.atari.atari_env import AtariEnv5#6# def test_exploration():7# # Test with a categorical variable and epsilon_greedy8#9# # No noise10# agent = AtariDreamerAgent(train_noise=0, eval_noise=0.5, expl_type="epsilon_greedy", expl_min=0)11# agent.initialize(AtariEnv().spaces)12# agent.sample_mode(0)13# action = torch.tensor([-1]) # Not a valid action, but it will let us check the action has been changed.14# new_action = agent.exploration(action)15# assert new_action.shape == action.shape16# assert new_action.item() == -117#18# # Decaying noise19# agent = AtariDreamerAgent(train_noise=1, eval_noise=0.5, expl_type="epsilon_greedy", expl_decay=5, expl_min=0)20# agent.initialize(AtariEnv().spaces)21# agent.sample_mode(0)22# action = torch.tensor([-1]) # Not a valid action, but it will let us check the action has been changed.23# new_action = agent.exploration(action)24# assert new_action.item() > -125#26# agent.sample_mode(10)27# new_action = agent.exploration(action) # We'd expect no exploration now28# assert new_action.item() == -129#30# agent = AtariDreamerAgent(train_noise=1, eval_noise=0.5, expl_type="epsilon_greedy", expl_decay=5, expl_min=1)31# agent.initialize(AtariEnv().spaces)32# agent.sample_mode(10)33# new_action = agent.exploration(action) # If expl_min is high, we expect high exploration even after many steps34# assert new_action.item() > -135#36# # Different modes37# agent = AtariDreamerAgent(train_noise=1, eval_noise=0, expl_type="epsilon_greedy", expl_min=0)38# agent.initialize(AtariEnv().spaces)39# agent.train_mode(0)40# new_action = agent.exploration(action)41# assert new_action.item() > -142#43# agent.eval_mode(0)44# new_action = agent.exploration(action)45# assert new_action.item() == -146#47# agent = AtariDreamerAgent(train_noise=0, eval_noise=1, expl_type="epsilon_greedy", expl_min=0)48# agent.initialize(AtariEnv().spaces)49# agent.train_mode(0)50# new_action = agent.exploration(action)51# assert new_action.item() == -152#53# agent.eval_mode(0)54# new_action = agent.exploration(action)55# assert new_action.item() > -156#57# # 0-dimensional action58# zero_dim_action = torch.tensor(-2)59# new_action = agent.exploration(zero_dim_action)60# assert new_action.shape == zero_dim_action.shape61# assert new_action.item() > -262#63# # Test with a continuous variable (completely random noise)64# agent = AtariDreamerAgent(train_noise=0.5, eval_noise=0, expl_type="completely_random", expl_min=0)65# agent.initialize(AtariEnv().spaces)66# agent.train_mode(0)67# action = torch.randn(100)68# new_action = agent.exploration(action)69# assert new_action.shape == action.shape70# assert torch.min(new_action).item() >= -171# assert torch.max(new_action).item() <= 172# assert not torch.all(torch.eq(new_action, action))73#74# agent = AtariDreamerAgent(train_noise=0, eval_noise=0, expl_type="completely_random", expl_min=0)75# agent.initialize(AtariEnv().spaces)76# agent.train_mode(0)77# new_action = agent.exploration(action)78# assert torch.all(torch.eq(new_action, action))79#80# # Test with a continuous variable (additive gaussian)81# agent = AtariDreamerAgent(train_noise=0, expl_type="additive_gaussian", expl_min=0)82# agent.initialize(AtariEnv().spaces)83# agent.train_mode(0)84# action = torch.rand(100)85# new_action = agent.exploration(action)86# assert new_action.shape == action.shape87# assert torch.all(torch.eq(new_action, action))88#89# agent = AtariDreamerAgent(train_noise=1, expl_type="additive_gaussian", expl_min=0)90# agent.initialize(AtariEnv().spaces)91# agent.train_mode(0)92# action = torch.randn(100)93# new_action = agent.exploration(action)94# assert not torch.all(torch.eq(new_action, action))95# assert torch.min(new_action).item() >= -196# assert torch.max(new_action).item() <= 1...

Full Screen

Full Screen

convertion_functions.py

Source:convertion_functions.py Github

copy

Full Screen

1def convert_form_to_type(fetched_elements, mandatory):2 return_elements = []3 for action in fetched_elements:4 if "form" in list(action.keys()) and action["form"] in ["nod", "shake"]:5 new_action = dict()6 for i in mandatory:7 new_action[i] = action[i]8 new_action["type"] = action["form"]9 else:10 new_action = dict()11 for i in mandatory:12 new_action[i] = action[i]13 return_elements.append(new_action)14 return return_elements15def fuse_stand(fetched_elements, mandatory):16 return_elements = []17 pattern = re.compile("stand_")18 for action in fetched_elements:19 if pattern.match(action["type"]):20 new_action = dict()21 for i in mandatory:22 new_action[i] = action[i]23 new_action["type"] = "stand_up"24 else:25 new_action = dict()26 for i in mandatory:27 new_action[i] = action[i]28 return_elements.append(new_action)29 return return_elements3031def fuse_point_object(fetched_elements, mandatory):32 return_elements = []33 pattern = re.compile("point_a")34 for action in fetched_elements:35 if pattern.match(action["type"]):36 new_action = dict()37 for i in mandatory:38 new_action[i] = action[i]39 new_action["type"] = "point_object"40 else:41 new_action = dict()42 for i in mandatory:43 new_action[i] = action[i]44 return_elements.append(new_action)45 return return_elements4647def fuse_point_person(fetched_elements, mandatory):48 return_elements = []49 pattern = re.compile("point_p")50 for action in fetched_elements:51 if pattern.match(action["type"]):52 new_action = dict()53 for i in mandatory:54 new_action[i] = action[i]55 new_action["type"] = "point_person"56 else:57 new_action = dict()58 for i in mandatory:59 new_action[i] = action[i]60 return_elements.append(new_action)61 return return_elements6263def fuse_focus_person(fetched_elements, mandatory):64 return_elements = []65 for action in fetched_elements:66 if action["type"] == "person":67 new_action = dict()68 for i in mandatory:69 new_action[i] = action[i]70 new_action["type"] = "look_at_person"71 else:72 new_action = dict()73 for i in mandatory:74 new_action[i] = action[i]75 return_elements.append(new_action)76 return return_elements7778def fuse_focus_object(fetched_elements, mandatory):79 return_elements = []80 for action in fetched_elements:81 if action["type"] == "place":82 new_action = dict()83 for i in mandatory:84 new_action[i] = action[i]85 new_action["type"] = "look_at_object"86 else:87 new_action = dict()88 for i in mandatory:89 new_action[i] = action[i]90 return_elements.append(new_action) ...

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