Best Python code snippet using ATX
C03P01_tests.py
Source:C03P01_tests.py
...27 def test_stringify_produces_correct_result_opened_interval_end(self):28 expected = '[1, 10)'29 self.assertEqual(expected, self.opened_interval_end.stringify())30 def test_is_inside_produces_correct_results_closed_interval(self):31 self.assertTrue(self.closed_interval.is_inside(self.start))32 self.assertTrue(self.closed_interval.is_inside(self.mid))33 self.assertTrue(self.closed_interval.is_inside(self.end))34 self.assertFalse(self.closed_interval.is_inside(self.start - 1))35 self.assertTrue(self.closed_interval.is_inside(self.start + 1))36 self.assertTrue(self.closed_interval.is_inside(self.end - 1))37 self.assertFalse(self.closed_interval.is_inside(self.end + 1))38 def test_is_inside_produces_correct_results_opened_interval(self):39 self.assertFalse(self.opened_interval.is_inside(self.start))40 self.assertTrue(self.opened_interval.is_inside(5))41 self.assertFalse(self.opened_interval.is_inside(self.end))42 self.assertFalse(self.opened_interval.is_inside(self.start - 1))43 self.assertTrue(self.opened_interval.is_inside(self.start + 1))44 self.assertTrue(self.opened_interval.is_inside(self.end - 1))45 self.assertFalse(self.opened_interval.is_inside(self.end + 1))46 def test_is_inside_produces_correct_results_opened_interval_start(self):47 self.assertFalse(self.opened_interval_start.is_inside(self.start))48 self.assertTrue(self.opened_interval_start.is_inside(self.mid))49 self.assertTrue(self.opened_interval_start.is_inside(self.end))50 self.assertFalse(self.opened_interval_start.is_inside(self.start - 1))51 self.assertTrue(self.opened_interval_start.is_inside(self.start + 1))52 self.assertTrue(self.opened_interval_start.is_inside(self.end - 1))53 self.assertFalse(self.opened_interval_start.is_inside(self.end + 1))54 def test_is_inside_produces_correct_results_opened_interval_end(self):55 self.assertTrue(self.opened_interval_end.is_inside(self.start))56 self.assertTrue(self.opened_interval_end.is_inside(self.mid))57 self.assertFalse(self.opened_interval_end.is_inside(self.end))58 self.assertFalse(self.opened_interval_end.is_inside(self.start - 1))59 self.assertTrue(self.opened_interval_end.is_inside(self.start + 1))60 self.assertTrue(self.opened_interval_end.is_inside(self.end - 1))61 self.assertFalse(self.opened_interval_end.is_inside(self.end + 1))62 def test_text_output_str_repr(self):63 expected = '[[1, 10], (1, 10), (1, 10], [1, 10)]'64 resulted = [result for result in self.test_instances_list]65 self.assertEqual(expected, str(resulted))66if __name__ == '__main__':67 unittest.main()68# closed_interval = Interval(1, 10)69#70# print(closed_interval.is_inside(1) is True)71# print(closed_interval.is_inside(5) is True)72# print(closed_interval.is_inside(10) is True)73#74# print(closed_interval.stringify() == '[1, 10]')75#76#77# closed_interval = Interval(1, 10, start_opened=True, end_opened=True)78#79# print(closed_interval.is_inside(1) is False)80# print(closed_interval.is_inside(5) is True)81# print(closed_interval.is_inside(10) is False)82#83# print(closed_interval.stringify() == '(1, 10)')84#85# half_opened_interval = Interval(1, 10, start_opened=False, end_opened=True)86#87# print(half_opened_interval.is_inside(1) is True)88# print(half_opened_interval.is_inside(5) is True)89# print(half_opened_interval.is_inside(10) is False)90#91# print(half_opened_interval.stringify() == '[1, 10)')92#93# half_opened_interval = Interval(1, 10, start_opened=True, end_opened=False)94#95# print(half_opened_interval.is_inside(1) is False)96# print(half_opened_interval.is_inside(5) is True)97# print(half_opened_interval.is_inside(10) is True)98#...
test_room_is_insided.py
Source:test_room_is_insided.py
1import numpy as np2import pyroomacoustics as pra3def test_room_is_inside():4 # fix the seed for repeatable testing5 np.random.seed(0)6 # This was a problematic case7 # if the source is placed at the same height as one of the corners8 # the test would fail, even though the source is in the room9 floorplan = [ [0, 6, 6, 2, 0],10 [0, 0, 5, 5, 3] ]11 source_loc = [ 2, 3 ] # same y-coordinate as the corner at [0, 3]12 room = pra.Room.from_corners(floorplan)13 room.add_source(source_loc)14 for i in range(100):15 # because the test is randomized, let's check many times16 assert room.is_inside([0,0], include_borders=True)17 assert not room.is_inside([0,0], include_borders=False)18 assert room.is_inside([3,0], include_borders=True)19 assert not room.is_inside([3,0], include_borders=False)20 assert room.is_inside([1,4], include_borders=True)21 assert not room.is_inside([1,4], include_borders=False)22 assert room.is_inside([0,1], include_borders=True)23 assert not room.is_inside([0,1], include_borders=False)24 assert not room.is_inside([0.5,4], include_borders=False)25 # now test in 3D26 room.extrude(4.)27 for i in range(100):28 # because the test is randomized, let's check many times29 assert room.is_inside([2, 3, 1.7])30 assert not room.is_inside([0.5, 4, 1.8])31 assert not room.is_inside([0.5, 4, 1.8])32 assert room.is_inside([0,0,0], include_borders=True)33 assert not room.is_inside([0,0,0], include_borders=False)34 assert room.is_inside([3,0,0], include_borders=True)35 assert not room.is_inside([3,0,0], include_borders=False)36 assert room.is_inside([0,1,0], include_borders=True)37 assert not room.is_inside([0,1,0], include_borders=False)38 assert room.is_inside([3,2,0], include_borders=True)39 assert not room.is_inside([3,2,0], include_borders=False)40 assert room.is_inside([1,4,3], include_borders=True)41 assert not room.is_inside([1,4,3], include_borders=False)42 assert not room.is_inside([2,2,7])43 assert not room.is_inside([2,2,-7])44if __name__ == '__main__':...
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!!