Best Python code snippet using hypothesis
planetarium.py
Source:planetarium.py  
...69                             elem['adjust']['move_index'][1],70                             ['shiitake', elem['adjust']['target'], 'surface'],71                             elem['adjust']['target_index'][0],72                             elem['adjust']['target_index'][1])73        pc.end_group()74    pc.translate([50, 50])75    pc.end_group()76    x = 077    for key in pipe.keys():78        for i in range(pipe[key]):79            pc.begin_group('pipe_' + str(key) + '_' + str(i), svg_group=True)80            pc.rect([0, 0], [4, key], fill='black', stroke='darkgray')81            pc.rect([4, 0], [8, key], fill='black', stroke='darkgray')82            pc.rect([8, 0], [12, key], fill='black', stroke='darkgray')83            pc.rect([12, 0], [16, key], fill='black', stroke='darkgray')84            pc.glue(['rect0'], 3, 0, root='active')85            pc.translate([x, 110])86            pc.end_group()87            x += 2588    for key in angle.keys():89        for i in range(angle[key]):90            pc.begin_group('angle_' + str(key) + '_' + str(i), svg_group=True)91            pc.rect([0, 0], [4, key], fill='black', stroke='darkgray')92            pc.rect([4, 0], [8, key], fill='black', stroke='darkgray')93            pc.rect([8, 0], [12, key], fill='black', stroke='darkgray')94            pc.rect([12, 0], [16, key], fill='black', stroke='darkgray')95            pc.translate([x, 110])96            pc.end_group()97            x += 2598    for i in range(8):99        pc.begin_group("plate" + str(i), svg_group=True)100        pc.polygon([[0, 0], [12, 0], [0, 12]], loop=True, fill='lightgray')101        pc.polygon([[0, 0], [0, -12], [12, 0]], loop=True, fill='lightgray')102        pc.circle([2, 2], 0.3, object_type='texture', fill='none')103        pc.circle([2, 6], 0.3, object_type='texture', fill='none')104        pc.circle([2, 8], 0.3, object_type='texture', fill='none')105        pc.circle([8, 2], 0.3, object_type='texture', fill='none')106        pc.circle([2, -2], 0.3, object_type='texture', fill='none')107        pc.circle([2, -6], 0.3, object_type='texture', fill='none')108        pc.circle([2, -8], 0.3, object_type='texture', fill='none')109        pc.circle([8, -2], 0.3, object_type='texture', fill='none')110        pc.translate([100 + i * 20, 15])111        pc.end_group()112    for i in range(2):113        pc.begin_group("latitude_gearbox_channel" + str(i), svg_group=True)114        pc.rect([0, 0], [5, 35], fill='lightgray')115        pc.rect([5, 0], [15, 35], fill='lightgray')116        pc.rect([15, 0], [20, 35], fill='lightgray')117        pc.rect([20, 0], [25, 35], fill='lightgray')118        pc.rect([25, 0], [35, 35], fill='lightgray')119        pc.rect([35, 0], [40, 35], fill='lightgray')120        pc.begin_group("final_bearing_unit" + str(i))121        pc.rect([-1, -3.5], [1, 3.5], stroke='none', fill='gray', object_type='texture')122        pc.circle([0, 3.5], 1, stroke='none', fill='gray', object_type='texture')123        pc.circle([0, -3.5], 1, stroke='none', fill='gray', object_type='texture')124        pc.circle([0, 3.5], 0.3, fill='none', object_type='texture')125        pc.circle([0, -3.5], 0.3, fill='none', object_type='texture')126        pc.circle([0, 0], 2.75, stroke='none', fill='gray', object_type='texture')127        pc.circle([0, 0], 2, stroke='none', fill='black', object_type='texture')128        pc.circle([0, 0], 1, fill='white', object_type='texture')129        pc.circle([20, 0], 1, fill='white', object_type='texture')130        pc.translate([10, 30])131        pc.end_group()132        small_bearing_pos = [[10, 15], [10, 20]]133        for j in range(2):134            pc.begin_group("small_bearing_unit" + str(i) + "_" + str(j))135            pc.rect([-2.25, -0.75], [2.25, 0.75], stroke='none', fill='gray', object_type='texture')136            pc.circle([2.25, 0], 0.75, stroke='none', fill='gray', object_type='texture')137            pc.circle([-2.25, 0], 0.75, stroke='none', fill='gray', object_type='texture')138            pc.circle([2.25, 0], 0.3, fill='none', object_type='texture')139            pc.circle([-2.25, 0], 0.3, fill='none', object_type='texture')140            pc.circle([0, 0], 1.8, stroke='none', fill='gray', object_type='texture')141            pc.circle([0, 0], 1.2, stroke='none', fill='black', object_type='texture')142            pc.circle([0, 0], 0.5, fill='gray', object_type='texture')143            pc.circle([20, 0], 0.5, fill='gray', object_type='texture')144            pc.translate(small_bearing_pos[j])145            pc.end_group()146        pc.translate([100 + i * 50, 30])147        pc.end_group()148        pc.begin_group("latitude_gearbox_plate" + str(i), svg_group=True)149        pc.rect([0, 0], [20, 24], fill='lightgray')150        pc.begin_group("small_bearing_unit" + str(i))151        pc.rect([-2.25, -0.75], [2.25, 0.75], stroke='none', fill='gray', object_type='texture')152        pc.circle([2.25, 0], 0.75, stroke='none', fill='gray', object_type='texture')153        pc.circle([-2.25, 0], 0.75, stroke='none', fill='gray', object_type='texture')154        pc.circle([2.25, 0], 0.3, fill='none', object_type='texture')155        pc.circle([-2.25, 0], 0.3, fill='none', object_type='texture')156        pc.circle([0, 0], 1.8, stroke='none', fill='gray', object_type='texture')157        pc.circle([0, 0], 1.2, stroke='none', fill='black', object_type='texture')158        pc.circle([0, 0], 0.5, fill='gray', object_type='texture')159        pc.translate([10, 10])160        pc.end_group()161        pc.translate([100 + i * 50, 70])162        pc.end_group()163        for j in range(2):164            pc.begin_group("latitude_bearing" + str(i) + "_" + str(j), svg_group=True)165            pc.rect([-2.5, 0], [2.5, 2.5], fill='black', stroke='darkgray')166            pc.circle([0, 2.5], 2.5, fill='lightgray')167            pc.circle([0, 2.5], 2.2, fill='black', object_type='texture', stroke='none')168            pc.circle([0, 2.5], 1.5, fill='darkgray', object_type='texture', stroke='none')169            pc.circle([0, 2.5], 1, fill='white', object_type='texture')170            pc.glue(['rect0'], 0, 1, width=2, root='active')171            pc.translate([30, 250])172            pc.end_group()173        pc.begin_group("latitude_bearing_side" + str(i), svg_group=True)174        pc.rect([-(1.25 * math.pi + 2.5), -1.6], [1.25 * math.pi + 2.5, 1.6], fill='lightgray')175        pc.glue(['rect0'], 0, 1, root='active', max_length=1.5, angle0=math.pi/3, angle1=math.pi/3)176        pc.glue(['rect0'], 2, 3, root='active', max_length=1.5, angle0=math.pi/3, angle1=math.pi/3)177        pc.begin_group()178        pc.rect([0, -1.6], [2.5, 1.6], fill='lightgray')179        pc.circle([1.3, 0], 0.3, fill='lightgray', object_type='texture')180        pc.adjust_points(['rect0'], 0, 3, ['latitude_bearing_side' + str(i), 'rect0'], 1, 2)181        pc.end_group()182        pc.begin_group()183        pc.rect([0, -1.6], [2.5, 1.6], fill='lightgray')184        pc.circle([1.3, 0], 0.3, fill='lightgray', object_type='texture')185        pc.adjust_points(['rect0'], 0, 3, ['latitude_bearing_side' + str(i), 'rect0'], 3, 0)186        pc.end_group()187        pc.end_group()188    for i in range(2):189        pc.begin_group("latitude_final_gear" + str(i), svg_group=True)190        pc.circle([0, 0], 8.25, fill='brown')191        pc.circle([0, 0], 1, fill='white', object_type='texture')192        pc.end_group()193    pc.begin_group("latitude_final_gear_side", svg_group=True)194    pc.rect([0, 0], [16.5 * math.pi, 2], fill='brown')195    for i in range(64):196        pc.polygon([[16.5 * math.pi / 64 * i, 0], [16.5 * math.pi / 64 * i, 2]], fill='none', object_type='texture')197    pc.glue(['rect0'], 0, 1, max_length=2, root='active', angle0=math.pi/3, angle1=math.pi/3)198    pc.glue(['rect0'], 2, 3, max_length=2, root='active', angle0=math.pi/3, angle1=math.pi/3)199    pc.glue(['rect0'], 1, 2, root='active', angle0=math.pi/2, angle1=math.pi/2, width=2)200    pc.end_group()201    for i in range(2):202        pc.begin_group("nisshu_final_gear" + str(i), svg_group=True)203        pc.circle([0, 0], 10.2, fill='dimgray')204        pc.circle([0, 0], 8, fill='white', object_type='texture')205        pc.translate([30 + 30 * i, 30])206        pc.end_group()207    pc.begin_group("nisshu_final_gear_side", svg_group=True)208    pc.rect([0, 0], [20.4 * math.pi, 1.5], fill='dimgray')209    for i in range(100):210        pc.polygon([[20.4 * math.pi / 100 * i, 0], [20.4 * math.pi / 100 * i, 1.5]], fill='none', object_type='texture')211    pc.glue(['rect0'], 0, 1, max_length=2, root='active', angle0=math.pi/3, angle1=math.pi/3)212    pc.glue(['rect0'], 2, 3, max_length=2, root='active', angle0=math.pi/3, angle1=math.pi/3)213    pc.glue(['rect0'], 1, 2, root='active', angle0=math.pi/2, angle1=math.pi/2, width=2)214    pc.end_group()215    pc.begin_group("nisshu_gearbox", svg_group=True)216    for i in range(2):217        pc.begin_group()218        pc.polygon([[0, 0], [9, 0], [16, 13.5], [16, 16.5], [9, 30], [0, 30], [7, 16.5], [7, 13.5]], loop=True, fill='black', stroke='darkgray')219        pc.rect([0, 30], [9, 39], fill='black', stroke='darkgray')220        pc.translate([0, 39 * i])221        pc.end_group()222    pc.glue(['group0', 'polygon0'], 0, 1, root='active')223    pc.end_group()224    for i in range(2):225        sign = 1 if i == 0 else -1226        pc.begin_group("nisshu_gearbox_plate" + str(i), svg_group=True)227        pc.polygon([[0, 0], [sign * 10, 0], [sign * 17, 13.5], [sign * 7, 13.5]], loop=True, fill='black', stroke='darkgray')228        pc.translate([10 + i * 30, 100])229        pc.end_group()230        pc.begin_group("nisshu_gearbox_support_pipe" + str(i), svg_group=True)231        for j in range(4):232            pc.rect([j * 3, 0], [(j + 1) * 3, 8], fill='black', stroke='darkgray')233        pc.glue(['rect0'], 3, 0, root='active', width=2)234        pc.end_group()235    pc.begin_group("nisshu_motor_mount", svg_group=True)236    pc.rect([0, 0], [9, 2], fill='black', stroke='darkgray')237    pc.rect([0, 2], [9, 11], fill='black', stroke='darkgray')238    pc.rect([0, 11], [9, 13], fill='black', stroke='darkgray')239    pc.rect([1.5, 3.5], [7.5, 9.5], fill='white', object_type='texture')240    pc.end_group()241    for i in range(2):242        pc.begin_group("motor" + str(i), svg_group=True)243        pc.rect([0, 0], [6, -6], fill='lightgray', stroke='black')244        pc.circle([3, -3], 2.5, fill='darkgray', stroke='none', object_type='texture')245        for j in range(4):246            pc.begin_group("side_surface" + str(j))247            pc.rect([j * 6, 0], [(j + 1) * 6, 10], fill='black', stroke='darkgray')248            pc.rect([j * 6, 0], [(j + 1) * 6, 1], fill='lightgray', stroke='none')249            pc.rect([j * 6, 9.5], [(j + 1) * 6, 10], fill='lightgray', stroke='none')250            pc.end_group()251            pc.glue(['side_surface' + str(j), 'rect0'], 2, 3, root='active')252        pc.glue(['rect0'], 0, 1, root='active')253        pc.glue(['rect0'], 1, 2, root='active')254        pc.glue(['rect0'], 3, 0, root='active')255        pc.glue(['side_surface0', 'rect0'], 3, 0, root='active')256        pc.translate([100, 80])257        pc.end_group()258    pc.begin_group("shiitake_base_polygon", svg_group=True)259    pentagon_side = math.sqrt(10**2 + 20**2 + 2 * 10 * 20 * math.cos(math.pi / 5))260    r = pentagon_side / 2.0 / math.sin(math.pi / 5)261    half_angle = math.asin(10 / r)262    vertex_list = []263    for i in range(5):264        vertex_list.append(np.array([r * math.cos(i * 2 * math.pi / 5 - half_angle),265                                     r * math.sin(i * 2 * math.pi / 5 - half_angle)]))266        vertex_list.append(np.array([r * math.cos(i * 2 * math.pi / 5 + half_angle),267                                     r * math.sin(i * 2 * math.pi / 5 + half_angle)]))268    pc.polygon(vertex_list, fill='lightgray', loop=True)269    pc.rect([-21.5, -6], [21.5, -4], fill='white', object_type='texture')270    pc.rect([-21.5, 6], [21.5, 4], fill='white', object_type='texture')271    pc.rect([6, -21.5], [4, 21.5], fill='white', object_type='texture')272    pc.rect([-6, -21.5], [-4, 21.5], fill='white', object_type='texture')273    pc.circle([0, 0], 20, fill='white', object_type='texture')274    pc.translate([170, 120])275    pc.end_group()276    pc.begin_group("kago_outer_plate_top", svg_group=True)277    for i in range(4):278        pc.begin_group()279        pc.rect([-8, -21.5], [8, -19], fill='lightgray')280        pc.rotate(i * math.pi / 2)281        pc.end_group()282    for i in range(4):283        pc.begin_group()284        pc.rect([-10, -22], [10, -18], fill='lightgray')285        pc.rotate(i * math.pi / 2 + math.pi / 4)286        pc.end_group()287    pc.translate([150, 270])288    pc.end_group()289    pc.begin_group("kago_outer_plate_back", svg_group=True)290    for i in range(4):291        pc.begin_group()292        pc.rect([-10, -22], [10, -18], fill='lightgray')293        pc.rotate(i * math.pi / 2 + math.pi / 4)294        pc.end_group()295    for i in range(4):296        pc.begin_group()297        pc.rect([-8, -21.5], [8, -19], fill='lightgray')298        pc.rotate(i * math.pi / 2)299        pc.end_group()300    pc.translate([100, 270])301    pc.end_group()302    for i in range(4):303        pc.begin_group("shiitake_base_bar" + str(i), svg_group=True)304        pc.rect([0, -21.5], [2, 21.5], fill='lightgray')305        pc.rect([0, -21.5], [-2, 21.5], fill='lightgray')306        pc.rect([0, -6], [2, -10], fill='white', object_type='texture')307        pc.rect([0, 6], [2, 10], fill='white', object_type='texture')308        sign = -1 if i % 2 else 1309        pc.rect([0, -4], [sign * 2, -6], fill='white', object_type='texture')310        pc.rect([0, 4], [sign * 2, 6], fill='white', object_type='texture')311        pc.translate([170 + i * 6, 200])312        pc.end_group()313        pc.begin_group("kago_base_angle" + str(i), svg_group=True)314        pc.rect([0, -21.5], [2, 21.5], fill='lightgray')315        pc.rect([2, -21.5], [4, 21.5], fill='lightgray')316        pc.rect([0, -21.5], [-2, 21.5], fill='lightgray')317        pc.rect([-2, -21.5], [-4, 21.5], fill='lightgray')318        pc.rect([-4, -4], [-2, -6], fill='white', object_type='texture')319        pc.rect([-4, 4], [-2, 6], fill='white', object_type='texture')320        pc.translate([170 + i * 10, 250])321        pc.end_group()322        pc.begin_group("kago_angle" + str(i), svg_group=True)323        pc.rect([0, 0], [2, 18], fill='lightgray')324        pc.rect([2, 0], [4, 18], fill='lightgray')325        pc.rect([0, 0], [-2, 18], fill='lightgray')326        pc.rect([-2, 0], [-4, 18], fill='lightgray')327        pc.rect([0, 0], [-2, -4], fill='lightgray')328        pc.rect([0, 0], [2, -4], fill='lightgray')329        pc.translate([10 + i * 10, 100])330        pc.end_group()331    for i in range(2):332        pc.begin_group("kago_channel" + str(i), svg_group=True)333        pc.polygon([[-6, -6], [-4.3, -6], [6, 4.3], [6, 6], [4.3, 6], [-6, -4.3]],334                   fill='lightgray', loop=True)335        pc.begin_group("side_plate0")336        pc.rect([-7, 0], [7, 2.5], fill='lightgray')337        pc.adjust_points(['rect0'], 0, 1,338                         ['kago_channel' + str(i), 'polygon0'], 2, 1)339        pc.end_group()340        pc.begin_group("side_plate1")341        pc.rect([-7, 0], [7, 2.5], fill='lightgray')342        pc.adjust_points(['rect0'], 0, 1,343                         ['kago_channel' + str(i), 'polygon0'], 5, 4)344        pc.end_group()345        pc.circle([-3.75, -3.75], 0.7, fill='white', object_type='texture')346        pc.circle([3.75, 3.75], 0.7, fill='white', object_type='texture')347        pc.translate([50 + 20 * i, 150])348        pc.end_group()349    pc.begin_group("kago_base_connector", svg_group=True)350    pc.rect([-6, -6], [6, 6], fill='lightgray')351    for i in range(4):352        pc.begin_group()353        pc.rect([-6, 6], [6, 8], fill='lightgray')354        pc.rotate(i * math.pi / 2)355        pc.end_group()356    pc.rect([-4, -4], [4, 4], fill='white', object_type='texture')357    pc.end_group()358    for i in range(4):359        pc.begin_group("zungiri" + str(i), svg_group=True)360        pc.rect([0, 0], [5, 36], fill='darkgray')361        for j in np.arange(0, 36, 0.2):362            pc.polygon([[0, j], [5, j]], fill='none', object_type='texture')363        pc.translate([150 + i * 10, 150])364        pc.end_group()365    for i in range(2):366        pc.begin_group("nisshu_center_pipe" + str(i), svg_group=True)367        pc.rect([0, 0], [3, 50], fill='darkslategray')368        pc.rect([3, 0], [6, 50], fill='darkslategray')369        pc.rect([6, 0], [9, 50], fill='darkslategray')370        pc.rect([9, 0], [12, 50], fill='darkslategray')371        pc.glue(['rect0'], 3, 0, root='active', width=2)372        pc.translate([10 + i * 20, 10])373        pc.end_group()374        pc.begin_group("nisshu_square_pipe" + str(i), svg_group=True)375        pc.rect([0, 0], [3, 30], fill='darkslategray')376        pc.rect([3, 0], [6, 30], fill='darkslategray')377        pc.rect([6, 0], [9, 30], fill='darkslategray')378        pc.rect([9, 0], [12, 30], fill='darkslategray')379        pc.glue(['rect0'], 3, 0, root='active', width=2)380        pc.translate([120 + i * 20, 10])381        pc.end_group()382        pc.begin_group("nisshu_channel" + str(i), svg_group=True)383        pc.rect([0, 0], [3, 116], fill='darkslategray')384        pc.rect([3, 0], [6, 116], fill='darkslategray')385        pc.rect([6, 0], [9, 116], fill='darkslategray')386        pc.translate([230 + i * 20, 10])387        pc.end_group()388    for i in range(8):389        pc.begin_group("nisshu_slant_pipe" + str(i), svg_group=True)390        pc.polygon([[0, 0], [3, 1.2], [3, 14.4 + 1.2], [0, 14.4]], loop=True, fill='darkslategray')391        pc.rect([3, 1.2], [6, 14.4 + 1.2], fill='darkslategray')392        pc.polygon([[6, 1.2], [9, 0], [9, 14.4], [6, 14.4 + 1.2]], loop=True, fill='darkslategray')393        pc.rect([9, 0], [12, 14.4], fill='darkslategray')394        pc.glue(['polygon0'], 3, 0, root='active', width=2)395        pc.translate([10 + i * 20, 60])396        pc.end_group()397        pc.begin_group("nisshu_axis_mount_pipe" + str(i), svg_group=True)398        for j in range(4):399            pc.rect([j * 3, 0], [(j + 1) * 3, 24], fill='black', stroke='darkgray')400            pc.glue(['rect' + str(j)], 0, 1, root='active')401        pc.glue(['rect0'], 3, 0, root='active', width=2)402        pc.translate([120 + i * 20, 60])403        pc.end_group()404    for i in range(2):405        pc.begin_group("nisshu_turntable_inner" + str(i), svg_group=True)406        pc.circle([0, 0], 9, fill='black', stroke='lightgray')407        pc.circle([0, 0], 2, fill='white', object_type='texture')408        for j in range(4):409            pc.begin_group()410            pc.circle([3.75, 3.75], 0.7, fill='white', object_type='texture')411            pc.rotate(j * math.pi / 2)412            pc.end_group()413        pc.end_group()414        pc.begin_group("nisshu_turntable_outer" + str(i), svg_group=True)415        pc.circle([0, 0], 12, fill='lightgray')416        pc.circle([0, 0], 8, fill='white')417        pc.end_group()418        pc.begin_group("nisshu_turntable_axis_outer" + str(i), svg_group=True)419        pc.rect([0, 0], [math.pi * 16, 1.5])420        pc.glue(['rect0'], 0, 1, root='active', max_length=1.5)421        pc.end_group()422        pc.begin_group("nisshu_slip_ring" + str(i), svg_group=True)423        pc.circle([0, 0], 13, fill='white', stroke='lightgray')424        pc.circle([0, 0], 11.5, fill='black', stroke='none', object_type='texture')425        pc.circle([0, 0], 8, fill='white', stroke='none', object_type='texture')426        pc.circle([0, 0], 2, fill='white', object_type='texture')427        for j in range(4):428            pc.begin_group()429            pc.circle([3.75, 3.75], 0.7, fill='white', object_type='texture')430            pc.rotate(j * math.pi / 2)431            pc.end_group()432        pc.end_group()433    pc.begin_group("nisshu_turntable_axis_inner", svg_group=True)434    pc.rect([0, 0], [math.pi * 16, 6])435    pc.glue(['rect0'], 0, 1, root='active', max_length=1.5)436    pc.glue(['rect0'], 2, 3, root='active', max_length=1.5)437    pc.end_group()438    for i in range(4):439        pc.begin_group("nisshu_spacer" + str(i), svg_group=True)440        for j in range(3):441            pc.rect([j * 1.5, 0], [(j + 1) * 1.5, 3], fill='gray')442            pc.glue(['rect' + str(j)], 2, 3, root='active')443        pc.glue(['rect0'], 3, 0, root='active', width=1.5)444        pc.translate([150 + i * 10 , 100])445        pc.end_group()446        pc.begin_group("nisshu_center_connect_plate" + str(i), svg_group=True)447        pc.polygon([[0, -3], [3, -3], [7, -1.5], [7, 1.5], [3, 3], [0, 3]], fill='darkslategray', loop=True)448        pc.end_group()449        pc.begin_group("nisshu_side_connect_plate" + str(i), svg_group=True)450        pc.polygon([[0, -1.5], [1.3, -5], [10, -5], [10, 5], [1.3, 5], [0, 1.5]], fill='darkslategray', loop=True)451        pc.end_group()452    pc.begin_group("latitude_axis0", svg_group=True)453    pc.rect([0, 0], [2 * math.pi, 60], fill='dimgray')454    for i in range(1, 60):455        pc.rect([0, i - 0.25], [2 * math.pi, i + 0.25], fill='none', stroke='black', object_type='texture')456    pc.glue(['rect0'], 3, 0, root='active', width=2)457    pc.end_group()458    pc.begin_group("latitude_axis1", svg_group=True)459    pc.rect([0, 0], [2 * math.pi, 73], fill='dimgray')460    for i in range(1, 73):461        pc.rect([0, i - 0.25], [2 * math.pi, i + 0.25], fill='none', stroke='black', object_type='texture')462    pc.glue(['rect0'], 3, 0, root='active', width=2)463    pc.end_group()464    #fixedstar_projector465    for i in range(32):466        pc.begin_group("fixedstar_side" + str(i), svg_group=True)467        pc.rect([0, 0], [8 * math.pi, 16.3], fill='lightgray')468        pc.glue(['rect0'], 3, 0, root='active')469        for j in range(10):470            pc.polygon([[0, 3 + j * 0.5], [8 * math.pi, 3 + j * 0.5]], fill='none', stroke='gray', object_type='texture')471        pc.polygon([[0, 11.3], [8 * math.pi, 11.3]], fill='none', stroke='gray', object_type='texture')472        pc.glue(['rect0'], 0, 1, max_length=2, angle0=math.pi/3, angle1=math.pi/3, root='active')473        pc.glue(['rect0'], 2, 3, max_length=2, angle0=math.pi/3, angle1=math.pi/3, root='active')474        pc.translate([10 + i * 30, 150])475        pc.end_group()476        pc.begin_group("fixedstar_top" + str(i), svg_group=True)477        pc.circle([0, 0], 4, fill='lightgray')478        pc.circle([0, 0], 1.75, fill='black', object_type='texture', stroke='white')479        pc.translate([10 + i * 10, 220])480        pc.end_group()481        pc.begin_group("fixedstar_bottom" + str(i), svg_group=True)482        pc.circle([0, 0], 4, fill='lightgray')483        pc.translate([10 + i * 10, 230])484        pc.end_group()485        for j in range(3):486            pc.begin_group("fixedstar_mount" + str(i) + "_" + str(j), svg_group=True)487            for k in range(3):488                pc.rect([k * 1.5, 0], [(k + 1) * 1.5, 5], fill='lightgray')489                pc.glue(['rect' + str(k)], 2, 3, root='active', angle0=math.pi/3, angle1=math.pi/3)490            pc.glue(['rect0'], 3, 0, root='active', width=1)491            pc.translate([10 + (i * 3 + j) * 6, 250])492            pc.end_group()493        pc.begin_group("triangle_plate" + str(i), svg_group=True)494        pc.regular_polygon(3, side=10, fill='lightgray')495        for j in range(3):496            pc.begin_group()497            pc.rect([2, -0.75], [6, 0.75], fill='lightgray')498            pc.rect([6, -0.75], [10, 0.75], fill='lightgray')499            pc.begin_group("hoseband")500            pc.rect([-0.5, -2.75],[0.5, 2.75], fill='darkgray')501            pc.polygon([[-0.5, -2.75], [-0.75, -3.75], [0.75, -3.75], [0.5, -2.75]], fill='orange', loop=True)502            pc.polygon([[-0.5, 2.75], [-0.75, 3.75], [0.75, 3.75], [0.5, 2.75]], fill='orange')503            pc.translate([7.5, 0])504            pc.end_group()505            pc.rotate(j * 2 * math.pi / 3)506            pc.end_group()507        pc.translate([10 + i * 20, 200])508        pc.end_group()...test_groups.py
Source:test_groups.py  
1from a1d05eba1.content_variations import build_content2def cc1():3    return build_content({4        'schema': '2',5        'survey': [6            {'type': 'begin_group',7             '$anchor': 'g1'},8            {'type': 'begin_group',9             '$anchor': 'g2'},10            {'type': 'begin_group',11             '$anchor': 'g3'},12            {'type': 'text',13            '$anchor': 't1'},14            {'type': 'end_group',15             '$anchor': '/g3'},16            {'type': 'end_group',17             '$anchor': '/g2'},18            {'type': 'end_group',19             '$anchor': '/g1'},20        ],21        'choices': {},22        'translations': [{'$anchor': 'tx0', 'name': ''}],23    })24def cc9():25    return build_content({26        'schema': '2',27        'survey': [28            {'type': 'group',29             '$anchor': 'g1',30             'rows': [31                {'type': 'group',32                 '$anchor': 'g2',33                 'rows': [34                    {'type': 'group',35                     '$anchor': 'g3',36                     'rows': [37                        {'type': 'text',38                        '$anchor': 't1'},39                     ],40                    },41                 ],42                },43             ],44            },45        ],46        'translations': [{'name': '', '$anchor': 'tx0'}]47    })48def test_surv_equiv_transforms():49    for cc in [cc1(), cc9()]:50        [row0, row1, row2, row3, row4, row5, row6] = list(cc.survey._tuple)51        assert row0._parent == cc.survey52        assert row1._parent == row053        assert row2._parent == row154        assert row3._parent == row255        assert row4._parent == row256        assert row5._parent == row157        assert row6._parent == row058        assert row4.flat_export() == {'$anchor': '/g3', 'type': 'end_group'}59        [row0] = cc.survey.rows60        assert row0.type == 'group'61        result = cc.export(schema='2', flat=True)62        assert len(result['survey']) == 763        tanks = cc.export(schema='1', flat=True)64        typs = cc._tanchors(schema='1', flat=True, key='type')65        assert typs == ['begin_group',66                        'begin_group',67                        'begin_group',68                        'text',69                        'end_group',70                        'end_group',71                        'end_group']72        zz = cc.export(schema='2', flat=False)73        assert len(cc.survey[0].rows) == 2 # g1, /g174        assert len(cc.survey[1].rows) == 2 # g2, /g275        assert len(cc.survey[2].rows) == 2 # g3, /g376        tanks2 = cc._tanchors(schema='2', flat=False)77        assert tanks2 == ['g1', 'g1.g2', 'g1.g2.g3', 'g1.g2.g3.t1']78        types = cc._tanchors(schema='2', flat=False, key='type')79        assert types == ['group',80                         'group.group',81                         'group.group.group',82                         'group.group.group.text']83        types = cc._tanchors(schema='2', flat=True, key='type')84        assert types == ['begin_group',85                         'begin_group',86                         'begin_group',87                         'text',88                         'end_group',89                         'end_group',90                         'end_group']91from pprint import pprint92from a1d05eba1.build_schema import MAIN_JSONSCHEMA93from jsonschema import validate94def test_odd_group_tree():95    cc = build_content({96        'schema': '2',97        'survey': [98            {'type': 'group',99             '$anchor': 'g1',100             'rows': [101                {'type': 'group',102                 '$anchor': 'g2',103                 'rows': [104                    {'type': 'text',105                    '$anchor': 'g2t1'},106                 ],107                },108                {'type': 'group',109                 '$anchor': 'g3',110                 'rows': [111                    {'type': 'text',112                    '$anchor': 'g3t1'},113                    {'type': 'integer',114                    '$anchor': 'g3t2'},115                    {'type': 'image',116                    '$anchor': 'g3t3'},117                 ],118                },119             ],120            },121        ],122        'translations': [{'name': '', '$anchor': 'tx0'}]123    })124    result = cc.export(schema='2', flat=False)125    validate(result, MAIN_JSONSCHEMA)126def test_repeats_with_repeat_count():127    cc = build_content({'choices': {},128                  'schema': '2',129                  'settings': {},130                  'metas': {},131                  'survey': [{'type': 'repeat',132                              '$anchor': 'rr',133                              'repeat_count': 2,134                              'label': {'tx0': 'tt'},135                              'name': 'rr',136                              'rows': [137                                {'$anchor': 't1', 'name': 't1', 'type': 'text'}138                               ],139                              }],140                  'translations': [{'$anchor': 'tx0', 'name': ''}]})141    result = cc.export(schema='2', flat=False)...test_document.py
Source:test_document.py  
...26    doc[r'\count1'].value=027    doc[r'\count0'].value=20028    doc[r'\count0'].value=20029    doc[r'\count1'].value=030    doc.end_group()31    doc[r'\count0'].value=10032    doc[r'\count1'].value=033def test_group_matching():34    doc = Document()35    g1 = doc.begin_group()36    assert g1 is not None37    g2 = doc.begin_group()38    assert g2 is not None39    doc.end_group(group=g2)40    doc.end_group(group=g1)41    g1 = doc.begin_group()42    g2 = doc.begin_group()43    doc.end_group()44    doc.end_group(group=g1)45    g1 = doc.begin_group()46    g2 = doc.begin_group()47    doc.end_group(group=g2)48    doc.end_group()49    g1 = doc.begin_group()50    g2 = doc.begin_group()51    doc.end_group()52    doc.end_group()53    g1 = doc.begin_group()54    g2 = doc.begin_group()55    with pytest.raises(ValueError):56        doc.end_group(group=g1)57def test_group_ephemeral():58    doc = Document()59    g1 = doc.begin_group()60    g2 = doc.begin_group()61    with pytest.raises(ValueError):62        doc.end_group(group=g1)63    doc = Document()64    g1 = doc.begin_group()65    g2 = doc.begin_group(ephemeral=True)66    doc.end_group(group=g1)67this_file_load_time = datetime.datetime.now()68def test_time():69    doc = Document()70    when = yex.control.parameter.file_load_time71    assert doc[r'\time'].value == when.hour*60+when.minute72    assert doc[r'\day'].value == when.day73    assert doc[r'\month'].value == when.month74    assert doc[r'\year'].value == when.year75    # In case the clock has ticked forward during running the test76    assert this_file_load_time-when < datetime.timedelta(seconds=3), \77        f"{when} {this_file_load_time}"78def test_set_global():79    doc = Document()80    assert doc[r'\count0'].value==081    doc[r'\count0'].value = 182    assert doc[r'\count0'].value==183    doc.begin_group()84    doc[r'\count0'].value = 285    assert doc[r'\count0'].value==286    doc.end_group()87    assert doc[r'\count0'].value==188    doc.begin_group()89    doc.next_assignment_is_global = True90    doc[r'\count0'].value = 291    assert doc[r'\count0'].value==292    doc.end_group()93    assert doc[r'\count0'].value==294def test_document_len():95    doc = Document()96    assert len(doc)==197    doc.begin_group()98    assert len(doc)==299    doc.end_group()100    assert len(doc)==1101def test_document_save(yex_test_fs):102    message = "Lorum ipsum dolor sit amet."103    y = yex.Document()104    y += (105        r"\def\TeX{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX}"106        r"\shipout\hbox{"107        f"{message}"108        r"}"109        )110    y.save('lorum.svg')111    result = ''.join(check_svg('lorum.svg'))112    assert result == message.replace(' ','')113def _test_font_control(...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!!
